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 );
239 E_(DecodeEncodedURI)( value );
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 );
251 E_(DecodeEncodedURI)( vol );
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];
305 playlist_item_t *p_item;
307 E_(ExtractURIValue)( p_request, "mrl", mrl, 1024 );
308 E_(DecodeEncodedURI)( mrl );
309 E_(ExtractURIValue)( p_request, "name", psz_name, 1024 );
310 E_(DecodeEncodedURI)( psz_name );
313 memcpy( psz_name, mrl, 1024 );
315 p_item = E_(MRLParse)( p_intf, mrl, psz_name );
317 if( !p_item || !p_item->input.psz_uri ||
318 !*p_item->input.psz_uri )
320 msg_Dbg( p_intf, "invalid requested mrl: %s", mrl );
324 playlist_AddItem( p_sys->p_playlist, p_item,
325 PLAYLIST_APPEND, PLAYLIST_END );
326 msg_Dbg( p_intf, "requested mrl add: %s", mrl );
333 int i_item, *p_items = NULL, i_nb_items = 0;
334 char item[512], *p_parser = p_request;
336 /* Get the list of items to delete */
338 E_(ExtractURIValue)( p_parser, "item", item, 512 )) )
340 if( !*item ) continue;
342 i_item = atoi( item );
343 p_items = realloc( p_items, (i_nb_items + 1) *
345 p_items[i_nb_items] = i_item;
352 for( i = 0; i < i_nb_items; i++ )
354 playlist_LockDelete( p_sys->p_playlist, p_items[i] );
355 msg_Dbg( p_intf, "requested playlist delete: %d",
361 if( p_items ) free( p_items );
366 int i_item, *p_items = NULL, i_nb_items = 0;
367 char item[512], *p_parser = p_request;
370 /* Get the list of items to keep */
372 E_(ExtractURIValue)( p_parser, "item", item, 512 )) )
374 if( !*item ) continue;
376 i_item = atoi( item );
377 p_items = realloc( p_items, (i_nb_items + 1) *
379 p_items[i_nb_items] = i_item;
383 for( i = p_sys->p_playlist->i_size - 1 ; i >= 0; i-- )
385 /* Check if the item is in the keep list */
386 for( j = 0 ; j < i_nb_items ; j++ )
389 p_sys->p_playlist->pp_items[i]->input.i_id ) break;
391 if( j == i_nb_items )
393 playlist_LockDelete( p_sys->p_playlist, p_sys->p_playlist->pp_items[i]->input.i_id );
394 msg_Dbg( p_intf, "requested playlist delete: %d",
399 if( p_items ) free( p_items );
404 playlist_LockClear( p_sys->p_playlist );
405 msg_Dbg( p_intf, "requested playlist empty" );
416 E_(ExtractURIValue)( p_request, "type", type, 12 );
417 E_(ExtractURIValue)( p_request, "order", order, 2 );
418 E_(ExtractURIValue)( p_request, "item", item, 512 );
419 i_item = atoi( item );
421 if( order[0] == '0' ) i_order = ORDER_NORMAL;
422 else i_order = ORDER_REVERSE;
424 if( !strcmp( type , "title" ) )
426 playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
427 p_sys->p_playlist->pp_views[0]->p_root,
428 SORT_TITLE_NODES_FIRST,
429 ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
430 msg_Dbg( p_intf, "requested playlist sort by title (%d)" , i_order );
432 else if( !strcmp( type , "author" ) )
434 playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
435 p_sys->p_playlist->pp_views[0]->p_root,
437 ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
438 msg_Dbg( p_intf, "requested playlist sort by author (%d)" , i_order );
440 else if( !strcmp( type , "shuffle" ) )
442 playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
443 p_sys->p_playlist->pp_views[0]->p_root,
445 ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
446 msg_Dbg( p_intf, "requested playlist shuffle");
457 E_(ExtractURIValue)( p_request, "psz_pos", psz_pos, 6 );
458 E_(ExtractURIValue)( p_request, "psz_newpos", psz_newpos, 6 );
459 i_pos = atoi( psz_pos );
460 i_newpos = atoi( psz_newpos );
461 if ( i_pos < i_newpos )
463 playlist_Move( p_sys->p_playlist, i_pos, i_newpos + 1 );
467 playlist_Move( p_sys->p_playlist, i_pos, i_newpos );
469 msg_Dbg( p_intf, "requested move playlist item %d to %d", i_pos, i_newpos);
477 E_(ExtractURIValue)( p_request, "id", id, 512 );
478 msg_Dbg( p_intf, "requested close id=%s", id );
480 if( p_sys->p_httpd->pf_control( p_sys->p_httpd, HTTPD_SET_CLOSE, id, NULL ) )
482 msg_Warn( p_intf, "close failed for id=%s", id );
489 msg_Dbg( p_intf, "requested shutdown" );
490 p_intf->p_vlc->b_die = VLC_TRUE;
497 static const char *vlm_properties[11] =
500 "enabled", "disabled", "loop", "unloop",
502 "input", "output", "option", "date", "period", "repeat", "append",
504 vlm_message_t *vlm_answer;
506 char *psz = malloc( strlen( p_request ) + 1000 );
511 if( p_intf->p_sys->p_vlm == NULL )
512 p_intf->p_sys->p_vlm = vlm_New( p_intf );
514 if( p_intf->p_sys->p_vlm == NULL ) break;
516 E_(ExtractURIValue)( p_request, "name", name, 512 );
517 if( E_(StrToMacroType)( control ) == MVLC_VLM_NEW )
520 E_(ExtractURIValue)( p_request, "type", type, 20 );
521 p += sprintf( psz, "new %s %s", name, type );
525 p += sprintf( psz, "setup %s", name );
527 /* Parse the request */
528 for( i = 0; i < 11; i++ )
531 E_(ExtractURIValue)( p_request,
532 vlm_properties[i], val, 512 );
533 E_(DecodeEncodedURI)( val );
534 if( strlen( val ) > 0 && i >= 4 )
536 p += sprintf( p, " %s %s", vlm_properties[i], val );
538 else if( E_(TestURIParam)( p_request, vlm_properties[i] ) && i < 4 )
540 p += sprintf( p, " %s", vlm_properties[i] );
543 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
544 if( vlm_answer->psz_value == NULL ) /* there is no error */
546 vlm_error = strdup( "" );
550 vlm_error = malloc( strlen(vlm_answer->psz_name) +
551 strlen(vlm_answer->psz_value) +
552 strlen( " : ") + 1 );
553 sprintf( vlm_error , "%s : %s" , vlm_answer->psz_name,
554 vlm_answer->psz_value );
557 E_(mvar_AppendNewVar)( p_args->vars, "vlm_error", vlm_error );
559 vlm_MessageDelete( vlm_answer );
567 vlm_message_t *vlm_answer;
570 if( p_intf->p_sys->p_vlm == NULL )
571 p_intf->p_sys->p_vlm = vlm_New( p_intf );
573 if( p_intf->p_sys->p_vlm == NULL ) break;
575 E_(ExtractURIValue)( p_request, "name", name, 512 );
576 sprintf( psz, "del %s", name );
578 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
579 /* FIXME do a vlm_answer -> var stack conversion */
580 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 if( E_(StrToMacroType)( control ) == MVLC_VLM_PLAY )
599 sprintf( psz, "control %s play", name );
600 else if( E_(StrToMacroType)( control ) == MVLC_VLM_PAUSE )
601 sprintf( psz, "control %s pause", name );
602 else if( E_(StrToMacroType)( control ) == MVLC_VLM_STOP )
603 sprintf( psz, "control %s stop", name );
604 else if( E_(StrToMacroType)( control ) == MVLC_VLM_SEEK )
607 E_(ExtractURIValue)( p_request, "percent", percent, 512 );
608 sprintf( psz, "control %s seek %s", name, percent );
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 );
619 vlm_message_t *vlm_answer;
623 if( p_intf->p_sys->p_vlm == NULL )
624 p_intf->p_sys->p_vlm = vlm_New( p_intf );
626 if( p_intf->p_sys->p_vlm == NULL ) break;
628 E_(ExtractURIValue)( p_request, "file", file, 512 );
629 E_(DecodeEncodedURI)( file );
631 if( E_(StrToMacroType)( control ) == MVLC_VLM_LOAD )
632 sprintf( psz, "load %s", file );
634 sprintf( psz, "save %s", file );
636 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
637 /* FIXME do a vlm_answer -> var stack conversion */
638 vlm_MessageDelete( vlm_answer );
645 PRINTS( "<!-- control param(%s) unsupported -->", control );
657 if( i_request <= 0 ||
658 *m->param1 == '\0' ||
659 strstr( p_request, m->param1 ) == NULL )
663 E_(ExtractURIValue)( p_request, m->param1, value, 512 );
664 E_(DecodeEncodedURI)( value );
666 switch( E_(StrToMacroType)( m->param2 ) )
670 config_PutInt( p_intf, m->param1, i );
674 config_PutFloat( p_intf, m->param1, f );
677 config_PutPsz( p_intf, m->param1, value );
680 PRINTS( "<!-- invalid type(%s) in set -->", m->param2 )
691 if( *m->param1 == '\0' )
696 switch( E_(StrToMacroType)( m->param2 ) )
699 i = config_GetInt( p_intf, m->param1 );
700 sprintf( value, "%d", i );
703 f = config_GetFloat( p_intf, m->param1 );
704 sprintf( value, "%f", f );
707 psz = config_GetPsz( p_intf, m->param1 );
710 strncpy( value, psz,sizeof( value ) );
712 value[sizeof( value ) - 1] = '\0';
716 msg_Dbg( p_intf, "%d: value = \"%s\"", __LINE__, value );
719 snprintf( value, sizeof( value ),
720 "invalid type(%s) in set", m->param2 );
721 value[sizeof( value ) - 1] = '\0';
724 PRINTS( "%s", value );
733 E_(EvaluateRPN)( p_intf, p_args->vars, &p_args->stack, m->param1 );
734 s = E_(SSPop)( &p_args->stack );
735 v = E_(mvar_GetValue)( p_args->vars, s );
739 v = s = E_(SSPop)( &p_args->stack );
747 E_(EvaluateRPN)( p_intf, p_args->vars, &p_args->stack, m->param1 );
750 /* Useful to learn stack management */
754 msg_Dbg( p_intf, "stack" );
755 for (i=0;i<(&p_args->stack)->i_stack;i++)
756 msg_Dbg( p_intf, "%d -> %s", i, (&p_args->stack)->stack[i] );
762 PRINTS( "<!-- invalid macro id=`%s' -->", m->id );
763 msg_Dbg( p_intf, "invalid macro id=`%s'", m->id );
771 char *E_(MacroSearch)( char *src, char *end, int i_mvlc, vlc_bool_t b_after )
778 if( src + 4 < end && !strncmp( (char *)src, "<vlc", 4 ) )
783 i_skip = E_(MacroParse)( &m, src );
785 i_id = E_(StrToMacroType)( m.id );
800 E_(MacroClean)( &m );
802 if( ( i_mvlc == MVLC_END && i_level == -1 ) ||
803 ( i_mvlc != MVLC_END && i_level == 0 && i_mvlc == i_id ) )
805 return src + ( b_after ? i_skip : 0 );
807 else if( i_level < 0 )
823 void E_(Execute)( httpd_file_sys_t *p_args,
824 char *p_request, int i_request,
825 char **pp_data, int *pi_data,
827 char *_src, char *_end )
829 intf_thread_t *p_intf = p_args->p_intf;
831 char *src, *dup, *end;
834 src = dup = malloc( _end - _src + 1 );
835 end = src +( _end - _src );
837 memcpy( src, _src, _end - _src );
840 /* we parse searching <vlc */
846 p = (char *)strstr( (char *)src, "<vlc" );
847 if( p < end && p == src )
851 src += E_(MacroParse)( &m, src );
853 //msg_Dbg( p_intf, "macro_id=%s", m.id );
855 switch( E_(StrToMacroType)( m.id ) )
862 char psz_file[MAX_DIR_SIZE];
872 if( m.param1[0] != sep )
874 strcpy( psz_file, p_args->file );
875 p = strrchr( psz_file, sep );
877 strcpy( p + 1, m.param1 );
879 strcpy( psz_file, m.param1 );
883 strcpy( psz_file, m.param1 );
886 /* We hereby assume that psz_file is in the
887 * local character encoding */
888 if( ( f = fopen( psz_file, "r" ) ) == NULL )
890 msg_Warn( p_args->p_intf,
891 "unable to include file %s (%s)",
892 psz_file, strerror(errno) );
896 /* first we load in a temporary buffer */
897 E_(FileLoad)( f, &p_buffer, &i_buffer );
899 /* we parse executing all <vlc /> macros */
900 E_(Execute)( p_args, p_request, i_request, pp_data, pi_data,
901 &dst, &p_buffer[0], &p_buffer[i_buffer] );
911 E_(EvaluateRPN)( p_intf, p_args->vars, &p_args->stack, m.param1 );
912 if( E_(SSPopN)( &p_args->stack, p_args->vars ) )
920 endif = E_(MacroSearch)( src, end, MVLC_END, VLC_TRUE );
924 char *start = E_(MacroSearch)( src, endif, MVLC_ELSE, VLC_TRUE );
928 char *stop = E_(MacroSearch)( start, endif, MVLC_END, VLC_FALSE );
931 E_(Execute)( p_args, p_request, i_request,
932 pp_data, pi_data, &dst, start, stop );
936 else if( i_test == 1 )
939 if( ( stop = E_(MacroSearch)( src, endif, MVLC_ELSE, VLC_FALSE ) ) == NULL )
941 stop = E_(MacroSearch)( src, endif, MVLC_END, VLC_FALSE );
945 E_(Execute)( p_args, p_request, i_request,
946 pp_data, pi_data, &dst, src, stop );
955 char *endfor = E_(MacroSearch)( src, end, MVLC_END, VLC_TRUE );
957 char *stop = E_(MacroSearch)( src, end, MVLC_END, VLC_FALSE );
964 if( !strcmp( m.param2, "integer" ) )
966 char *arg = E_(SSPop)( &p_args->stack );
967 index = E_(mvar_IntegerSetNew)( m.param1, arg );
970 else if( !strcmp( m.param2, "directory" ) )
972 char *arg = E_(SSPop)( &p_args->stack );
973 index = E_(mvar_FileSetNew)( p_intf, m.param1, arg );
976 else if( !strcmp( m.param2, "object" ) )
978 char *arg = E_(SSPop)( &p_args->stack );
979 index = E_(mvar_ObjectSetNew)( p_intf, m.param1, arg );
982 else if( !strcmp( m.param2, "playlist" ) )
984 index = E_(mvar_PlaylistSetNew)( p_intf, m.param1,
985 p_intf->p_sys->p_playlist );
987 else if( !strcmp( m.param2, "information" ) )
989 index = E_(mvar_InfoSetNew)( p_intf, m.param1,
990 p_intf->p_sys->p_input );
992 else if( !strcmp( m.param2, "program" )
993 || !strcmp( m.param2, "title" )
994 || !strcmp( m.param2, "chapter" )
995 || !strcmp( m.param2, "audio-es" )
996 || !strcmp( m.param2, "video-es" )
997 || !strcmp( m.param2, "spu-es" ) )
999 index = E_(mvar_InputVarSetNew)( p_intf, m.param1,
1000 p_intf->p_sys->p_input,
1003 else if( !strcmp( m.param2, "vlm" ) )
1005 if( p_intf->p_sys->p_vlm == NULL )
1006 p_intf->p_sys->p_vlm = vlm_New( p_intf );
1007 index = E_(mvar_VlmSetNew)( m.param1, p_intf->p_sys->p_vlm );
1010 else if( !strcmp( m.param2, "hosts" ) )
1012 index = E_(mvar_HttpdInfoSetNew)( m.param1, p_intf->p_sys->p_httpd, HTTPD_GET_HOSTS );
1014 else if( !strcmp( m.param2, "urls" ) )
1016 index = E_(mvar_HttpdInfoSetNew)( m.param1, p_intf->p_sys->p_httpd, HTTPD_GET_URLS );
1018 else if( !strcmp( m.param2, "connections" ) )
1020 index = E_(mvar_HttpdInfoSetNew)(m.param1, p_intf->p_sys->p_httpd, HTTPD_GET_CONNECTIONS);
1023 else if( ( v = E_(mvar_GetVar)( p_args->vars, m.param2 ) ) )
1025 index = E_(mvar_Duplicate)( v );
1029 msg_Dbg( p_intf, "invalid index constructor (%s)", m.param2 );
1034 for( i_idx = 0; i_idx < index->i_field; i_idx++ )
1036 mvar_t *f = E_(mvar_Duplicate)( index->field[i_idx] );
1038 //msg_Dbg( p_intf, "foreach field[%d] name=%s value=%s", i_idx, f->name, f->value );
1041 f->name = strdup( m.param1 );
1044 E_(mvar_PushVar)( p_args->vars, f );
1045 E_(Execute)( p_args, p_request, i_request,
1046 pp_data, pi_data, &dst, start, stop );
1047 E_(mvar_RemoveVar)( p_args->vars, f );
1049 E_(mvar_Delete)( f );
1051 E_(mvar_Delete)( index );
1058 E_(MacroDo)( p_args, &m, p_request, i_request,
1059 pp_data, pi_data, &dst );
1063 E_(MacroClean)( &m );
1067 i_copy = ( (p == NULL || p > end ) ? end : p ) - src;
1070 int i_index = dst - *pp_data;
1073 *pp_data = realloc( *pp_data, *pi_data );
1074 dst = (*pp_data) + i_index;
1076 memcpy( dst, src, i_copy );