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 input_item_t *p_input;
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_input = E_(MRLParse)( p_intf, mrl, psz_name );
332 if( !p_input || p_input->psz_uri ||
335 msg_Dbg( p_intf, "invalid requested mrl: %s", mrl );
339 playlist_PlaylistAddInput( p_sys->p_playlist, p_input,
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]->p_input->i_id )
407 if( j == i_nb_items )
409 playlist_LockDelete( p_sys->p_playlist,
410 p_sys->p_playlist->pp_items[i]->p_input->i_id );
411 msg_Dbg( p_intf, "requested playlist delete: %d",
416 if( p_items ) free( p_items );
421 playlist_LockClear( p_sys->p_playlist );
422 msg_Dbg( p_intf, "requested playlist empty" );
433 E_(ExtractURIValue)( p_request, "type", type, 12 );
434 E_(ExtractURIValue)( p_request, "order", order, 2 );
435 E_(ExtractURIValue)( p_request, "item", item, 512 );
436 i_item = atoi( item );
438 if( order[0] == '0' ) i_order = ORDER_NORMAL;
439 else i_order = ORDER_REVERSE;
441 if( !strcmp( type , "title" ) )
443 playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
444 /* Ugly hack,but not worse than before ... */
445 p_sys->p_playlist->p_root_onelevel,
446 SORT_TITLE_NODES_FIRST,
447 ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
448 msg_Dbg( p_intf, "requested playlist sort by title (%d)" , i_order );
450 else if( !strcmp( type , "author" ) )
452 playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
453 p_sys->p_playlist->p_root_onelevel,
455 ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
456 msg_Dbg( p_intf, "requested playlist sort by author (%d)" , i_order );
458 else if( !strcmp( type , "shuffle" ) )
460 playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
461 p_sys->p_playlist->p_root_onelevel,
463 ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
464 msg_Dbg( p_intf, "requested playlist shuffle");
475 E_(ExtractURIValue)( p_request, "psz_pos", psz_pos, 6 );
476 E_(ExtractURIValue)( p_request, "psz_newpos", psz_newpos, 6 );
477 i_pos = atoi( psz_pos );
478 i_newpos = atoi( psz_newpos );
479 /* FIXME FIXME TODO TODO XXX XXX
480 ( duplicate from rpn.c )
481 if ( i_pos < i_newpos )
483 playlist_Move( p_sys->p_playlist, i_pos, i_newpos + 1 );
487 playlist_Move( p_sys->p_playlist, i_pos, i_newpos );
489 msg_Dbg( p_intf, "requested move playlist item %d to %d", i_pos, i_newpos);
490 FIXME FIXME TODO TODO XXX XXX */
498 E_(ExtractURIValue)( p_request, "id", id, 512 );
499 msg_Dbg( p_intf, "requested close id=%s", id );
501 if( p_sys->p_httpd->pf_control( p_sys->p_httpd, HTTPD_SET_CLOSE, id, NULL ) )
503 msg_Warn( p_intf, "close failed for id=%s", id );
510 msg_Dbg( p_intf, "requested shutdown" );
511 p_intf->p_vlc->b_die = VLC_TRUE;
518 static const char *vlm_properties[11] =
521 "enabled", "disabled", "loop", "unloop",
523 "input", "output", "option", "date", "period", "repeat", "append",
525 vlm_message_t *vlm_answer;
527 char *psz = malloc( strlen( p_request ) + 1000 );
532 if( p_intf->p_sys->p_vlm == NULL )
533 p_intf->p_sys->p_vlm = vlm_New( p_intf );
535 if( p_intf->p_sys->p_vlm == NULL ) break;
537 E_(ExtractURIValue)( p_request, "name", name, 512 );
538 if( E_(StrToMacroType)( control ) == MVLC_VLM_NEW )
541 E_(ExtractURIValue)( p_request, "type", type, 20 );
542 p += sprintf( psz, "new %s %s", name, type );
546 p += sprintf( psz, "setup %s", name );
548 /* Parse the request */
549 for( i = 0; i < 11; i++ )
552 E_(ExtractURIValue)( p_request,
553 vlm_properties[i], val, 512 );
555 if( strlen( val ) > 0 && i >= 4 )
557 p += sprintf( p, " %s %s", vlm_properties[i], val );
559 else if( E_(TestURIParam)( p_request, vlm_properties[i] ) && i < 4 )
561 p += sprintf( p, " %s", vlm_properties[i] );
564 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
565 if( vlm_answer->psz_value == NULL ) /* there is no error */
567 vlm_error = strdup( "" );
571 vlm_error = malloc( strlen(vlm_answer->psz_name) +
572 strlen(vlm_answer->psz_value) +
573 strlen( " : ") + 1 );
574 sprintf( vlm_error , "%s : %s" , vlm_answer->psz_name,
575 vlm_answer->psz_value );
578 E_(mvar_AppendNewVar)( p_args->vars, "vlm_error", vlm_error );
580 vlm_MessageDelete( vlm_answer );
588 vlm_message_t *vlm_answer;
591 if( p_intf->p_sys->p_vlm == NULL )
592 p_intf->p_sys->p_vlm = vlm_New( p_intf );
594 if( p_intf->p_sys->p_vlm == NULL ) break;
596 E_(ExtractURIValue)( p_request, "name", name, 512 );
597 sprintf( psz, "del %s", name );
599 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
600 /* FIXME do a vlm_answer -> var stack conversion */
601 vlm_MessageDelete( vlm_answer );
610 vlm_message_t *vlm_answer;
613 if( p_intf->p_sys->p_vlm == NULL )
614 p_intf->p_sys->p_vlm = vlm_New( p_intf );
616 if( p_intf->p_sys->p_vlm == NULL ) break;
618 E_(ExtractURIValue)( p_request, "name", name, 512 );
619 if( E_(StrToMacroType)( control ) == MVLC_VLM_PLAY )
620 sprintf( psz, "control %s play", name );
621 else if( E_(StrToMacroType)( control ) == MVLC_VLM_PAUSE )
622 sprintf( psz, "control %s pause", name );
623 else if( E_(StrToMacroType)( control ) == MVLC_VLM_STOP )
624 sprintf( psz, "control %s stop", name );
625 else if( E_(StrToMacroType)( control ) == MVLC_VLM_SEEK )
628 E_(ExtractURIValue)( p_request, "percent", percent, 512 );
629 sprintf( psz, "control %s seek %s", name, percent );
632 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
633 /* FIXME do a vlm_answer -> var stack conversion */
634 vlm_MessageDelete( vlm_answer );
640 vlm_message_t *vlm_answer;
644 if( p_intf->p_sys->p_vlm == NULL )
645 p_intf->p_sys->p_vlm = vlm_New( p_intf );
647 if( p_intf->p_sys->p_vlm == NULL ) break;
649 E_(ExtractURIValue)( p_request, "file", file, 512 );
652 if( E_(StrToMacroType)( control ) == MVLC_VLM_LOAD )
653 sprintf( psz, "load %s", file );
655 sprintf( psz, "save %s", file );
657 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
658 /* FIXME do a vlm_answer -> var stack conversion */
659 vlm_MessageDelete( vlm_answer );
666 PRINTS( "<!-- control param(%s) unsupported -->", control );
678 if( i_request <= 0 ||
679 *m->param1 == '\0' ||
680 strstr( p_request, m->param1 ) == NULL )
684 E_(ExtractURIValue)( p_request, m->param1, value, 512 );
687 switch( E_(StrToMacroType)( m->param2 ) )
691 config_PutInt( p_intf, m->param1, i );
695 config_PutFloat( p_intf, m->param1, f );
698 config_PutPsz( p_intf, m->param1, value );
701 PRINTS( "<!-- invalid type(%s) in set -->", m->param2 )
713 if( *m->param1 == '\0' )
718 switch( E_(StrToMacroType)( m->param2 ) )
721 i = config_GetInt( p_intf, m->param1 );
722 sprintf( value, "%d", i );
725 f = config_GetFloat( p_intf, m->param1 );
726 div = lldiv( f * 1000000 , 1000000 );
727 sprintf( value, I64Fd".%06u", div.quot,
728 (unsigned int)div.rem );
731 psz = config_GetPsz( p_intf, m->param1 );
734 strlcpy( value, psz,sizeof( value ) );
739 msg_Dbg( p_intf, "%d: value = \"%s\"", __LINE__, value );
742 snprintf( value, sizeof( value ),
743 "invalid type(%s) in set", m->param2 );
746 PRINTS( "%s", value );
755 E_(EvaluateRPN)( p_intf, p_args->vars, &p_args->stack, m->param1 );
756 s = E_(SSPop)( &p_args->stack );
757 v = E_(mvar_GetValue)( p_args->vars, s );
761 v = s = E_(SSPop)( &p_args->stack );
769 E_(EvaluateRPN)( p_intf, p_args->vars, &p_args->stack, m->param1 );
772 /* Useful to learn stack management */
776 msg_Dbg( p_intf, "stack" );
777 for (i=0;i<(&p_args->stack)->i_stack;i++)
778 msg_Dbg( p_intf, "%d -> %s", i, (&p_args->stack)->stack[i] );
784 PRINTS( "<!-- invalid macro id=`%s' -->", m->id );
785 msg_Dbg( p_intf, "invalid macro id=`%s'", m->id );
793 char *E_(MacroSearch)( char *src, char *end, int i_mvlc, vlc_bool_t b_after )
800 if( src + 4 < end && !strncmp( (char *)src, "<vlc", 4 ) )
805 i_skip = E_(MacroParse)( &m, src );
807 i_id = E_(StrToMacroType)( m.id );
822 E_(MacroClean)( &m );
824 if( ( i_mvlc == MVLC_END && i_level == -1 ) ||
825 ( i_mvlc != MVLC_END && i_level == 0 && i_mvlc == i_id ) )
827 return src + ( b_after ? i_skip : 0 );
829 else if( i_level < 0 )
845 void E_(Execute)( httpd_file_sys_t *p_args,
846 char *p_request, int i_request,
847 char **pp_data, int *pi_data,
849 char *_src, char *_end )
851 intf_thread_t *p_intf = p_args->p_intf;
853 char *src, *dup, *end;
856 src = dup = malloc( _end - _src + 1 );
857 end = src +( _end - _src );
859 memcpy( src, _src, _end - _src );
862 /* we parse searching <vlc */
868 p = (char *)strstr( (char *)src, "<vlc" );
869 if( p < end && p == src )
873 src += E_(MacroParse)( &m, src );
875 //msg_Dbg( p_intf, "macro_id=%s", m.id );
877 switch( E_(StrToMacroType)( m.id ) )
884 char psz_file[MAX_DIR_SIZE];
894 if( m.param1[0] != sep )
896 strcpy( psz_file, p_args->file );
897 p = strrchr( psz_file, sep );
899 strcpy( p + 1, m.param1 );
901 strcpy( psz_file, m.param1 );
905 strcpy( psz_file, m.param1 );
908 /* We hereby assume that psz_file is in the
909 * local character encoding */
910 if( ( f = fopen( psz_file, "r" ) ) == NULL )
912 msg_Warn( p_args->p_intf,
913 "unable to include file %s (%s)",
914 psz_file, strerror(errno) );
918 /* first we load in a temporary buffer */
919 E_(FileLoad)( f, &p_buffer, &i_buffer );
921 /* we parse executing all <vlc /> macros */
922 E_(Execute)( p_args, p_request, i_request, pp_data, pi_data,
923 &dst, &p_buffer[0], &p_buffer[i_buffer] );
933 E_(EvaluateRPN)( p_intf, p_args->vars, &p_args->stack, m.param1 );
934 if( E_(SSPopN)( &p_args->stack, p_args->vars ) )
942 endif = E_(MacroSearch)( src, end, MVLC_END, VLC_TRUE );
946 char *start = E_(MacroSearch)( src, endif, MVLC_ELSE, VLC_TRUE );
950 char *stop = E_(MacroSearch)( start, endif, MVLC_END, VLC_FALSE );
953 E_(Execute)( p_args, p_request, i_request,
954 pp_data, pi_data, &dst, start, stop );
958 else if( i_test == 1 )
961 if( ( stop = E_(MacroSearch)( src, endif, MVLC_ELSE, VLC_FALSE ) ) == NULL )
963 stop = E_(MacroSearch)( src, endif, MVLC_END, VLC_FALSE );
967 E_(Execute)( p_args, p_request, i_request,
968 pp_data, pi_data, &dst, src, stop );
977 char *endfor = E_(MacroSearch)( src, end, MVLC_END, VLC_TRUE );
979 char *stop = E_(MacroSearch)( src, end, MVLC_END, VLC_FALSE );
986 if( !strcmp( m.param2, "integer" ) )
988 char *arg = E_(SSPop)( &p_args->stack );
989 index = E_(mvar_IntegerSetNew)( m.param1, arg );
992 else if( !strcmp( m.param2, "directory" ) )
994 char *arg = E_(SSPop)( &p_args->stack );
995 index = E_(mvar_FileSetNew)( p_intf, m.param1, arg );
998 else if( !strcmp( m.param2, "object" ) )
1000 char *arg = E_(SSPop)( &p_args->stack );
1001 index = E_(mvar_ObjectSetNew)( p_intf, m.param1, arg );
1004 else if( !strcmp( m.param2, "playlist" ) )
1006 index = E_(mvar_PlaylistSetNew)( p_intf, m.param1,
1007 p_intf->p_sys->p_playlist );
1009 else if( !strcmp( m.param2, "information" ) )
1011 index = E_(mvar_InfoSetNew)( p_intf, m.param1,
1012 p_intf->p_sys->p_input );
1014 else if( !strcmp( m.param2, "program" )
1015 || !strcmp( m.param2, "title" )
1016 || !strcmp( m.param2, "chapter" )
1017 || !strcmp( m.param2, "audio-es" )
1018 || !strcmp( m.param2, "video-es" )
1019 || !strcmp( m.param2, "spu-es" ) )
1021 index = E_(mvar_InputVarSetNew)( p_intf, m.param1,
1022 p_intf->p_sys->p_input,
1025 else if( !strcmp( m.param2, "vlm" ) )
1027 if( p_intf->p_sys->p_vlm == NULL )
1028 p_intf->p_sys->p_vlm = vlm_New( p_intf );
1029 index = E_(mvar_VlmSetNew)( m.param1, p_intf->p_sys->p_vlm );
1032 else if( !strcmp( m.param2, "hosts" ) )
1034 index = E_(mvar_HttpdInfoSetNew)( m.param1, p_intf->p_sys->p_httpd, HTTPD_GET_HOSTS );
1036 else if( !strcmp( m.param2, "urls" ) )
1038 index = E_(mvar_HttpdInfoSetNew)( m.param1, p_intf->p_sys->p_httpd, HTTPD_GET_URLS );
1040 else if( !strcmp( m.param2, "connections" ) )
1042 index = E_(mvar_HttpdInfoSetNew)(m.param1, p_intf->p_sys->p_httpd, HTTPD_GET_CONNECTIONS);
1045 else if( ( v = E_(mvar_GetVar)( p_args->vars, m.param2 ) ) )
1047 index = E_(mvar_Duplicate)( v );
1051 msg_Dbg( p_intf, "invalid index constructor (%s)", m.param2 );
1056 for( i_idx = 0; i_idx < index->i_field; i_idx++ )
1058 mvar_t *f = E_(mvar_Duplicate)( index->field[i_idx] );
1060 //msg_Dbg( p_intf, "foreach field[%d] name=%s value=%s", i_idx, f->name, f->value );
1063 f->name = strdup( m.param1 );
1066 E_(mvar_PushVar)( p_args->vars, f );
1067 E_(Execute)( p_args, p_request, i_request,
1068 pp_data, pi_data, &dst, start, stop );
1069 E_(mvar_RemoveVar)( p_args->vars, f );
1071 E_(mvar_Delete)( f );
1073 E_(mvar_Delete)( index );
1080 E_(MacroDo)( p_args, &m, p_request, i_request,
1081 pp_data, pi_data, &dst );
1085 E_(MacroClean)( &m );
1089 i_copy = ( (p == NULL || p > end ) ? end : p ) - src;
1092 int i_index = dst - *pp_data;
1095 *pp_data = realloc( *pp_data, *pi_data );
1096 dst = (*pp_data) + i_index;
1098 memcpy( dst, src, i_copy );