1 /*****************************************************************************
2 * macro.c : Custom <vlc> macro handling
3 *****************************************************************************
4 * Copyright (C) 2001-2005 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 *****************************************************************************/
30 static int MacroParse( macro_t *m, char *psz_src )
32 char *dup = strdup( (char *)psz_src );
37 #define EXTRACT( name, l ) \
39 p = strchr( src, '"' ); \
44 m->name = strdup( src ); \
65 if( !strncmp( src, "id=\"", 4 ) )
69 else if( !strncmp( src, "param1=\"", 8 ) )
73 else if( !strncmp( src, "param2=\"", 8 ) )
82 if( strstr( src, "/>" ) )
84 src = strstr( src, "/>" ) + 2;
95 if( m->param1 == NULL )
97 m->param1 = strdup( "" );
99 if( m->param2 == NULL )
101 m->param2 = strdup( "" );
110 static void MacroClean( macro_t *m )
117 static int StrToMacroType( const char *name )
121 if( !name || *name == '\0')
125 for( i = 0; StrToMacroTypeTab[i].psz_name != NULL; i++ )
127 if( !strcmp( name, StrToMacroTypeTab[i].psz_name ) )
129 return StrToMacroTypeTab[i].i_type;
135 static void MacroDo( httpd_file_sys_t *p_args,
137 char *p_request, int i_request,
138 char **pp_data, int *pi_data,
141 intf_thread_t *p_intf = p_args->p_intf;
142 intf_sys_t *p_sys = p_args->p_intf->p_sys;
147 int __i__ = *pp_dst - *pp_data; \
149 *pp_data = realloc( *pp_data, *pi_data ); \
150 *pp_dst = (*pp_data) + __i__; \
152 #define PRINT( str ) \
153 ALLOC( strlen( str ) + 1 ); \
154 *pp_dst += sprintf( *pp_dst, "%s", str );
156 #define PRINTS( str, s ) \
157 ALLOC( strlen( str ) + strlen( s ) + 1 ); \
159 char * psz_cur = *pp_dst; \
160 *pp_dst += sprintf( *pp_dst, str, s ); \
161 while( psz_cur && *psz_cur ) \
163 /* Prevent script injection */ \
164 if( *psz_cur == '<' ) *psz_cur = '*'; \
165 if( *psz_cur == '>' ) *psz_cur = '*'; \
170 switch( StrToMacroType( m->id ) )
177 E_(ExtractURIValue)( p_request, "control", control, 512 );
178 if( *m->param1 && !strstr( m->param1, control ) )
180 msg_Warn( p_intf, "unauthorized control=%s", control );
183 switch( StrToMacroType( control ) )
190 E_(ExtractURIValue)( p_request, "item", item, 512 );
191 i_item = atoi( item );
192 /* id = 0 : simply ask playlist to play */
195 playlist_Play( p_sys->p_playlist );
196 msg_Dbg( p_intf, "requested playlist play" );
199 playlist_Control( p_sys->p_playlist, PLAYLIST_VIEWPLAY,
201 playlist_ItemGetById( p_sys->p_playlist,
202 i_item, VLC_TRUE ) );
203 msg_Dbg( p_intf, "requested playlist item: %i", i_item );
207 playlist_Control( p_sys->p_playlist, PLAYLIST_STOP,
209 msg_Dbg( p_intf, "requested playlist stop" );
212 playlist_Control( p_sys->p_playlist, PLAYLIST_PAUSE,
214 msg_Dbg( p_intf, "requested playlist pause" );
217 playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP,
219 msg_Dbg( p_intf, "requested playlist next" );
222 playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP,
224 msg_Dbg( p_intf, "requested playlist previous" );
226 case MVLC_FULLSCREEN:
229 vout_thread_t *p_vout;
230 p_vout = vlc_object_find( p_sys->p_input,
231 VLC_OBJECT_VOUT, FIND_CHILD );
235 p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
236 vlc_object_release( p_vout );
237 msg_Dbg( p_intf, "requested fullscreen toggle" );
244 E_(ExtractURIValue)( p_request, "seek_value", value, 30 );
246 E_(HandleSeek)( p_intf, value );
252 audio_volume_t i_volume;
255 E_(ExtractURIValue)( p_request, "value", vol, 8 );
256 aout_VolumeGet( p_intf, &i_volume );
261 i_value = atoi( vol + 1 );
262 if( (i_volume + i_value) > AOUT_VOLUME_MAX )
264 aout_VolumeSet( p_intf , AOUT_VOLUME_MAX );
265 msg_Dbg( p_intf, "requested volume set: max" );
269 aout_VolumeSet( p_intf , (i_volume + i_value) );
270 msg_Dbg( p_intf, "requested volume set: +%i", (i_volume + i_value) );
273 else if( vol[0] == '-' )
275 i_value = atoi( vol + 1 );
276 if( (i_volume - i_value) < AOUT_VOLUME_MIN )
278 aout_VolumeSet( p_intf , AOUT_VOLUME_MIN );
279 msg_Dbg( p_intf, "requested volume set: min" );
283 aout_VolumeSet( p_intf , (i_volume - i_value) );
284 msg_Dbg( p_intf, "requested volume set: -%i", (i_volume - i_value) );
287 else if( strstr(vol, "%") != NULL )
289 i_value = atoi( vol );
290 if( (i_value <= 400) && (i_value>=0) ){
291 aout_VolumeSet( p_intf, (i_value * (AOUT_VOLUME_MAX - AOUT_VOLUME_MIN))/400+AOUT_VOLUME_MIN);
292 msg_Dbg( p_intf, "requested volume set: %i%%", atoi( vol ));
297 i_value = atoi( vol );
298 if( ( i_value <= AOUT_VOLUME_MAX ) && ( i_value >= AOUT_VOLUME_MIN ) )
300 aout_VolumeSet( p_intf , atoi( vol ) );
301 msg_Dbg( p_intf, "requested volume set: %i", atoi( vol ) );
307 /* playlist management */
310 char mrl[1024], psz_name[1024], tmp[1024];
312 input_item_t *p_input;
314 E_(ExtractURIValue)( p_request, "mrl", tmp, 1024 );
316 E_(ExtractURIValue)( p_request, "name", psz_name, 1024 );
317 decode_URI( psz_name );
320 memcpy( psz_name, tmp, 1024 );
322 /* addslashes for backward compatibility with the old
325 while( *str != '\0' )
327 if( *str == '"' || *str == '\'' || *str == '\\' )
336 p_input = E_(MRLParse)( p_intf, mrl, psz_name );
338 char *psz_uri = input_item_GetURI( p_input );
339 if( !p_input || !psz_uri || !*psz_uri )
341 msg_Dbg( p_intf, "invalid requested mrl: %s", mrl );
345 playlist_AddInput( p_sys->p_playlist, p_input,
346 PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE,
348 vlc_gc_decref( p_input );
349 msg_Dbg( p_intf, "requested mrl add: %s", mrl );
357 int i_item, *p_items = NULL, i_nb_items = 0;
358 char item[512], *p_parser = p_request;
360 /* Get the list of items to delete */
362 E_(ExtractURIValue)( p_parser, "item", item, 512 )) )
364 if( !*item ) continue;
366 i_item = atoi( item );
367 p_items = realloc( p_items, (i_nb_items + 1) *
369 p_items[i_nb_items] = i_item;
376 for( i = 0; i < i_nb_items; i++ )
378 playlist_DeleteFromInput( p_sys->p_playlist,
379 p_items[i], VLC_FALSE );
380 msg_Dbg( p_intf, "requested playlist delete: %d",
386 if( p_items ) free( p_items );
391 int i_item, *p_items = NULL, i_nb_items = 0;
392 char item[512], *p_parser = p_request;
395 /* Get the list of items to keep */
397 E_(ExtractURIValue)( p_parser, "item", item, 512 )) )
399 if( !*item ) continue;
401 i_item = atoi( item );
402 p_items = realloc( p_items, (i_nb_items + 1) *
404 p_items[i_nb_items] = i_item;
408 for( i = p_sys->p_playlist->items.i_size - 1 ; i >= 0; i-- )
410 /* Check if the item is in the keep list */
411 for( j = 0 ; j < i_nb_items ; j++ )
414 ARRAY_VAL(p_sys->p_playlist->items,i)
418 if( j == i_nb_items )
420 playlist_DeleteFromInput( p_sys->p_playlist,
421 p_sys->p_playlist->items.p_elems[i]->i_id,
423 msg_Dbg( p_intf, "requested playlist delete: %d",
428 if( p_items ) free( p_items );
433 playlist_Clear( p_sys->p_playlist, VLC_FALSE );
434 msg_Dbg( p_intf, "requested playlist empty" );
445 E_(ExtractURIValue)( p_request, "type", type, 12 );
446 E_(ExtractURIValue)( p_request, "order", order, 2 );
447 E_(ExtractURIValue)( p_request, "item", item, 512 );
448 i_item = atoi( item );
450 if( order[0] == '0' ) i_order = ORDER_NORMAL;
451 else i_order = ORDER_REVERSE;
453 if( !strcmp( type , "title" ) )
455 playlist_RecursiveNodeSort( p_sys->p_playlist,
456 /* Ugly hack,but not worse than before ... */
457 p_sys->p_playlist->p_root_onelevel,
458 SORT_TITLE_NODES_FIRST,
459 ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
460 msg_Dbg( p_intf, "requested playlist sort by title (%d)" , i_order );
462 else if( !strcmp( type , "author" ) )
464 playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
465 p_sys->p_playlist->p_root_onelevel,
467 ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
468 msg_Dbg( p_intf, "requested playlist sort by author (%d)" , i_order );
470 else if( !strcmp( type , "shuffle" ) )
472 playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
473 p_sys->p_playlist->p_root_onelevel,
475 ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
476 msg_Dbg( p_intf, "requested playlist shuffle");
487 E_(ExtractURIValue)( p_request, "psz_pos", psz_pos, 6 );
488 E_(ExtractURIValue)( p_request, "psz_newpos", psz_newpos, 6 );
489 i_pos = atoi( psz_pos );
490 i_newpos = atoi( psz_newpos );
491 /* FIXME FIXME TODO TODO XXX XXX
492 ( duplicate from rpn.c )
493 if ( i_pos < i_newpos )
495 playlist_Move( p_sys->p_playlist, i_pos, i_newpos + 1 );
499 playlist_Move( p_sys->p_playlist, i_pos, i_newpos );
501 msg_Dbg( p_intf, "requested move playlist item %d to %d", i_pos, i_newpos);
502 FIXME FIXME TODO TODO XXX XXX */
510 E_(ExtractURIValue)( p_request, "id", id, 512 );
511 msg_Dbg( p_intf, "requested close id=%s", id );
513 if( p_sys->p_httpd->pf_control( p_sys->p_httpd, HTTPD_SET_CLOSE, id, NULL ) )
515 msg_Warn( p_intf, "close failed for id=%s", id );
522 msg_Dbg( p_intf, "requested shutdown" );
523 vlc_object_kill( p_intf->p_libvlc );
530 static const char *vlm_properties[11] =
533 "enabled", "disabled", "loop", "unloop",
535 "input", "output", "option", "date", "period", "repeat", "append",
537 vlm_message_t *vlm_answer;
539 char *psz = malloc( strlen( p_request ) + 1000 );
544 if( p_intf->p_sys->p_vlm == NULL )
545 p_intf->p_sys->p_vlm = vlm_New( p_intf );
547 if( p_intf->p_sys->p_vlm == NULL ) break;
549 E_(ExtractURIValue)( p_request, "name", name, 512 );
550 if( StrToMacroType( control ) == MVLC_VLM_NEW )
553 E_(ExtractURIValue)( p_request, "type", type, 20 );
554 p += sprintf( psz, "new %s %s", name, type );
558 p += sprintf( psz, "setup %s", name );
560 /* Parse the request */
561 for( i = 0; i < 11; i++ )
564 E_(ExtractURIValue)( p_request,
565 vlm_properties[i], val, 512 );
567 if( strlen( val ) > 0 && i >= 4 )
569 p += sprintf( p, " %s %s", vlm_properties[i], val );
571 else if( E_(TestURIParam)( p_request, vlm_properties[i] ) && i < 4 )
573 p += sprintf( p, " %s", vlm_properties[i] );
576 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
577 if( vlm_answer->psz_value == NULL ) /* there is no error */
579 vlm_error = strdup( "" );
583 vlm_error = malloc( strlen(vlm_answer->psz_name) +
584 strlen(vlm_answer->psz_value) +
585 strlen( " : ") + 1 );
586 sprintf( vlm_error , "%s : %s" , vlm_answer->psz_name,
587 vlm_answer->psz_value );
590 E_(mvar_AppendNewVar)( p_args->vars, "vlm_error", vlm_error );
592 vlm_MessageDelete( vlm_answer );
600 vlm_message_t *vlm_answer;
603 if( p_intf->p_sys->p_vlm == NULL )
604 p_intf->p_sys->p_vlm = vlm_New( p_intf );
606 if( p_intf->p_sys->p_vlm == NULL ) break;
608 E_(ExtractURIValue)( p_request, "name", name, 512 );
609 sprintf( psz, "del %s", name );
611 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
612 /* FIXME do a vlm_answer -> var stack conversion */
613 vlm_MessageDelete( vlm_answer );
622 vlm_message_t *vlm_answer;
625 if( p_intf->p_sys->p_vlm == NULL )
626 p_intf->p_sys->p_vlm = vlm_New( p_intf );
628 if( p_intf->p_sys->p_vlm == NULL ) break;
630 E_(ExtractURIValue)( p_request, "name", name, 512 );
631 if( StrToMacroType( control ) == MVLC_VLM_PLAY )
632 sprintf( psz, "control %s play", name );
633 else if( StrToMacroType( control ) == MVLC_VLM_PAUSE )
634 sprintf( psz, "control %s pause", name );
635 else if( StrToMacroType( control ) == MVLC_VLM_STOP )
636 sprintf( psz, "control %s stop", name );
637 else if( StrToMacroType( control ) == MVLC_VLM_SEEK )
640 E_(ExtractURIValue)( p_request, "percent", percent, 512 );
641 sprintf( psz, "control %s seek %s", name, percent );
644 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
645 /* FIXME do a vlm_answer -> var stack conversion */
646 vlm_MessageDelete( vlm_answer );
652 vlm_message_t *vlm_answer;
656 if( p_intf->p_sys->p_vlm == NULL )
657 p_intf->p_sys->p_vlm = vlm_New( p_intf );
659 if( p_intf->p_sys->p_vlm == NULL ) break;
661 E_(ExtractURIValue)( p_request, "file", file, 512 );
664 if( StrToMacroType( control ) == MVLC_VLM_LOAD )
665 sprintf( psz, "load %s", file );
667 sprintf( psz, "save %s", file );
669 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
670 /* FIXME do a vlm_answer -> var stack conversion */
671 vlm_MessageDelete( vlm_answer );
678 PRINTS( "<!-- control param(%s) unsupported -->", control );
690 if( i_request <= 0 ||
691 *m->param1 == '\0' ||
692 strstr( p_request, m->param1 ) == NULL )
696 E_(ExtractURIValue)( p_request, m->param1, value, 512 );
699 switch( StrToMacroType( m->param2 ) )
703 config_PutInt( p_intf, m->param1, i );
707 config_PutFloat( p_intf, m->param1, f );
710 config_PutPsz( p_intf, m->param1, value );
713 PRINTS( "<!-- invalid type(%s) in set -->", m->param2 )
725 if( *m->param1 == '\0' )
730 switch( StrToMacroType( m->param2 ) )
733 i = config_GetInt( p_intf, m->param1 );
734 sprintf( value, "%d", i );
737 f = config_GetFloat( p_intf, m->param1 );
738 div = lldiv( f * 1000000 , 1000000 );
739 sprintf( value, "%lld.%06u", div.quot,
740 (unsigned int)div.rem );
743 psz = config_GetPsz( p_intf, m->param1 );
746 strlcpy( value, psz,sizeof( value ) );
751 msg_Dbg( p_intf, "%d: value = \"%s\"", __LINE__, value );
754 snprintf( value, sizeof( value ),
755 "invalid type(%s) in set", m->param2 );
758 PRINTS( "%s", value );
767 E_(EvaluateRPN)( p_intf, p_args->vars, &p_args->stack, m->param1 );
768 s = E_(SSPop)( &p_args->stack );
769 v = E_(mvar_GetValue)( p_args->vars, s );
773 v = s = E_(SSPop)( &p_args->stack );
781 E_(EvaluateRPN)( p_intf, p_args->vars, &p_args->stack, m->param1 );
784 /* Useful to learn stack management */
788 msg_Dbg( p_intf, "stack" );
789 for (i=0;i<(&p_args->stack)->i_stack;i++)
790 msg_Dbg( p_intf, "%d -> %s", i, (&p_args->stack)->stack[i] );
796 PRINTS( "<!-- invalid macro id=`%s' -->", m->id );
797 msg_Dbg( p_intf, "invalid macro id=`%s'", m->id );
806 char *MacroSearch( char *src, char *end, int i_mvlc, vlc_bool_t b_after )
813 if( src + 4 < end && !strncmp( (char *)src, "<vlc", 4 ) )
818 i_skip = MacroParse( &m, src );
820 i_id = StrToMacroType( m.id );
837 if( ( i_mvlc == MVLC_END && i_level == -1 ) ||
838 ( i_mvlc != MVLC_END && i_level == 0 && i_mvlc == i_id ) )
840 return src + ( b_after ? i_skip : 0 );
842 else if( i_level < 0 )
858 void E_(Execute)( httpd_file_sys_t *p_args,
859 char *p_request, int i_request,
860 char **pp_data, int *pi_data,
862 char *_src, char *_end )
864 intf_thread_t *p_intf = p_args->p_intf;
866 char *src, *dup, *end;
869 src = dup = malloc( _end - _src + 1 );
870 end = src +( _end - _src );
872 memcpy( src, _src, _end - _src );
875 /* we parse searching <vlc */
881 p = (char *)strstr( (char *)src, "<vlc" );
882 if( p < end && p == src )
886 src += MacroParse( &m, src );
888 //msg_Dbg( p_intf, "macro_id=%s", m.id );
890 switch( StrToMacroType( m.id ) )
897 char psz_file[MAX_DIR_SIZE];
907 if( m.param1[0] != sep )
909 strcpy( psz_file, p_args->file );
910 p = strrchr( psz_file, sep );
912 strcpy( p + 1, m.param1 );
914 strcpy( psz_file, m.param1 );
918 strcpy( psz_file, m.param1 );
921 /* We hereby assume that psz_file is in the
922 * local character encoding */
923 if( ( f = fopen( psz_file, "r" ) ) == NULL )
925 msg_Warn( p_args->p_intf,
926 "unable to include file %s (%m)",
931 /* first we load in a temporary buffer */
932 E_(FileLoad)( f, &p_buffer, &i_buffer );
934 /* we parse executing all <vlc /> macros */
935 E_(Execute)( p_args, p_request, i_request, pp_data, pi_data,
936 &dst, &p_buffer[0], &p_buffer[i_buffer] );
946 E_(EvaluateRPN)( p_intf, p_args->vars, &p_args->stack, m.param1 );
947 if( E_(SSPopN)( &p_args->stack, p_args->vars ) )
955 endif = MacroSearch( src, end, MVLC_END, VLC_TRUE );
959 char *start = MacroSearch( src, endif, MVLC_ELSE, VLC_TRUE );
963 char *stop = MacroSearch( start, endif, MVLC_END, VLC_FALSE );
966 E_(Execute)( p_args, p_request, i_request,
967 pp_data, pi_data, &dst, start, stop );
971 else if( i_test == 1 )
974 if( ( stop = MacroSearch( src, endif, MVLC_ELSE, VLC_FALSE ) ) == NULL )
976 stop = MacroSearch( src, endif, MVLC_END, VLC_FALSE );
980 E_(Execute)( p_args, p_request, i_request,
981 pp_data, pi_data, &dst, src, stop );
990 char *endfor = MacroSearch( src, end, MVLC_END, VLC_TRUE );
992 char *stop = MacroSearch( src, end, MVLC_END, VLC_FALSE );
999 if( !strcmp( m.param2, "integer" ) )
1001 char *arg = E_(SSPop)( &p_args->stack );
1002 index = E_(mvar_IntegerSetNew)( m.param1, arg );
1005 else if( !strcmp( m.param2, "directory" ) )
1007 char *arg = E_(SSPop)( &p_args->stack );
1008 index = E_(mvar_FileSetNew)( p_intf, m.param1, arg );
1011 else if( !strcmp( m.param2, "object" ) )
1013 char *arg = E_(SSPop)( &p_args->stack );
1014 index = E_(mvar_ObjectSetNew)( p_intf, m.param1, arg );
1017 else if( !strcmp( m.param2, "playlist" ) )
1019 index = E_(mvar_PlaylistSetNew)( p_intf, m.param1,
1020 p_intf->p_sys->p_playlist );
1022 else if( !strcmp( m.param2, "information" ) )
1024 index = E_(mvar_InfoSetNew)( p_intf, m.param1,
1025 p_intf->p_sys->p_input );
1027 else if( !strcmp( m.param2, "program" )
1028 || !strcmp( m.param2, "title" )
1029 || !strcmp( m.param2, "chapter" )
1030 || !strcmp( m.param2, "audio-es" )
1031 || !strcmp( m.param2, "video-es" )
1032 || !strcmp( m.param2, "spu-es" ) )
1034 index = E_(mvar_InputVarSetNew)( p_intf, m.param1,
1035 p_intf->p_sys->p_input,
1038 else if( !strcmp( m.param2, "vlm" ) )
1040 if( p_intf->p_sys->p_vlm == NULL )
1041 p_intf->p_sys->p_vlm = vlm_New( p_intf );
1042 index = E_(mvar_VlmSetNew)( m.param1, p_intf->p_sys->p_vlm );
1045 else if( !strcmp( m.param2, "hosts" ) )
1047 index = E_(mvar_HttpdInfoSetNew)( m.param1, p_intf->p_sys->p_httpd, HTTPD_GET_HOSTS );
1049 else if( !strcmp( m.param2, "urls" ) )
1051 index = E_(mvar_HttpdInfoSetNew)( m.param1, p_intf->p_sys->p_httpd, HTTPD_GET_URLS );
1053 else if( !strcmp( m.param2, "connections" ) )
1055 index = E_(mvar_HttpdInfoSetNew)(m.param1, p_intf->p_sys->p_httpd, HTTPD_GET_CONNECTIONS);
1058 else if( ( v = E_(mvar_GetVar)( p_args->vars, m.param2 ) ) )
1060 index = E_(mvar_Duplicate)( v );
1064 msg_Dbg( p_intf, "invalid index constructor (%s)", m.param2 );
1069 for( i_idx = 0; i_idx < index->i_field; i_idx++ )
1071 mvar_t *f = E_(mvar_Duplicate)( index->field[i_idx] );
1073 //msg_Dbg( p_intf, "foreach field[%d] name=%s value=%s", i_idx, f->name, f->value );
1076 f->name = strdup( m.param1 );
1079 E_(mvar_PushVar)( p_args->vars, f );
1080 E_(Execute)( p_args, p_request, i_request,
1081 pp_data, pi_data, &dst, start, stop );
1082 E_(mvar_RemoveVar)( p_args->vars, f );
1084 E_(mvar_Delete)( f );
1086 E_(mvar_Delete)( index );
1093 MacroDo( p_args, &m, p_request, i_request,
1094 pp_data, pi_data, &dst );
1102 i_copy = ( (p == NULL || p > end ) ? end : p ) - src;
1105 int i_index = dst - *pp_data;
1108 *pp_data = realloc( *pp_data, *pi_data );
1109 dst = (*pp_data) + i_index;
1111 memcpy( dst, src, i_copy );