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_INTF" ) )
45 p_object = VLC_OBJECT(p_intf);
46 else if( !strcmp( psz_object, "VLC_OBJECT_PLAYLIST" ) )
47 p_object = VLC_OBJECT(p_sys->p_playlist);
48 else if( !strcmp( psz_object, "VLC_OBJECT_INPUT" ) )
49 p_object = VLC_OBJECT(p_sys->p_input);
50 else if( p_sys->p_input )
52 if( !strcmp( psz_object, "VLC_OBJECT_VOUT" ) )
53 p_object = VLC_OBJECT( input_GetVout( p_sys->p_input ) );
54 else if( !strcmp( psz_object, "VLC_OBJECT_AOUT" ) )
55 p_object = VLC_OBJECT( input_GetAout( p_sys->p_input ) );
57 *pb_need_release = true;
60 msg_Warn( p_intf, "unknown object type (%s)", psz_object );
65 void SSInit( rpn_stack_t *st )
70 void SSClean( rpn_stack_t *st )
72 while( st->i_stack > 0 )
74 free( st->stack[--st->i_stack] );
78 void SSPush( rpn_stack_t *st, const char *s )
80 if( st->i_stack < STACK_MAX )
82 st->stack[st->i_stack++] = strdup( s );
86 char *SSPop( rpn_stack_t *st )
88 if( st->i_stack <= 0 )
94 return st->stack[--st->i_stack];
98 int SSPopN( rpn_stack_t *st, mvar_t *vars )
106 i = strtol( name, &end, 0 );
109 const char *value = mvar_GetValue( vars, name );
117 void SSPushN( rpn_stack_t *st, int i )
121 snprintf( v, sizeof (v), "%d", i );
125 void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars,
126 rpn_stack_t *st, char *exp )
128 intf_sys_t *p_sys = p_intf->p_sys;
130 while( exp != NULL && *exp != '\0' )
143 p = FirstWord( exp, exp );
150 p = FirstWord( exp, exp );
154 exp += strlen( exp );
166 /* 1. Integer function */
167 if( !strcmp( s, "!" ) )
169 SSPushN( st, ~SSPopN( st, vars ) );
171 else if( !strcmp( s, "^" ) )
173 SSPushN( st, SSPopN( st, vars ) ^ SSPopN( st, vars ) );
175 else if( !strcmp( s, "&" ) )
177 SSPushN( st, SSPopN( st, vars ) & SSPopN( st, vars ) );
179 else if( !strcmp( s, "|" ) )
181 SSPushN( st, SSPopN( st, vars ) | SSPopN( st, vars ) );
183 else if( !strcmp( s, "+" ) )
185 SSPushN( st, SSPopN( st, vars ) + SSPopN( st, vars ) );
187 else if( !strcmp( s, "-" ) )
189 int j = SSPopN( st, vars );
190 int i = SSPopN( st, vars );
191 SSPushN( st, i - j );
193 else if( !strcmp( s, "*" ) )
195 SSPushN( st, SSPopN( st, vars ) * SSPopN( st, vars ) );
197 else if( !strcmp( s, "/" ) )
201 j = SSPopN( st, vars );
202 i = SSPopN( st, vars );
204 SSPushN( st, j != 0 ? i / j : 0 );
206 else if( !strcmp( s, "%" ) )
210 j = SSPopN( st, vars );
211 i = SSPopN( st, vars );
213 SSPushN( st, j != 0 ? i % j : 0 );
215 /* 2. integer tests */
216 else if( !strcmp( s, "=" ) )
218 SSPushN( st, SSPopN( st, vars ) == SSPopN( st, vars ) ? -1 : 0 );
220 else if( !strcmp( s, "!=" ) )
222 SSPushN( st, SSPopN( st, vars ) != SSPopN( st, vars ) ? -1 : 0 );
224 else if( !strcmp( s, "<" ) )
226 int j = SSPopN( st, vars );
227 int i = SSPopN( st, vars );
229 SSPushN( st, i < j ? -1 : 0 );
231 else if( !strcmp( s, ">" ) )
233 int j = SSPopN( st, vars );
234 int i = SSPopN( st, vars );
236 SSPushN( st, i > j ? -1 : 0 );
238 else if( !strcmp( s, "<=" ) )
240 int j = SSPopN( st, vars );
241 int i = SSPopN( st, vars );
243 SSPushN( st, i <= j ? -1 : 0 );
245 else if( !strcmp( s, ">=" ) )
247 int j = SSPopN( st, vars );
248 int i = SSPopN( st, vars );
250 SSPushN( st, i >= j ? -1 : 0 );
252 /* 3. string functions */
253 else if( !strcmp( s, "strcat" ) )
255 char *s2 = SSPop( st );
256 char *s1 = SSPop( st );
257 char *str = malloc( strlen( s1 ) + strlen( s2 ) + 1 );
267 else if( !strcmp( s, "strcmp" ) )
269 char *s2 = SSPop( st );
270 char *s1 = SSPop( st );
272 SSPushN( st, strcmp( s1, s2 ) );
276 else if( !strcmp( s, "strncmp" ) )
278 int n = SSPopN( st, vars );
279 char *s2 = SSPop( st );
280 char *s1 = SSPop( st );
282 SSPushN( st, strncmp( s1, s2 , n ) );
286 else if( !strcmp( s, "strsub" ) )
288 int n = SSPopN( st, vars );
289 int m = SSPopN( st, vars );
291 char *s = SSPop( st );
303 str = malloc( i_len + 1 );
305 memcpy( str, s + m - 1, i_len );
312 else if( !strcmp( s, "strlen" ) )
314 char *str = SSPop( st );
316 SSPushN( st, strlen( str ) );
319 else if( !strcmp( s, "str_replace" ) )
321 char *psz_to = SSPop( st );
322 char *psz_from = SSPop( st );
323 char *psz_in = SSPop( st );
324 char *psz_in_current = psz_in;
325 char *psz_out = malloc( strlen(psz_in) * strlen(psz_to) + 1 );
326 char *psz_out_current = psz_out;
328 while( (p = strstr( psz_in_current, psz_from )) != NULL )
330 memcpy( psz_out_current, psz_in_current, p - psz_in_current );
331 psz_out_current += p - psz_in_current;
332 strcpy( psz_out_current, psz_to );
333 psz_out_current += strlen(psz_to);
334 psz_in_current = p + strlen(psz_from);
336 strcpy( psz_out_current, psz_in_current );
337 psz_out_current += strlen(psz_in_current);
338 *psz_out_current = '\0';
340 SSPush( st, psz_out );
346 else if( !strcmp( s, "url_extract" ) )
348 const char *url = mvar_GetValue( vars, "url_value" );
349 char *name = SSPop( st );
350 char *value = ExtractURIString( url, name );
362 else if( !strcmp( s, "url_encode" ) )
364 char *url = SSPop( st );
365 char *value = vlc_UrlEncode( url );
370 else if( !strcmp( s, "xml_encode" ) )
372 char *url = SSPop( st );
373 char *value = convert_xml_special_chars( url );
378 else if( !strcmp( s, "addslashes" ) )
380 char *psz_src = SSPop( st );
384 p = psz_dest = malloc( strlen( str ) * 2 + 1 );
386 while( *str != '\0' )
388 if( *str == '"' || *str == '\'' || *str == '\\' )
397 SSPush( st, psz_dest );
401 else if( !strcmp( s, "stripslashes" ) )
403 char *psz_src = SSPop( st );
407 p = psz_dest = strdup( psz_src );
411 if( *str == '\\' && *(str + 1) )
419 SSPush( st, psz_dest );
423 else if( !strcmp( s, "htmlspecialchars" ) )
425 char *psz_src = SSPop( st );
428 psz_dest = convert_xml_special_chars( psz_src );
430 SSPush( st, psz_dest );
434 else if( !strcmp( s, "realpath" ) )
436 char *psz_src = SSPop( st );
437 char *psz_dir = RealPath( psz_src );
439 SSPush( st, psz_dir );
443 /* 4. stack functions */
444 else if( !strcmp( s, "dup" ) )
446 char *str = SSPop( st );
451 else if( !strcmp( s, "drop" ) )
453 char *str = SSPop( st );
456 else if( !strcmp( s, "swap" ) )
458 char *s1 = SSPop( st );
459 char *s2 = SSPop( st );
466 else if( !strcmp( s, "flush" ) )
471 else if( !strcmp( s, "store" ) )
473 char *value = SSPop( st );
474 char *name = SSPop( st );
476 mvar_PushNewVar( vars, name, value );
480 else if( !strcmp( s, "value" ) )
482 char *name = SSPop( st );
483 const char *value = mvar_GetValue( vars, name );
489 /* 5. player control */
490 else if( !strcmp( s, "vlc_play" ) )
492 int i_id = SSPopN( st, vars );
495 playlist_Lock( p_sys->p_playlist );
496 i_ret = playlist_Control( p_sys->p_playlist, PLAYLIST_VIEWPLAY,
498 playlist_ItemGetById( p_sys->p_playlist,
500 playlist_Unlock( p_sys->p_playlist );
501 msg_Dbg( p_intf, "requested playlist item: %i", i_id );
502 SSPushN( st, i_ret );
504 else if( !strcmp( s, "vlc_stop" ) )
506 playlist_Control( p_sys->p_playlist, PLAYLIST_STOP, pl_Unlocked );
507 msg_Dbg( p_intf, "requested playlist stop" );
509 else if( !strcmp( s, "vlc_pause" ) )
511 playlist_Control( p_sys->p_playlist, PLAYLIST_PAUSE, pl_Unlocked );
512 msg_Dbg( p_intf, "requested playlist pause" );
514 else if( !strcmp( s, "vlc_next" ) )
516 playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, pl_Unlocked, 1 );
517 msg_Dbg( p_intf, "requested playlist next" );
519 else if( !strcmp( s, "vlc_previous" ) )
521 playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, pl_Unlocked, -1 );
522 msg_Dbg( p_intf, "requested playlist previous" );
524 else if( !strcmp( s, "vlc_seek" ) )
526 char *psz_value = SSPop( st );
527 HandleSeek( p_intf, psz_value );
528 msg_Dbg( p_intf, "requested playlist seek: %s", psz_value );
531 else if( !strcmp( s, "vlc_var_type" )
532 || !strcmp( s, "vlc_config_type" ) )
534 vlc_object_t *p_object;
535 const char *psz_type = NULL;
538 if( !strcmp( s, "vlc_var_type" ) )
540 char *psz_object = SSPop( st );
541 char *psz_variable = SSPop( st );
544 p_object = GetVLCObject( p_intf, psz_object, &b_need_release );
546 if( p_object != NULL )
547 i_type = var_Type( p_object, psz_variable );
548 free( psz_variable );
550 if( b_need_release && p_object != NULL )
551 vlc_object_release( p_object );
555 char *psz_variable = SSPop( st );
556 p_object = VLC_OBJECT(p_intf);
557 i_type = config_GetType( p_object, psz_variable );
558 free( psz_variable );
561 if( p_object != NULL )
563 switch( i_type & VLC_VAR_TYPE )
566 psz_type = "VLC_VAR_BOOL";
568 case VLC_VAR_INTEGER:
569 psz_type = "VLC_VAR_INTEGER";
572 psz_type = "VLC_VAR_HOTKEY";
575 psz_type = "VLC_VAR_STRING";
578 psz_type = "VLC_VAR_MODULE";
581 psz_type = "VLC_VAR_FILE";
583 case VLC_VAR_DIRECTORY:
584 psz_type = "VLC_VAR_DIRECTORY";
586 case VLC_VAR_VARIABLE:
587 psz_type = "VLC_VAR_VARIABLE";
590 psz_type = "VLC_VAR_FLOAT";
593 psz_type = "UNDEFINED";
597 psz_type = "INVALID";
599 SSPush( st, psz_type );
601 else if( !strcmp( s, "vlc_var_set" ) )
603 char *psz_object = SSPop( st );
604 char *psz_variable = SSPop( st );
607 vlc_object_t *p_object = GetVLCObject( p_intf, psz_object,
610 if( p_object != NULL )
612 bool b_error = false;
613 char *psz_value = NULL;
617 i_type = var_Type( p_object, psz_variable );
619 switch( i_type & VLC_VAR_TYPE )
622 val.b_bool = SSPopN( st, vars );
623 msg_Dbg( p_intf, "requested %s var change: %s->%d",
624 psz_object, psz_variable, val.b_bool );
626 case VLC_VAR_INTEGER:
628 val.i_int = SSPopN( st, vars );
629 msg_Dbg( p_intf, "requested %s var change: %s->%d",
630 psz_object, psz_variable, val.i_int );
635 case VLC_VAR_DIRECTORY:
636 case VLC_VAR_VARIABLE:
637 val.psz_string = psz_value = SSPop( st );
638 msg_Dbg( p_intf, "requested %s var change: %s->%s",
639 psz_object, psz_variable, psz_value );
642 psz_value = SSPop( st );
643 val.f_float = atof( psz_value );
644 msg_Dbg( p_intf, "requested %s var change: %s->%f",
645 psz_object, psz_variable, val.f_float );
649 msg_Warn( p_intf, "invalid %s variable type %d (%s)",
650 psz_object, i_type & VLC_VAR_TYPE, psz_variable );
655 var_Set( p_object, psz_variable, val );
656 if( psz_value != NULL )
660 msg_Warn( p_intf, "vlc_var_set called without an object" );
661 free( psz_variable );
664 if( b_need_release && p_object != NULL )
665 vlc_object_release( p_object );
667 else if( !strcmp( s, "vlc_var_get" ) )
669 char *psz_object = SSPop( st );
670 char *psz_variable = SSPop( st );
673 vlc_object_t *p_object = GetVLCObject( p_intf, psz_object,
676 if( p_object != NULL )
681 i_type = var_Type( p_object, psz_variable );
682 var_Get( p_object, psz_variable, &val );
684 switch( i_type & VLC_VAR_TYPE )
687 SSPushN( st, val.b_bool );
689 case VLC_VAR_INTEGER:
691 SSPushN( st, val.i_int );
696 case VLC_VAR_DIRECTORY:
697 case VLC_VAR_VARIABLE:
698 SSPush( st, val.psz_string );
699 free( val.psz_string );
704 lldiv_t value = lldiv( val.f_float * 1000000, 1000000 );
705 snprintf( psz_value, sizeof(psz_value), "%lld.%06u",
706 value.quot, (unsigned int)value.rem );
707 SSPush( st, psz_value );
711 msg_Warn( p_intf, "invalid %s variable type %d (%s)",
712 psz_object, i_type & VLC_VAR_TYPE, psz_variable );
718 msg_Warn( p_intf, "vlc_var_get called without an object" );
721 free( psz_variable );
724 if( b_need_release && p_object != NULL )
725 vlc_object_release( p_object );
727 else if( !strcmp( s, "vlc_object_exists" ) )
729 char *psz_object = SSPop( st );
732 vlc_object_t *p_object = GetVLCObject( p_intf, psz_object,
734 if( b_need_release && p_object != NULL )
735 vlc_object_release( p_object );
737 if( p_object != NULL )
742 else if( !strcmp( s, "vlc_config_set" ) )
744 char *psz_variable = SSPop( st );
745 int i_type = config_GetType( p_intf, psz_variable );
747 switch( i_type & VLC_VAR_TYPE )
750 case VLC_VAR_INTEGER:
751 config_PutInt( p_intf, psz_variable, SSPopN( st, vars ) );
756 case VLC_VAR_DIRECTORY:
758 char *psz_string = SSPop( st );
759 config_PutPsz( p_intf, psz_variable, psz_string );
765 char *psz_string = SSPop( st );
766 config_PutFloat( p_intf, psz_variable, atof(psz_string) );
771 msg_Warn( p_intf, "vlc_config_set called on unknown var (%s)",
774 free( psz_variable );
776 else if( !strcmp( s, "vlc_config_get" ) )
778 char *psz_variable = SSPop( st );
779 int i_type = config_GetType( p_intf, psz_variable );
781 switch( i_type & VLC_VAR_TYPE )
784 case VLC_VAR_INTEGER:
785 SSPushN( st, config_GetInt( p_intf, psz_variable ) );
790 case VLC_VAR_DIRECTORY:
792 char *psz_string = config_GetPsz( p_intf, psz_variable );
793 SSPush( st, psz_string );
800 lldiv_t value = lldiv( config_GetFloat( p_intf, psz_variable )
801 * 1000000, 1000000 );
802 snprintf( psz_string, sizeof(psz_string), "%lld.%06u",
803 value.quot, (unsigned int)value.rem );
804 SSPush( st, psz_string );
808 msg_Warn( p_intf, "vlc_config_get called on unknown var (%s)",
812 free( psz_variable );
814 else if( !strcmp( s, "vlc_config_save" ) )
816 char *psz_module = SSPop( st );
824 i_result = config_SaveConfigFile( p_intf, psz_module );
826 if( psz_module != NULL )
828 SSPushN( st, i_result );
830 else if( !strcmp( s, "vlc_config_reset" ) )
832 config_ResetAll( p_intf );
834 /* 6. playlist functions */
835 else if( !strcmp( s, "playlist_add" ) )
837 char *psz_name = SSPop( st );
838 char *mrl = SSPop( st );
839 input_item_t *p_input;
842 p_input = MRLParse( p_intf, mrl, psz_name );
844 char *psz_uri = input_item_GetURI( p_input );
845 if( !p_input || !psz_uri || !*psz_uri )
847 i_ret = VLC_EGENERIC;
848 msg_Dbg( p_intf, "invalid requested mrl: %s", mrl );
852 i_ret = playlist_AddInput( p_sys->p_playlist, p_input,
853 PLAYLIST_APPEND, PLAYLIST_END, true,
855 if( i_ret == VLC_SUCCESS )
857 playlist_item_t *p_item;
858 msg_Dbg( p_intf, "requested mrl add: %s", mrl );
859 p_item = playlist_ItemGetByInput( p_sys->p_playlist,
863 i_ret = p_item->i_id;
866 msg_Warn( p_intf, "adding mrl %s failed", mrl );
867 vlc_gc_decref( p_input );
870 SSPushN( st, i_ret );
875 else if( !strcmp( s, "playlist_empty" ) )
877 playlist_Clear( p_sys->p_playlist, pl_Unlocked );
878 msg_Dbg( p_intf, "requested playlist empty" );
880 else if( !strcmp( s, "playlist_delete" ) )
882 int i_id = SSPopN( st, vars );
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_Unlocked );
889 msg_Dbg( p_intf, "requested playlist delete: %d", i_id );
893 msg_Dbg( p_intf, "couldn't find playlist item to delete (%d)",
897 else if( !strcmp( s, "playlist_move" ) )
899 /*int i_newpos =*/ SSPopN( st, vars );
900 /*int i_pos =*/ SSPopN( st, vars );
901 /* FIXME FIXME TODO TODO XXX XXX
902 do not release before fixing this
903 if ( i_pos < i_newpos )
905 playlist_Move( p_sys->p_playlist, i_pos, i_newpos + 1 );
909 playlist_Move( p_sys->p_playlist, i_pos, i_newpos );
911 msg_Dbg( p_intf, "requested to move playlist item %d to %d",
913 FIXME FIXME TODO TODO XXX XXX */
914 msg_Err( p_intf, "moving using indexes is obsolete. We need to update this function" );
916 else if( !strcmp( s, "playlist_sort" ) )
918 int i_order = SSPopN( st, vars );
919 int i_sort = SSPopN( st, vars );
920 i_order = i_order % 2;
922 /* FIXME FIXME TODO TODO XXX XXX
923 do not release before fixing this
924 playlist_RecursiveNodeSort( p_sys->p_playlist,
925 p_sys->p_playlist->p_general,
927 msg_Dbg( p_intf, "requested sort playlist by : %d in order : %d",
929 FIXME FIXME TODO TODO XXX XXX */
930 msg_Err( p_intf, "this needs to be fixed to use the new playlist framework" );
932 else if( !strcmp( s, "services_discovery_add" ) )
934 char *psz_sd = SSPop( st );
935 playlist_ServicesDiscoveryAdd( p_sys->p_playlist, psz_sd );
938 else if( !strcmp( s, "services_discovery_remove" ) )
940 char *psz_sd = SSPop( st );
941 playlist_ServicesDiscoveryRemove( p_sys->p_playlist, psz_sd );
944 else if( !strcmp( s, "services_discovery_is_loaded" ) )
946 char *psz_sd = SSPop( st );
948 playlist_IsServicesDiscoveryLoaded( p_sys->p_playlist, psz_sd ) );
951 else if( !strcmp( s, "vlc_volume_set" ) )
953 char *psz_vol = SSPop( st );
955 audio_volume_t i_volume;
956 aout_VolumeGet( p_intf, &i_volume );
957 if( psz_vol[0] == '+' )
959 i_value = atoi( psz_vol );
960 if( (i_volume + i_value) > AOUT_VOLUME_MAX )
961 aout_VolumeSet( p_intf, AOUT_VOLUME_MAX );
963 aout_VolumeSet( p_intf, i_volume + i_value );
965 else if( psz_vol[0] == '-' )
967 i_value = atoi( psz_vol );
968 if( (i_volume + i_value) < AOUT_VOLUME_MIN )
969 aout_VolumeSet( p_intf, AOUT_VOLUME_MIN );
971 aout_VolumeSet( p_intf, i_volume + i_value );
973 else if( strstr( psz_vol, "%") != NULL )
975 i_value = atoi( psz_vol );
976 if( i_value < 0 ) i_value = 0;
977 if( i_value > 400 ) i_value = 400;
978 aout_VolumeSet( p_intf, (i_value * (AOUT_VOLUME_MAX - AOUT_VOLUME_MIN))/400+AOUT_VOLUME_MIN);
982 i_value = atoi( psz_vol );
983 if( i_value > AOUT_VOLUME_MAX ) i_value = AOUT_VOLUME_MAX;
984 if( i_value < AOUT_VOLUME_MIN ) i_value = AOUT_VOLUME_MIN;
985 aout_VolumeSet( p_intf, i_value );
987 aout_VolumeGet( p_intf, &i_volume );
990 else if( !strcmp( s, "vlc_get_meta" ) )
992 char *psz_meta = SSPop( st );
993 char *psz_val = NULL;
994 if( p_sys->p_input && input_GetItem(p_sys->p_input) )
996 #define p_item input_GetItem( p_sys->p_input )
997 if( !strcmp( psz_meta, "ARTIST" ) )
999 psz_val = input_item_GetArtist( p_item );
1001 else if( !strcmp( psz_meta, "TITLE" ) )
1003 psz_val = input_item_GetTitle( p_item );
1005 psz_val = input_item_GetName( p_item );
1007 else if( !strcmp( psz_meta, "ALBUM" ) )
1009 psz_val = input_item_GetAlbum( p_item );
1011 else if( !strcmp( psz_meta, "GENRE" ) )
1013 psz_val = input_item_GetGenre( p_item );
1015 else if( !strcmp( psz_meta, "COPYRIGHT" ) )
1017 psz_val = input_item_GetCopyright( p_item );
1019 else if( !strcmp( psz_meta, "TRACK_NUMBER" ) )
1021 psz_val = input_item_GetTrackNum( p_item );
1023 else if( !strcmp( psz_meta, "DESCRIPTION" ) )
1025 psz_val = input_item_GetDescription( p_item );
1027 else if( !strcmp( psz_meta, "RATING" ) )
1029 psz_val = input_item_GetRating( p_item );
1031 else if( !strcmp( psz_meta, "DATE" ) )
1033 psz_val = input_item_GetDate( p_item );
1035 else if( !strcmp( psz_meta, "URL" ) )
1037 psz_val = input_item_GetURL( p_item );
1039 else if( !strcmp( psz_meta, "LANGUAGE" ) )
1041 psz_val = input_item_GetLanguage( p_item );
1043 else if( !strcmp( psz_meta, "NOW_PLAYING" ) )
1045 psz_val = input_item_GetNowPlaying( p_item );
1047 else if( !strcmp( psz_meta, "PUBLISHER" ) )
1049 psz_val = input_item_GetPublisher( p_item );
1051 else if( !strcmp( psz_meta, "ENCODED_BY" ) )
1053 psz_val = input_item_GetEncodedBy( p_item );
1055 else if( !strcmp( psz_meta, "ART_URL" ) )
1057 psz_val = input_item_GetEncodedBy( p_item );
1059 else if( !strcmp( psz_meta, "TRACK_ID" ) )
1061 psz_val = input_item_GetTrackID( p_item );
1065 if( psz_val == NULL ) psz_val = strdup( "" );
1066 SSPush( st, psz_val );
1071 else if( !strcmp( s, "vlm_command" ) || !strcmp( s, "vlm_cmd" ) )
1074 char *psz_cmd = strdup( "" );
1076 vlm_message_t *vlm_answer;
1078 /* make sure that we have a vlm object */
1079 if( p_intf->p_sys->p_vlm == NULL )
1080 p_intf->p_sys->p_vlm = vlm_New( p_intf );
1083 /* vlm command uses the ';' delimiter
1084 * (else we can't know when to stop) */
1085 while( strcmp( psz_elt = SSPop( st ), "" )
1086 && strcmp( psz_elt, ";" ) )
1089 if( asprintf( &psz_buf, "%s %s", psz_cmd, psz_elt ) == -1 )
1096 msg_Dbg( p_intf, "executing vlm command: %s", psz_cmd );
1097 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz_cmd, &vlm_answer );
1099 if( vlm_answer->psz_value == NULL )
1101 psz_error = strdup( "" );
1105 if( asprintf( &psz_error , "%s : %s" , vlm_answer->psz_name,
1106 vlm_answer->psz_value ) == -1 )
1110 mvar_AppendNewVar( vars, "vlm_error", psz_error );
1111 /* this is kind of a duplicate but we need to have the message
1112 * without the command name for the "export" command */
1113 mvar_AppendNewVar( vars, "vlm_value", vlm_answer->psz_value );
1114 vlm_MessageDelete( vlm_answer );
1119 #endif /* ENABLE_VLM */
1120 else if( !strcmp( s, "snapshot" ) )
1122 if( p_sys->p_input )
1124 vout_thread_t *p_vout = input_GetVout( p_sys->p_input );
1127 vout_Control( p_vout, VOUT_SNAPSHOT );
1128 vlc_object_release( p_vout );
1129 msg_Dbg( p_intf, "requested snapshot" );