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 )
108 i = strtol( name, &end, 0 );
111 const char *value = mvar_GetValue( vars, name );
119 void SSPushN( rpn_stack_t *st, int i )
123 snprintf( v, sizeof (v), "%d", i );
127 void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars,
128 rpn_stack_t *st, char *exp )
130 intf_sys_t *p_sys = p_intf->p_sys;
132 while( exp != NULL && *exp != '\0' )
145 p = FirstWord( exp, exp );
152 p = FirstWord( exp, exp );
156 exp += strlen( exp );
168 /* 1. Integer function */
169 if( !strcmp( s, "!" ) )
171 SSPushN( st, ~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 SSPushN( st, SSPopN( st, vars ) + SSPopN( st, vars ) );
189 else if( !strcmp( s, "-" ) )
191 int j = SSPopN( st, vars );
192 int i = SSPopN( st, vars );
193 SSPushN( st, i - j );
195 else if( !strcmp( s, "*" ) )
197 SSPushN( st, SSPopN( st, vars ) * SSPopN( st, vars ) );
199 else if( !strcmp( s, "/" ) )
203 j = SSPopN( st, vars );
204 i = SSPopN( st, vars );
206 SSPushN( st, j != 0 ? i / j : 0 );
208 else if( !strcmp( s, "%" ) )
212 j = SSPopN( st, vars );
213 i = SSPopN( st, vars );
215 SSPushN( st, j != 0 ? i % j : 0 );
217 /* 2. integer tests */
218 else if( !strcmp( s, "=" ) )
220 SSPushN( st, SSPopN( st, vars ) == SSPopN( st, vars ) ? -1 : 0 );
222 else if( !strcmp( s, "!=" ) )
224 SSPushN( st, SSPopN( st, vars ) != SSPopN( st, vars ) ? -1 : 0 );
226 else if( !strcmp( s, "<" ) )
228 int j = SSPopN( st, vars );
229 int i = SSPopN( st, vars );
231 SSPushN( st, i < j ? -1 : 0 );
233 else if( !strcmp( s, ">" ) )
235 int j = SSPopN( st, vars );
236 int i = SSPopN( st, vars );
238 SSPushN( st, i > j ? -1 : 0 );
240 else if( !strcmp( s, "<=" ) )
242 int j = SSPopN( st, vars );
243 int i = SSPopN( st, vars );
245 SSPushN( st, i <= j ? -1 : 0 );
247 else if( !strcmp( s, ">=" ) )
249 int j = SSPopN( st, vars );
250 int i = SSPopN( st, vars );
252 SSPushN( st, i >= j ? -1 : 0 );
254 /* 3. string functions */
255 else if( !strcmp( s, "strcat" ) )
257 char *s2 = SSPop( st );
258 char *s1 = SSPop( st );
259 char *str = malloc( strlen( s1 ) + strlen( s2 ) + 1 );
269 else if( !strcmp( s, "strcmp" ) )
271 char *s2 = SSPop( st );
272 char *s1 = SSPop( st );
274 SSPushN( st, strcmp( s1, s2 ) );
278 else if( !strcmp( s, "strncmp" ) )
280 int n = SSPopN( st, vars );
281 char *s2 = SSPop( st );
282 char *s1 = SSPop( st );
284 SSPushN( st, strncmp( s1, s2 , n ) );
288 else if( !strcmp( s, "strsub" ) )
290 int n = SSPopN( st, vars );
291 int m = SSPopN( st, vars );
293 char *s = SSPop( st );
305 str = malloc( i_len + 1 );
307 memcpy( str, s + m - 1, i_len );
314 else if( !strcmp( s, "strlen" ) )
316 char *str = SSPop( st );
318 SSPushN( st, strlen( str ) );
321 else if( !strcmp( s, "str_replace" ) )
323 char *psz_to = SSPop( st );
324 char *psz_from = SSPop( st );
325 char *psz_in = SSPop( st );
326 char *psz_in_current = psz_in;
327 char *psz_out = malloc( strlen(psz_in) * strlen(psz_to) + 1 );
328 char *psz_out_current = psz_out;
330 while( (p = strstr( psz_in_current, psz_from )) != NULL )
332 memcpy( psz_out_current, psz_in_current, p - psz_in_current );
333 psz_out_current += p - psz_in_current;
334 strcpy( psz_out_current, psz_to );
335 psz_out_current += strlen(psz_to);
336 psz_in_current = p + strlen(psz_from);
338 strcpy( psz_out_current, psz_in_current );
339 psz_out_current += strlen(psz_in_current);
340 *psz_out_current = '\0';
342 SSPush( st, psz_out );
348 else if( !strcmp( s, "url_extract" ) )
350 const char *url = mvar_GetValue( vars, "url_value" );
351 char *name = SSPop( st );
352 char *value = ExtractURIString( url, name );
364 else if( !strcmp( s, "url_encode" ) )
366 char *url = SSPop( st );
367 char *value = vlc_UrlEncode( url );
372 else if( !strcmp( s, "xml_encode" ) )
374 char *url = SSPop( st );
375 char *value = convert_xml_special_chars( url );
380 else if( !strcmp( s, "addslashes" ) )
382 char *psz_src = SSPop( st );
386 p = psz_dest = malloc( strlen( str ) * 2 + 1 );
388 while( *str != '\0' )
390 if( *str == '"' || *str == '\'' || *str == '\\' )
399 SSPush( st, psz_dest );
403 else if( !strcmp( s, "stripslashes" ) )
405 char *psz_src = SSPop( st );
409 p = psz_dest = strdup( psz_src );
413 if( *str == '\\' && *(str + 1) )
421 SSPush( st, psz_dest );
425 else if( !strcmp( s, "htmlspecialchars" ) )
427 char *psz_src = SSPop( st );
430 psz_dest = convert_xml_special_chars( psz_src );
432 SSPush( st, psz_dest );
436 else if( !strcmp( s, "realpath" ) )
438 char *psz_src = SSPop( st );
439 char *psz_dir = RealPath( psz_src );
441 SSPush( st, psz_dir );
445 /* 4. stack functions */
446 else if( !strcmp( s, "dup" ) )
448 char *str = SSPop( st );
453 else if( !strcmp( s, "drop" ) )
455 char *str = SSPop( st );
458 else if( !strcmp( s, "swap" ) )
460 char *s1 = SSPop( st );
461 char *s2 = SSPop( st );
468 else if( !strcmp( s, "flush" ) )
473 else if( !strcmp( s, "store" ) )
475 char *value = SSPop( st );
476 char *name = SSPop( st );
478 mvar_PushNewVar( vars, name, value );
482 else if( !strcmp( s, "value" ) )
484 char *name = SSPop( st );
485 const char *value = mvar_GetValue( vars, name );
491 /* 5. player control */
492 else if( !strcmp( s, "vlc_play" ) )
494 int i_id = SSPopN( st, vars );
497 vlc_object_lock( p_sys->p_playlist );
498 i_ret = playlist_Control( p_sys->p_playlist, PLAYLIST_VIEWPLAY,
500 playlist_ItemGetById( p_sys->p_playlist,
502 vlc_object_unlock( p_sys->p_playlist );
503 msg_Dbg( p_intf, "requested playlist item: %i", i_id );
504 SSPushN( st, i_ret );
506 else if( !strcmp( s, "vlc_stop" ) )
508 playlist_Control( p_sys->p_playlist, PLAYLIST_STOP, pl_Unlocked );
509 msg_Dbg( p_intf, "requested playlist stop" );
511 else if( !strcmp( s, "vlc_pause" ) )
513 playlist_Control( p_sys->p_playlist, PLAYLIST_PAUSE, pl_Unlocked );
514 msg_Dbg( p_intf, "requested playlist pause" );
516 else if( !strcmp( s, "vlc_next" ) )
518 playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, pl_Unlocked, 1 );
519 msg_Dbg( p_intf, "requested playlist next" );
521 else if( !strcmp( s, "vlc_previous" ) )
523 playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, pl_Unlocked, -1 );
524 msg_Dbg( p_intf, "requested playlist previous" );
526 else if( !strcmp( s, "vlc_seek" ) )
528 char *psz_value = SSPop( st );
529 HandleSeek( p_intf, psz_value );
530 msg_Dbg( p_intf, "requested playlist seek: %s", psz_value );
533 else if( !strcmp( s, "vlc_var_type" )
534 || !strcmp( s, "vlc_config_type" ) )
536 vlc_object_t *p_object;
537 const char *psz_type = NULL;
540 if( !strcmp( s, "vlc_var_type" ) )
542 char *psz_object = SSPop( st );
543 char *psz_variable = SSPop( st );
546 p_object = GetVLCObject( p_intf, psz_object, &b_need_release );
548 if( p_object != NULL )
549 i_type = var_Type( p_object, psz_variable );
550 free( psz_variable );
552 if( b_need_release && p_object != NULL )
553 vlc_object_release( p_object );
557 char *psz_variable = SSPop( st );
558 p_object = VLC_OBJECT(p_intf);
559 i_type = config_GetType( p_object, psz_variable );
560 free( psz_variable );
563 if( p_object != NULL )
565 switch( i_type & VLC_VAR_TYPE )
568 psz_type = "VLC_VAR_BOOL";
570 case VLC_VAR_INTEGER:
571 psz_type = "VLC_VAR_INTEGER";
574 psz_type = "VLC_VAR_HOTKEY";
577 psz_type = "VLC_VAR_STRING";
580 psz_type = "VLC_VAR_MODULE";
583 psz_type = "VLC_VAR_FILE";
585 case VLC_VAR_DIRECTORY:
586 psz_type = "VLC_VAR_DIRECTORY";
588 case VLC_VAR_VARIABLE:
589 psz_type = "VLC_VAR_VARIABLE";
592 psz_type = "VLC_VAR_FLOAT";
595 psz_type = "UNDEFINED";
599 psz_type = "INVALID";
601 SSPush( st, psz_type );
603 else if( !strcmp( s, "vlc_var_set" ) )
605 char *psz_object = SSPop( st );
606 char *psz_variable = SSPop( st );
609 vlc_object_t *p_object = GetVLCObject( p_intf, psz_object,
612 if( p_object != NULL )
614 bool b_error = false;
615 char *psz_value = NULL;
619 i_type = var_Type( p_object, psz_variable );
621 switch( i_type & VLC_VAR_TYPE )
624 val.b_bool = SSPopN( st, vars );
625 msg_Dbg( p_intf, "requested %s var change: %s->%d",
626 psz_object, psz_variable, val.b_bool );
628 case VLC_VAR_INTEGER:
630 val.i_int = SSPopN( st, vars );
631 msg_Dbg( p_intf, "requested %s var change: %s->%d",
632 psz_object, psz_variable, val.i_int );
637 case VLC_VAR_DIRECTORY:
638 case VLC_VAR_VARIABLE:
639 val.psz_string = psz_value = SSPop( st );
640 msg_Dbg( p_intf, "requested %s var change: %s->%s",
641 psz_object, psz_variable, psz_value );
644 psz_value = SSPop( st );
645 val.f_float = atof( psz_value );
646 msg_Dbg( p_intf, "requested %s var change: %s->%f",
647 psz_object, psz_variable, val.f_float );
651 msg_Warn( p_intf, "invalid %s variable type %d (%s)",
652 psz_object, i_type & VLC_VAR_TYPE, psz_variable );
657 var_Set( p_object, psz_variable, val );
658 if( psz_value != NULL )
662 msg_Warn( p_intf, "vlc_var_set called without an object" );
663 free( psz_variable );
666 if( b_need_release && p_object != NULL )
667 vlc_object_release( p_object );
669 else if( !strcmp( s, "vlc_var_get" ) )
671 char *psz_object = SSPop( st );
672 char *psz_variable = SSPop( st );
675 vlc_object_t *p_object = GetVLCObject( p_intf, psz_object,
678 if( p_object != NULL )
683 i_type = var_Type( p_object, psz_variable );
684 var_Get( p_object, psz_variable, &val );
686 switch( i_type & VLC_VAR_TYPE )
689 SSPushN( st, val.b_bool );
691 case VLC_VAR_INTEGER:
693 SSPushN( st, val.i_int );
698 case VLC_VAR_DIRECTORY:
699 case VLC_VAR_VARIABLE:
700 SSPush( st, val.psz_string );
701 free( val.psz_string );
706 lldiv_t value = lldiv( val.f_float * 1000000, 1000000 );
707 snprintf( psz_value, sizeof(psz_value), "%lld.%06u",
708 value.quot, (unsigned int)value.rem );
709 SSPush( st, psz_value );
713 msg_Warn( p_intf, "invalid %s variable type %d (%s)",
714 psz_object, i_type & VLC_VAR_TYPE, psz_variable );
720 msg_Warn( p_intf, "vlc_var_get called without an object" );
723 free( psz_variable );
726 if( b_need_release && p_object != NULL )
727 vlc_object_release( p_object );
729 else if( !strcmp( s, "vlc_object_exists" ) )
731 char *psz_object = SSPop( st );
734 vlc_object_t *p_object = GetVLCObject( p_intf, psz_object,
736 if( b_need_release && p_object != NULL )
737 vlc_object_release( p_object );
739 if( p_object != NULL )
744 else if( !strcmp( s, "vlc_config_set" ) )
746 char *psz_variable = SSPop( st );
747 int i_type = config_GetType( p_intf, psz_variable );
749 switch( i_type & VLC_VAR_TYPE )
752 case VLC_VAR_INTEGER:
753 config_PutInt( p_intf, psz_variable, SSPopN( st, vars ) );
758 case VLC_VAR_DIRECTORY:
760 char *psz_string = SSPop( st );
761 config_PutPsz( p_intf, psz_variable, psz_string );
767 char *psz_string = SSPop( st );
768 config_PutFloat( p_intf, psz_variable, atof(psz_string) );
773 msg_Warn( p_intf, "vlc_config_set called on unknown var (%s)",
776 free( psz_variable );
778 else if( !strcmp( s, "vlc_config_get" ) )
780 char *psz_variable = SSPop( st );
781 int i_type = config_GetType( p_intf, psz_variable );
783 switch( i_type & VLC_VAR_TYPE )
786 case VLC_VAR_INTEGER:
787 SSPushN( st, config_GetInt( p_intf, psz_variable ) );
792 case VLC_VAR_DIRECTORY:
794 char *psz_string = config_GetPsz( p_intf, psz_variable );
795 SSPush( st, psz_string );
802 lldiv_t value = lldiv( config_GetFloat( p_intf, psz_variable )
803 * 1000000, 1000000 );
804 snprintf( psz_string, sizeof(psz_string), "%lld.%06u",
805 value.quot, (unsigned int)value.rem );
806 SSPush( st, psz_string );
810 msg_Warn( p_intf, "vlc_config_get called on unknown var (%s)",
814 free( psz_variable );
816 else if( !strcmp( s, "vlc_config_save" ) )
818 char *psz_module = SSPop( st );
826 i_result = config_SaveConfigFile( p_intf, psz_module );
828 if( psz_module != NULL )
830 SSPushN( st, i_result );
832 else if( !strcmp( s, "vlc_config_reset" ) )
834 config_ResetAll( p_intf );
836 /* 6. playlist functions */
837 else if( !strcmp( s, "playlist_add" ) )
839 char *psz_name = SSPop( st );
840 char *mrl = SSPop( st );
841 input_item_t *p_input;
844 p_input = MRLParse( p_intf, mrl, psz_name );
846 char *psz_uri = input_item_GetURI( p_input );
847 if( !p_input || !psz_uri || !*psz_uri )
849 i_ret = VLC_EGENERIC;
850 msg_Dbg( p_intf, "invalid requested mrl: %s", mrl );
854 i_ret = playlist_AddInput( p_sys->p_playlist, p_input,
855 PLAYLIST_APPEND, PLAYLIST_END, true,
857 if( i_ret == VLC_SUCCESS )
859 playlist_item_t *p_item;
860 msg_Dbg( p_intf, "requested mrl add: %s", mrl );
861 p_item = playlist_ItemGetByInput( p_sys->p_playlist,
865 i_ret = p_item->i_id;
868 msg_Warn( p_intf, "adding mrl %s failed", mrl );
869 vlc_gc_decref( p_input );
872 SSPushN( st, i_ret );
877 else if( !strcmp( s, "playlist_empty" ) )
879 playlist_Clear( p_sys->p_playlist, pl_Unlocked );
880 msg_Dbg( p_intf, "requested playlist empty" );
882 else if( !strcmp( s, "playlist_delete" ) )
884 int i_id = SSPopN( st, vars );
885 playlist_item_t *p_item = playlist_ItemGetById( p_sys->p_playlist,
889 playlist_DeleteFromInput( p_sys->p_playlist,
890 p_item->p_input->i_id, pl_Unlocked );
891 msg_Dbg( p_intf, "requested playlist delete: %d", i_id );
895 msg_Dbg( p_intf, "couldn't find playlist item to delete (%d)",
899 else if( !strcmp( s, "playlist_move" ) )
901 /*int i_newpos =*/ SSPopN( st, vars );
902 /*int i_pos =*/ SSPopN( st, vars );
903 /* FIXME FIXME TODO TODO XXX XXX
904 do not release before fixing this
905 if ( i_pos < i_newpos )
907 playlist_Move( p_sys->p_playlist, i_pos, i_newpos + 1 );
911 playlist_Move( p_sys->p_playlist, i_pos, i_newpos );
913 msg_Dbg( p_intf, "requested to move playlist item %d to %d",
915 FIXME FIXME TODO TODO XXX XXX */
916 msg_Err( p_intf, "moving using indexes is obsolete. We need to update this function" );
918 else if( !strcmp( s, "playlist_sort" ) )
920 int i_order = SSPopN( st, vars );
921 int i_sort = SSPopN( st, vars );
922 i_order = i_order % 2;
924 /* FIXME FIXME TODO TODO XXX XXX
925 do not release before fixing this
926 playlist_RecursiveNodeSort( p_sys->p_playlist,
927 p_sys->p_playlist->p_general,
929 msg_Dbg( p_intf, "requested sort playlist by : %d in order : %d",
931 FIXME FIXME TODO TODO XXX XXX */
932 msg_Err( p_intf, "this needs to be fixed to use the new playlist framework" );
934 else if( !strcmp( s, "services_discovery_add" ) )
936 char *psz_sd = SSPop( st );
937 playlist_ServicesDiscoveryAdd( p_sys->p_playlist, psz_sd );
940 else if( !strcmp( s, "services_discovery_remove" ) )
942 char *psz_sd = SSPop( st );
943 playlist_ServicesDiscoveryRemove( p_sys->p_playlist, psz_sd );
946 else if( !strcmp( s, "services_discovery_is_loaded" ) )
948 char *psz_sd = SSPop( st );
950 playlist_IsServicesDiscoveryLoaded( p_sys->p_playlist, psz_sd ) );
953 else if( !strcmp( s, "vlc_volume_set" ) )
955 char *psz_vol = SSPop( st );
957 audio_volume_t i_volume;
958 aout_VolumeGet( p_intf, &i_volume );
959 if( psz_vol[0] == '+' )
961 i_value = atoi( psz_vol );
962 if( (i_volume + i_value) > AOUT_VOLUME_MAX )
963 aout_VolumeSet( p_intf, AOUT_VOLUME_MAX );
965 aout_VolumeSet( p_intf, i_volume + i_value );
967 else if( psz_vol[0] == '-' )
969 i_value = atoi( psz_vol );
970 if( (i_volume + i_value) < AOUT_VOLUME_MIN )
971 aout_VolumeSet( p_intf, AOUT_VOLUME_MIN );
973 aout_VolumeSet( p_intf, i_volume + i_value );
975 else if( strstr( psz_vol, "%") != NULL )
977 i_value = atoi( psz_vol );
978 if( i_value < 0 ) i_value = 0;
979 if( i_value > 400 ) i_value = 400;
980 aout_VolumeSet( p_intf, (i_value * (AOUT_VOLUME_MAX - AOUT_VOLUME_MIN))/400+AOUT_VOLUME_MIN);
984 i_value = atoi( psz_vol );
985 if( i_value > AOUT_VOLUME_MAX ) i_value = AOUT_VOLUME_MAX;
986 if( i_value < AOUT_VOLUME_MIN ) i_value = AOUT_VOLUME_MIN;
987 aout_VolumeSet( p_intf, i_value );
989 aout_VolumeGet( p_intf, &i_volume );
992 else if( !strcmp( s, "vlc_get_meta" ) )
994 char *psz_meta = SSPop( st );
995 char *psz_val = NULL;
996 if( p_sys->p_input && input_GetItem(p_sys->p_input) )
998 #define p_item input_GetItem( p_sys->p_input )
999 if( !strcmp( psz_meta, "ARTIST" ) )
1001 psz_val = input_item_GetArtist( p_item );
1003 else if( !strcmp( psz_meta, "TITLE" ) )
1005 psz_val = input_item_GetTitle( p_item );
1007 psz_val = input_item_GetName( p_item );
1009 else if( !strcmp( psz_meta, "ALBUM" ) )
1011 psz_val = input_item_GetAlbum( p_item );
1013 else if( !strcmp( psz_meta, "GENRE" ) )
1015 psz_val = input_item_GetGenre( p_item );
1017 else if( !strcmp( psz_meta, "COPYRIGHT" ) )
1019 psz_val = input_item_GetCopyright( p_item );
1021 else if( !strcmp( psz_meta, "TRACK_NUMBER" ) )
1023 psz_val = input_item_GetTrackNum( p_item );
1025 else if( !strcmp( psz_meta, "DESCRIPTION" ) )
1027 psz_val = input_item_GetDescription( p_item );
1029 else if( !strcmp( psz_meta, "RATING" ) )
1031 psz_val = input_item_GetRating( p_item );
1033 else if( !strcmp( psz_meta, "DATE" ) )
1035 psz_val = input_item_GetDate( p_item );
1037 else if( !strcmp( psz_meta, "URL" ) )
1039 psz_val = input_item_GetURL( p_item );
1041 else if( !strcmp( psz_meta, "LANGUAGE" ) )
1043 psz_val = input_item_GetLanguage( p_item );
1045 else if( !strcmp( psz_meta, "NOW_PLAYING" ) )
1047 psz_val = input_item_GetNowPlaying( p_item );
1049 else if( !strcmp( psz_meta, "PUBLISHER" ) )
1051 psz_val = input_item_GetPublisher( p_item );
1053 else if( !strcmp( psz_meta, "ENCODED_BY" ) )
1055 psz_val = input_item_GetEncodedBy( p_item );
1057 else if( !strcmp( psz_meta, "ART_URL" ) )
1059 psz_val = input_item_GetEncodedBy( p_item );
1061 else if( !strcmp( psz_meta, "TRACK_ID" ) )
1063 psz_val = input_item_GetTrackID( p_item );
1067 if( psz_val == NULL ) psz_val = strdup( "" );
1068 SSPush( st, psz_val );
1073 else if( !strcmp( s, "vlm_command" ) || !strcmp( s, "vlm_cmd" ) )
1076 char *psz_cmd = strdup( "" );
1078 vlm_message_t *vlm_answer;
1080 /* make sure that we have a vlm object */
1081 if( p_intf->p_sys->p_vlm == NULL )
1082 p_intf->p_sys->p_vlm = vlm_New( p_intf );
1085 /* vlm command uses the ';' delimiter
1086 * (else we can't know when to stop) */
1087 while( strcmp( psz_elt = SSPop( st ), "" )
1088 && strcmp( psz_elt, ";" ) )
1091 (char *)malloc( strlen( psz_cmd ) + strlen( psz_elt ) + 2 );
1092 sprintf( psz_buf, "%s %s", psz_cmd, psz_elt );
1098 msg_Dbg( p_intf, "executing vlm command: %s", psz_cmd );
1099 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz_cmd, &vlm_answer );
1101 if( vlm_answer->psz_value == NULL )
1103 psz_error = strdup( "" );
1107 psz_error = malloc( strlen(vlm_answer->psz_name) +
1108 strlen(vlm_answer->psz_value) +
1109 strlen( " : ") + 1 );
1110 sprintf( psz_error , "%s : %s" , vlm_answer->psz_name,
1111 vlm_answer->psz_value );
1114 mvar_AppendNewVar( vars, "vlm_error", psz_error );
1115 /* this is kind of a duplicate but we need to have the message
1116 * without the command name for the "export" command */
1117 mvar_AppendNewVar( vars, "vlm_value", vlm_answer->psz_value );
1118 vlm_MessageDelete( vlm_answer );
1123 #endif /* ENABLE_VLM */
1124 else if( !strcmp( s, "snapshot" ) )
1126 if( p_sys->p_input )
1128 vout_thread_t *p_vout;
1129 p_vout = vlc_object_find( p_sys->p_input,
1130 VLC_OBJECT_VOUT, FIND_CHILD );
1134 vout_Control( p_vout, VOUT_SNAPSHOT );
1135 vlc_object_release( p_vout );
1136 msg_Dbg( p_intf, "requested snapshot" );