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 vlc_object_t *p_object = NULL;
40 *pb_need_release = false;
42 if( !strcmp( psz_object, "VLC_OBJECT_LIBVLC" ) )
43 p_object = VLC_OBJECT(p_intf->p_libvlc);
44 else if( !strcmp( psz_object, "VLC_OBJECT_PLAYLIST" ) )
45 p_object = VLC_OBJECT(p_sys->p_playlist);
46 else if( !strcmp( psz_object, "VLC_OBJECT_INPUT" ) )
47 p_object = VLC_OBJECT(p_sys->p_input);
48 else if( p_sys->p_input )
50 if( !strcmp( psz_object, "VLC_OBJECT_VOUT" ) )
51 p_object = VLC_OBJECT( input_GetVout( p_sys->p_input ) );
52 else if( !strcmp( psz_object, "VLC_OBJECT_AOUT" ) )
53 p_object = VLC_OBJECT( input_GetAout( p_sys->p_input ) );
55 *pb_need_release = true;
58 msg_Warn( p_intf, "unknown object type (%s)", psz_object );
63 void SSInit( rpn_stack_t *st )
68 void SSClean( rpn_stack_t *st )
70 while( st->i_stack > 0 )
72 free( st->stack[--st->i_stack] );
76 void SSPush( rpn_stack_t *st, const char *s )
78 if( st->i_stack < STACK_MAX )
80 st->stack[st->i_stack++] = strdup( s );
84 char *SSPop( rpn_stack_t *st )
86 if( st->i_stack <= 0 )
92 return st->stack[--st->i_stack];
96 int SSPopN( rpn_stack_t *st, mvar_t *vars )
104 i = strtol( name, &end, 0 );
107 const char *value = mvar_GetValue( vars, name );
115 void SSPushN( rpn_stack_t *st, int i )
119 snprintf( v, sizeof (v), "%d", i );
123 void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars,
124 rpn_stack_t *st, char *exp )
126 intf_sys_t *p_sys = p_intf->p_sys;
128 while( exp != NULL && *exp != '\0' )
141 p = FirstWord( exp, exp );
148 p = FirstWord( exp, exp );
152 exp += strlen( exp );
164 /* 1. Integer function */
165 if( !strcmp( s, "!" ) )
167 SSPushN( st, ~SSPopN( st, vars ) );
169 else if( !strcmp( s, "^" ) )
171 SSPushN( st, SSPopN( st, vars ) ^ SSPopN( st, vars ) );
173 else if( !strcmp( s, "&" ) )
175 SSPushN( st, SSPopN( st, vars ) & SSPopN( st, vars ) );
177 else if( !strcmp( s, "|" ) )
179 SSPushN( st, SSPopN( st, vars ) | SSPopN( st, vars ) );
181 else if( !strcmp( s, "+" ) )
183 SSPushN( st, SSPopN( st, vars ) + SSPopN( st, vars ) );
185 else if( !strcmp( s, "-" ) )
187 int j = SSPopN( st, vars );
188 int i = SSPopN( st, vars );
189 SSPushN( st, i - j );
191 else if( !strcmp( s, "*" ) )
193 SSPushN( st, SSPopN( st, vars ) * SSPopN( st, vars ) );
195 else if( !strcmp( s, "/" ) )
199 j = SSPopN( st, vars );
200 i = SSPopN( st, vars );
202 SSPushN( st, j != 0 ? i / j : 0 );
204 else if( !strcmp( s, "%" ) )
208 j = SSPopN( st, vars );
209 i = SSPopN( st, vars );
211 SSPushN( st, j != 0 ? i % j : 0 );
213 /* 2. integer tests */
214 else if( !strcmp( s, "=" ) )
216 SSPushN( st, SSPopN( st, vars ) == SSPopN( st, vars ) ? -1 : 0 );
218 else if( !strcmp( s, "!=" ) )
220 SSPushN( st, SSPopN( st, vars ) != SSPopN( st, vars ) ? -1 : 0 );
222 else if( !strcmp( s, "<" ) )
224 int j = SSPopN( st, vars );
225 int i = SSPopN( st, vars );
227 SSPushN( st, i < j ? -1 : 0 );
229 else if( !strcmp( s, ">" ) )
231 int j = SSPopN( st, vars );
232 int i = SSPopN( st, vars );
234 SSPushN( st, i > j ? -1 : 0 );
236 else if( !strcmp( s, "<=" ) )
238 int j = SSPopN( st, vars );
239 int i = SSPopN( st, vars );
241 SSPushN( st, i <= j ? -1 : 0 );
243 else if( !strcmp( s, ">=" ) )
245 int j = SSPopN( st, vars );
246 int i = SSPopN( st, vars );
248 SSPushN( st, i >= j ? -1 : 0 );
250 /* 3. string functions */
251 else if( !strcmp( s, "strcat" ) )
253 char *s2 = SSPop( st );
254 char *s1 = SSPop( st );
255 char *str = malloc( strlen( s1 ) + strlen( s2 ) + 1 );
265 else if( !strcmp( s, "strcmp" ) )
267 char *s2 = SSPop( st );
268 char *s1 = SSPop( st );
270 SSPushN( st, strcmp( s1, s2 ) );
274 else if( !strcmp( s, "strncmp" ) )
276 int n = SSPopN( st, vars );
277 char *s2 = SSPop( st );
278 char *s1 = SSPop( st );
280 SSPushN( st, strncmp( s1, s2 , n ) );
284 else if( !strcmp( s, "strsub" ) )
286 int n = SSPopN( st, vars );
287 int m = SSPopN( st, vars );
289 char *s = SSPop( st );
301 str = malloc( i_len + 1 );
303 memcpy( str, s + m - 1, i_len );
310 else if( !strcmp( s, "strlen" ) )
312 char *str = SSPop( st );
314 SSPushN( st, strlen( str ) );
317 else if( !strcmp( s, "str_replace" ) )
319 char *psz_to = SSPop( st );
320 char *psz_from = SSPop( st );
321 char *psz_in = SSPop( st );
322 char *psz_in_current = psz_in;
323 char *psz_out = malloc( strlen(psz_in) * strlen(psz_to) + 1 );
324 char *psz_out_current = psz_out;
326 while( (p = strstr( psz_in_current, psz_from )) != NULL )
328 memcpy( psz_out_current, psz_in_current, p - psz_in_current );
329 psz_out_current += p - psz_in_current;
330 strcpy( psz_out_current, psz_to );
331 psz_out_current += strlen(psz_to);
332 psz_in_current = p + strlen(psz_from);
334 strcpy( psz_out_current, psz_in_current );
335 psz_out_current += strlen(psz_in_current);
336 *psz_out_current = '\0';
338 SSPush( st, psz_out );
344 else if( !strcmp( s, "url_extract" ) )
346 const char *url = mvar_GetValue( vars, "url_value" );
347 char *name = SSPop( st );
348 char *value = ExtractURIString( url, name );
360 else if( !strcmp( s, "url_encode" ) )
362 char *url = SSPop( st );
363 char *value = vlc_UrlEncode( url );
368 else if( !strcmp( s, "xml_encode" ) )
370 char *url = SSPop( st );
371 char *value = convert_xml_special_chars( url );
376 else if( !strcmp( s, "addslashes" ) )
378 char *psz_src = SSPop( st );
382 p = psz_dest = malloc( strlen( str ) * 2 + 1 );
384 while( *str != '\0' )
386 if( *str == '"' || *str == '\'' || *str == '\\' )
395 SSPush( st, psz_dest );
399 else if( !strcmp( s, "stripslashes" ) )
401 char *psz_src = SSPop( st );
405 p = psz_dest = strdup( psz_src );
409 if( *str == '\\' && *(str + 1) )
417 SSPush( st, psz_dest );
421 else if( !strcmp( s, "htmlspecialchars" ) )
423 char *psz_src = SSPop( st );
426 psz_dest = convert_xml_special_chars( psz_src );
428 SSPush( st, psz_dest );
432 else if( !strcmp( s, "realpath" ) )
434 char *psz_src = SSPop( st );
435 char *psz_dir = RealPath( psz_src );
437 SSPush( st, psz_dir );
441 /* 4. stack functions */
442 else if( !strcmp( s, "dup" ) )
444 char *str = SSPop( st );
449 else if( !strcmp( s, "drop" ) )
451 char *str = SSPop( st );
454 else if( !strcmp( s, "swap" ) )
456 char *s1 = SSPop( st );
457 char *s2 = SSPop( st );
464 else if( !strcmp( s, "flush" ) )
469 else if( !strcmp( s, "store" ) )
471 char *value = SSPop( st );
472 char *name = SSPop( st );
474 mvar_PushNewVar( vars, name, value );
478 else if( !strcmp( s, "value" ) )
480 char *name = SSPop( st );
481 const char *value = mvar_GetValue( vars, name );
487 /* 5. player control */
488 else if( !strcmp( s, "vlc_play" ) )
490 int i_id = SSPopN( st, vars );
493 playlist_Lock( p_sys->p_playlist );
494 i_ret = playlist_Control( p_sys->p_playlist, PLAYLIST_VIEWPLAY,
496 playlist_ItemGetById( p_sys->p_playlist,
498 playlist_Unlock( p_sys->p_playlist );
499 msg_Dbg( p_intf, "requested playlist item: %i", i_id );
500 SSPushN( st, i_ret );
502 else if( !strcmp( s, "vlc_stop" ) )
504 playlist_Control( p_sys->p_playlist, PLAYLIST_STOP, pl_Unlocked );
505 msg_Dbg( p_intf, "requested playlist stop" );
507 else if( !strcmp( s, "vlc_pause" ) )
509 playlist_Control( p_sys->p_playlist, PLAYLIST_PAUSE, pl_Unlocked );
510 msg_Dbg( p_intf, "requested playlist pause" );
512 else if( !strcmp( s, "vlc_next" ) )
514 playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, pl_Unlocked, 1 );
515 msg_Dbg( p_intf, "requested playlist next" );
517 else if( !strcmp( s, "vlc_previous" ) )
519 playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, pl_Unlocked, -1 );
520 msg_Dbg( p_intf, "requested playlist previous" );
522 else if( !strcmp( s, "vlc_seek" ) )
524 char *psz_value = SSPop( st );
525 HandleSeek( p_intf, psz_value );
526 msg_Dbg( p_intf, "requested playlist seek: %s", psz_value );
529 else if( !strcmp( s, "vlc_var_type" )
530 || !strcmp( s, "vlc_config_type" ) )
532 vlc_object_t *p_object;
533 const char *psz_type = NULL;
536 if( !strcmp( s, "vlc_var_type" ) )
538 char *psz_object = SSPop( st );
539 char *psz_variable = SSPop( st );
542 p_object = GetVLCObject( p_intf, psz_object, &b_need_release );
544 if( p_object != NULL )
545 i_type = var_Type( p_object, psz_variable );
546 free( psz_variable );
548 if( b_need_release && p_object != NULL )
549 vlc_object_release( p_object );
553 char *psz_variable = SSPop( st );
554 p_object = VLC_OBJECT(p_intf);
555 i_type = config_GetType( p_object, psz_variable );
556 free( psz_variable );
559 if( p_object != NULL )
561 switch( i_type & VLC_VAR_TYPE )
564 psz_type = "VLC_VAR_BOOL";
566 case VLC_VAR_INTEGER:
567 psz_type = "VLC_VAR_INTEGER";
570 psz_type = "VLC_VAR_HOTKEY";
573 psz_type = "VLC_VAR_STRING";
576 psz_type = "VLC_VAR_MODULE";
579 psz_type = "VLC_VAR_FILE";
581 case VLC_VAR_DIRECTORY:
582 psz_type = "VLC_VAR_DIRECTORY";
584 case VLC_VAR_VARIABLE:
585 psz_type = "VLC_VAR_VARIABLE";
588 psz_type = "VLC_VAR_FLOAT";
591 psz_type = "UNDEFINED";
595 psz_type = "INVALID";
597 SSPush( st, psz_type );
599 else if( !strcmp( s, "vlc_var_set" ) )
601 char *psz_object = SSPop( st );
602 char *psz_variable = SSPop( st );
605 vlc_object_t *p_object = GetVLCObject( p_intf, psz_object,
608 if( p_object != NULL )
610 bool b_error = false;
611 char *psz_value = NULL;
615 i_type = var_Type( p_object, psz_variable );
617 switch( i_type & VLC_VAR_TYPE )
620 val.b_bool = SSPopN( st, vars );
621 msg_Dbg( p_intf, "requested %s var change: %s->%d",
622 psz_object, psz_variable, val.b_bool );
624 case VLC_VAR_INTEGER:
626 val.i_int = SSPopN( st, vars );
627 msg_Dbg( p_intf, "requested %s var change: %s->%d",
628 psz_object, psz_variable, val.i_int );
633 case VLC_VAR_DIRECTORY:
634 case VLC_VAR_VARIABLE:
635 val.psz_string = psz_value = SSPop( st );
636 msg_Dbg( p_intf, "requested %s var change: %s->%s",
637 psz_object, psz_variable, psz_value );
640 psz_value = SSPop( st );
641 val.f_float = atof( psz_value );
642 msg_Dbg( p_intf, "requested %s var change: %s->%f",
643 psz_object, psz_variable, val.f_float );
647 msg_Warn( p_intf, "invalid %s variable type %d (%s)",
648 psz_object, i_type & VLC_VAR_TYPE, psz_variable );
653 var_Set( p_object, psz_variable, val );
654 if( psz_value != NULL )
658 msg_Warn( p_intf, "vlc_var_set called without an object" );
659 free( psz_variable );
662 if( b_need_release && p_object != NULL )
663 vlc_object_release( p_object );
665 else if( !strcmp( s, "vlc_var_get" ) )
667 char *psz_object = SSPop( st );
668 char *psz_variable = SSPop( st );
671 vlc_object_t *p_object = GetVLCObject( p_intf, psz_object,
674 if( p_object != NULL )
679 i_type = var_Type( p_object, psz_variable );
680 var_Get( p_object, psz_variable, &val );
682 switch( i_type & VLC_VAR_TYPE )
685 SSPushN( st, val.b_bool );
687 case VLC_VAR_INTEGER:
689 SSPushN( st, val.i_int );
694 case VLC_VAR_DIRECTORY:
695 case VLC_VAR_VARIABLE:
696 SSPush( st, val.psz_string );
697 free( val.psz_string );
702 lldiv_t value = lldiv( val.f_float * 1000000, 1000000 );
703 snprintf( psz_value, sizeof(psz_value), "%lld.%06u",
704 value.quot, (unsigned int)value.rem );
705 SSPush( st, psz_value );
709 msg_Warn( p_intf, "invalid %s variable type %d (%s)",
710 psz_object, i_type & VLC_VAR_TYPE, psz_variable );
716 msg_Warn( p_intf, "vlc_var_get called without an object" );
719 free( psz_variable );
722 if( b_need_release && p_object != NULL )
723 vlc_object_release( p_object );
725 else if( !strcmp( s, "vlc_object_exists" ) )
727 char *psz_object = SSPop( st );
730 vlc_object_t *p_object = GetVLCObject( p_intf, psz_object,
732 if( b_need_release && p_object != NULL )
733 vlc_object_release( p_object );
735 if( p_object != NULL )
740 else if( !strcmp( s, "vlc_config_set" ) )
742 char *psz_variable = SSPop( st );
743 int i_type = config_GetType( p_intf, psz_variable );
745 switch( i_type & VLC_VAR_TYPE )
748 case VLC_VAR_INTEGER:
749 config_PutInt( p_intf, psz_variable, SSPopN( st, vars ) );
754 case VLC_VAR_DIRECTORY:
756 char *psz_string = SSPop( st );
757 config_PutPsz( p_intf, psz_variable, psz_string );
763 char *psz_string = SSPop( st );
764 config_PutFloat( p_intf, psz_variable, atof(psz_string) );
769 msg_Warn( p_intf, "vlc_config_set called on unknown var (%s)",
772 free( psz_variable );
774 else if( !strcmp( s, "vlc_config_get" ) )
776 char *psz_variable = SSPop( st );
777 int i_type = config_GetType( p_intf, psz_variable );
779 switch( i_type & VLC_VAR_TYPE )
782 case VLC_VAR_INTEGER:
783 SSPushN( st, config_GetInt( p_intf, psz_variable ) );
788 case VLC_VAR_DIRECTORY:
790 char *psz_string = config_GetPsz( p_intf, psz_variable );
791 SSPush( st, psz_string );
798 lldiv_t value = lldiv( config_GetFloat( p_intf, psz_variable )
799 * 1000000, 1000000 );
800 snprintf( psz_string, sizeof(psz_string), "%lld.%06u",
801 value.quot, (unsigned int)value.rem );
802 SSPush( st, psz_string );
806 msg_Warn( p_intf, "vlc_config_get called on unknown var (%s)",
810 free( psz_variable );
812 else if( !strcmp( s, "vlc_config_save" ) )
814 char *psz_module = SSPop( st );
822 i_result = config_SaveConfigFile( p_intf, psz_module );
824 if( psz_module != NULL )
826 SSPushN( st, i_result );
828 else if( !strcmp( s, "vlc_config_reset" ) )
830 config_ResetAll( p_intf );
832 /* 6. playlist functions */
833 else if( !strcmp( s, "playlist_add" ) )
835 char *psz_name = SSPop( st );
836 char *mrl = SSPop( st );
837 input_item_t *p_input;
840 p_input = MRLParse( p_intf, mrl, psz_name );
842 char *psz_uri = input_item_GetURI( p_input );
843 if( !p_input || !psz_uri || !*psz_uri )
845 i_ret = VLC_EGENERIC;
846 msg_Dbg( p_intf, "invalid requested mrl: %s", mrl );
850 i_ret = playlist_AddInput( p_sys->p_playlist, p_input,
851 PLAYLIST_APPEND, PLAYLIST_END, true,
853 if( i_ret == VLC_SUCCESS )
855 playlist_item_t *p_item;
856 msg_Dbg( p_intf, "requested mrl add: %s", mrl );
857 playlist_Lock( p_sys->p_playlist );
858 p_item = playlist_ItemGetByInput( p_sys->p_playlist,
861 i_ret = p_item->i_id;
862 playlist_Unlock( p_sys->p_playlist );
865 msg_Warn( p_intf, "adding mrl %s failed", mrl );
866 vlc_gc_decref( p_input );
869 SSPushN( st, i_ret );
874 else if( !strcmp( s, "playlist_empty" ) )
876 playlist_Clear( p_sys->p_playlist, pl_Unlocked );
877 msg_Dbg( p_intf, "requested playlist empty" );
879 else if( !strcmp( s, "playlist_delete" ) )
881 int i_id = SSPopN( st, vars );
882 playlist_Lock( p_sys->p_playlist );
883 playlist_item_t *p_item = playlist_ItemGetById( p_sys->p_playlist,
887 playlist_DeleteFromInput( p_sys->p_playlist,
888 p_item->p_input->i_id, pl_Locked );
889 msg_Dbg( p_intf, "requested playlist delete: %d", i_id );
893 msg_Dbg( p_intf, "couldn't find playlist item to delete (%d)",
896 playlist_Unlock( p_sys->p_playlist );
898 else if( !strcmp( s, "playlist_move" ) )
900 /*int i_newpos =*/ SSPopN( st, vars );
901 /*int i_pos =*/ SSPopN( st, vars );
902 /* FIXME FIXME TODO TODO XXX XXX
903 do not release before fixing this
904 if ( i_pos < i_newpos )
906 playlist_Move( p_sys->p_playlist, i_pos, i_newpos + 1 );
910 playlist_Move( p_sys->p_playlist, i_pos, i_newpos );
912 msg_Dbg( p_intf, "requested to move playlist item %d to %d",
914 FIXME FIXME TODO TODO XXX XXX */
915 msg_Err( p_intf, "moving using indexes is obsolete. We need to update this function" );
917 else if( !strcmp( s, "playlist_sort" ) )
919 int i_order = SSPopN( st, vars );
920 int i_sort = SSPopN( st, vars );
921 i_order = i_order % 2;
923 /* FIXME FIXME TODO TODO XXX XXX
924 do not release before fixing this
925 playlist_RecursiveNodeSort( p_sys->p_playlist,
926 p_sys->p_playlist->p_general,
928 msg_Dbg( p_intf, "requested sort playlist by : %d in order : %d",
930 FIXME FIXME TODO TODO XXX XXX */
931 msg_Err( p_intf, "this needs to be fixed to use the new playlist framework" );
933 else if( !strcmp( s, "services_discovery_add" ) )
935 char *psz_sd = SSPop( st );
936 playlist_ServicesDiscoveryAdd( p_sys->p_playlist, psz_sd );
939 else if( !strcmp( s, "services_discovery_remove" ) )
941 char *psz_sd = SSPop( st );
942 playlist_ServicesDiscoveryRemove( p_sys->p_playlist, psz_sd );
945 else if( !strcmp( s, "services_discovery_is_loaded" ) )
947 char *psz_sd = SSPop( st );
949 playlist_IsServicesDiscoveryLoaded( p_sys->p_playlist, psz_sd ) );
952 else if( !strcmp( s, "vlc_volume_set" ) )
954 char *psz_vol = SSPop( st );
956 audio_volume_t i_volume;
957 aout_VolumeGet( p_intf, &i_volume );
958 if( psz_vol[0] == '+' )
960 i_value = atoi( psz_vol );
961 if( (i_volume + i_value) > AOUT_VOLUME_MAX )
962 aout_VolumeSet( p_intf, AOUT_VOLUME_MAX );
964 aout_VolumeSet( p_intf, i_volume + i_value );
966 else if( psz_vol[0] == '-' )
968 i_value = atoi( psz_vol );
969 if( (i_volume + i_value) < AOUT_VOLUME_MIN )
970 aout_VolumeSet( p_intf, AOUT_VOLUME_MIN );
972 aout_VolumeSet( p_intf, i_volume + i_value );
974 else if( strstr( psz_vol, "%") != NULL )
976 i_value = atoi( psz_vol );
977 if( i_value < 0 ) i_value = 0;
978 if( i_value > 400 ) i_value = 400;
979 aout_VolumeSet( p_intf, (i_value * (AOUT_VOLUME_MAX - AOUT_VOLUME_MIN))/400+AOUT_VOLUME_MIN);
983 i_value = atoi( psz_vol );
984 if( i_value > AOUT_VOLUME_MAX ) i_value = AOUT_VOLUME_MAX;
985 if( i_value < AOUT_VOLUME_MIN ) i_value = AOUT_VOLUME_MIN;
986 aout_VolumeSet( p_intf, i_value );
988 aout_VolumeGet( p_intf, &i_volume );
991 else if( !strcmp( s, "vlc_get_meta" ) )
993 char *psz_meta = SSPop( st );
994 char *psz_val = NULL;
995 if( p_sys->p_input && input_GetItem(p_sys->p_input) )
997 #define p_item input_GetItem( p_sys->p_input )
998 if( !strcmp( psz_meta, "ARTIST" ) )
1000 psz_val = input_item_GetArtist( p_item );
1002 else if( !strcmp( psz_meta, "TITLE" ) )
1004 psz_val = input_item_GetTitle( p_item );
1006 psz_val = input_item_GetName( p_item );
1008 else if( !strcmp( psz_meta, "ALBUM" ) )
1010 psz_val = input_item_GetAlbum( p_item );
1012 else if( !strcmp( psz_meta, "GENRE" ) )
1014 psz_val = input_item_GetGenre( p_item );
1016 else if( !strcmp( psz_meta, "COPYRIGHT" ) )
1018 psz_val = input_item_GetCopyright( p_item );
1020 else if( !strcmp( psz_meta, "TRACK_NUMBER" ) )
1022 psz_val = input_item_GetTrackNum( p_item );
1024 else if( !strcmp( psz_meta, "DESCRIPTION" ) )
1026 psz_val = input_item_GetDescription( p_item );
1028 else if( !strcmp( psz_meta, "RATING" ) )
1030 psz_val = input_item_GetRating( p_item );
1032 else if( !strcmp( psz_meta, "DATE" ) )
1034 psz_val = input_item_GetDate( p_item );
1036 else if( !strcmp( psz_meta, "URL" ) )
1038 psz_val = input_item_GetURL( p_item );
1040 else if( !strcmp( psz_meta, "LANGUAGE" ) )
1042 psz_val = input_item_GetLanguage( p_item );
1044 else if( !strcmp( psz_meta, "NOW_PLAYING" ) )
1046 psz_val = input_item_GetNowPlaying( p_item );
1048 else if( !strcmp( psz_meta, "PUBLISHER" ) )
1050 psz_val = input_item_GetPublisher( p_item );
1052 else if( !strcmp( psz_meta, "ENCODED_BY" ) )
1054 psz_val = input_item_GetEncodedBy( p_item );
1056 else if( !strcmp( psz_meta, "ART_URL" ) )
1058 psz_val = input_item_GetEncodedBy( p_item );
1060 else if( !strcmp( psz_meta, "TRACK_ID" ) )
1062 psz_val = input_item_GetTrackID( p_item );
1066 if( psz_val == NULL ) psz_val = strdup( "" );
1067 SSPush( st, psz_val );
1072 else if( !strcmp( s, "vlm_command" ) || !strcmp( s, "vlm_cmd" ) )
1075 char *psz_cmd = strdup( "" );
1077 vlm_message_t *vlm_answer;
1079 /* make sure that we have a vlm object */
1080 if( p_intf->p_sys->p_vlm == NULL )
1081 p_intf->p_sys->p_vlm = vlm_New( p_intf );
1084 /* vlm command uses the ';' delimiter
1085 * (else we can't know when to stop) */
1086 while( strcmp( psz_elt = SSPop( st ), "" )
1087 && strcmp( psz_elt, ";" ) )
1090 if( asprintf( &psz_buf, "%s %s", psz_cmd, psz_elt ) == -1 )
1097 msg_Dbg( p_intf, "executing vlm command: %s", psz_cmd );
1098 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz_cmd, &vlm_answer );
1100 if( vlm_answer->psz_value == NULL )
1102 psz_error = strdup( "" );
1106 if( asprintf( &psz_error , "%s : %s" , vlm_answer->psz_name,
1107 vlm_answer->psz_value ) == -1 )
1111 mvar_AppendNewVar( vars, "vlm_error", psz_error );
1112 /* this is kind of a duplicate but we need to have the message
1113 * without the command name for the "export" command */
1114 mvar_AppendNewVar( vars, "vlm_value", vlm_answer->psz_value );
1115 vlm_MessageDelete( vlm_answer );
1120 #endif /* ENABLE_VLM */
1121 else if( !strcmp( s, "snapshot" ) )
1123 if( p_sys->p_input )
1125 vout_thread_t *p_vout = input_GetVout( p_sys->p_input );
1128 var_TriggerCallback( p_vout, "video-snapshot" );
1129 vlc_object_release( p_vout );
1130 msg_Dbg( p_intf, "requested snapshot" );