1 /*****************************************************************************
2 * rpn.c : RPN evaluator for the HTTP Interface
3 *****************************************************************************
4 * Copyright (C) 2001-2006 the VideoLAN team
7 * Authors: Gildas Bazin <gbazin@netcourrier.com>
8 * Laurent Aimar <fenrir@via.ecp.fr>
9 * Christophe Massiot <massiot@via.ecp.fr>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
32 #include "vlc_strings.h"
34 static vlc_object_t *GetVLCObject( intf_thread_t *p_intf,
35 const char *psz_object,
36 bool *pb_need_release )
38 intf_sys_t *p_sys = p_intf->p_sys;
39 int i_object_type = 0;
40 vlc_object_t *p_object = NULL;
41 *pb_need_release = false;
43 if( !strcmp( psz_object, "VLC_OBJECT_LIBVLC" ) )
44 p_object = VLC_OBJECT(p_intf->p_libvlc);
45 else if( !strcmp( psz_object, "VLC_OBJECT_INTF" ) )
46 p_object = VLC_OBJECT(p_intf);
47 else if( !strcmp( psz_object, "VLC_OBJECT_PLAYLIST" ) )
48 p_object = VLC_OBJECT(p_sys->p_playlist);
49 else if( !strcmp( psz_object, "VLC_OBJECT_INPUT" ) )
50 p_object = VLC_OBJECT(p_sys->p_input);
51 else if( !strcmp( psz_object, "VLC_OBJECT_VOUT" ) )
52 i_object_type = VLC_OBJECT_VOUT;
53 else if( !strcmp( psz_object, "VLC_OBJECT_AOUT" ) )
54 i_object_type = VLC_OBJECT_AOUT;
56 msg_Warn( p_intf, "unknown object type (%s)", psz_object );
58 if( p_object == NULL && i_object_type )
60 *pb_need_release = true;
61 p_object = vlc_object_find( p_intf, i_object_type, FIND_ANYWHERE );
67 void SSInit( rpn_stack_t *st )
72 void SSClean( rpn_stack_t *st )
74 while( st->i_stack > 0 )
76 free( st->stack[--st->i_stack] );
80 void SSPush( rpn_stack_t *st, const char *s )
82 if( st->i_stack < STACK_MAX )
84 st->stack[st->i_stack++] = strdup( s );
88 char *SSPop( rpn_stack_t *st )
90 if( st->i_stack <= 0 )
96 return st->stack[--st->i_stack];
100 int SSPopN( rpn_stack_t *st, mvar_t *vars )
109 i = strtol( name, &end, 0 );
112 value = mvar_GetValue( vars, name );
120 void SSPushN( rpn_stack_t *st, int i )
124 snprintf( v, sizeof (v), "%d", i );
128 void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars,
129 rpn_stack_t *st, char *exp )
131 intf_sys_t *p_sys = p_intf->p_sys;
133 while( exp != NULL && *exp != '\0' )
146 p = FirstWord( exp, exp );
153 p = FirstWord( exp, exp );
157 exp += strlen( exp );
169 /* 1. Integer function */
170 if( !strcmp( s, "!" ) )
172 SSPushN( st, ~SSPopN( st, vars ) );
174 else if( !strcmp( s, "^" ) )
176 SSPushN( st, SSPopN( st, vars ) ^ SSPopN( st, vars ) );
178 else if( !strcmp( s, "&" ) )
180 SSPushN( st, SSPopN( st, vars ) & SSPopN( st, vars ) );
182 else if( !strcmp( s, "|" ) )
184 SSPushN( st, SSPopN( st, vars ) | SSPopN( st, vars ) );
186 else if( !strcmp( s, "+" ) )
188 SSPushN( st, SSPopN( st, vars ) + SSPopN( st, vars ) );
190 else if( !strcmp( s, "-" ) )
192 int j = SSPopN( st, vars );
193 int i = SSPopN( st, vars );
194 SSPushN( st, i - j );
196 else if( !strcmp( s, "*" ) )
198 SSPushN( st, SSPopN( st, vars ) * SSPopN( st, vars ) );
200 else if( !strcmp( s, "/" ) )
204 j = SSPopN( st, vars );
205 i = SSPopN( st, vars );
207 SSPushN( st, j != 0 ? i / j : 0 );
209 else if( !strcmp( s, "%" ) )
213 j = SSPopN( st, vars );
214 i = SSPopN( st, vars );
216 SSPushN( st, j != 0 ? i % j : 0 );
218 /* 2. integer tests */
219 else if( !strcmp( s, "=" ) )
221 SSPushN( st, SSPopN( st, vars ) == SSPopN( st, vars ) ? -1 : 0 );
223 else if( !strcmp( s, "!=" ) )
225 SSPushN( st, SSPopN( st, vars ) != SSPopN( st, vars ) ? -1 : 0 );
227 else if( !strcmp( s, "<" ) )
229 int j = SSPopN( st, vars );
230 int i = SSPopN( st, vars );
232 SSPushN( st, i < j ? -1 : 0 );
234 else if( !strcmp( s, ">" ) )
236 int j = SSPopN( st, vars );
237 int i = SSPopN( st, vars );
239 SSPushN( st, i > j ? -1 : 0 );
241 else if( !strcmp( s, "<=" ) )
243 int j = SSPopN( st, vars );
244 int i = SSPopN( st, vars );
246 SSPushN( st, i <= j ? -1 : 0 );
248 else if( !strcmp( s, ">=" ) )
250 int j = SSPopN( st, vars );
251 int i = SSPopN( st, vars );
253 SSPushN( st, i >= j ? -1 : 0 );
255 /* 3. string functions */
256 else if( !strcmp( s, "strcat" ) )
258 char *s2 = SSPop( st );
259 char *s1 = SSPop( st );
260 char *str = malloc( strlen( s1 ) + strlen( s2 ) + 1 );
270 else if( !strcmp( s, "strcmp" ) )
272 char *s2 = SSPop( st );
273 char *s1 = SSPop( st );
275 SSPushN( st, strcmp( s1, s2 ) );
279 else if( !strcmp( s, "strncmp" ) )
281 int n = SSPopN( st, vars );
282 char *s2 = SSPop( st );
283 char *s1 = SSPop( st );
285 SSPushN( st, strncmp( s1, s2 , n ) );
289 else if( !strcmp( s, "strsub" ) )
291 int n = SSPopN( st, vars );
292 int m = SSPopN( st, vars );
294 char *s = SSPop( st );
306 str = malloc( i_len + 1 );
308 memcpy( str, s + m - 1, i_len );
315 else if( !strcmp( s, "strlen" ) )
317 char *str = SSPop( st );
319 SSPushN( st, strlen( str ) );
322 else if( !strcmp( s, "str_replace" ) )
324 char *psz_to = SSPop( st );
325 char *psz_from = SSPop( st );
326 char *psz_in = SSPop( st );
327 char *psz_in_current = psz_in;
328 char *psz_out = malloc( strlen(psz_in) * strlen(psz_to) + 1 );
329 char *psz_out_current = psz_out;
331 while( (p = strstr( psz_in_current, psz_from )) != NULL )
333 memcpy( psz_out_current, psz_in_current, p - psz_in_current );
334 psz_out_current += p - psz_in_current;
335 strcpy( psz_out_current, psz_to );
336 psz_out_current += strlen(psz_to);
337 psz_in_current = p + strlen(psz_from);
339 strcpy( psz_out_current, psz_in_current );
340 psz_out_current += strlen(psz_in_current);
341 *psz_out_current = '\0';
343 SSPush( st, psz_out );
349 else if( !strcmp( s, "url_extract" ) )
351 char *url = mvar_GetValue( vars, "url_value" );
352 char *name = SSPop( st );
353 char *value = ExtractURIString( url, name );
365 else if( !strcmp( s, "url_encode" ) )
367 char *url = SSPop( st );
368 char *value = vlc_UrlEncode( url );
373 else if( !strcmp( s, "addslashes" ) )
375 char *psz_src = SSPop( st );
379 p = psz_dest = malloc( strlen( str ) * 2 + 1 );
381 while( *str != '\0' )
383 if( *str == '"' || *str == '\'' || *str == '\\' )
392 SSPush( st, psz_dest );
396 else if( !strcmp( s, "stripslashes" ) )
398 char *psz_src = SSPop( st );
402 p = psz_dest = strdup( psz_src );
406 if( *str == '\\' && *(str + 1) )
414 SSPush( st, psz_dest );
418 else if( !strcmp( s, "htmlspecialchars" ) )
420 char *psz_src = SSPop( st );
423 psz_dest = convert_xml_special_chars( psz_src );
425 SSPush( st, psz_dest );
429 else if( !strcmp( s, "realpath" ) )
431 char *psz_src = SSPop( st );
432 char *psz_dir = RealPath( p_intf, psz_src );
434 SSPush( st, psz_dir );
438 /* 4. stack functions */
439 else if( !strcmp( s, "dup" ) )
441 char *str = SSPop( st );
446 else if( !strcmp( s, "drop" ) )
448 char *str = SSPop( st );
451 else if( !strcmp( s, "swap" ) )
453 char *s1 = SSPop( st );
454 char *s2 = SSPop( st );
461 else if( !strcmp( s, "flush" ) )
466 else if( !strcmp( s, "store" ) )
468 char *value = SSPop( st );
469 char *name = SSPop( st );
471 mvar_PushNewVar( vars, name, value );
475 else if( !strcmp( s, "value" ) )
477 char *name = SSPop( st );
478 char *value = mvar_GetValue( vars, name );
484 /* 5. player control */
485 else if( !strcmp( s, "vlc_play" ) )
487 int i_id = SSPopN( st, vars );
490 i_ret = playlist_Control( p_sys->p_playlist, PLAYLIST_VIEWPLAY,
492 playlist_ItemGetById( p_sys->p_playlist,
494 msg_Dbg( p_intf, "requested playlist item: %i", i_id );
495 SSPushN( st, i_ret );
497 else if( !strcmp( s, "vlc_stop" ) )
499 playlist_Control( p_sys->p_playlist, PLAYLIST_STOP, true );
500 msg_Dbg( p_intf, "requested playlist stop" );
502 else if( !strcmp( s, "vlc_pause" ) )
504 playlist_Control( p_sys->p_playlist, PLAYLIST_PAUSE, true );
505 msg_Dbg( p_intf, "requested playlist pause" );
507 else if( !strcmp( s, "vlc_next" ) )
509 playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, true, 1 );
510 msg_Dbg( p_intf, "requested playlist next" );
512 else if( !strcmp( s, "vlc_previous" ) )
514 playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, true, -1 );
515 msg_Dbg( p_intf, "requested playlist previous" );
517 else if( !strcmp( s, "vlc_seek" ) )
519 char *psz_value = SSPop( st );
520 HandleSeek( p_intf, psz_value );
521 msg_Dbg( p_intf, "requested playlist seek: %s", psz_value );
524 else if( !strcmp( s, "vlc_var_type" )
525 || !strcmp( s, "vlc_config_type" ) )
527 vlc_object_t *p_object;
528 const char *psz_type = NULL;
531 if( !strcmp( s, "vlc_var_type" ) )
533 char *psz_object = SSPop( st );
534 char *psz_variable = SSPop( st );
537 p_object = GetVLCObject( p_intf, psz_object, &b_need_release );
539 if( p_object != NULL )
540 i_type = var_Type( p_object, psz_variable );
541 free( psz_variable );
543 if( b_need_release && p_object != NULL )
544 vlc_object_release( p_object );
548 char *psz_variable = SSPop( st );
549 p_object = VLC_OBJECT(p_intf);
550 i_type = config_GetType( p_object, psz_variable );
551 free( psz_variable );
554 if( p_object != NULL )
556 switch( i_type & VLC_VAR_TYPE )
559 psz_type = "VLC_VAR_BOOL";
561 case VLC_VAR_INTEGER:
562 psz_type = "VLC_VAR_INTEGER";
565 psz_type = "VLC_VAR_HOTKEY";
568 psz_type = "VLC_VAR_STRING";
571 psz_type = "VLC_VAR_MODULE";
574 psz_type = "VLC_VAR_FILE";
576 case VLC_VAR_DIRECTORY:
577 psz_type = "VLC_VAR_DIRECTORY";
579 case VLC_VAR_VARIABLE:
580 psz_type = "VLC_VAR_VARIABLE";
583 psz_type = "VLC_VAR_FLOAT";
586 psz_type = "UNDEFINED";
590 psz_type = "INVALID";
592 SSPush( st, psz_type );
594 else if( !strcmp( s, "vlc_var_set" ) )
596 char *psz_object = SSPop( st );
597 char *psz_variable = SSPop( st );
600 vlc_object_t *p_object = GetVLCObject( p_intf, psz_object,
603 if( p_object != NULL )
605 bool b_error = false;
606 char *psz_value = NULL;
610 i_type = var_Type( p_object, psz_variable );
612 switch( i_type & VLC_VAR_TYPE )
615 val.b_bool = SSPopN( st, vars );
616 msg_Dbg( p_intf, "requested %s var change: %s->%d",
617 psz_object, psz_variable, val.b_bool );
619 case VLC_VAR_INTEGER:
621 val.i_int = SSPopN( st, vars );
622 msg_Dbg( p_intf, "requested %s var change: %s->%d",
623 psz_object, psz_variable, val.i_int );
628 case VLC_VAR_DIRECTORY:
629 case VLC_VAR_VARIABLE:
630 val.psz_string = psz_value = SSPop( st );
631 msg_Dbg( p_intf, "requested %s var change: %s->%s",
632 psz_object, psz_variable, psz_value );
635 psz_value = SSPop( st );
636 val.f_float = atof( psz_value );
637 msg_Dbg( p_intf, "requested %s var change: %s->%f",
638 psz_object, psz_variable, val.f_float );
642 msg_Warn( p_intf, "invalid %s variable type %d (%s)",
643 psz_object, i_type & VLC_VAR_TYPE, psz_variable );
648 var_Set( p_object, psz_variable, val );
649 if( psz_value != NULL )
653 msg_Warn( p_intf, "vlc_var_set called without an object" );
654 free( psz_variable );
657 if( b_need_release && p_object != NULL )
658 vlc_object_release( p_object );
660 else if( !strcmp( s, "vlc_var_get" ) )
662 char *psz_object = SSPop( st );
663 char *psz_variable = SSPop( st );
666 vlc_object_t *p_object = GetVLCObject( p_intf, psz_object,
669 if( p_object != NULL )
674 i_type = var_Type( p_object, psz_variable );
675 var_Get( p_object, psz_variable, &val );
677 switch( i_type & VLC_VAR_TYPE )
680 SSPushN( st, val.b_bool );
682 case VLC_VAR_INTEGER:
684 SSPushN( st, val.i_int );
689 case VLC_VAR_DIRECTORY:
690 case VLC_VAR_VARIABLE:
691 SSPush( st, val.psz_string );
692 free( val.psz_string );
697 lldiv_t value = lldiv( val.f_float * 1000000, 1000000 );
698 snprintf( psz_value, sizeof(psz_value), "%lld.%06u",
699 value.quot, (unsigned int)value.rem );
700 SSPush( st, psz_value );
704 msg_Warn( p_intf, "invalid %s variable type %d (%s)",
705 psz_object, i_type & VLC_VAR_TYPE, psz_variable );
711 msg_Warn( p_intf, "vlc_var_get called without an object" );
714 free( psz_variable );
717 if( b_need_release && p_object != NULL )
718 vlc_object_release( p_object );
720 else if( !strcmp( s, "vlc_object_exists" ) )
722 char *psz_object = SSPop( st );
725 vlc_object_t *p_object = GetVLCObject( p_intf, psz_object,
727 if( b_need_release && p_object != NULL )
728 vlc_object_release( p_object );
730 if( p_object != NULL )
735 else if( !strcmp( s, "vlc_config_set" ) )
737 char *psz_variable = SSPop( st );
738 int i_type = config_GetType( p_intf, psz_variable );
740 switch( i_type & VLC_VAR_TYPE )
743 case VLC_VAR_INTEGER:
744 config_PutInt( p_intf, psz_variable, SSPopN( st, vars ) );
749 case VLC_VAR_DIRECTORY:
751 char *psz_string = SSPop( st );
752 config_PutPsz( p_intf, psz_variable, psz_string );
758 char *psz_string = SSPop( st );
759 config_PutFloat( p_intf, psz_variable, atof(psz_string) );
764 msg_Warn( p_intf, "vlc_config_set called on unknown var (%s)",
767 free( psz_variable );
769 else if( !strcmp( s, "vlc_config_get" ) )
771 char *psz_variable = SSPop( st );
772 int i_type = config_GetType( p_intf, psz_variable );
774 switch( i_type & VLC_VAR_TYPE )
777 case VLC_VAR_INTEGER:
778 SSPushN( st, config_GetInt( p_intf, psz_variable ) );
783 case VLC_VAR_DIRECTORY:
785 char *psz_string = config_GetPsz( p_intf, psz_variable );
786 SSPush( st, psz_string );
793 lldiv_t value = lldiv( config_GetFloat( p_intf, psz_variable )
794 * 1000000, 1000000 );
795 snprintf( psz_string, sizeof(psz_string), "%lld.%06u",
796 value.quot, (unsigned int)value.rem );
797 SSPush( st, psz_string );
801 msg_Warn( p_intf, "vlc_config_get called on unknown var (%s)",
805 free( psz_variable );
807 else if( !strcmp( s, "vlc_config_save" ) )
809 char *psz_module = SSPop( st );
817 i_result = config_SaveConfigFile( p_intf, psz_module );
819 if( psz_module != NULL )
821 SSPushN( st, i_result );
823 else if( !strcmp( s, "vlc_config_reset" ) )
825 config_ResetAll( p_intf );
827 /* 6. playlist functions */
828 else if( !strcmp( s, "playlist_add" ) )
830 char *psz_name = SSPop( st );
831 char *mrl = SSPop( st );
832 input_item_t *p_input;
835 p_input = MRLParse( p_intf, mrl, psz_name );
837 char *psz_uri = input_item_GetURI( p_input );
838 if( !p_input || !psz_uri || !*psz_uri )
840 i_ret = VLC_EGENERIC;
841 msg_Dbg( p_intf, "invalid requested mrl: %s", mrl );
845 i_ret = playlist_AddInput( p_sys->p_playlist, p_input,
846 PLAYLIST_APPEND, PLAYLIST_END, true,
848 vlc_gc_decref( p_input );
849 if( i_ret == VLC_SUCCESS )
850 msg_Dbg( p_intf, "requested mrl add: %s", mrl );
852 msg_Warn( p_intf, "adding mrl %s failed", mrl );
855 SSPushN( st, i_ret );
860 else if( !strcmp( s, "playlist_empty" ) )
862 playlist_Clear( p_sys->p_playlist, false );
863 msg_Dbg( p_intf, "requested playlist empty" );
865 else if( !strcmp( s, "playlist_delete" ) )
867 int i_id = SSPopN( st, vars );
868 playlist_item_t *p_item = playlist_ItemGetById( p_sys->p_playlist,
872 playlist_DeleteFromInput( p_sys->p_playlist,
873 p_item->p_input->i_id, false );
874 msg_Dbg( p_intf, "requested playlist delete: %d", i_id );
878 msg_Dbg( p_intf, "couldn't find playlist item to delete (%d)",
882 else if( !strcmp( s, "playlist_move" ) )
884 /*int i_newpos =*/ SSPopN( st, vars );
885 /*int i_pos =*/ SSPopN( st, vars );
886 /* FIXME FIXME TODO TODO XXX XXX
887 do not release before fixing this
888 if ( i_pos < i_newpos )
890 playlist_Move( p_sys->p_playlist, i_pos, i_newpos + 1 );
894 playlist_Move( p_sys->p_playlist, i_pos, i_newpos );
896 msg_Dbg( p_intf, "requested to move playlist item %d to %d",
898 FIXME FIXME TODO TODO XXX XXX */
899 msg_Err( p_intf, "moving using indexes is obsolete. We need to update this function" );
901 else if( !strcmp( s, "playlist_sort" ) )
903 int i_order = SSPopN( st, vars );
904 int i_sort = SSPopN( st, vars );
905 i_order = i_order % 2;
907 /* FIXME FIXME TODO TODO XXX XXX
908 do not release before fixing this
909 playlist_RecursiveNodeSort( p_sys->p_playlist,
910 p_sys->p_playlist->p_general,
912 msg_Dbg( p_intf, "requested sort playlist by : %d in order : %d",
914 FIXME FIXME TODO TODO XXX XXX */
915 msg_Err( p_intf, "this needs to be fixed to use the new playlist framework" );
917 else if( !strcmp( s, "services_discovery_add" ) )
919 char *psz_sd = SSPop( st );
920 playlist_ServicesDiscoveryAdd( p_sys->p_playlist, psz_sd );
923 else if( !strcmp( s, "services_discovery_remove" ) )
925 char *psz_sd = SSPop( st );
926 playlist_ServicesDiscoveryRemove( p_sys->p_playlist, psz_sd );
929 else if( !strcmp( s, "services_discovery_is_loaded" ) )
931 char *psz_sd = SSPop( st );
933 playlist_IsServicesDiscoveryLoaded( p_sys->p_playlist, psz_sd ) );
936 else if( !strcmp( s, "vlc_volume_set" ) )
938 char *psz_vol = SSPop( st );
940 audio_volume_t i_volume;
941 aout_VolumeGet( p_intf, &i_volume );
942 if( psz_vol[0] == '+' )
944 i_value = atoi( psz_vol );
945 if( (i_volume + i_value) > AOUT_VOLUME_MAX )
946 aout_VolumeSet( p_intf, AOUT_VOLUME_MAX );
948 aout_VolumeSet( p_intf, i_volume + i_value );
950 else if( psz_vol[0] == '-' )
952 i_value = atoi( psz_vol );
953 if( (i_volume + i_value) < AOUT_VOLUME_MIN )
954 aout_VolumeSet( p_intf, AOUT_VOLUME_MIN );
956 aout_VolumeSet( p_intf, i_volume + i_value );
958 else if( strstr( psz_vol, "%") != NULL )
960 i_value = atoi( psz_vol );
961 if( i_value < 0 ) i_value = 0;
962 if( i_value > 400 ) i_value = 400;
963 aout_VolumeSet( p_intf, (i_value * (AOUT_VOLUME_MAX - AOUT_VOLUME_MIN))/400+AOUT_VOLUME_MIN);
967 i_value = atoi( psz_vol );
968 if( i_value > AOUT_VOLUME_MAX ) i_value = AOUT_VOLUME_MAX;
969 if( i_value < AOUT_VOLUME_MIN ) i_value = AOUT_VOLUME_MIN;
970 aout_VolumeSet( p_intf, i_value );
972 aout_VolumeGet( p_intf, &i_volume );
975 else if( !strcmp( s, "vlc_get_meta" ) )
977 char *psz_meta = SSPop( st );
978 char *psz_val = NULL;
979 if( p_sys->p_input && input_GetItem(p_sys->p_input) )
981 #define p_item input_GetItem( p_sys->p_input )
982 if( !strcmp( psz_meta, "ARTIST" ) )
984 psz_val = input_item_GetArtist( p_item );
986 else if( !strcmp( psz_meta, "TITLE" ) )
988 psz_val = input_item_GetTitle( p_item );
990 psz_val = input_item_GetName( p_item );
992 else if( !strcmp( psz_meta, "ALBUM" ) )
994 psz_val = input_item_GetAlbum( p_item );
996 else if( !strcmp( psz_meta, "GENRE" ) )
998 psz_val = input_item_GetGenre( p_item );
1002 if( psz_val == NULL ) psz_val = strdup( "" );
1003 SSPush( st, psz_val );
1008 else if( !strcmp( s, "vlm_command" ) || !strcmp( s, "vlm_cmd" ) )
1011 char *psz_cmd = strdup( "" );
1013 vlm_message_t *vlm_answer;
1015 /* make sure that we have a vlm object */
1016 if( p_intf->p_sys->p_vlm == NULL )
1017 p_intf->p_sys->p_vlm = vlm_New( p_intf );
1020 /* vlm command uses the ';' delimiter
1021 * (else we can't know when to stop) */
1022 while( strcmp( psz_elt = SSPop( st ), "" )
1023 && strcmp( psz_elt, ";" ) )
1026 (char *)malloc( strlen( psz_cmd ) + strlen( psz_elt ) + 2 );
1027 sprintf( psz_buf, "%s %s", psz_cmd, psz_elt );
1033 msg_Dbg( p_intf, "executing vlm command: %s", psz_cmd );
1034 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz_cmd, &vlm_answer );
1036 if( vlm_answer->psz_value == NULL )
1038 psz_error = strdup( "" );
1042 psz_error = malloc( strlen(vlm_answer->psz_name) +
1043 strlen(vlm_answer->psz_value) +
1044 strlen( " : ") + 1 );
1045 sprintf( psz_error , "%s : %s" , vlm_answer->psz_name,
1046 vlm_answer->psz_value );
1049 mvar_AppendNewVar( vars, "vlm_error", psz_error );
1050 /* this is kind of a duplicate but we need to have the message
1051 * without the command name for the "export" command */
1052 mvar_AppendNewVar( vars, "vlm_value", vlm_answer->psz_value );
1053 vlm_MessageDelete( vlm_answer );
1058 #endif /* ENABLE_VLM */
1059 else if( !strcmp( s, "snapshot" ) )
1061 if( p_sys->p_input )
1063 vout_thread_t *p_vout;
1064 p_vout = vlc_object_find( p_sys->p_input,
1065 VLC_OBJECT_VOUT, FIND_CHILD );
1069 vout_Control( p_vout, VOUT_SNAPSHOT );
1070 vlc_object_release( p_vout );
1071 msg_Dbg( p_intf, "requested snapshot" );