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, "xml_encode" ) )
375 char *url = SSPop( st );
376 char *value = convert_xml_special_chars( url );
381 else if( !strcmp( s, "addslashes" ) )
383 char *psz_src = SSPop( st );
387 p = psz_dest = malloc( strlen( str ) * 2 + 1 );
389 while( *str != '\0' )
391 if( *str == '"' || *str == '\'' || *str == '\\' )
400 SSPush( st, psz_dest );
404 else if( !strcmp( s, "stripslashes" ) )
406 char *psz_src = SSPop( st );
410 p = psz_dest = strdup( psz_src );
414 if( *str == '\\' && *(str + 1) )
422 SSPush( st, psz_dest );
426 else if( !strcmp( s, "htmlspecialchars" ) )
428 char *psz_src = SSPop( st );
431 psz_dest = convert_xml_special_chars( psz_src );
433 SSPush( st, psz_dest );
437 else if( !strcmp( s, "realpath" ) )
439 char *psz_src = SSPop( st );
440 char *psz_dir = RealPath( psz_src );
442 SSPush( st, psz_dir );
446 /* 4. stack functions */
447 else if( !strcmp( s, "dup" ) )
449 char *str = SSPop( st );
454 else if( !strcmp( s, "drop" ) )
456 char *str = SSPop( st );
459 else if( !strcmp( s, "swap" ) )
461 char *s1 = SSPop( st );
462 char *s2 = SSPop( st );
469 else if( !strcmp( s, "flush" ) )
474 else if( !strcmp( s, "store" ) )
476 char *value = SSPop( st );
477 char *name = SSPop( st );
479 mvar_PushNewVar( vars, name, value );
483 else if( !strcmp( s, "value" ) )
485 char *name = SSPop( st );
486 char *value = mvar_GetValue( vars, name );
492 /* 5. player control */
493 else if( !strcmp( s, "vlc_play" ) )
495 int i_id = SSPopN( st, vars );
498 i_ret = playlist_Control( p_sys->p_playlist, PLAYLIST_VIEWPLAY,
500 playlist_ItemGetById( p_sys->p_playlist,
502 msg_Dbg( p_intf, "requested playlist item: %i", i_id );
503 SSPushN( st, i_ret );
505 else if( !strcmp( s, "vlc_stop" ) )
507 playlist_Control( p_sys->p_playlist, PLAYLIST_STOP, true );
508 msg_Dbg( p_intf, "requested playlist stop" );
510 else if( !strcmp( s, "vlc_pause" ) )
512 playlist_Control( p_sys->p_playlist, PLAYLIST_PAUSE, true );
513 msg_Dbg( p_intf, "requested playlist pause" );
515 else if( !strcmp( s, "vlc_next" ) )
517 playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, true, 1 );
518 msg_Dbg( p_intf, "requested playlist next" );
520 else if( !strcmp( s, "vlc_previous" ) )
522 playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, true, -1 );
523 msg_Dbg( p_intf, "requested playlist previous" );
525 else if( !strcmp( s, "vlc_seek" ) )
527 char *psz_value = SSPop( st );
528 HandleSeek( p_intf, psz_value );
529 msg_Dbg( p_intf, "requested playlist seek: %s", psz_value );
532 else if( !strcmp( s, "vlc_var_type" )
533 || !strcmp( s, "vlc_config_type" ) )
535 vlc_object_t *p_object;
536 const char *psz_type = NULL;
539 if( !strcmp( s, "vlc_var_type" ) )
541 char *psz_object = SSPop( st );
542 char *psz_variable = SSPop( st );
545 p_object = GetVLCObject( p_intf, psz_object, &b_need_release );
547 if( p_object != NULL )
548 i_type = var_Type( p_object, psz_variable );
549 free( psz_variable );
551 if( b_need_release && p_object != NULL )
552 vlc_object_release( p_object );
556 char *psz_variable = SSPop( st );
557 p_object = VLC_OBJECT(p_intf);
558 i_type = config_GetType( p_object, psz_variable );
559 free( psz_variable );
562 if( p_object != NULL )
564 switch( i_type & VLC_VAR_TYPE )
567 psz_type = "VLC_VAR_BOOL";
569 case VLC_VAR_INTEGER:
570 psz_type = "VLC_VAR_INTEGER";
573 psz_type = "VLC_VAR_HOTKEY";
576 psz_type = "VLC_VAR_STRING";
579 psz_type = "VLC_VAR_MODULE";
582 psz_type = "VLC_VAR_FILE";
584 case VLC_VAR_DIRECTORY:
585 psz_type = "VLC_VAR_DIRECTORY";
587 case VLC_VAR_VARIABLE:
588 psz_type = "VLC_VAR_VARIABLE";
591 psz_type = "VLC_VAR_FLOAT";
594 psz_type = "UNDEFINED";
598 psz_type = "INVALID";
600 SSPush( st, psz_type );
602 else if( !strcmp( s, "vlc_var_set" ) )
604 char *psz_object = SSPop( st );
605 char *psz_variable = SSPop( st );
608 vlc_object_t *p_object = GetVLCObject( p_intf, psz_object,
611 if( p_object != NULL )
613 bool b_error = false;
614 char *psz_value = NULL;
618 i_type = var_Type( p_object, psz_variable );
620 switch( i_type & VLC_VAR_TYPE )
623 val.b_bool = SSPopN( st, vars );
624 msg_Dbg( p_intf, "requested %s var change: %s->%d",
625 psz_object, psz_variable, val.b_bool );
627 case VLC_VAR_INTEGER:
629 val.i_int = SSPopN( st, vars );
630 msg_Dbg( p_intf, "requested %s var change: %s->%d",
631 psz_object, psz_variable, val.i_int );
636 case VLC_VAR_DIRECTORY:
637 case VLC_VAR_VARIABLE:
638 val.psz_string = psz_value = SSPop( st );
639 msg_Dbg( p_intf, "requested %s var change: %s->%s",
640 psz_object, psz_variable, psz_value );
643 psz_value = SSPop( st );
644 val.f_float = atof( psz_value );
645 msg_Dbg( p_intf, "requested %s var change: %s->%f",
646 psz_object, psz_variable, val.f_float );
650 msg_Warn( p_intf, "invalid %s variable type %d (%s)",
651 psz_object, i_type & VLC_VAR_TYPE, psz_variable );
656 var_Set( p_object, psz_variable, val );
657 if( psz_value != NULL )
661 msg_Warn( p_intf, "vlc_var_set called without an object" );
662 free( psz_variable );
665 if( b_need_release && p_object != NULL )
666 vlc_object_release( p_object );
668 else if( !strcmp( s, "vlc_var_get" ) )
670 char *psz_object = SSPop( st );
671 char *psz_variable = SSPop( st );
674 vlc_object_t *p_object = GetVLCObject( p_intf, psz_object,
677 if( p_object != NULL )
682 i_type = var_Type( p_object, psz_variable );
683 var_Get( p_object, psz_variable, &val );
685 switch( i_type & VLC_VAR_TYPE )
688 SSPushN( st, val.b_bool );
690 case VLC_VAR_INTEGER:
692 SSPushN( st, val.i_int );
697 case VLC_VAR_DIRECTORY:
698 case VLC_VAR_VARIABLE:
699 SSPush( st, val.psz_string );
700 free( val.psz_string );
705 lldiv_t value = lldiv( val.f_float * 1000000, 1000000 );
706 snprintf( psz_value, sizeof(psz_value), "%lld.%06u",
707 value.quot, (unsigned int)value.rem );
708 SSPush( st, psz_value );
712 msg_Warn( p_intf, "invalid %s variable type %d (%s)",
713 psz_object, i_type & VLC_VAR_TYPE, psz_variable );
719 msg_Warn( p_intf, "vlc_var_get called without an object" );
722 free( psz_variable );
725 if( b_need_release && p_object != NULL )
726 vlc_object_release( p_object );
728 else if( !strcmp( s, "vlc_object_exists" ) )
730 char *psz_object = SSPop( st );
733 vlc_object_t *p_object = GetVLCObject( p_intf, psz_object,
735 if( b_need_release && p_object != NULL )
736 vlc_object_release( p_object );
738 if( p_object != NULL )
743 else if( !strcmp( s, "vlc_config_set" ) )
745 char *psz_variable = SSPop( st );
746 int i_type = config_GetType( p_intf, psz_variable );
748 switch( i_type & VLC_VAR_TYPE )
751 case VLC_VAR_INTEGER:
752 config_PutInt( p_intf, psz_variable, SSPopN( st, vars ) );
757 case VLC_VAR_DIRECTORY:
759 char *psz_string = SSPop( st );
760 config_PutPsz( p_intf, psz_variable, psz_string );
766 char *psz_string = SSPop( st );
767 config_PutFloat( p_intf, psz_variable, atof(psz_string) );
772 msg_Warn( p_intf, "vlc_config_set called on unknown var (%s)",
775 free( psz_variable );
777 else if( !strcmp( s, "vlc_config_get" ) )
779 char *psz_variable = SSPop( st );
780 int i_type = config_GetType( p_intf, psz_variable );
782 switch( i_type & VLC_VAR_TYPE )
785 case VLC_VAR_INTEGER:
786 SSPushN( st, config_GetInt( p_intf, psz_variable ) );
791 case VLC_VAR_DIRECTORY:
793 char *psz_string = config_GetPsz( p_intf, psz_variable );
794 SSPush( st, psz_string );
801 lldiv_t value = lldiv( config_GetFloat( p_intf, psz_variable )
802 * 1000000, 1000000 );
803 snprintf( psz_string, sizeof(psz_string), "%lld.%06u",
804 value.quot, (unsigned int)value.rem );
805 SSPush( st, psz_string );
809 msg_Warn( p_intf, "vlc_config_get called on unknown var (%s)",
813 free( psz_variable );
815 else if( !strcmp( s, "vlc_config_save" ) )
817 char *psz_module = SSPop( st );
825 i_result = config_SaveConfigFile( p_intf, psz_module );
827 if( psz_module != NULL )
829 SSPushN( st, i_result );
831 else if( !strcmp( s, "vlc_config_reset" ) )
833 config_ResetAll( p_intf );
835 /* 6. playlist functions */
836 else if( !strcmp( s, "playlist_add" ) )
838 char *psz_name = SSPop( st );
839 char *mrl = SSPop( st );
840 input_item_t *p_input;
843 p_input = MRLParse( p_intf, mrl, psz_name );
845 char *psz_uri = input_item_GetURI( p_input );
846 if( !p_input || !psz_uri || !*psz_uri )
848 i_ret = VLC_EGENERIC;
849 msg_Dbg( p_intf, "invalid requested mrl: %s", mrl );
853 i_ret = playlist_AddInput( p_sys->p_playlist, p_input,
854 PLAYLIST_APPEND, PLAYLIST_END, true,
856 vlc_gc_decref( p_input );
857 if( i_ret == VLC_SUCCESS )
858 msg_Dbg( p_intf, "requested mrl add: %s", mrl );
860 msg_Warn( p_intf, "adding mrl %s failed", mrl );
863 SSPushN( st, i_ret );
868 else if( !strcmp( s, "playlist_empty" ) )
870 playlist_Clear( p_sys->p_playlist, false );
871 msg_Dbg( p_intf, "requested playlist empty" );
873 else if( !strcmp( s, "playlist_delete" ) )
875 int i_id = SSPopN( st, vars );
876 playlist_item_t *p_item = playlist_ItemGetById( p_sys->p_playlist,
880 playlist_DeleteFromInput( p_sys->p_playlist,
881 p_item->p_input->i_id, false );
882 msg_Dbg( p_intf, "requested playlist delete: %d", i_id );
886 msg_Dbg( p_intf, "couldn't find playlist item to delete (%d)",
890 else if( !strcmp( s, "playlist_move" ) )
892 /*int i_newpos =*/ SSPopN( st, vars );
893 /*int i_pos =*/ SSPopN( st, vars );
894 /* FIXME FIXME TODO TODO XXX XXX
895 do not release before fixing this
896 if ( i_pos < i_newpos )
898 playlist_Move( p_sys->p_playlist, i_pos, i_newpos + 1 );
902 playlist_Move( p_sys->p_playlist, i_pos, i_newpos );
904 msg_Dbg( p_intf, "requested to move playlist item %d to %d",
906 FIXME FIXME TODO TODO XXX XXX */
907 msg_Err( p_intf, "moving using indexes is obsolete. We need to update this function" );
909 else if( !strcmp( s, "playlist_sort" ) )
911 int i_order = SSPopN( st, vars );
912 int i_sort = SSPopN( st, vars );
913 i_order = i_order % 2;
915 /* FIXME FIXME TODO TODO XXX XXX
916 do not release before fixing this
917 playlist_RecursiveNodeSort( p_sys->p_playlist,
918 p_sys->p_playlist->p_general,
920 msg_Dbg( p_intf, "requested sort playlist by : %d in order : %d",
922 FIXME FIXME TODO TODO XXX XXX */
923 msg_Err( p_intf, "this needs to be fixed to use the new playlist framework" );
925 else if( !strcmp( s, "services_discovery_add" ) )
927 char *psz_sd = SSPop( st );
928 playlist_ServicesDiscoveryAdd( p_sys->p_playlist, psz_sd );
931 else if( !strcmp( s, "services_discovery_remove" ) )
933 char *psz_sd = SSPop( st );
934 playlist_ServicesDiscoveryRemove( p_sys->p_playlist, psz_sd );
937 else if( !strcmp( s, "services_discovery_is_loaded" ) )
939 char *psz_sd = SSPop( st );
941 playlist_IsServicesDiscoveryLoaded( p_sys->p_playlist, psz_sd ) );
944 else if( !strcmp( s, "vlc_volume_set" ) )
946 char *psz_vol = SSPop( st );
948 audio_volume_t i_volume;
949 aout_VolumeGet( p_intf, &i_volume );
950 if( psz_vol[0] == '+' )
952 i_value = atoi( psz_vol );
953 if( (i_volume + i_value) > AOUT_VOLUME_MAX )
954 aout_VolumeSet( p_intf, AOUT_VOLUME_MAX );
956 aout_VolumeSet( p_intf, i_volume + i_value );
958 else if( psz_vol[0] == '-' )
960 i_value = atoi( psz_vol );
961 if( (i_volume + i_value) < AOUT_VOLUME_MIN )
962 aout_VolumeSet( p_intf, AOUT_VOLUME_MIN );
964 aout_VolumeSet( p_intf, i_volume + i_value );
966 else if( strstr( psz_vol, "%") != NULL )
968 i_value = atoi( psz_vol );
969 if( i_value < 0 ) i_value = 0;
970 if( i_value > 400 ) i_value = 400;
971 aout_VolumeSet( p_intf, (i_value * (AOUT_VOLUME_MAX - AOUT_VOLUME_MIN))/400+AOUT_VOLUME_MIN);
975 i_value = atoi( psz_vol );
976 if( i_value > AOUT_VOLUME_MAX ) i_value = AOUT_VOLUME_MAX;
977 if( i_value < AOUT_VOLUME_MIN ) i_value = AOUT_VOLUME_MIN;
978 aout_VolumeSet( p_intf, i_value );
980 aout_VolumeGet( p_intf, &i_volume );
983 else if( !strcmp( s, "vlc_get_meta" ) )
985 char *psz_meta = SSPop( st );
986 char *psz_val = NULL;
987 if( p_sys->p_input && input_GetItem(p_sys->p_input) )
989 #define p_item input_GetItem( p_sys->p_input )
990 if( !strcmp( psz_meta, "ARTIST" ) )
992 psz_val = input_item_GetArtist( p_item );
994 else if( !strcmp( psz_meta, "TITLE" ) )
996 psz_val = input_item_GetTitle( p_item );
998 psz_val = input_item_GetName( p_item );
1000 else if( !strcmp( psz_meta, "ALBUM" ) )
1002 psz_val = input_item_GetAlbum( p_item );
1004 else if( !strcmp( psz_meta, "GENRE" ) )
1006 psz_val = input_item_GetGenre( p_item );
1010 if( psz_val == NULL ) psz_val = strdup( "" );
1011 SSPush( st, psz_val );
1016 else if( !strcmp( s, "vlm_command" ) || !strcmp( s, "vlm_cmd" ) )
1019 char *psz_cmd = strdup( "" );
1021 vlm_message_t *vlm_answer;
1023 /* make sure that we have a vlm object */
1024 if( p_intf->p_sys->p_vlm == NULL )
1025 p_intf->p_sys->p_vlm = vlm_New( p_intf );
1028 /* vlm command uses the ';' delimiter
1029 * (else we can't know when to stop) */
1030 while( strcmp( psz_elt = SSPop( st ), "" )
1031 && strcmp( psz_elt, ";" ) )
1034 (char *)malloc( strlen( psz_cmd ) + strlen( psz_elt ) + 2 );
1035 sprintf( psz_buf, "%s %s", psz_cmd, psz_elt );
1041 msg_Dbg( p_intf, "executing vlm command: %s", psz_cmd );
1042 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz_cmd, &vlm_answer );
1044 if( vlm_answer->psz_value == NULL )
1046 psz_error = strdup( "" );
1050 psz_error = malloc( strlen(vlm_answer->psz_name) +
1051 strlen(vlm_answer->psz_value) +
1052 strlen( " : ") + 1 );
1053 sprintf( psz_error , "%s : %s" , vlm_answer->psz_name,
1054 vlm_answer->psz_value );
1057 mvar_AppendNewVar( vars, "vlm_error", psz_error );
1058 /* this is kind of a duplicate but we need to have the message
1059 * without the command name for the "export" command */
1060 mvar_AppendNewVar( vars, "vlm_value", vlm_answer->psz_value );
1061 vlm_MessageDelete( vlm_answer );
1066 #endif /* ENABLE_VLM */
1067 else if( !strcmp( s, "snapshot" ) )
1069 if( p_sys->p_input )
1071 vout_thread_t *p_vout;
1072 p_vout = vlc_object_find( p_sys->p_input,
1073 VLC_OBJECT_VOUT, FIND_CHILD );
1077 vout_Control( p_vout, VOUT_SNAPSHOT );
1078 vlc_object_release( p_vout );
1079 msg_Dbg( p_intf, "requested snapshot" );