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 *****************************************************************************/
29 int E_(MacroParse)( macro_t *m, char *psz_src )
31 char *dup = strdup( (char *)psz_src );
36 #define EXTRACT( name, l ) \
38 p = strchr( src, '"' ); \
43 m->name = strdup( src ); \
64 if( !strncmp( src, "id=\"", 4 ) )
68 else if( !strncmp( src, "param1=\"", 8 ) )
72 else if( !strncmp( src, "param2=\"", 8 ) )
81 if( strstr( src, "/>" ) )
83 src = strstr( src, "/>" ) + 2;
94 if( m->param1 == NULL )
96 m->param1 = strdup( "" );
98 if( m->param2 == NULL )
100 m->param2 = strdup( "" );
109 void E_(MacroClean)( macro_t *m )
116 int E_(StrToMacroType)( char *name )
120 if( !name || *name == '\0')
124 for( i = 0; StrToMacroTypeTab[i].psz_name != NULL; i++ )
126 if( !strcmp( name, StrToMacroTypeTab[i].psz_name ) )
128 return StrToMacroTypeTab[i].i_type;
134 void E_(MacroDo)( httpd_file_sys_t *p_args,
136 char *p_request, int i_request,
137 char **pp_data, int *pi_data,
140 intf_thread_t *p_intf = p_args->p_intf;
141 intf_sys_t *p_sys = p_args->p_intf->p_sys;
146 int __i__ = *pp_dst - *pp_data; \
148 *pp_data = realloc( *pp_data, *pi_data ); \
149 *pp_dst = (*pp_data) + __i__; \
151 #define PRINT( str ) \
152 ALLOC( strlen( str ) + 1 ); \
153 *pp_dst += sprintf( *pp_dst, "%s", str );
155 #define PRINTS( str, s ) \
156 ALLOC( strlen( str ) + strlen( s ) + 1 ); \
158 char * psz_cur = *pp_dst; \
159 *pp_dst += sprintf( *pp_dst, str, s ); \
160 while( psz_cur && *psz_cur ) \
162 /* Prevent script injection */ \
163 if( *psz_cur == '<' ) *psz_cur = '*'; \
164 if( *psz_cur == '>' ) *psz_cur = '*'; \
169 switch( E_(StrToMacroType)( m->id ) )
176 E_(ExtractURIValue)( p_request, "control", control, 512 );
177 if( *m->param1 && !strstr( m->param1, control ) )
179 msg_Warn( p_intf, "unauthorized control=%s", control );
182 switch( E_(StrToMacroType)( control ) )
189 E_(ExtractURIValue)( p_request, "item", item, 512 );
190 i_item = atoi( item );
191 /* id = 0 : simply ask playlist to play */
194 playlist_Play( p_sys->p_playlist );
195 msg_Dbg( p_intf, "requested playlist play" );
198 playlist_Control( p_sys->p_playlist, PLAYLIST_ITEMPLAY,
199 playlist_ItemGetById( p_sys->p_playlist,
201 msg_Dbg( p_intf, "requested playlist item: %i", i_item );
205 playlist_Control( p_sys->p_playlist, PLAYLIST_STOP );
206 msg_Dbg( p_intf, "requested playlist stop" );
209 playlist_Control( p_sys->p_playlist, PLAYLIST_PAUSE );
210 msg_Dbg( p_intf, "requested playlist pause" );
213 playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, 1 );
214 msg_Dbg( p_intf, "requested playlist next" );
217 playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, -1 );
218 msg_Dbg( p_intf, "requested playlist previous" );
220 case MVLC_FULLSCREEN:
223 vout_thread_t *p_vout;
224 p_vout = vlc_object_find( p_sys->p_input,
225 VLC_OBJECT_VOUT, FIND_CHILD );
229 p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
230 vlc_object_release( p_vout );
231 msg_Dbg( p_intf, "requested fullscreen toggle" );
238 E_(ExtractURIValue)( p_request, "seek_value", value, 30 );
240 E_(HandleSeek)( p_intf, value );
246 audio_volume_t i_volume;
249 E_(ExtractURIValue)( p_request, "value", vol, 8 );
250 aout_VolumeGet( p_intf, &i_volume );
255 i_value = atoi( vol + 1 );
256 if( (i_volume + i_value) > AOUT_VOLUME_MAX )
258 aout_VolumeSet( p_intf , AOUT_VOLUME_MAX );
259 msg_Dbg( p_intf, "requested volume set: max" );
263 aout_VolumeSet( p_intf , (i_volume + i_value) );
264 msg_Dbg( p_intf, "requested volume set: +%i", (i_volume + i_value) );
267 else if( vol[0] == '-' )
269 i_value = atoi( vol + 1 );
270 if( (i_volume - i_value) < AOUT_VOLUME_MIN )
272 aout_VolumeSet( p_intf , AOUT_VOLUME_MIN );
273 msg_Dbg( p_intf, "requested volume set: min" );
277 aout_VolumeSet( p_intf , (i_volume - i_value) );
278 msg_Dbg( p_intf, "requested volume set: -%i", (i_volume - i_value) );
281 else if( strstr(vol, "%") != NULL )
283 i_value = atoi( vol );
284 if( (i_value <= 400) && (i_value>=0) ){
285 aout_VolumeSet( p_intf, (i_value * (AOUT_VOLUME_MAX - AOUT_VOLUME_MIN))/400+AOUT_VOLUME_MIN);
286 msg_Dbg( p_intf, "requested volume set: %i%%", atoi( vol ));
291 i_value = atoi( vol );
292 if( ( i_value <= AOUT_VOLUME_MAX ) && ( i_value >= AOUT_VOLUME_MIN ) )
294 aout_VolumeSet( p_intf , atoi( vol ) );
295 msg_Dbg( p_intf, "requested volume set: %i", atoi( vol ) );
301 /* playlist management */
304 char mrl[1024], psz_name[1024], tmp[1024];
306 playlist_item_t *p_item;
308 E_(ExtractURIValue)( p_request, "mrl", tmp, 1024 );
310 E_(ExtractURIValue)( p_request, "name", psz_name, 1024 );
311 decode_URI( psz_name );
314 memcpy( psz_name, tmp, 1024 );
316 /* addslashes for backward compatibility with the old
319 while( *str != '\0' )
321 if( *str == '"' || *str == '\'' || *str == '\\' )
330 p_item = E_(MRLParse)( p_intf, mrl, psz_name );
332 if( !p_item || !p_item->input.psz_uri ||
333 !*p_item->input.psz_uri )
335 msg_Dbg( p_intf, "invalid requested mrl: %s", mrl );
339 playlist_AddItem( p_sys->p_playlist, p_item,
340 PLAYLIST_APPEND, PLAYLIST_END );
341 msg_Dbg( p_intf, "requested mrl add: %s", mrl );
348 int i_item, *p_items = NULL, i_nb_items = 0;
349 char item[512], *p_parser = p_request;
351 /* Get the list of items to delete */
353 E_(ExtractURIValue)( p_parser, "item", item, 512 )) )
355 if( !*item ) continue;
357 i_item = atoi( item );
358 p_items = realloc( p_items, (i_nb_items + 1) *
360 p_items[i_nb_items] = i_item;
367 for( i = 0; i < i_nb_items; i++ )
369 playlist_LockDelete( p_sys->p_playlist, p_items[i] );
370 msg_Dbg( p_intf, "requested playlist delete: %d",
376 if( p_items ) free( p_items );
381 int i_item, *p_items = NULL, i_nb_items = 0;
382 char item[512], *p_parser = p_request;
385 /* Get the list of items to keep */
387 E_(ExtractURIValue)( p_parser, "item", item, 512 )) )
389 if( !*item ) continue;
391 i_item = atoi( item );
392 p_items = realloc( p_items, (i_nb_items + 1) *
394 p_items[i_nb_items] = i_item;
398 for( i = p_sys->p_playlist->i_size - 1 ; i >= 0; i-- )
400 /* Check if the item is in the keep list */
401 for( j = 0 ; j < i_nb_items ; j++ )
404 p_sys->p_playlist->pp_items[i]->input.i_id ) break;
406 if( j == i_nb_items )
408 playlist_LockDelete( p_sys->p_playlist, p_sys->p_playlist->pp_items[i]->input.i_id );
409 msg_Dbg( p_intf, "requested playlist delete: %d",
414 if( p_items ) free( p_items );
419 playlist_LockClear( p_sys->p_playlist );
420 msg_Dbg( p_intf, "requested playlist empty" );
431 E_(ExtractURIValue)( p_request, "type", type, 12 );
432 E_(ExtractURIValue)( p_request, "order", order, 2 );
433 E_(ExtractURIValue)( p_request, "item", item, 512 );
434 i_item = atoi( item );
436 if( order[0] == '0' ) i_order = ORDER_NORMAL;
437 else i_order = ORDER_REVERSE;
439 if( !strcmp( type , "title" ) )
441 playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
442 p_sys->p_playlist->pp_views[0]->p_root,
443 SORT_TITLE_NODES_FIRST,
444 ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
445 msg_Dbg( p_intf, "requested playlist sort by title (%d)" , i_order );
447 else if( !strcmp( type , "author" ) )
449 playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
450 p_sys->p_playlist->pp_views[0]->p_root,
452 ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
453 msg_Dbg( p_intf, "requested playlist sort by author (%d)" , i_order );
455 else if( !strcmp( type , "shuffle" ) )
457 playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
458 p_sys->p_playlist->pp_views[0]->p_root,
460 ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
461 msg_Dbg( p_intf, "requested playlist shuffle");
472 E_(ExtractURIValue)( p_request, "psz_pos", psz_pos, 6 );
473 E_(ExtractURIValue)( p_request, "psz_newpos", psz_newpos, 6 );
474 i_pos = atoi( psz_pos );
475 i_newpos = atoi( psz_newpos );
476 if ( i_pos < i_newpos )
478 playlist_Move( p_sys->p_playlist, i_pos, i_newpos + 1 );
482 playlist_Move( p_sys->p_playlist, i_pos, i_newpos );
484 msg_Dbg( p_intf, "requested move playlist item %d to %d", i_pos, i_newpos);
492 E_(ExtractURIValue)( p_request, "id", id, 512 );
493 msg_Dbg( p_intf, "requested close id=%s", id );
495 if( p_sys->p_httpd->pf_control( p_sys->p_httpd, HTTPD_SET_CLOSE, id, NULL ) )
497 msg_Warn( p_intf, "close failed for id=%s", id );
504 msg_Dbg( p_intf, "requested shutdown" );
505 p_intf->p_vlc->b_die = VLC_TRUE;
512 static const char *vlm_properties[11] =
515 "enabled", "disabled", "loop", "unloop",
517 "input", "output", "option", "date", "period", "repeat", "append",
519 vlm_message_t *vlm_answer;
521 char *psz = malloc( strlen( p_request ) + 1000 );
526 if( p_intf->p_sys->p_vlm == NULL )
527 p_intf->p_sys->p_vlm = vlm_New( p_intf );
529 if( p_intf->p_sys->p_vlm == NULL ) break;
531 E_(ExtractURIValue)( p_request, "name", name, 512 );
532 if( E_(StrToMacroType)( control ) == MVLC_VLM_NEW )
535 E_(ExtractURIValue)( p_request, "type", type, 20 );
536 p += sprintf( psz, "new %s %s", name, type );
540 p += sprintf( psz, "setup %s", name );
542 /* Parse the request */
543 for( i = 0; i < 11; i++ )
546 E_(ExtractURIValue)( p_request,
547 vlm_properties[i], val, 512 );
549 if( strlen( val ) > 0 && i >= 4 )
551 p += sprintf( p, " %s %s", vlm_properties[i], val );
553 else if( E_(TestURIParam)( p_request, vlm_properties[i] ) && i < 4 )
555 p += sprintf( p, " %s", vlm_properties[i] );
558 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
559 if( vlm_answer->psz_value == NULL ) /* there is no error */
561 vlm_error = strdup( "" );
565 vlm_error = malloc( strlen(vlm_answer->psz_name) +
566 strlen(vlm_answer->psz_value) +
567 strlen( " : ") + 1 );
568 sprintf( vlm_error , "%s : %s" , vlm_answer->psz_name,
569 vlm_answer->psz_value );
572 E_(mvar_AppendNewVar)( p_args->vars, "vlm_error", vlm_error );
574 vlm_MessageDelete( vlm_answer );
582 vlm_message_t *vlm_answer;
585 if( p_intf->p_sys->p_vlm == NULL )
586 p_intf->p_sys->p_vlm = vlm_New( p_intf );
588 if( p_intf->p_sys->p_vlm == NULL ) break;
590 E_(ExtractURIValue)( p_request, "name", name, 512 );
591 sprintf( psz, "del %s", name );
593 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
594 /* FIXME do a vlm_answer -> var stack conversion */
595 vlm_MessageDelete( vlm_answer );
604 vlm_message_t *vlm_answer;
607 if( p_intf->p_sys->p_vlm == NULL )
608 p_intf->p_sys->p_vlm = vlm_New( p_intf );
610 if( p_intf->p_sys->p_vlm == NULL ) break;
612 E_(ExtractURIValue)( p_request, "name", name, 512 );
613 if( E_(StrToMacroType)( control ) == MVLC_VLM_PLAY )
614 sprintf( psz, "control %s play", name );
615 else if( E_(StrToMacroType)( control ) == MVLC_VLM_PAUSE )
616 sprintf( psz, "control %s pause", name );
617 else if( E_(StrToMacroType)( control ) == MVLC_VLM_STOP )
618 sprintf( psz, "control %s stop", name );
619 else if( E_(StrToMacroType)( control ) == MVLC_VLM_SEEK )
622 E_(ExtractURIValue)( p_request, "percent", percent, 512 );
623 sprintf( psz, "control %s seek %s", name, percent );
626 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
627 /* FIXME do a vlm_answer -> var stack conversion */
628 vlm_MessageDelete( vlm_answer );
634 vlm_message_t *vlm_answer;
638 if( p_intf->p_sys->p_vlm == NULL )
639 p_intf->p_sys->p_vlm = vlm_New( p_intf );
641 if( p_intf->p_sys->p_vlm == NULL ) break;
643 E_(ExtractURIValue)( p_request, "file", file, 512 );
646 if( E_(StrToMacroType)( control ) == MVLC_VLM_LOAD )
647 sprintf( psz, "load %s", file );
649 sprintf( psz, "save %s", file );
651 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
652 /* FIXME do a vlm_answer -> var stack conversion */
653 vlm_MessageDelete( vlm_answer );
660 PRINTS( "<!-- control param(%s) unsupported -->", control );
672 if( i_request <= 0 ||
673 *m->param1 == '\0' ||
674 strstr( p_request, m->param1 ) == NULL )
678 E_(ExtractURIValue)( p_request, m->param1, value, 512 );
681 switch( E_(StrToMacroType)( m->param2 ) )
685 config_PutInt( p_intf, m->param1, i );
689 config_PutFloat( p_intf, m->param1, f );
692 config_PutPsz( p_intf, m->param1, value );
695 PRINTS( "<!-- invalid type(%s) in set -->", m->param2 )
707 if( *m->param1 == '\0' )
712 switch( E_(StrToMacroType)( m->param2 ) )
715 i = config_GetInt( p_intf, m->param1 );
716 sprintf( value, "%d", i );
719 f = config_GetFloat( p_intf, m->param1 );
720 div = lldiv( f * 1000000 , 1000000 );
721 sprintf( value, I64Fd".%06u", div.quot,
722 (unsigned int)div.rem );
725 psz = config_GetPsz( p_intf, m->param1 );
728 strlcpy( value, psz,sizeof( value ) );
733 msg_Dbg( p_intf, "%d: value = \"%s\"", __LINE__, value );
736 snprintf( value, sizeof( value ),
737 "invalid type(%s) in set", m->param2 );
740 PRINTS( "%s", value );
749 E_(EvaluateRPN)( p_intf, p_args->vars, &p_args->stack, m->param1 );
750 s = E_(SSPop)( &p_args->stack );
751 v = E_(mvar_GetValue)( p_args->vars, s );
755 v = s = E_(SSPop)( &p_args->stack );
763 E_(EvaluateRPN)( p_intf, p_args->vars, &p_args->stack, m->param1 );
766 /* Useful to learn stack management */
770 msg_Dbg( p_intf, "stack" );
771 for (i=0;i<(&p_args->stack)->i_stack;i++)
772 msg_Dbg( p_intf, "%d -> %s", i, (&p_args->stack)->stack[i] );
778 PRINTS( "<!-- invalid macro id=`%s' -->", m->id );
779 msg_Dbg( p_intf, "invalid macro id=`%s'", m->id );
787 char *E_(MacroSearch)( char *src, char *end, int i_mvlc, vlc_bool_t b_after )
794 if( src + 4 < end && !strncmp( (char *)src, "<vlc", 4 ) )
799 i_skip = E_(MacroParse)( &m, src );
801 i_id = E_(StrToMacroType)( m.id );
816 E_(MacroClean)( &m );
818 if( ( i_mvlc == MVLC_END && i_level == -1 ) ||
819 ( i_mvlc != MVLC_END && i_level == 0 && i_mvlc == i_id ) )
821 return src + ( b_after ? i_skip : 0 );
823 else if( i_level < 0 )
839 void E_(Execute)( httpd_file_sys_t *p_args,
840 char *p_request, int i_request,
841 char **pp_data, int *pi_data,
843 char *_src, char *_end )
845 intf_thread_t *p_intf = p_args->p_intf;
847 char *src, *dup, *end;
850 src = dup = malloc( _end - _src + 1 );
851 end = src +( _end - _src );
853 memcpy( src, _src, _end - _src );
856 /* we parse searching <vlc */
862 p = (char *)strstr( (char *)src, "<vlc" );
863 if( p < end && p == src )
867 src += E_(MacroParse)( &m, src );
869 //msg_Dbg( p_intf, "macro_id=%s", m.id );
871 switch( E_(StrToMacroType)( m.id ) )
878 char psz_file[MAX_DIR_SIZE];
888 if( m.param1[0] != sep )
890 strcpy( psz_file, p_args->file );
891 p = strrchr( psz_file, sep );
893 strcpy( p + 1, m.param1 );
895 strcpy( psz_file, m.param1 );
899 strcpy( psz_file, m.param1 );
902 /* We hereby assume that psz_file is in the
903 * local character encoding */
904 if( ( f = fopen( psz_file, "r" ) ) == NULL )
906 msg_Warn( p_args->p_intf,
907 "unable to include file %s (%s)",
908 psz_file, strerror(errno) );
912 /* first we load in a temporary buffer */
913 E_(FileLoad)( f, &p_buffer, &i_buffer );
915 /* we parse executing all <vlc /> macros */
916 E_(Execute)( p_args, p_request, i_request, pp_data, pi_data,
917 &dst, &p_buffer[0], &p_buffer[i_buffer] );
927 E_(EvaluateRPN)( p_intf, p_args->vars, &p_args->stack, m.param1 );
928 if( E_(SSPopN)( &p_args->stack, p_args->vars ) )
936 endif = E_(MacroSearch)( src, end, MVLC_END, VLC_TRUE );
940 char *start = E_(MacroSearch)( src, endif, MVLC_ELSE, VLC_TRUE );
944 char *stop = E_(MacroSearch)( start, endif, MVLC_END, VLC_FALSE );
947 E_(Execute)( p_args, p_request, i_request,
948 pp_data, pi_data, &dst, start, stop );
952 else if( i_test == 1 )
955 if( ( stop = E_(MacroSearch)( src, endif, MVLC_ELSE, VLC_FALSE ) ) == NULL )
957 stop = E_(MacroSearch)( src, endif, MVLC_END, VLC_FALSE );
961 E_(Execute)( p_args, p_request, i_request,
962 pp_data, pi_data, &dst, src, stop );
971 char *endfor = E_(MacroSearch)( src, end, MVLC_END, VLC_TRUE );
973 char *stop = E_(MacroSearch)( src, end, MVLC_END, VLC_FALSE );
980 if( !strcmp( m.param2, "integer" ) )
982 char *arg = E_(SSPop)( &p_args->stack );
983 index = E_(mvar_IntegerSetNew)( m.param1, arg );
986 else if( !strcmp( m.param2, "directory" ) )
988 char *arg = E_(SSPop)( &p_args->stack );
989 index = E_(mvar_FileSetNew)( p_intf, m.param1, arg );
992 else if( !strcmp( m.param2, "object" ) )
994 char *arg = E_(SSPop)( &p_args->stack );
995 index = E_(mvar_ObjectSetNew)( p_intf, m.param1, arg );
998 else if( !strcmp( m.param2, "playlist" ) )
1000 index = E_(mvar_PlaylistSetNew)( p_intf, m.param1,
1001 p_intf->p_sys->p_playlist );
1003 else if( !strcmp( m.param2, "information" ) )
1005 index = E_(mvar_InfoSetNew)( p_intf, m.param1,
1006 p_intf->p_sys->p_input );
1008 else if( !strcmp( m.param2, "program" )
1009 || !strcmp( m.param2, "title" )
1010 || !strcmp( m.param2, "chapter" )
1011 || !strcmp( m.param2, "audio-es" )
1012 || !strcmp( m.param2, "video-es" )
1013 || !strcmp( m.param2, "spu-es" ) )
1015 index = E_(mvar_InputVarSetNew)( p_intf, m.param1,
1016 p_intf->p_sys->p_input,
1019 else if( !strcmp( m.param2, "vlm" ) )
1021 if( p_intf->p_sys->p_vlm == NULL )
1022 p_intf->p_sys->p_vlm = vlm_New( p_intf );
1023 index = E_(mvar_VlmSetNew)( m.param1, p_intf->p_sys->p_vlm );
1026 else if( !strcmp( m.param2, "hosts" ) )
1028 index = E_(mvar_HttpdInfoSetNew)( m.param1, p_intf->p_sys->p_httpd, HTTPD_GET_HOSTS );
1030 else if( !strcmp( m.param2, "urls" ) )
1032 index = E_(mvar_HttpdInfoSetNew)( m.param1, p_intf->p_sys->p_httpd, HTTPD_GET_URLS );
1034 else if( !strcmp( m.param2, "connections" ) )
1036 index = E_(mvar_HttpdInfoSetNew)(m.param1, p_intf->p_sys->p_httpd, HTTPD_GET_CONNECTIONS);
1039 else if( ( v = E_(mvar_GetVar)( p_args->vars, m.param2 ) ) )
1041 index = E_(mvar_Duplicate)( v );
1045 msg_Dbg( p_intf, "invalid index constructor (%s)", m.param2 );
1050 for( i_idx = 0; i_idx < index->i_field; i_idx++ )
1052 mvar_t *f = E_(mvar_Duplicate)( index->field[i_idx] );
1054 //msg_Dbg( p_intf, "foreach field[%d] name=%s value=%s", i_idx, f->name, f->value );
1057 f->name = strdup( m.param1 );
1060 E_(mvar_PushVar)( p_args->vars, f );
1061 E_(Execute)( p_args, p_request, i_request,
1062 pp_data, pi_data, &dst, start, stop );
1063 E_(mvar_RemoveVar)( p_args->vars, f );
1065 E_(mvar_Delete)( f );
1067 E_(mvar_Delete)( index );
1074 E_(MacroDo)( p_args, &m, p_request, i_request,
1075 pp_data, pi_data, &dst );
1079 E_(MacroClean)( &m );
1083 i_copy = ( (p == NULL || p > end ) ? end : p ) - src;
1086 int i_index = dst - *pp_data;
1089 *pp_data = realloc( *pp_data, *pi_data );
1090 dst = (*pp_data) + i_index;
1092 memcpy( dst, src, i_copy );