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 *****************************************************************************/
33 static int MacroParse( macro_t *m, char *psz_src )
35 char *dup = strdup( (char *)psz_src );
40 #define EXTRACT( name, l ) \
42 p = strchr( src, '"' ); \
47 m->name = strdup( src ); \
68 if( !strncmp( src, "id=\"", 4 ) )
72 else if( !strncmp( src, "param1=\"", 8 ) )
76 else if( !strncmp( src, "param2=\"", 8 ) )
85 if( strstr( src, "/>" ) )
87 src = strstr( src, "/>" ) + 2;
98 if( m->param1 == NULL )
100 m->param1 = strdup( "" );
102 if( m->param2 == NULL )
104 m->param2 = strdup( "" );
113 static void MacroClean( macro_t *m )
120 static int StrToMacroType( const char *name )
124 if( !name || *name == '\0')
128 for( i = 0; StrToMacroTypeTab[i].psz_name != NULL; i++ )
130 if( !strcmp( name, StrToMacroTypeTab[i].psz_name ) )
132 return StrToMacroTypeTab[i].i_type;
138 static void MacroDo( httpd_file_sys_t *p_args,
140 char *p_request, int i_request,
141 char **pp_data, int *pi_data,
144 intf_thread_t *p_intf = p_args->p_intf;
145 intf_sys_t *p_sys = p_args->p_intf->p_sys;
150 int __i__ = *pp_dst - *pp_data; \
152 *pp_data = realloc( *pp_data, *pi_data ); \
153 *pp_dst = (*pp_data) + __i__; \
155 #define PRINT( str ) \
156 ALLOC( strlen( str ) + 1 ); \
157 *pp_dst += sprintf( *pp_dst, "%s", str );
159 #define PRINTS( str, s ) \
160 ALLOC( strlen( str ) + strlen( s ) + 1 ); \
162 char * psz_cur = *pp_dst; \
163 *pp_dst += sprintf( *pp_dst, str, s ); \
164 while( psz_cur && *psz_cur ) \
166 /* Prevent script injection */ \
167 if( *psz_cur == '<' ) *psz_cur = '*'; \
168 if( *psz_cur == '>' ) *psz_cur = '*'; \
173 switch( StrToMacroType( m->id ) )
180 E_(ExtractURIValue)( p_request, "control", control, 512 );
181 if( *m->param1 && !strstr( m->param1, control ) )
183 msg_Warn( p_intf, "unauthorized control=%s", control );
186 switch( StrToMacroType( control ) )
193 E_(ExtractURIValue)( p_request, "item", item, 512 );
194 i_item = atoi( item );
195 /* id = 0 : simply ask playlist to play */
198 playlist_Play( p_sys->p_playlist );
199 msg_Dbg( p_intf, "requested playlist play" );
202 playlist_Control( p_sys->p_playlist, PLAYLIST_VIEWPLAY,
204 playlist_ItemGetById( p_sys->p_playlist,
205 i_item, VLC_TRUE ) );
206 msg_Dbg( p_intf, "requested playlist item: %i", i_item );
210 playlist_Control( p_sys->p_playlist, PLAYLIST_STOP,
212 msg_Dbg( p_intf, "requested playlist stop" );
215 playlist_Control( p_sys->p_playlist, PLAYLIST_PAUSE,
217 msg_Dbg( p_intf, "requested playlist pause" );
220 playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP,
222 msg_Dbg( p_intf, "requested playlist next" );
225 playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP,
227 msg_Dbg( p_intf, "requested playlist previous" );
229 case MVLC_FULLSCREEN:
232 vout_thread_t *p_vout;
233 p_vout = vlc_object_find( p_sys->p_input,
234 VLC_OBJECT_VOUT, FIND_CHILD );
238 p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
239 vlc_object_release( p_vout );
240 msg_Dbg( p_intf, "requested fullscreen toggle" );
247 E_(ExtractURIValue)( p_request, "seek_value", value, 30 );
249 E_(HandleSeek)( p_intf, value );
255 audio_volume_t i_volume;
258 E_(ExtractURIValue)( p_request, "value", vol, 8 );
259 aout_VolumeGet( p_intf, &i_volume );
264 i_value = atoi( vol + 1 );
265 if( (i_volume + i_value) > AOUT_VOLUME_MAX )
267 aout_VolumeSet( p_intf , AOUT_VOLUME_MAX );
268 msg_Dbg( p_intf, "requested volume set: max" );
272 aout_VolumeSet( p_intf , (i_volume + i_value) );
273 msg_Dbg( p_intf, "requested volume set: +%i", (i_volume + i_value) );
276 else if( vol[0] == '-' )
278 i_value = atoi( vol + 1 );
279 if( (i_volume - i_value) < AOUT_VOLUME_MIN )
281 aout_VolumeSet( p_intf , AOUT_VOLUME_MIN );
282 msg_Dbg( p_intf, "requested volume set: min" );
286 aout_VolumeSet( p_intf , (i_volume - i_value) );
287 msg_Dbg( p_intf, "requested volume set: -%i", (i_volume - i_value) );
290 else if( strstr(vol, "%") != NULL )
292 i_value = atoi( vol );
293 if( (i_value <= 400) && (i_value>=0) ){
294 aout_VolumeSet( p_intf, (i_value * (AOUT_VOLUME_MAX - AOUT_VOLUME_MIN))/400+AOUT_VOLUME_MIN);
295 msg_Dbg( p_intf, "requested volume set: %i%%", atoi( vol ));
300 i_value = atoi( vol );
301 if( ( i_value <= AOUT_VOLUME_MAX ) && ( i_value >= AOUT_VOLUME_MIN ) )
303 aout_VolumeSet( p_intf , atoi( vol ) );
304 msg_Dbg( p_intf, "requested volume set: %i", atoi( vol ) );
310 /* playlist management */
313 char mrl[1024], psz_name[1024], tmp[1024];
315 input_item_t *p_input;
317 E_(ExtractURIValue)( p_request, "mrl", tmp, 1024 );
319 E_(ExtractURIValue)( p_request, "name", psz_name, 1024 );
320 decode_URI( psz_name );
323 memcpy( psz_name, tmp, 1024 );
325 /* addslashes for backward compatibility with the old
328 while( *str != '\0' )
330 if( *str == '"' || *str == '\'' || *str == '\\' )
339 p_input = E_(MRLParse)( p_intf, mrl, psz_name );
341 char *psz_uri = input_item_GetURI( p_input );
342 if( !p_input || !psz_uri || !*psz_uri )
344 msg_Dbg( p_intf, "invalid requested mrl: %s", mrl );
348 playlist_AddInput( p_sys->p_playlist, p_input,
349 PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE,
351 vlc_gc_decref( p_input );
352 msg_Dbg( p_intf, "requested mrl add: %s", mrl );
360 int i_item, *p_items = NULL, i_nb_items = 0;
361 char item[512], *p_parser = p_request;
363 /* Get the list of items to delete */
365 E_(ExtractURIValue)( p_parser, "item", item, 512 )) )
367 if( !*item ) continue;
369 i_item = atoi( item );
370 p_items = realloc( p_items, (i_nb_items + 1) *
372 p_items[i_nb_items] = i_item;
379 for( i = 0; i < i_nb_items; i++ )
381 playlist_DeleteFromInput( p_sys->p_playlist,
382 p_items[i], VLC_FALSE );
383 msg_Dbg( p_intf, "requested playlist delete: %d",
389 if( p_items ) free( p_items );
394 int i_item, *p_items = NULL, i_nb_items = 0;
395 char item[512], *p_parser = p_request;
398 /* Get the list of items to keep */
400 E_(ExtractURIValue)( p_parser, "item", item, 512 )) )
402 if( !*item ) continue;
404 i_item = atoi( item );
405 p_items = realloc( p_items, (i_nb_items + 1) *
407 p_items[i_nb_items] = i_item;
411 for( i = p_sys->p_playlist->items.i_size - 1 ; i >= 0; i-- )
413 /* Check if the item is in the keep list */
414 for( j = 0 ; j < i_nb_items ; j++ )
417 ARRAY_VAL(p_sys->p_playlist->items,i)
421 if( j == i_nb_items )
423 playlist_DeleteFromInput( p_sys->p_playlist,
424 p_sys->p_playlist->items.p_elems[i]->i_id,
426 msg_Dbg( p_intf, "requested playlist delete: %d",
431 if( p_items ) free( p_items );
436 playlist_Clear( p_sys->p_playlist, VLC_FALSE );
437 msg_Dbg( p_intf, "requested playlist empty" );
448 E_(ExtractURIValue)( p_request, "type", type, 12 );
449 E_(ExtractURIValue)( p_request, "order", order, 2 );
450 E_(ExtractURIValue)( p_request, "item", item, 512 );
451 i_item = atoi( item );
453 if( order[0] == '0' ) i_order = ORDER_NORMAL;
454 else i_order = ORDER_REVERSE;
456 if( !strcmp( type , "title" ) )
458 playlist_RecursiveNodeSort( p_sys->p_playlist,
459 /* Ugly hack,but not worse than before ... */
460 p_sys->p_playlist->p_root_onelevel,
461 SORT_TITLE_NODES_FIRST,
462 ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
463 msg_Dbg( p_intf, "requested playlist sort by title (%d)" , i_order );
465 else if( !strcmp( type , "author" ) )
467 playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
468 p_sys->p_playlist->p_root_onelevel,
470 ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
471 msg_Dbg( p_intf, "requested playlist sort by author (%d)" , i_order );
473 else if( !strcmp( type , "shuffle" ) )
475 playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
476 p_sys->p_playlist->p_root_onelevel,
478 ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
479 msg_Dbg( p_intf, "requested playlist shuffle");
490 E_(ExtractURIValue)( p_request, "psz_pos", psz_pos, 6 );
491 E_(ExtractURIValue)( p_request, "psz_newpos", psz_newpos, 6 );
492 i_pos = atoi( psz_pos );
493 i_newpos = atoi( psz_newpos );
494 /* FIXME FIXME TODO TODO XXX XXX
495 ( duplicate from rpn.c )
496 if ( i_pos < i_newpos )
498 playlist_Move( p_sys->p_playlist, i_pos, i_newpos + 1 );
502 playlist_Move( p_sys->p_playlist, i_pos, i_newpos );
504 msg_Dbg( p_intf, "requested move playlist item %d to %d", i_pos, i_newpos);
505 FIXME FIXME TODO TODO XXX XXX */
513 E_(ExtractURIValue)( p_request, "id", id, 512 );
514 msg_Dbg( p_intf, "requested close id=%s", id );
516 if( p_sys->p_httpd->pf_control( p_sys->p_httpd, HTTPD_SET_CLOSE, id, NULL ) )
518 msg_Warn( p_intf, "close failed for id=%s", id );
525 msg_Dbg( p_intf, "requested shutdown" );
526 vlc_object_kill( p_intf->p_libvlc );
533 static const char *vlm_properties[11] =
536 "enabled", "disabled", "loop", "unloop",
538 "input", "output", "option", "date", "period", "repeat", "append",
540 vlm_message_t *vlm_answer;
542 char *psz = malloc( strlen( p_request ) + 1000 );
547 if( p_intf->p_sys->p_vlm == NULL )
548 p_intf->p_sys->p_vlm = vlm_New( p_intf );
550 if( p_intf->p_sys->p_vlm == NULL ) break;
552 E_(ExtractURIValue)( p_request, "name", name, 512 );
553 if( StrToMacroType( control ) == MVLC_VLM_NEW )
556 E_(ExtractURIValue)( p_request, "type", type, 20 );
557 p += sprintf( psz, "new %s %s", name, type );
561 p += sprintf( psz, "setup %s", name );
563 /* Parse the request */
564 for( i = 0; i < 11; i++ )
567 E_(ExtractURIValue)( p_request,
568 vlm_properties[i], val, 512 );
570 if( strlen( val ) > 0 && i >= 4 )
572 p += sprintf( p, " %s %s", vlm_properties[i], val );
574 else if( E_(TestURIParam)( p_request, vlm_properties[i] ) && i < 4 )
576 p += sprintf( p, " %s", vlm_properties[i] );
579 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
580 if( vlm_answer->psz_value == NULL ) /* there is no error */
582 vlm_error = strdup( "" );
586 vlm_error = malloc( strlen(vlm_answer->psz_name) +
587 strlen(vlm_answer->psz_value) +
588 strlen( " : ") + 1 );
589 sprintf( vlm_error , "%s : %s" , vlm_answer->psz_name,
590 vlm_answer->psz_value );
593 E_(mvar_AppendNewVar)( p_args->vars, "vlm_error", vlm_error );
595 vlm_MessageDelete( vlm_answer );
603 vlm_message_t *vlm_answer;
606 if( p_intf->p_sys->p_vlm == NULL )
607 p_intf->p_sys->p_vlm = vlm_New( p_intf );
609 if( p_intf->p_sys->p_vlm == NULL ) break;
611 E_(ExtractURIValue)( p_request, "name", name, 512 );
612 sprintf( psz, "del %s", name );
614 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
615 /* FIXME do a vlm_answer -> var stack conversion */
616 vlm_MessageDelete( vlm_answer );
625 vlm_message_t *vlm_answer;
628 if( p_intf->p_sys->p_vlm == NULL )
629 p_intf->p_sys->p_vlm = vlm_New( p_intf );
631 if( p_intf->p_sys->p_vlm == NULL ) break;
633 E_(ExtractURIValue)( p_request, "name", name, 512 );
634 if( StrToMacroType( control ) == MVLC_VLM_PLAY )
635 sprintf( psz, "control %s play", name );
636 else if( StrToMacroType( control ) == MVLC_VLM_PAUSE )
637 sprintf( psz, "control %s pause", name );
638 else if( StrToMacroType( control ) == MVLC_VLM_STOP )
639 sprintf( psz, "control %s stop", name );
640 else if( StrToMacroType( control ) == MVLC_VLM_SEEK )
643 E_(ExtractURIValue)( p_request, "percent", percent, 512 );
644 sprintf( psz, "control %s seek %s", name, percent );
647 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
648 /* FIXME do a vlm_answer -> var stack conversion */
649 vlm_MessageDelete( vlm_answer );
655 vlm_message_t *vlm_answer;
659 if( p_intf->p_sys->p_vlm == NULL )
660 p_intf->p_sys->p_vlm = vlm_New( p_intf );
662 if( p_intf->p_sys->p_vlm == NULL ) break;
664 E_(ExtractURIValue)( p_request, "file", file, 512 );
667 if( StrToMacroType( control ) == MVLC_VLM_LOAD )
668 sprintf( psz, "load %s", file );
670 sprintf( psz, "save %s", file );
672 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
673 /* FIXME do a vlm_answer -> var stack conversion */
674 vlm_MessageDelete( vlm_answer );
681 PRINTS( "<!-- control param(%s) unsupported -->", control );
693 if( i_request <= 0 ||
694 *m->param1 == '\0' ||
695 strstr( p_request, m->param1 ) == NULL )
699 E_(ExtractURIValue)( p_request, m->param1, value, 512 );
702 switch( StrToMacroType( m->param2 ) )
706 config_PutInt( p_intf, m->param1, i );
710 config_PutFloat( p_intf, m->param1, f );
713 config_PutPsz( p_intf, m->param1, value );
716 PRINTS( "<!-- invalid type(%s) in set -->", m->param2 )
728 if( *m->param1 == '\0' )
733 switch( StrToMacroType( m->param2 ) )
736 i = config_GetInt( p_intf, m->param1 );
737 sprintf( value, "%d", i );
740 f = config_GetFloat( p_intf, m->param1 );
741 div = lldiv( f * 1000000 , 1000000 );
742 sprintf( value, "%lld.%06u", div.quot,
743 (unsigned int)div.rem );
746 psz = config_GetPsz( p_intf, m->param1 );
749 strlcpy( value, psz,sizeof( value ) );
754 msg_Dbg( p_intf, "%d: value = \"%s\"", __LINE__, value );
757 snprintf( value, sizeof( value ),
758 "invalid type(%s) in set", m->param2 );
761 PRINTS( "%s", value );
770 E_(EvaluateRPN)( p_intf, p_args->vars, &p_args->stack, m->param1 );
771 s = E_(SSPop)( &p_args->stack );
772 v = E_(mvar_GetValue)( p_args->vars, s );
776 v = s = E_(SSPop)( &p_args->stack );
784 E_(EvaluateRPN)( p_intf, p_args->vars, &p_args->stack, m->param1 );
787 /* Useful to learn stack management */
791 msg_Dbg( p_intf, "stack" );
792 for (i=0;i<(&p_args->stack)->i_stack;i++)
793 msg_Dbg( p_intf, "%d -> %s", i, (&p_args->stack)->stack[i] );
799 PRINTS( "<!-- invalid macro id=`%s' -->", m->id );
800 msg_Dbg( p_intf, "invalid macro id=`%s'", m->id );
809 char *MacroSearch( char *src, char *end, int i_mvlc, vlc_bool_t b_after )
816 if( src + 4 < end && !strncmp( (char *)src, "<vlc", 4 ) )
821 i_skip = MacroParse( &m, src );
823 i_id = StrToMacroType( m.id );
840 if( ( i_mvlc == MVLC_END && i_level == -1 ) ||
841 ( i_mvlc != MVLC_END && i_level == 0 && i_mvlc == i_id ) )
843 return src + ( b_after ? i_skip : 0 );
845 else if( i_level < 0 )
861 void E_(Execute)( httpd_file_sys_t *p_args,
862 char *p_request, int i_request,
863 char **pp_data, int *pi_data,
865 char *_src, char *_end )
867 intf_thread_t *p_intf = p_args->p_intf;
869 char *src, *dup, *end;
872 src = dup = malloc( _end - _src + 1 );
873 end = src +( _end - _src );
875 memcpy( src, _src, _end - _src );
878 /* we parse searching <vlc */
884 p = (char *)strstr( (char *)src, "<vlc" );
885 if( p < end && p == src )
889 src += MacroParse( &m, src );
891 //msg_Dbg( p_intf, "macro_id=%s", m.id );
893 switch( StrToMacroType( m.id ) )
900 char psz_file[MAX_DIR_SIZE];
910 if( m.param1[0] != sep )
912 strcpy( psz_file, p_args->file );
913 p = strrchr( psz_file, sep );
915 strcpy( p + 1, m.param1 );
917 strcpy( psz_file, m.param1 );
921 strcpy( psz_file, m.param1 );
924 /* We hereby assume that psz_file is in the
925 * local character encoding */
926 if( ( f = fopen( psz_file, "r" ) ) == NULL )
928 msg_Warn( p_args->p_intf,
929 "unable to include file %s (%m)",
934 /* first we load in a temporary buffer */
935 E_(FileLoad)( f, &p_buffer, &i_buffer );
937 /* we parse executing all <vlc /> macros */
938 E_(Execute)( p_args, p_request, i_request, pp_data, pi_data,
939 &dst, &p_buffer[0], &p_buffer[i_buffer] );
949 E_(EvaluateRPN)( p_intf, p_args->vars, &p_args->stack, m.param1 );
950 if( E_(SSPopN)( &p_args->stack, p_args->vars ) )
958 endif = MacroSearch( src, end, MVLC_END, VLC_TRUE );
962 char *start = MacroSearch( src, endif, MVLC_ELSE, VLC_TRUE );
966 char *stop = MacroSearch( start, endif, MVLC_END, VLC_FALSE );
969 E_(Execute)( p_args, p_request, i_request,
970 pp_data, pi_data, &dst, start, stop );
974 else if( i_test == 1 )
977 if( ( stop = MacroSearch( src, endif, MVLC_ELSE, VLC_FALSE ) ) == NULL )
979 stop = MacroSearch( src, endif, MVLC_END, VLC_FALSE );
983 E_(Execute)( p_args, p_request, i_request,
984 pp_data, pi_data, &dst, src, stop );
993 char *endfor = MacroSearch( src, end, MVLC_END, VLC_TRUE );
995 char *stop = MacroSearch( src, end, MVLC_END, VLC_FALSE );
1002 if( !strcmp( m.param2, "integer" ) )
1004 char *arg = E_(SSPop)( &p_args->stack );
1005 index = E_(mvar_IntegerSetNew)( m.param1, arg );
1008 else if( !strcmp( m.param2, "directory" ) )
1010 char *arg = E_(SSPop)( &p_args->stack );
1011 index = E_(mvar_FileSetNew)( p_intf, m.param1, arg );
1014 else if( !strcmp( m.param2, "object" ) )
1016 char *arg = E_(SSPop)( &p_args->stack );
1017 index = E_(mvar_ObjectSetNew)( p_intf, m.param1, arg );
1020 else if( !strcmp( m.param2, "playlist" ) )
1022 index = E_(mvar_PlaylistSetNew)( p_intf, m.param1,
1023 p_intf->p_sys->p_playlist );
1025 else if( !strcmp( m.param2, "information" ) )
1027 index = E_(mvar_InfoSetNew)( p_intf, m.param1,
1028 p_intf->p_sys->p_input );
1030 else if( !strcmp( m.param2, "program" )
1031 || !strcmp( m.param2, "title" )
1032 || !strcmp( m.param2, "chapter" )
1033 || !strcmp( m.param2, "audio-es" )
1034 || !strcmp( m.param2, "video-es" )
1035 || !strcmp( m.param2, "spu-es" ) )
1037 index = E_(mvar_InputVarSetNew)( p_intf, m.param1,
1038 p_intf->p_sys->p_input,
1041 else if( !strcmp( m.param2, "vlm" ) )
1043 if( p_intf->p_sys->p_vlm == NULL )
1044 p_intf->p_sys->p_vlm = vlm_New( p_intf );
1045 index = E_(mvar_VlmSetNew)( m.param1, p_intf->p_sys->p_vlm );
1048 else if( !strcmp( m.param2, "hosts" ) )
1050 index = E_(mvar_HttpdInfoSetNew)( m.param1, p_intf->p_sys->p_httpd, HTTPD_GET_HOSTS );
1052 else if( !strcmp( m.param2, "urls" ) )
1054 index = E_(mvar_HttpdInfoSetNew)( m.param1, p_intf->p_sys->p_httpd, HTTPD_GET_URLS );
1056 else if( !strcmp( m.param2, "connections" ) )
1058 index = E_(mvar_HttpdInfoSetNew)(m.param1, p_intf->p_sys->p_httpd, HTTPD_GET_CONNECTIONS);
1061 else if( ( v = E_(mvar_GetVar)( p_args->vars, m.param2 ) ) )
1063 index = E_(mvar_Duplicate)( v );
1067 msg_Dbg( p_intf, "invalid index constructor (%s)", m.param2 );
1072 for( i_idx = 0; i_idx < index->i_field; i_idx++ )
1074 mvar_t *f = E_(mvar_Duplicate)( index->field[i_idx] );
1076 //msg_Dbg( p_intf, "foreach field[%d] name=%s value=%s", i_idx, f->name, f->value );
1079 f->name = strdup( m.param1 );
1082 E_(mvar_PushVar)( p_args->vars, f );
1083 E_(Execute)( p_args, p_request, i_request,
1084 pp_data, pi_data, &dst, start, stop );
1085 E_(mvar_RemoveVar)( p_args->vars, f );
1087 E_(mvar_Delete)( f );
1089 E_(mvar_Delete)( index );
1096 MacroDo( p_args, &m, p_request, i_request,
1097 pp_data, pi_data, &dst );
1105 i_copy = ( (p == NULL || p > end ) ? end : p ) - src;
1108 int i_index = dst - *pp_data;
1111 *pp_data = realloc( *pp_data, *pi_data );
1112 dst = (*pp_data) + i_index;
1114 memcpy( dst, src, i_copy );