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_VIEWPLAY,
200 playlist_ItemGetById( p_sys->p_playlist,
202 msg_Dbg( p_intf, "requested playlist item: %i", i_item );
206 playlist_Control( p_sys->p_playlist, PLAYLIST_STOP );
207 msg_Dbg( p_intf, "requested playlist stop" );
210 playlist_Control( p_sys->p_playlist, PLAYLIST_PAUSE );
211 msg_Dbg( p_intf, "requested playlist pause" );
214 playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, 1 );
215 msg_Dbg( p_intf, "requested playlist next" );
218 playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, -1 );
219 msg_Dbg( p_intf, "requested playlist previous" );
221 case MVLC_FULLSCREEN:
224 vout_thread_t *p_vout;
225 p_vout = vlc_object_find( p_sys->p_input,
226 VLC_OBJECT_VOUT, FIND_CHILD );
230 p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
231 vlc_object_release( p_vout );
232 msg_Dbg( p_intf, "requested fullscreen toggle" );
239 E_(ExtractURIValue)( p_request, "seek_value", value, 30 );
241 E_(HandleSeek)( p_intf, value );
247 audio_volume_t i_volume;
250 E_(ExtractURIValue)( p_request, "value", vol, 8 );
251 aout_VolumeGet( p_intf, &i_volume );
256 i_value = atoi( vol + 1 );
257 if( (i_volume + i_value) > AOUT_VOLUME_MAX )
259 aout_VolumeSet( p_intf , AOUT_VOLUME_MAX );
260 msg_Dbg( p_intf, "requested volume set: max" );
264 aout_VolumeSet( p_intf , (i_volume + i_value) );
265 msg_Dbg( p_intf, "requested volume set: +%i", (i_volume + i_value) );
268 else if( vol[0] == '-' )
270 i_value = atoi( vol + 1 );
271 if( (i_volume - i_value) < AOUT_VOLUME_MIN )
273 aout_VolumeSet( p_intf , AOUT_VOLUME_MIN );
274 msg_Dbg( p_intf, "requested volume set: min" );
278 aout_VolumeSet( p_intf , (i_volume - i_value) );
279 msg_Dbg( p_intf, "requested volume set: -%i", (i_volume - i_value) );
282 else if( strstr(vol, "%") != NULL )
284 i_value = atoi( vol );
285 if( (i_value <= 400) && (i_value>=0) ){
286 aout_VolumeSet( p_intf, (i_value * (AOUT_VOLUME_MAX - AOUT_VOLUME_MIN))/400+AOUT_VOLUME_MIN);
287 msg_Dbg( p_intf, "requested volume set: %i%%", atoi( vol ));
292 i_value = atoi( vol );
293 if( ( i_value <= AOUT_VOLUME_MAX ) && ( i_value >= AOUT_VOLUME_MIN ) )
295 aout_VolumeSet( p_intf , atoi( vol ) );
296 msg_Dbg( p_intf, "requested volume set: %i", atoi( vol ) );
302 /* playlist management */
305 char mrl[1024], psz_name[1024], tmp[1024];
307 input_item_t *p_input;
309 E_(ExtractURIValue)( p_request, "mrl", tmp, 1024 );
311 E_(ExtractURIValue)( p_request, "name", psz_name, 1024 );
312 decode_URI( psz_name );
315 memcpy( psz_name, tmp, 1024 );
317 /* addslashes for backward compatibility with the old
320 while( *str != '\0' )
322 if( *str == '"' || *str == '\'' || *str == '\\' )
331 p_input = E_(MRLParse)( p_intf, mrl, psz_name );
333 if( !p_input || p_input->psz_uri ||
336 msg_Dbg( p_intf, "invalid requested mrl: %s", mrl );
340 playlist_PlaylistAddInput( p_sys->p_playlist, p_input,
341 PLAYLIST_APPEND, PLAYLIST_END );
342 msg_Dbg( p_intf, "requested mrl add: %s", mrl );
349 int i_item, *p_items = NULL, i_nb_items = 0;
350 char item[512], *p_parser = p_request;
352 /* Get the list of items to delete */
354 E_(ExtractURIValue)( p_parser, "item", item, 512 )) )
356 if( !*item ) continue;
358 i_item = atoi( item );
359 p_items = realloc( p_items, (i_nb_items + 1) *
361 p_items[i_nb_items] = i_item;
368 for( i = 0; i < i_nb_items; i++ )
370 playlist_LockDelete( p_sys->p_playlist, p_items[i] );
371 msg_Dbg( p_intf, "requested playlist delete: %d",
377 if( p_items ) free( p_items );
382 int i_item, *p_items = NULL, i_nb_items = 0;
383 char item[512], *p_parser = p_request;
386 /* Get the list of items to keep */
388 E_(ExtractURIValue)( p_parser, "item", item, 512 )) )
390 if( !*item ) continue;
392 i_item = atoi( item );
393 p_items = realloc( p_items, (i_nb_items + 1) *
395 p_items[i_nb_items] = i_item;
399 for( i = p_sys->p_playlist->i_size - 1 ; i >= 0; i-- )
401 /* Check if the item is in the keep list */
402 for( j = 0 ; j < i_nb_items ; j++ )
405 p_sys->p_playlist->pp_items[i]->p_input->i_id )
408 if( j == i_nb_items )
410 playlist_LockDelete( p_sys->p_playlist,
411 p_sys->p_playlist->pp_items[i]->p_input->i_id );
412 msg_Dbg( p_intf, "requested playlist delete: %d",
417 if( p_items ) free( p_items );
422 playlist_LockClear( p_sys->p_playlist );
423 msg_Dbg( p_intf, "requested playlist empty" );
434 E_(ExtractURIValue)( p_request, "type", type, 12 );
435 E_(ExtractURIValue)( p_request, "order", order, 2 );
436 E_(ExtractURIValue)( p_request, "item", item, 512 );
437 i_item = atoi( item );
439 if( order[0] == '0' ) i_order = ORDER_NORMAL;
440 else i_order = ORDER_REVERSE;
442 if( !strcmp( type , "title" ) )
444 playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
445 /* Ugly hack,but not worse than before ... */
446 p_sys->p_playlist->p_root_onelevel,
447 SORT_TITLE_NODES_FIRST,
448 ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
449 msg_Dbg( p_intf, "requested playlist sort by title (%d)" , i_order );
451 else if( !strcmp( type , "author" ) )
453 playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
454 p_sys->p_playlist->p_root_onelevel,
456 ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
457 msg_Dbg( p_intf, "requested playlist sort by author (%d)" , i_order );
459 else if( !strcmp( type , "shuffle" ) )
461 playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
462 p_sys->p_playlist->p_root_onelevel,
464 ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
465 msg_Dbg( p_intf, "requested playlist shuffle");
476 E_(ExtractURIValue)( p_request, "psz_pos", psz_pos, 6 );
477 E_(ExtractURIValue)( p_request, "psz_newpos", psz_newpos, 6 );
478 i_pos = atoi( psz_pos );
479 i_newpos = atoi( psz_newpos );
480 /* FIXME FIXME TODO TODO XXX XXX
481 ( duplicate from rpn.c )
482 if ( i_pos < i_newpos )
484 playlist_Move( p_sys->p_playlist, i_pos, i_newpos + 1 );
488 playlist_Move( p_sys->p_playlist, i_pos, i_newpos );
490 msg_Dbg( p_intf, "requested move playlist item %d to %d", i_pos, i_newpos);
491 FIXME FIXME TODO TODO XXX XXX */
499 E_(ExtractURIValue)( p_request, "id", id, 512 );
500 msg_Dbg( p_intf, "requested close id=%s", id );
502 if( p_sys->p_httpd->pf_control( p_sys->p_httpd, HTTPD_SET_CLOSE, id, NULL ) )
504 msg_Warn( p_intf, "close failed for id=%s", id );
511 msg_Dbg( p_intf, "requested shutdown" );
512 p_intf->p_vlc->b_die = VLC_TRUE;
519 static const char *vlm_properties[11] =
522 "enabled", "disabled", "loop", "unloop",
524 "input", "output", "option", "date", "period", "repeat", "append",
526 vlm_message_t *vlm_answer;
528 char *psz = malloc( strlen( p_request ) + 1000 );
533 if( p_intf->p_sys->p_vlm == NULL )
534 p_intf->p_sys->p_vlm = vlm_New( p_intf );
536 if( p_intf->p_sys->p_vlm == NULL ) break;
538 E_(ExtractURIValue)( p_request, "name", name, 512 );
539 if( E_(StrToMacroType)( control ) == MVLC_VLM_NEW )
542 E_(ExtractURIValue)( p_request, "type", type, 20 );
543 p += sprintf( psz, "new %s %s", name, type );
547 p += sprintf( psz, "setup %s", name );
549 /* Parse the request */
550 for( i = 0; i < 11; i++ )
553 E_(ExtractURIValue)( p_request,
554 vlm_properties[i], val, 512 );
556 if( strlen( val ) > 0 && i >= 4 )
558 p += sprintf( p, " %s %s", vlm_properties[i], val );
560 else if( E_(TestURIParam)( p_request, vlm_properties[i] ) && i < 4 )
562 p += sprintf( p, " %s", vlm_properties[i] );
565 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
566 if( vlm_answer->psz_value == NULL ) /* there is no error */
568 vlm_error = strdup( "" );
572 vlm_error = malloc( strlen(vlm_answer->psz_name) +
573 strlen(vlm_answer->psz_value) +
574 strlen( " : ") + 1 );
575 sprintf( vlm_error , "%s : %s" , vlm_answer->psz_name,
576 vlm_answer->psz_value );
579 E_(mvar_AppendNewVar)( p_args->vars, "vlm_error", vlm_error );
581 vlm_MessageDelete( vlm_answer );
589 vlm_message_t *vlm_answer;
592 if( p_intf->p_sys->p_vlm == NULL )
593 p_intf->p_sys->p_vlm = vlm_New( p_intf );
595 if( p_intf->p_sys->p_vlm == NULL ) break;
597 E_(ExtractURIValue)( p_request, "name", name, 512 );
598 sprintf( psz, "del %s", name );
600 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
601 /* FIXME do a vlm_answer -> var stack conversion */
602 vlm_MessageDelete( vlm_answer );
611 vlm_message_t *vlm_answer;
614 if( p_intf->p_sys->p_vlm == NULL )
615 p_intf->p_sys->p_vlm = vlm_New( p_intf );
617 if( p_intf->p_sys->p_vlm == NULL ) break;
619 E_(ExtractURIValue)( p_request, "name", name, 512 );
620 if( E_(StrToMacroType)( control ) == MVLC_VLM_PLAY )
621 sprintf( psz, "control %s play", name );
622 else if( E_(StrToMacroType)( control ) == MVLC_VLM_PAUSE )
623 sprintf( psz, "control %s pause", name );
624 else if( E_(StrToMacroType)( control ) == MVLC_VLM_STOP )
625 sprintf( psz, "control %s stop", name );
626 else if( E_(StrToMacroType)( control ) == MVLC_VLM_SEEK )
629 E_(ExtractURIValue)( p_request, "percent", percent, 512 );
630 sprintf( psz, "control %s seek %s", name, percent );
633 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
634 /* FIXME do a vlm_answer -> var stack conversion */
635 vlm_MessageDelete( vlm_answer );
641 vlm_message_t *vlm_answer;
645 if( p_intf->p_sys->p_vlm == NULL )
646 p_intf->p_sys->p_vlm = vlm_New( p_intf );
648 if( p_intf->p_sys->p_vlm == NULL ) break;
650 E_(ExtractURIValue)( p_request, "file", file, 512 );
653 if( E_(StrToMacroType)( control ) == MVLC_VLM_LOAD )
654 sprintf( psz, "load %s", file );
656 sprintf( psz, "save %s", file );
658 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
659 /* FIXME do a vlm_answer -> var stack conversion */
660 vlm_MessageDelete( vlm_answer );
667 PRINTS( "<!-- control param(%s) unsupported -->", control );
679 if( i_request <= 0 ||
680 *m->param1 == '\0' ||
681 strstr( p_request, m->param1 ) == NULL )
685 E_(ExtractURIValue)( p_request, m->param1, value, 512 );
688 switch( E_(StrToMacroType)( m->param2 ) )
692 config_PutInt( p_intf, m->param1, i );
696 config_PutFloat( p_intf, m->param1, f );
699 config_PutPsz( p_intf, m->param1, value );
702 PRINTS( "<!-- invalid type(%s) in set -->", m->param2 )
714 if( *m->param1 == '\0' )
719 switch( E_(StrToMacroType)( m->param2 ) )
722 i = config_GetInt( p_intf, m->param1 );
723 sprintf( value, "%d", i );
726 f = config_GetFloat( p_intf, m->param1 );
727 div = lldiv( f * 1000000 , 1000000 );
728 sprintf( value, "%lld.%06u", div.quot,
729 (unsigned int)div.rem );
732 psz = config_GetPsz( p_intf, m->param1 );
735 strlcpy( value, psz,sizeof( value ) );
740 msg_Dbg( p_intf, "%d: value = \"%s\"", __LINE__, value );
743 snprintf( value, sizeof( value ),
744 "invalid type(%s) in set", m->param2 );
747 PRINTS( "%s", value );
756 E_(EvaluateRPN)( p_intf, p_args->vars, &p_args->stack, m->param1 );
757 s = E_(SSPop)( &p_args->stack );
758 v = E_(mvar_GetValue)( p_args->vars, s );
762 v = s = E_(SSPop)( &p_args->stack );
770 E_(EvaluateRPN)( p_intf, p_args->vars, &p_args->stack, m->param1 );
773 /* Useful to learn stack management */
777 msg_Dbg( p_intf, "stack" );
778 for (i=0;i<(&p_args->stack)->i_stack;i++)
779 msg_Dbg( p_intf, "%d -> %s", i, (&p_args->stack)->stack[i] );
785 PRINTS( "<!-- invalid macro id=`%s' -->", m->id );
786 msg_Dbg( p_intf, "invalid macro id=`%s'", m->id );
794 char *E_(MacroSearch)( char *src, char *end, int i_mvlc, vlc_bool_t b_after )
801 if( src + 4 < end && !strncmp( (char *)src, "<vlc", 4 ) )
806 i_skip = E_(MacroParse)( &m, src );
808 i_id = E_(StrToMacroType)( m.id );
823 E_(MacroClean)( &m );
825 if( ( i_mvlc == MVLC_END && i_level == -1 ) ||
826 ( i_mvlc != MVLC_END && i_level == 0 && i_mvlc == i_id ) )
828 return src + ( b_after ? i_skip : 0 );
830 else if( i_level < 0 )
846 void E_(Execute)( httpd_file_sys_t *p_args,
847 char *p_request, int i_request,
848 char **pp_data, int *pi_data,
850 char *_src, char *_end )
852 intf_thread_t *p_intf = p_args->p_intf;
854 char *src, *dup, *end;
857 src = dup = malloc( _end - _src + 1 );
858 end = src +( _end - _src );
860 memcpy( src, _src, _end - _src );
863 /* we parse searching <vlc */
869 p = (char *)strstr( (char *)src, "<vlc" );
870 if( p < end && p == src )
874 src += E_(MacroParse)( &m, src );
876 //msg_Dbg( p_intf, "macro_id=%s", m.id );
878 switch( E_(StrToMacroType)( m.id ) )
885 char psz_file[MAX_DIR_SIZE];
895 if( m.param1[0] != sep )
897 strcpy( psz_file, p_args->file );
898 p = strrchr( psz_file, sep );
900 strcpy( p + 1, m.param1 );
902 strcpy( psz_file, m.param1 );
906 strcpy( psz_file, m.param1 );
909 /* We hereby assume that psz_file is in the
910 * local character encoding */
911 if( ( f = fopen( psz_file, "r" ) ) == NULL )
913 msg_Warn( p_args->p_intf,
914 "unable to include file %s (%s)",
915 psz_file, strerror(errno) );
919 /* first we load in a temporary buffer */
920 E_(FileLoad)( f, &p_buffer, &i_buffer );
922 /* we parse executing all <vlc /> macros */
923 E_(Execute)( p_args, p_request, i_request, pp_data, pi_data,
924 &dst, &p_buffer[0], &p_buffer[i_buffer] );
934 E_(EvaluateRPN)( p_intf, p_args->vars, &p_args->stack, m.param1 );
935 if( E_(SSPopN)( &p_args->stack, p_args->vars ) )
943 endif = E_(MacroSearch)( src, end, MVLC_END, VLC_TRUE );
947 char *start = E_(MacroSearch)( src, endif, MVLC_ELSE, VLC_TRUE );
951 char *stop = E_(MacroSearch)( start, endif, MVLC_END, VLC_FALSE );
954 E_(Execute)( p_args, p_request, i_request,
955 pp_data, pi_data, &dst, start, stop );
959 else if( i_test == 1 )
962 if( ( stop = E_(MacroSearch)( src, endif, MVLC_ELSE, VLC_FALSE ) ) == NULL )
964 stop = E_(MacroSearch)( src, endif, MVLC_END, VLC_FALSE );
968 E_(Execute)( p_args, p_request, i_request,
969 pp_data, pi_data, &dst, src, stop );
978 char *endfor = E_(MacroSearch)( src, end, MVLC_END, VLC_TRUE );
980 char *stop = E_(MacroSearch)( src, end, MVLC_END, VLC_FALSE );
987 if( !strcmp( m.param2, "integer" ) )
989 char *arg = E_(SSPop)( &p_args->stack );
990 index = E_(mvar_IntegerSetNew)( m.param1, arg );
993 else if( !strcmp( m.param2, "directory" ) )
995 char *arg = E_(SSPop)( &p_args->stack );
996 index = E_(mvar_FileSetNew)( p_intf, m.param1, arg );
999 else if( !strcmp( m.param2, "object" ) )
1001 char *arg = E_(SSPop)( &p_args->stack );
1002 index = E_(mvar_ObjectSetNew)( p_intf, m.param1, arg );
1005 else if( !strcmp( m.param2, "playlist" ) )
1007 index = E_(mvar_PlaylistSetNew)( p_intf, m.param1,
1008 p_intf->p_sys->p_playlist );
1010 else if( !strcmp( m.param2, "information" ) )
1012 index = E_(mvar_InfoSetNew)( p_intf, m.param1,
1013 p_intf->p_sys->p_input );
1015 else if( !strcmp( m.param2, "program" )
1016 || !strcmp( m.param2, "title" )
1017 || !strcmp( m.param2, "chapter" )
1018 || !strcmp( m.param2, "audio-es" )
1019 || !strcmp( m.param2, "video-es" )
1020 || !strcmp( m.param2, "spu-es" ) )
1022 index = E_(mvar_InputVarSetNew)( p_intf, m.param1,
1023 p_intf->p_sys->p_input,
1026 else if( !strcmp( m.param2, "vlm" ) )
1028 if( p_intf->p_sys->p_vlm == NULL )
1029 p_intf->p_sys->p_vlm = vlm_New( p_intf );
1030 index = E_(mvar_VlmSetNew)( m.param1, p_intf->p_sys->p_vlm );
1033 else if( !strcmp( m.param2, "hosts" ) )
1035 index = E_(mvar_HttpdInfoSetNew)( m.param1, p_intf->p_sys->p_httpd, HTTPD_GET_HOSTS );
1037 else if( !strcmp( m.param2, "urls" ) )
1039 index = E_(mvar_HttpdInfoSetNew)( m.param1, p_intf->p_sys->p_httpd, HTTPD_GET_URLS );
1041 else if( !strcmp( m.param2, "connections" ) )
1043 index = E_(mvar_HttpdInfoSetNew)(m.param1, p_intf->p_sys->p_httpd, HTTPD_GET_CONNECTIONS);
1046 else if( ( v = E_(mvar_GetVar)( p_args->vars, m.param2 ) ) )
1048 index = E_(mvar_Duplicate)( v );
1052 msg_Dbg( p_intf, "invalid index constructor (%s)", m.param2 );
1057 for( i_idx = 0; i_idx < index->i_field; i_idx++ )
1059 mvar_t *f = E_(mvar_Duplicate)( index->field[i_idx] );
1061 //msg_Dbg( p_intf, "foreach field[%d] name=%s value=%s", i_idx, f->name, f->value );
1064 f->name = strdup( m.param1 );
1067 E_(mvar_PushVar)( p_args->vars, f );
1068 E_(Execute)( p_args, p_request, i_request,
1069 pp_data, pi_data, &dst, start, stop );
1070 E_(mvar_RemoveVar)( p_args->vars, f );
1072 E_(mvar_Delete)( f );
1074 E_(mvar_Delete)( index );
1081 E_(MacroDo)( p_args, &m, p_request, i_request,
1082 pp_data, pi_data, &dst );
1086 E_(MacroClean)( &m );
1090 i_copy = ( (p == NULL || p > end ) ? end : p ) - src;
1093 int i_index = dst - *pp_data;
1096 *pp_data = realloc( *pp_data, *pi_data );
1097 dst = (*pp_data) + i_index;
1099 memcpy( dst, src, i_copy );