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 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 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,
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 ExtractURIValue( p_request, "seek_value", value, 30 );
249 HandleSeek( p_intf, value );
255 audio_volume_t i_volume;
258 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 ExtractURIValue( p_request, "mrl", tmp, 1024 );
319 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 = 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 int i_ret = playlist_AddInput( p_sys->p_playlist,
350 PLAYLIST_APPEND, PLAYLIST_END, true,
352 vlc_gc_decref( p_input );
353 if( i_ret == VLC_SUCCESS )
354 msg_Dbg( p_intf, "requested mrl add: %s", mrl );
356 msg_Warn( p_intf, "adding mrl %s failed", mrl );
364 int i_item, *p_items = NULL, i_nb_items = 0;
366 const char *p_parser = p_request;
368 /* Get the list of items to delete */
370 ExtractURIValue( p_parser, "item", item, 512 )) )
372 if( !*item ) continue;
374 i_item = atoi( item );
375 p_items = realloc( p_items, (i_nb_items + 1) *
377 p_items[i_nb_items] = i_item;
384 for( i = 0; i < i_nb_items; i++ )
386 playlist_DeleteFromInput( p_sys->p_playlist,
388 msg_Dbg( p_intf, "requested playlist delete: %d",
399 int i_item, *p_items = NULL, i_nb_items = 0;
401 const char *p_parser = p_request;
404 /* Get the list of items to keep */
406 ExtractURIValue( p_parser, "item", item, 512 )) )
408 if( !*item ) continue;
410 i_item = atoi( item );
411 p_items = realloc( p_items, (i_nb_items + 1) *
413 p_items[i_nb_items] = i_item;
417 for( i = p_sys->p_playlist->items.i_size - 1 ; i >= 0; i-- )
419 /* Check if the item is in the keep list */
420 for( j = 0 ; j < i_nb_items ; j++ )
423 ARRAY_VAL(p_sys->p_playlist->items,i)
427 if( j == i_nb_items )
429 playlist_DeleteFromInput( p_sys->p_playlist,
430 p_sys->p_playlist->items.p_elems[i]->i_id,
432 msg_Dbg( p_intf, "requested playlist delete: %d",
442 playlist_Clear( p_sys->p_playlist, false );
443 msg_Dbg( p_intf, "requested playlist empty" );
454 ExtractURIValue( p_request, "type", type, 12 );
455 ExtractURIValue( p_request, "order", order, 2 );
456 ExtractURIValue( p_request, "item", item, 512 );
457 i_item = atoi( item );
459 if( order[0] == '0' ) i_order = ORDER_NORMAL;
460 else i_order = ORDER_REVERSE;
462 if( !strcmp( type , "title" ) )
464 playlist_RecursiveNodeSort( p_sys->p_playlist,
465 /* Ugly hack,but not worse than before ... */
466 p_sys->p_playlist->p_root_onelevel,
467 SORT_TITLE_NODES_FIRST,
468 ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
469 msg_Dbg( p_intf, "requested playlist sort by title (%d)" , i_order );
471 else if( !strcmp( type , "author" ) )
473 playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
474 p_sys->p_playlist->p_root_onelevel,
476 ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
477 msg_Dbg( p_intf, "requested playlist sort by author (%d)" , i_order );
479 else if( !strcmp( type , "shuffle" ) )
481 playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
482 p_sys->p_playlist->p_root_onelevel,
484 ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
485 msg_Dbg( p_intf, "requested playlist shuffle");
496 ExtractURIValue( p_request, "psz_pos", psz_pos, 6 );
497 ExtractURIValue( p_request, "psz_newpos", psz_newpos, 6 );
498 i_pos = atoi( psz_pos );
499 i_newpos = atoi( psz_newpos );
500 /* FIXME FIXME TODO TODO XXX XXX
501 ( duplicate from rpn.c )
502 if ( i_pos < i_newpos )
504 playlist_Move( p_sys->p_playlist, i_pos, i_newpos + 1 );
508 playlist_Move( p_sys->p_playlist, i_pos, i_newpos );
510 msg_Dbg( p_intf, "requested move playlist item %d to %d", i_pos, i_newpos);
511 FIXME FIXME TODO TODO XXX XXX */
519 ExtractURIValue( p_request, "id", id, 512 );
520 msg_Dbg( p_intf, "requested close id=%s", id );
522 if( p_sys->p_httpd->pf_control( p_sys->p_httpd, HTTPD_SET_CLOSE, id, NULL ) )
524 msg_Warn( p_intf, "close failed for id=%s", id );
531 msg_Dbg( p_intf, "requested shutdown" );
532 vlc_object_kill( p_intf->p_libvlc );
540 static const char vlm_properties[][9] =
543 "enabled", "disabled", "loop", "unloop",
545 "input", "output", "option", "date", "period",
546 "repeat", "append", "",
548 vlm_message_t *vlm_answer;
550 char *psz = malloc( strlen( p_request ) + 1000 );
555 if( p_intf->p_sys->p_vlm == NULL )
556 p_intf->p_sys->p_vlm = vlm_New( p_intf );
558 if( p_intf->p_sys->p_vlm == NULL )
564 ExtractURIValue( p_request, "name", name, 512 );
565 if( StrToMacroType( control ) == MVLC_VLM_NEW )
568 ExtractURIValue( p_request, "type", type, 20 );
569 p += sprintf( psz, "new %s %s", name, type );
573 p += sprintf( psz, "setup %s", name );
575 /* Parse the request */
576 for( i = 0; vlm_properties[i][0]; i++ )
579 ExtractURIValue( p_request,
580 vlm_properties[i], val, 512 );
582 if( strlen( val ) > 0 && i >= 4 )
584 p += sprintf( p, " %s %s", vlm_properties[i], val );
586 else if( TestURIParam( p_request, vlm_properties[i] ) && i < 4 )
588 p += sprintf( p, " %s", vlm_properties[i] );
591 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
592 if( vlm_answer->psz_value == NULL ) /* there is no error */
594 vlm_error = strdup( "" );
598 vlm_error = malloc( strlen(vlm_answer->psz_name) +
599 strlen(vlm_answer->psz_value) +
600 strlen( " : ") + 1 );
601 sprintf( vlm_error , "%s : %s" , vlm_answer->psz_name,
602 vlm_answer->psz_value );
605 mvar_AppendNewVar( p_args->vars, "vlm_error", vlm_error );
607 vlm_MessageDelete( vlm_answer );
615 vlm_message_t *vlm_answer;
618 if( p_intf->p_sys->p_vlm == NULL )
619 p_intf->p_sys->p_vlm = vlm_New( p_intf );
621 if( p_intf->p_sys->p_vlm == NULL ) break;
623 ExtractURIValue( p_request, "name", name, 512 );
624 sprintf( psz, "del %s", name );
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 );
637 vlm_message_t *vlm_answer;
640 if( p_intf->p_sys->p_vlm == NULL )
641 p_intf->p_sys->p_vlm = vlm_New( p_intf );
643 if( p_intf->p_sys->p_vlm == NULL ) break;
645 ExtractURIValue( p_request, "name", name, 512 );
646 if( StrToMacroType( control ) == MVLC_VLM_PLAY )
647 sprintf( psz, "control %s play", name );
648 else if( StrToMacroType( control ) == MVLC_VLM_PAUSE )
649 sprintf( psz, "control %s pause", name );
650 else if( StrToMacroType( control ) == MVLC_VLM_STOP )
651 sprintf( psz, "control %s stop", name );
652 else if( StrToMacroType( control ) == MVLC_VLM_SEEK )
655 ExtractURIValue( p_request, "percent", percent, 512 );
656 sprintf( psz, "control %s seek %s", name, percent );
659 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
660 /* FIXME do a vlm_answer -> var stack conversion */
661 vlm_MessageDelete( vlm_answer );
667 vlm_message_t *vlm_answer;
671 if( p_intf->p_sys->p_vlm == NULL )
672 p_intf->p_sys->p_vlm = vlm_New( p_intf );
674 if( p_intf->p_sys->p_vlm == NULL ) break;
676 ExtractURIValue( p_request, "file", file, 512 );
679 if( StrToMacroType( control ) == MVLC_VLM_LOAD )
680 sprintf( psz, "load %s", file );
682 sprintf( psz, "save %s", file );
684 vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer );
685 /* FIXME do a vlm_answer -> var stack conversion */
686 vlm_MessageDelete( vlm_answer );
689 #endif /* ENABLE_VLM */
693 PRINTS( "<!-- control param(%s) unsupported -->", control );
705 if( i_request <= 0 ||
706 *m->param1 == '\0' ||
707 strstr( p_request, m->param1 ) == NULL )
711 ExtractURIValue( p_request, m->param1, value, 512 );
714 switch( StrToMacroType( m->param2 ) )
718 config_PutInt( p_intf, m->param1, i );
722 config_PutFloat( p_intf, m->param1, f );
725 config_PutPsz( p_intf, m->param1, value );
728 PRINTS( "<!-- invalid type(%s) in set -->", m->param2 )
740 if( *m->param1 == '\0' )
745 switch( StrToMacroType( m->param2 ) )
748 i = config_GetInt( p_intf, m->param1 );
749 sprintf( value, "%d", i );
752 f = config_GetFloat( p_intf, m->param1 );
753 div = lldiv( f * 1000000 , 1000000 );
754 sprintf( value, "%lld.%06u", div.quot,
755 (unsigned int)div.rem );
758 psz = config_GetPsz( p_intf, m->param1 );
761 strlcpy( value, psz,sizeof( value ) );
766 msg_Dbg( p_intf, "%d: value = \"%s\"", __LINE__, value );
769 snprintf( value, sizeof( value ),
770 "invalid type(%s) in set", m->param2 );
773 PRINTS( "%s", value );
783 EvaluateRPN( p_intf, p_args->vars, &p_args->stack, m->param1 );
784 s = SSPop( &p_args->stack );
785 v = mvar_GetValue( p_args->vars, s );
789 v = s = SSPop( &p_args->stack );
797 EvaluateRPN( p_intf, p_args->vars, &p_args->stack, m->param1 );
800 /* Useful to learn stack management */
804 msg_Dbg( p_intf, "stack" );
805 for (i=0;i<(&p_args->stack)->i_stack;i++)
806 msg_Dbg( p_intf, "%d -> %s", i, (&p_args->stack)->stack[i] );
812 PRINTS( "<!-- invalid macro id=`%s' -->", m->id );
813 msg_Dbg( p_intf, "invalid macro id=`%s'", m->id );
822 char *MacroSearch( char *src, char *end, int i_mvlc, bool b_after )
829 if( src + 4 < end && !strncmp( (char *)src, "<vlc", 4 ) )
834 i_skip = MacroParse( &m, src );
836 i_id = StrToMacroType( m.id );
853 if( ( i_mvlc == MVLC_END && i_level == -1 ) ||
854 ( i_mvlc != MVLC_END && i_level == 0 && i_mvlc == i_id ) )
856 return src + ( b_after ? i_skip : 0 );
858 else if( i_level < 0 )
874 void Execute( httpd_file_sys_t *p_args,
875 char *p_request, int i_request,
876 char **pp_data, int *pi_data,
878 char *_src, char *_end )
880 intf_thread_t *p_intf = p_args->p_intf;
882 char *src, *dup, *end;
885 src = dup = malloc( _end - _src + 1 );
886 end = src +( _end - _src );
888 memcpy( src, _src, _end - _src );
891 /* we parse searching <vlc */
897 p = (char *)strstr( (char *)src, "<vlc" );
898 if( p < end && p == src )
902 src += MacroParse( &m, src );
904 //msg_Dbg( p_intf, "macro_id=%s", m.id );
906 switch( StrToMacroType( m.id ) )
913 char psz_file[MAX_DIR_SIZE];
923 if( m.param1[0] != sep )
925 strcpy( psz_file, p_args->file );
926 p = strrchr( psz_file, sep );
928 strcpy( p + 1, m.param1 );
930 strcpy( psz_file, m.param1 );
934 strcpy( psz_file, m.param1 );
937 /* We hereby assume that psz_file is in the
938 * local character encoding */
939 if( ( f = fopen( psz_file, "r" ) ) == NULL )
941 msg_Warn( p_args->p_intf,
942 "unable to include file %s (%m)",
947 /* first we load in a temporary buffer */
948 FileLoad( f, &p_buffer, &i_buffer );
950 /* we parse executing all <vlc /> macros */
951 Execute( p_args, p_request, i_request, pp_data, pi_data,
952 &dst, &p_buffer[0], &p_buffer[i_buffer] );
962 EvaluateRPN( p_intf, p_args->vars, &p_args->stack, m.param1 );
963 if( SSPopN( &p_args->stack, p_args->vars ) )
971 endif = MacroSearch( src, end, MVLC_END, true );
975 char *start = MacroSearch( src, endif, MVLC_ELSE, true );
979 char *stop = MacroSearch( start, endif, MVLC_END, false );
982 Execute( p_args, p_request, i_request,
983 pp_data, pi_data, &dst, start, stop );
987 else if( i_test == 1 )
990 if( ( stop = MacroSearch( src, endif, MVLC_ELSE, false ) ) == NULL )
992 stop = MacroSearch( src, endif, MVLC_END, false );
996 Execute( p_args, p_request, i_request,
997 pp_data, pi_data, &dst, src, stop );
1006 char *endfor = MacroSearch( src, end, MVLC_END, true );
1008 char *stop = MacroSearch( src, end, MVLC_END, false );
1015 if( !strcmp( m.param2, "integer" ) )
1017 char *arg = SSPop( &p_args->stack );
1018 index = mvar_IntegerSetNew( m.param1, arg );
1021 else if( !strcmp( m.param2, "directory" ) )
1023 char *arg = SSPop( &p_args->stack );
1024 index = mvar_FileSetNew( p_intf, m.param1, arg );
1027 else if( !strcmp( m.param2, "object" ) )
1029 char *arg = SSPop( &p_args->stack );
1030 index = mvar_ObjectSetNew( p_intf, m.param1, arg );
1033 else if( !strcmp( m.param2, "playlist" ) )
1035 index = mvar_PlaylistSetNew( p_intf, m.param1,
1036 p_intf->p_sys->p_playlist );
1038 else if( !strcmp( m.param2, "information" ) )
1040 index = mvar_InfoSetNew( m.param1,
1041 p_intf->p_sys->p_input );
1043 else if( !strcmp( m.param2, "program" )
1044 || !strcmp( m.param2, "title" )
1045 || !strcmp( m.param2, "chapter" )
1046 || !strcmp( m.param2, "audio-es" )
1047 || !strcmp( m.param2, "video-es" )
1048 || !strcmp( m.param2, "spu-es" ) )
1050 index = mvar_InputVarSetNew( p_intf, m.param1,
1051 p_intf->p_sys->p_input,
1055 else if( !strcmp( m.param2, "vlm" ) )
1057 if( p_intf->p_sys->p_vlm == NULL )
1058 p_intf->p_sys->p_vlm = vlm_New( p_intf );
1059 index = mvar_VlmSetNew( m.param1, p_intf->p_sys->p_vlm );
1063 else if( !strcmp( m.param2, "hosts" ) )
1065 index = mvar_HttpdInfoSetNew( m.param1, p_intf->p_sys->p_httpd, HTTPD_GET_HOSTS );
1067 else if( !strcmp( m.param2, "urls" ) )
1069 index = mvar_HttpdInfoSetNew( m.param1, p_intf->p_sys->p_httpd, HTTPD_GET_URLS );
1071 else if( !strcmp( m.param2, "connections" ) )
1073 index = mvar_HttpdInfoSetNew(m.param1, p_intf->p_sys->p_httpd, HTTPD_GET_CONNECTIONS);
1076 else if( ( v = mvar_GetVar( p_args->vars, m.param2 ) ) )
1078 index = mvar_Duplicate( v );
1082 msg_Dbg( p_intf, "invalid index constructor (%s)", m.param2 );
1087 for( i_idx = 0; i_idx < index->i_field; i_idx++ )
1089 mvar_t *f = mvar_Duplicate( index->field[i_idx] );
1091 //msg_Dbg( p_intf, "foreach field[%d] name=%s value=%s", i_idx, f->name, f->value );
1094 f->name = strdup( m.param1 );
1097 mvar_PushVar( p_args->vars, f );
1098 Execute( p_args, p_request, i_request,
1099 pp_data, pi_data, &dst, start, stop );
1100 mvar_RemoveVar( p_args->vars, f );
1104 mvar_Delete( index );
1111 MacroDo( p_args, &m, p_request, i_request,
1112 pp_data, pi_data, &dst );
1120 i_copy = ( (p == NULL || p > end ) ? end : p ) - src;
1123 int i_index = dst - *pp_data;
1126 *pp_data = realloc( *pp_data, *pi_data );
1127 dst = (*pp_data) + i_index;
1129 memcpy( dst, src, i_copy );