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 *****************************************************************************/
29 static vlc_object_t *GetVLCObject( intf_thread_t *p_intf,
30 const char *psz_object,
31 vlc_bool_t *pb_need_release )
33 intf_sys_t *p_sys = p_intf->p_sys;
34 int i_object_type = 0;
35 vlc_object_t *p_object = NULL;
36 *pb_need_release = VLC_FALSE;
38 if( !strcmp( psz_object, "VLC_OBJECT_ROOT" ) )
39 i_object_type = VLC_OBJECT_ROOT;
40 else if( !strcmp( psz_object, "VLC_OBJECT_VLC" ) )
41 p_object = VLC_OBJECT(p_intf->p_vlc);
42 else if( !strcmp( psz_object, "VLC_OBJECT_INTF" ) )
43 p_object = VLC_OBJECT(p_intf);
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( !strcmp( psz_object, "VLC_OBJECT_VOUT" ) )
49 i_object_type = VLC_OBJECT_VOUT;
50 else if( !strcmp( psz_object, "VLC_OBJECT_AOUT" ) )
51 i_object_type = VLC_OBJECT_AOUT;
52 else if( !strcmp( psz_object, "VLC_OBJECT_SOUT" ) )
53 i_object_type = VLC_OBJECT_SOUT;
55 msg_Warn( p_intf, "unknown object type (%s)", psz_object );
57 if( p_object == NULL && i_object_type )
59 *pb_need_release = VLC_TRUE;
60 p_object = vlc_object_find( p_intf, i_object_type, FIND_ANYWHERE );
66 void E_(SSInit)( rpn_stack_t *st )
71 void E_(SSClean)( rpn_stack_t *st )
73 while( st->i_stack > 0 )
75 free( st->stack[--st->i_stack] );
79 void E_(SSPush)( rpn_stack_t *st, const char *s )
81 if( st->i_stack < STACK_MAX )
83 st->stack[st->i_stack++] = strdup( s );
87 char *E_(SSPop)( rpn_stack_t *st )
89 if( st->i_stack <= 0 )
95 return st->stack[--st->i_stack];
99 int E_(SSPopN)( rpn_stack_t *st, mvar_t *vars )
107 name = E_(SSPop)( st );
108 i = strtol( name, &end, 0 );
111 value = E_(mvar_GetValue)( vars, name );
119 void E_(SSPushN)( rpn_stack_t *st, int i )
123 sprintf( v, "%d", i );
127 void E_(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 = E_(FirstWord)( exp, exp );
146 E_(SSPush)( st, exp );
152 p = E_(FirstWord)( exp, exp );
156 exp += strlen( exp );
168 /* 1. Integer function */
169 if( !strcmp( s, "!" ) )
171 E_(SSPushN)( st, ~E_(SSPopN)( st, vars ) );
173 else if( !strcmp( s, "^" ) )
175 E_(SSPushN)( st, E_(SSPopN)( st, vars ) ^ E_(SSPopN)( st, vars ) );
177 else if( !strcmp( s, "&" ) )
179 E_(SSPushN)( st, E_(SSPopN)( st, vars ) & E_(SSPopN)( st, vars ) );
181 else if( !strcmp( s, "|" ) )
183 E_(SSPushN)( st, E_(SSPopN)( st, vars ) | E_(SSPopN)( st, vars ) );
185 else if( !strcmp( s, "+" ) )
187 E_(SSPushN)( st, E_(SSPopN)( st, vars ) + E_(SSPopN)( st, vars ) );
189 else if( !strcmp( s, "-" ) )
191 int j = E_(SSPopN)( st, vars );
192 int i = E_(SSPopN)( st, vars );
193 E_(SSPushN)( st, i - j );
195 else if( !strcmp( s, "*" ) )
197 E_(SSPushN)( st, E_(SSPopN)( st, vars ) * E_(SSPopN)( st, vars ) );
199 else if( !strcmp( s, "/" ) )
203 j = E_(SSPopN)( st, vars );
204 i = E_(SSPopN)( st, vars );
206 E_(SSPushN)( st, j != 0 ? i / j : 0 );
208 else if( !strcmp( s, "%" ) )
212 j = E_(SSPopN)( st, vars );
213 i = E_(SSPopN)( st, vars );
215 E_(SSPushN)( st, j != 0 ? i % j : 0 );
217 /* 2. integer tests */
218 else if( !strcmp( s, "=" ) )
220 E_(SSPushN)( st, E_(SSPopN)( st, vars ) == E_(SSPopN)( st, vars ) ? -1 : 0 );
222 else if( !strcmp( s, "!=" ) )
224 E_(SSPushN)( st, E_(SSPopN)( st, vars ) != E_(SSPopN)( st, vars ) ? -1 : 0 );
226 else if( !strcmp( s, "<" ) )
228 int j = E_(SSPopN)( st, vars );
229 int i = E_(SSPopN)( st, vars );
231 E_(SSPushN)( st, i < j ? -1 : 0 );
233 else if( !strcmp( s, ">" ) )
235 int j = E_(SSPopN)( st, vars );
236 int i = E_(SSPopN)( st, vars );
238 E_(SSPushN)( st, i > j ? -1 : 0 );
240 else if( !strcmp( s, "<=" ) )
242 int j = E_(SSPopN)( st, vars );
243 int i = E_(SSPopN)( st, vars );
245 E_(SSPushN)( st, i <= j ? -1 : 0 );
247 else if( !strcmp( s, ">=" ) )
249 int j = E_(SSPopN)( st, vars );
250 int i = E_(SSPopN)( st, vars );
252 E_(SSPushN)( st, i >= j ? -1 : 0 );
254 /* 3. string functions */
255 else if( !strcmp( s, "strcat" ) )
257 char *s2 = E_(SSPop)( st );
258 char *s1 = E_(SSPop)( st );
259 char *str = malloc( strlen( s1 ) + strlen( s2 ) + 1 );
264 E_(SSPush)( st, str );
269 else if( !strcmp( s, "strcmp" ) )
271 char *s2 = E_(SSPop)( st );
272 char *s1 = E_(SSPop)( st );
274 E_(SSPushN)( st, strcmp( s1, s2 ) );
278 else if( !strcmp( s, "strncmp" ) )
280 int n = E_(SSPopN)( st, vars );
281 char *s2 = E_(SSPop)( st );
282 char *s1 = E_(SSPop)( st );
284 E_(SSPushN)( st, strncmp( s1, s2 , n ) );
288 else if( !strcmp( s, "strsub" ) )
290 int n = E_(SSPopN)( st, vars );
291 int m = E_(SSPopN)( st, vars );
293 char *s = E_(SSPop)( st );
305 str = malloc( i_len + 1 );
307 memcpy( str, s + m - 1, i_len );
310 E_(SSPush)( st, str );
314 else if( !strcmp( s, "strlen" ) )
316 char *str = E_(SSPop)( st );
318 E_(SSPushN)( st, strlen( str ) );
321 else if( !strcmp( s, "str_replace" ) )
323 char *psz_to = E_(SSPop)( st );
324 char *psz_from = E_(SSPop)( st );
325 char *psz_in = E_(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 E_(SSPush)( st, psz_out );
348 else if( !strcmp( s, "url_extract" ) )
350 char *url = E_(mvar_GetValue)( vars, "url_value" );
351 char *name = E_(SSPop)( st );
355 E_(ExtractURIValue)( url, name, value, 512 );
356 E_(DecodeEncodedURI)( value );
357 tmp = E_(FromUTF8)( p_intf, value );
358 E_(SSPush)( st, tmp );
362 else if( !strcmp( s, "url_encode" ) )
364 char *url = E_(SSPop)( st );
367 value = E_(ToUTF8)( p_intf, url );
370 value = vlc_UrlEncode( url );
372 E_(SSPush)( st, value );
375 else if( !strcmp( s, "addslashes" ) )
377 char *psz_src = E_(SSPop)( st );
381 p = psz_dest = malloc( strlen( str ) * 2 + 1 );
383 while( *str != '\0' )
385 if( *str == '"' || *str == '\'' || *str == '\\' )
394 E_(SSPush)( st, psz_dest );
398 else if( !strcmp( s, "stripslashes" ) )
400 char *psz_src = E_(SSPop)( st );
403 p = psz_dest = strdup( psz_src );
407 if( *psz_src == '\\' && *(psz_src + 1) )
415 E_(SSPush)( st, psz_dest );
419 else if( !strcmp( s, "htmlspecialchars" ) )
421 char *psz_src = E_(SSPop)( st );
425 p = psz_dest = malloc( strlen( str ) * 6 + 1 );
427 while( *str != '\0' )
431 strcpy( p, "&" );
434 else if( *str == '\"' )
436 strcpy( p, """ );
439 else if( *str == '\'' )
441 strcpy( p, "'" );
444 else if( *str == '<' )
449 else if( *str == '>' )
462 E_(SSPush)( st, psz_dest );
466 else if( !strcmp( s, "realpath" ) )
468 char *psz_src = E_(SSPop)( st );
469 char *psz_dir = E_(RealPath)( p_intf, psz_src );
471 E_(SSPush)( st, psz_dir );
475 /* 4. stack functions */
476 else if( !strcmp( s, "dup" ) )
478 char *str = E_(SSPop)( st );
479 E_(SSPush)( st, str );
480 E_(SSPush)( st, str );
483 else if( !strcmp( s, "drop" ) )
485 char *str = E_(SSPop)( st );
488 else if( !strcmp( s, "swap" ) )
490 char *s1 = E_(SSPop)( st );
491 char *s2 = E_(SSPop)( st );
493 E_(SSPush)( st, s1 );
494 E_(SSPush)( st, s2 );
498 else if( !strcmp( s, "flush" ) )
503 else if( !strcmp( s, "store" ) )
505 char *value = E_(SSPop)( st );
506 char *name = E_(SSPop)( st );
508 E_(mvar_PushNewVar)( vars, name, value );
512 else if( !strcmp( s, "value" ) )
514 char *name = E_(SSPop)( st );
515 char *value = E_(mvar_GetValue)( vars, name );
517 E_(SSPush)( st, value );
521 /* 5. player control */
522 else if( !strcmp( s, "vlc_play" ) )
524 int i_id = E_(SSPopN)( st, vars );
527 i_ret = playlist_Control( p_sys->p_playlist, PLAYLIST_ITEMPLAY,
528 playlist_ItemGetById( p_sys->p_playlist,
530 msg_Dbg( p_intf, "requested playlist item: %i", i_id );
531 E_(SSPushN)( st, i_ret );
533 else if( !strcmp( s, "vlc_stop" ) )
535 playlist_Control( p_sys->p_playlist, PLAYLIST_STOP );
536 msg_Dbg( p_intf, "requested playlist stop" );
538 else if( !strcmp( s, "vlc_pause" ) )
540 playlist_Control( p_sys->p_playlist, PLAYLIST_PAUSE );
541 msg_Dbg( p_intf, "requested playlist pause" );
543 else if( !strcmp( s, "vlc_next" ) )
545 playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, 1 );
546 msg_Dbg( p_intf, "requested playlist next" );
548 else if( !strcmp( s, "vlc_previous" ) )
550 playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, -1 );
551 msg_Dbg( p_intf, "requested playlist previous" );
553 else if( !strcmp( s, "vlc_seek" ) )
555 char *psz_value = E_(SSPop)( st );
556 E_(HandleSeek)( p_intf, psz_value );
557 msg_Dbg( p_intf, "requested playlist seek: %s", psz_value );
560 else if( !strcmp( s, "vlc_var_type" )
561 || !strcmp( s, "vlc_config_type" ) )
563 vlc_object_t *p_object;
564 const char *psz_type = NULL;
567 if( !strcmp( s, "vlc_var_type" ) )
569 char *psz_object = E_(SSPop)( st );
570 char *psz_variable = E_(SSPop)( st );
571 vlc_bool_t b_need_release;
573 p_object = GetVLCObject( p_intf, psz_object, &b_need_release );
575 if( p_object != NULL )
576 i_type = var_Type( p_object, psz_variable );
577 free( psz_variable );
579 if( b_need_release && p_object != NULL )
580 vlc_object_release( p_object );
584 char *psz_variable = E_(SSPop)( st );
585 p_object = VLC_OBJECT(p_intf);
586 i_type = config_GetType( p_object, psz_variable );
587 free( psz_variable );
590 if( p_object != NULL )
592 switch( i_type & VLC_VAR_TYPE )
595 psz_type = "VLC_VAR_BOOL";
597 case VLC_VAR_INTEGER:
598 psz_type = "VLC_VAR_INTEGER";
601 psz_type = "VLC_VAR_HOTKEY";
604 psz_type = "VLC_VAR_STRING";
607 psz_type = "VLC_VAR_MODULE";
610 psz_type = "VLC_VAR_FILE";
612 case VLC_VAR_DIRECTORY:
613 psz_type = "VLC_VAR_DIRECTORY";
615 case VLC_VAR_VARIABLE:
616 psz_type = "VLC_VAR_VARIABLE";
619 psz_type = "VLC_VAR_FLOAT";
622 psz_type = "UNDEFINED";
626 psz_type = "INVALID";
628 E_(SSPush)( st, psz_type );
630 else if( !strcmp( s, "vlc_var_set" ) )
632 char *psz_object = E_(SSPop)( st );
633 char *psz_variable = E_(SSPop)( st );
634 vlc_bool_t b_need_release;
636 vlc_object_t *p_object = GetVLCObject( p_intf, psz_object,
639 if( p_object != NULL )
641 vlc_bool_t b_error = VLC_FALSE;
642 char *psz_value = NULL;
646 i_type = var_Type( p_object, psz_variable );
648 switch( i_type & VLC_VAR_TYPE )
651 val.b_bool = E_(SSPopN)( st, vars );
652 msg_Dbg( p_intf, "requested %s var change: %s->%d",
653 psz_object, psz_variable, val.b_bool );
655 case VLC_VAR_INTEGER:
657 val.i_int = E_(SSPopN)( st, vars );
658 msg_Dbg( p_intf, "requested %s var change: %s->%d",
659 psz_object, psz_variable, val.i_int );
664 case VLC_VAR_DIRECTORY:
665 case VLC_VAR_VARIABLE:
666 val.psz_string = psz_value = E_(SSPop)( st );
667 msg_Dbg( p_intf, "requested %s var change: %s->%s",
668 psz_object, psz_variable, psz_value );
671 psz_value = E_(SSPop)( st );
672 val.f_float = atof( psz_value );
673 msg_Dbg( p_intf, "requested %s var change: %s->%f",
674 psz_object, psz_variable, val.f_float );
677 E_(SSPopN)( st, vars );
678 msg_Warn( p_intf, "invalid %s variable type %d (%s)",
679 psz_object, i_type & VLC_VAR_TYPE, psz_variable );
684 var_Set( p_object, psz_variable, val );
685 if( psz_value != NULL )
689 msg_Warn( p_intf, "vlc_var_set called without an object" );
690 free( psz_variable );
693 if( b_need_release && p_object != NULL )
694 vlc_object_release( p_object );
696 else if( !strcmp( s, "vlc_var_get" ) )
698 char *psz_object = E_(SSPop)( st );
699 char *psz_variable = E_(SSPop)( st );
700 vlc_bool_t b_need_release;
702 vlc_object_t *p_object = GetVLCObject( p_intf, psz_object,
705 if( p_object != NULL )
710 i_type = var_Type( p_object, psz_variable );
711 var_Get( p_object, psz_variable, &val );
713 switch( i_type & VLC_VAR_TYPE )
716 E_(SSPushN)( st, val.b_bool );
718 case VLC_VAR_INTEGER:
720 E_(SSPushN)( st, val.i_int );
725 case VLC_VAR_DIRECTORY:
726 case VLC_VAR_VARIABLE:
727 E_(SSPush)( st, val.psz_string );
728 free( val.psz_string );
733 snprintf( psz_value, sizeof(psz_value), "%f", val.f_float );
734 E_(SSPush)( st, psz_value );
738 msg_Warn( p_intf, "invalid %s variable type %d (%s)",
739 psz_object, i_type & VLC_VAR_TYPE, psz_variable );
740 E_(SSPush)( st, "" );
745 msg_Warn( p_intf, "vlc_var_get called without an object" );
746 E_(SSPush)( st, "" );
748 free( psz_variable );
751 if( b_need_release && p_object != NULL )
752 vlc_object_release( p_object );
754 else if( !strcmp( s, "vlc_object_exists" ) )
756 char *psz_object = E_(SSPop)( st );
757 vlc_bool_t b_need_release;
759 vlc_object_t *p_object = GetVLCObject( p_intf, psz_object,
761 if( b_need_release && p_object != NULL )
762 vlc_object_release( p_object );
764 if( p_object != NULL )
765 E_(SSPush)( st, "1" );
767 E_(SSPush)( st, "0" );
769 else if( !strcmp( s, "vlc_config_set" ) )
771 char *psz_variable = E_(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 config_PutInt( p_intf, psz_variable, E_(SSPopN)( st, vars ) );
783 case VLC_VAR_DIRECTORY:
785 char *psz_string = E_(SSPop)( st );
786 config_PutPsz( p_intf, psz_variable, psz_string );
792 char *psz_string = E_(SSPop)( st );
793 config_PutFloat( p_intf, psz_variable, atof(psz_string) );
798 msg_Warn( p_intf, "vlc_config_set called on unknown var (%s)",
801 free( psz_variable );
803 else if( !strcmp( s, "vlc_config_get" ) )
805 char *psz_variable = E_(SSPop)( st );
806 int i_type = config_GetType( p_intf, psz_variable );
808 switch( i_type & VLC_VAR_TYPE )
811 case VLC_VAR_INTEGER:
812 E_(SSPushN)( st, config_GetInt( p_intf, psz_variable ) );
817 case VLC_VAR_DIRECTORY:
819 char *psz_string = config_GetPsz( p_intf, psz_variable );
820 E_(SSPush)( st, psz_string );
827 snprintf( psz_string, sizeof(psz_string), "%f",
828 config_GetFloat( p_intf, psz_variable ) );
829 E_(SSPush)( st, psz_string );
833 msg_Warn( p_intf, "vlc_config_get called on unknown var (%s)",
836 free( psz_variable );
838 else if( !strcmp( s, "vlc_config_save" ) )
840 char *psz_module = E_(SSPop)( st );
848 i_result = config_SaveConfigFile( p_intf, psz_module );
850 if( psz_module != NULL )
852 E_(SSPushN)( st, i_result );
854 else if( !strcmp( s, "vlc_config_reset" ) )
856 config_ResetAll( p_intf );
858 /* 6. playlist functions */
859 else if( !strcmp( s, "playlist_add" ) )
861 char *psz_name = E_(SSPop)( st );
862 char *mrl = E_(SSPop)( st );
864 playlist_item_t *p_item;
867 tmp = E_(ToUTF8)( p_intf, psz_name );
870 tmp = E_(ToUTF8)( p_intf, mrl );
876 p_item = E_(MRLParse)( p_intf, mrl, mrl );
880 p_item = E_(MRLParse)( p_intf, mrl, psz_name );
883 if( p_item == NULL || p_item->input.psz_uri == NULL ||
884 !*p_item->input.psz_uri )
887 msg_Dbg( p_intf, "invalid requested mrl: %s", mrl );
891 i_id = playlist_AddItem( p_sys->p_playlist, p_item,
892 PLAYLIST_APPEND, PLAYLIST_END );
893 msg_Dbg( p_intf, "requested mrl add: %s", mrl );
895 E_(SSPushN)( st, i_id );
900 else if( !strcmp( s, "playlist_empty" ) )
902 playlist_LockClear( p_sys->p_playlist );
903 msg_Dbg( p_intf, "requested playlist empty" );
905 else if( !strcmp( s, "playlist_delete" ) )
907 int i_id = E_(SSPopN)( st, vars );
908 playlist_LockDelete( p_sys->p_playlist, i_id );
909 msg_Dbg( p_intf, "requested playlist delete: %d", i_id );
911 else if( !strcmp( s, "playlist_move" ) )
913 int i_newpos = E_(SSPopN)( st, vars );
914 int i_pos = E_(SSPopN)( st, vars );
915 if ( i_pos < i_newpos )
917 playlist_Move( p_sys->p_playlist, i_pos, i_newpos + 1 );
921 playlist_Move( p_sys->p_playlist, i_pos, i_newpos );
923 msg_Dbg( p_intf, "requested to move playlist item %d to %d",
926 else if( !strcmp( s, "vlc_volume_set" ) )
928 char *psz_vol = E_(SSPop)( st );
930 audio_volume_t i_volume;
931 aout_VolumeGet( p_intf, &i_volume );
932 if( psz_vol[0] == '+' )
934 i_value = atoi( psz_vol );
935 if( (i_volume + i_value) > AOUT_VOLUME_MAX )
936 aout_VolumeSet( p_intf, AOUT_VOLUME_MAX );
938 aout_VolumeSet( p_intf, i_volume + i_value );
940 else if( psz_vol[0] == '-' )
942 i_value = atoi( psz_vol );
943 if( (i_volume + i_value) < AOUT_VOLUME_MIN )
944 aout_VolumeSet( p_intf, AOUT_VOLUME_MIN );
946 aout_VolumeSet( p_intf, i_volume + i_value );
948 else if( strstr( psz_vol, "%") != NULL )
950 i_value = atoi( psz_vol );
951 if( i_value < 0 ) i_value = 0;
952 if( i_value > 400 ) i_value = 400;
953 aout_VolumeSet( p_intf, (i_value * (AOUT_VOLUME_MAX - AOUT_VOLUME_MIN))/400+AOUT_VOLUME_MIN);
957 i_value = atoi( psz_vol );
958 if( i_value > AOUT_VOLUME_MAX ) i_value = AOUT_VOLUME_MAX;
959 if( i_value < AOUT_VOLUME_MIN ) i_value = AOUT_VOLUME_MIN;
960 aout_VolumeSet( p_intf, i_value );
962 aout_VolumeGet( p_intf, &i_volume );
964 else if( !strcmp( s, "vlm_command" ) || !strcmp( s, "vlm_cmd" ) )
967 char *psz_cmd = strdup( "" );
969 vlm_message_t *vlm_answer;
971 /* make sure that we have a vlm object */
972 if( p_intf->p_sys->p_vlm == NULL )
973 p_intf->p_sys->p_vlm = vlm_New( p_intf );
976 /* vlm command uses the ';' delimiter
977 * (else we can't know when to stop) */
978 while( strcmp( psz_elt = E_(SSPop)( st ), "" )
979 && strcmp( psz_elt, ";" ) )
982 (char *)malloc( strlen( psz_cmd ) + strlen( psz_elt ) + 2 );
983 sprintf( psz_buf, "%s %s", psz_cmd, psz_elt );
989 msg_Dbg( p_intf, "executing vlm command: %s", psz_cmd );
990 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz_cmd, &vlm_answer );
992 if( vlm_answer->psz_value == NULL )
994 psz_error = strdup( "" );
998 psz_error = malloc( strlen(vlm_answer->psz_name) +
999 strlen(vlm_answer->psz_value) +
1000 strlen( " : ") + 1 );
1001 sprintf( psz_error , "%s : %s" , vlm_answer->psz_name,
1002 vlm_answer->psz_value );
1005 E_(mvar_AppendNewVar)( vars, "vlm_error", psz_error );
1006 /* this is kind of a duplicate but we need to have the message
1007 * without the command name for the "export" command */
1008 E_(mvar_AppendNewVar)( vars, "vlm_value", vlm_answer->psz_value );
1009 vlm_MessageDelete( vlm_answer );
1016 E_(SSPush)( st, s );