1 /*****************************************************************************
2 * http.c : HTTP/HTTPS Remote control interface
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 *****************************************************************************/
28 /*****************************************************************************
30 *****************************************************************************/
31 static int Open ( vlc_object_t * );
32 static void Close( vlc_object_t * );
34 #define HOST_TEXT N_( "Host address" )
35 #define HOST_LONGTEXT N_( \
36 "You can set the address and port the http interface will bind to." )
37 #define SRC_TEXT N_( "Source directory" )
38 #define SRC_LONGTEXT N_( "Source directory" )
39 #define CHARSET_TEXT N_( "Charset" )
40 #define CHARSET_LONGTEXT N_( \
41 "Charset declared in Content-Type header (default UTF-8)." )
42 #define HANDLERS_TEXT N_( "Handlers" )
43 #define HANDLERS_LONGTEXT N_( \
44 "List of extensions and executable paths (for instance: " \
45 "php=/usr/bin/php,pl=/usr/bin/perl)." )
46 #define CERT_TEXT N_( "Certificate file" )
47 #define CERT_LONGTEXT N_( "HTTP interface x509 PEM certificate file " \
49 #define KEY_TEXT N_( "Private key file" )
50 #define KEY_LONGTEXT N_( "HTTP interface x509 PEM private key file" )
51 #define CA_TEXT N_( "Root CA file" )
52 #define CA_LONGTEXT N_( "HTTP interface x509 PEM trusted root CA " \
54 #define CRL_TEXT N_( "CRL file" )
55 #define CRL_LONGTEXT N_( "HTTP interace Certificates Revocation List file" )
58 set_shortname( _("HTTP"));
59 set_description( _("HTTP remote control interface") );
60 set_category( CAT_INTERFACE );
61 set_subcategory( SUBCAT_INTERFACE_MAIN );
62 add_string ( "http-host", NULL, NULL, HOST_TEXT, HOST_LONGTEXT, VLC_TRUE );
63 add_string ( "http-src", NULL, NULL, SRC_TEXT, SRC_LONGTEXT, VLC_TRUE );
64 add_string ( "http-charset", "UTF-8", NULL, CHARSET_TEXT, CHARSET_LONGTEXT, VLC_TRUE );
65 #if defined( HAVE_FORK ) || defined( WIN32 )
66 add_string ( "http-handlers", NULL, NULL, HANDLERS_TEXT, HANDLERS_LONGTEXT, VLC_TRUE );
68 set_section( N_("HTTP SSL" ), 0 );
69 add_string ( "http-intf-cert", NULL, NULL, CERT_TEXT, CERT_LONGTEXT, VLC_TRUE );
70 add_string ( "http-intf-key", NULL, NULL, KEY_TEXT, KEY_LONGTEXT, VLC_TRUE );
71 add_string ( "http-intf-ca", NULL, NULL, CA_TEXT, CA_LONGTEXT, VLC_TRUE );
72 add_string ( "http-intf-crl", NULL, NULL, CRL_TEXT, CRL_LONGTEXT, VLC_TRUE );
73 set_capability( "interface", 0 );
74 set_callbacks( Open, Close );
78 /*****************************************************************************
80 *****************************************************************************/
81 static void Run ( intf_thread_t *p_intf );
83 /*****************************************************************************
85 *****************************************************************************/
86 #if !defined(__APPLE__) && !defined(SYS_BEOS) && !defined(WIN32)
87 static int DirectoryCheck( char *psz_dir )
91 #ifdef HAVE_SYS_STAT_H
92 struct stat stat_info;
94 if( utf8_stat( psz_dir, &stat_info ) == -1 || !S_ISDIR( stat_info.st_mode ) )
100 if( ( p_dir = utf8_opendir( psz_dir ) ) == NULL )
111 /*****************************************************************************
112 * Activate: initialize and create stuff
113 *****************************************************************************/
114 static int Open( vlc_object_t *p_this )
116 intf_thread_t *p_intf = (intf_thread_t*)p_this;
119 const char *psz_cert = NULL, *psz_key = NULL, *psz_ca = NULL,
125 psz_address = config_GetPsz( p_intf, "http-host" );
126 if( psz_address != NULL )
128 char *psz_parser = strchr( psz_address, ':' );
131 *psz_parser++ = '\0';
132 i_port = atoi( psz_parser );
136 psz_address = strdup("");
138 p_intf->p_sys = p_sys = malloc( sizeof( intf_sys_t ) );
141 return( VLC_ENOMEM );
143 p_sys->p_playlist = NULL;
144 p_sys->p_input = NULL;
146 p_sys->psz_address = psz_address;
147 p_sys->i_port = i_port;
149 /* determine Content-Type value for HTML pages */
150 psz_src = config_GetPsz( p_intf, "http-charset" );
151 if( psz_src == NULL || !*psz_src )
153 if( psz_src != NULL ) free( psz_src );
154 psz_src = strdup("UTF-8");
157 p_sys->psz_html_type = malloc( 20 + strlen( psz_src ) );
158 if( p_sys->psz_html_type == NULL )
160 free( p_sys->psz_address );
165 sprintf( p_sys->psz_html_type, "text/html; charset=%s", psz_src );
166 msg_Dbg( p_intf, "using charset=%s", psz_src );
168 if( strcmp( psz_src, "UTF-8" ) )
170 char psz_encoding[strlen( psz_src ) + sizeof( "//translit")];
171 sprintf( psz_encoding, "%s//translit", psz_src);
173 p_sys->iconv_from_utf8 = vlc_iconv_open( psz_encoding, "UTF-8" );
174 if( p_sys->iconv_from_utf8 == (vlc_iconv_t)-1 )
175 msg_Warn( p_intf, "unable to perform charset conversion to %s",
179 p_sys->iconv_to_utf8 = vlc_iconv_open( "UTF-8", psz_src );
180 if( p_sys->iconv_to_utf8 == (vlc_iconv_t)-1 )
182 "unable to perform charset conversion from %s",
188 p_sys->iconv_from_utf8 = p_sys->iconv_to_utf8 = (vlc_iconv_t)-1;
191 p_sys->psz_charset = psz_src;
194 /* determine file handler associations */
195 p_sys->i_handlers = 0;
196 p_sys->pp_handlers = NULL;
197 #if defined( HAVE_FORK ) || defined( WIN32 )
198 psz_src = config_GetPsz( p_intf, "http-handlers" );
199 if( psz_src != NULL && *psz_src )
204 http_association_t *p_handler;
206 char *psz_program, *psz_options;
207 p = strchr( p, '=' );
208 if( p == NULL ) break;
211 p = strchr( p, ',' );
215 p_handler = malloc( sizeof( http_association_t ) );
216 p_handler->psz_ext = strdup( psz_ext );
217 psz_options = E_(FirstWord)( psz_program, psz_program );
218 p_handler->i_argc = 0;
219 p_handler->ppsz_argv = NULL;
220 TAB_APPEND( p_handler->i_argc, p_handler->ppsz_argv,
221 strdup( psz_program ) );
222 while( psz_options != NULL && *psz_options )
224 char *psz_next = E_(FirstWord)( psz_options, psz_options );
225 TAB_APPEND( p_handler->i_argc, p_handler->ppsz_argv,
226 strdup( psz_options ) );
227 psz_options = psz_next;
229 /* NULL will be appended later on */
231 TAB_APPEND( p_sys->i_handlers, p_sys->pp_handlers, p_handler );
234 if( psz_src != NULL )
238 /* determine SSL configuration */
239 psz_cert = config_GetPsz( p_intf, "http-intf-cert" );
240 if ( psz_cert != NULL )
242 msg_Dbg( p_intf, "enabling TLS for HTTP interface (cert file: %s)",
244 psz_key = config_GetPsz( p_intf, "http-intf-key" );
245 psz_ca = config_GetPsz( p_intf, "http-intf-ca" );
246 psz_crl = config_GetPsz( p_intf, "http-intf-crl" );
257 /* Ugly hack to allow to run several HTTP servers on different ports. */
258 sprintf( psz_tmp, ":%d", i_port + 1 );
259 config_PutPsz( p_intf, "http-host", psz_tmp );
261 msg_Dbg( p_intf, "base %s:%d", psz_address, i_port );
263 p_sys->p_httpd_host = httpd_TLSHostNew( VLC_OBJECT(p_intf), psz_address,
264 i_port, psz_cert, psz_key, psz_ca,
266 if( p_sys->p_httpd_host == NULL )
268 msg_Err( p_intf, "cannot listen on %s:%d", psz_address, i_port );
269 free( p_sys->psz_html_type );
270 free( p_sys->psz_address );
276 p_sys->pp_files = NULL;
278 #if defined(__APPLE__) || defined(SYS_BEOS) || defined(WIN32)
279 if ( ( psz_src = config_GetPsz( p_intf, "http-src" )) == NULL )
281 char * psz_vlcpath = p_intf->p_libvlc->psz_vlcpath;
282 psz_src = malloc( strlen(psz_vlcpath) + strlen("/share/http" ) + 1 );
283 if( !psz_src ) return VLC_ENOMEM;
285 sprintf( psz_src, "%s/http", psz_vlcpath );
287 sprintf( psz_src, "%s/share/http", psz_vlcpath );
291 psz_src = config_GetPsz( p_intf, "http-src" );
293 if( !psz_src || *psz_src == '\0' )
295 if( !DirectoryCheck( "share/http" ) )
297 psz_src = strdup( "share/http" );
299 else if( !DirectoryCheck( DATA_PATH "/http" ) )
301 psz_src = strdup( DATA_PATH "/http" );
306 if( !psz_src || *psz_src == '\0' )
308 msg_Err( p_intf, "invalid src dir" );
312 /* remove trainling \ or / */
313 if( psz_src[strlen( psz_src ) - 1] == '\\' ||
314 psz_src[strlen( psz_src ) - 1] == '/' )
316 psz_src[strlen( psz_src ) - 1] = '\0';
319 E_(ParseDirectory)( p_intf, psz_src, psz_src );
322 if( p_sys->i_files <= 0 )
324 msg_Err( p_intf, "cannot find any files (%s)", psz_src );
327 p_intf->pf_run = Run;
333 if( psz_src ) free( psz_src );
334 if( p_sys->pp_files )
336 free( p_sys->pp_files );
338 httpd_HostDelete( p_sys->p_httpd_host );
339 free( p_sys->psz_address );
340 free( p_sys->psz_html_type );
341 if( p_sys->iconv_from_utf8 != (vlc_iconv_t)-1 )
342 vlc_iconv_close( p_sys->iconv_from_utf8 );
343 if( p_sys->iconv_to_utf8 != (vlc_iconv_t)-1 )
344 vlc_iconv_close( p_sys->iconv_to_utf8 );
349 /*****************************************************************************
350 * Close: destroy interface
351 *****************************************************************************/
352 static void Close ( vlc_object_t *p_this )
354 intf_thread_t *p_intf = (intf_thread_t *)p_this;
355 intf_sys_t *p_sys = p_intf->p_sys;
361 vlm_Delete( p_sys->p_vlm );
363 for( i = 0; i < p_sys->i_files; i++ )
365 if( p_sys->pp_files[i]->b_handler )
366 httpd_HandlerDelete( ((httpd_handler_sys_t *)p_sys->pp_files[i])->p_handler );
368 httpd_FileDelete( p_sys->pp_files[i]->p_file );
369 if( p_sys->pp_files[i]->p_redir )
370 httpd_RedirectDelete( p_sys->pp_files[i]->p_redir );
371 if( p_sys->pp_files[i]->p_redir2 )
372 httpd_RedirectDelete( p_sys->pp_files[i]->p_redir2 );
374 free( p_sys->pp_files[i]->file );
375 free( p_sys->pp_files[i]->name );
376 free( p_sys->pp_files[i] );
378 if( p_sys->pp_files )
380 free( p_sys->pp_files );
382 for( i = 0; i < p_sys->i_handlers; i++ )
384 http_association_t *p_handler = p_sys->pp_handlers[i];
386 free( p_handler->psz_ext );
387 for( j = 0; j < p_handler->i_argc; j++ )
388 free( p_handler->ppsz_argv[j] );
389 if( p_handler->i_argc )
390 free( p_handler->ppsz_argv );
393 if( p_sys->i_handlers )
394 free( p_sys->pp_handlers );
395 httpd_HostDelete( p_sys->p_httpd_host );
396 free( p_sys->psz_address );
397 free( p_sys->psz_html_type );
399 if( p_sys->iconv_from_utf8 != (vlc_iconv_t)-1 )
400 vlc_iconv_close( p_sys->iconv_from_utf8 );
401 if( p_sys->iconv_to_utf8 != (vlc_iconv_t)-1 )
402 vlc_iconv_close( p_sys->iconv_to_utf8 );
406 /*****************************************************************************
407 * Run: http interface thread
408 *****************************************************************************/
409 static void Run( intf_thread_t *p_intf )
411 intf_sys_t *p_sys = p_intf->p_sys;
413 while( !p_intf->b_die )
415 /* get the playlist */
416 if( p_sys->p_playlist == NULL )
418 p_sys->p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
421 /* Manage the input part */
422 if( p_sys->p_input == NULL )
424 if( p_sys->p_playlist )
426 p_sys->p_input = p_sys->p_playlist->p_input;
429 else if( p_sys->p_input->b_dead || p_sys->p_input->b_die )
431 p_sys->p_input = NULL;
436 msleep( INTF_IDLE_SLEEP );
441 vlc_object_release( p_sys->p_input );
442 p_sys->p_input = NULL;
445 if( p_sys->p_playlist )
447 vlc_object_release( p_sys->p_playlist );
448 p_sys->p_playlist = NULL;
452 /****************************************************************************
454 ****************************************************************************
455 * a file with b_html is parsed and all "macro" replaced
456 ****************************************************************************/
457 static void Callback404( httpd_file_sys_t *p_args, char **pp_data,
460 char *p = *pp_data = malloc( 10240 );
465 p += sprintf( p, "<html>\n" );
466 p += sprintf( p, "<head>\n" );
467 p += sprintf( p, "<title>Error loading %s</title>\n", p_args->file );
468 p += sprintf( p, "</head>\n" );
469 p += sprintf( p, "<body>\n" );
470 p += sprintf( p, "<h1><center>Error loading %s for %s</center></h1>\n", p_args->file, p_args->name );
471 p += sprintf( p, "<hr />\n" );
472 p += sprintf( p, "<a href=\"http://www.videolan.org/\">VideoLAN</a>\n" );
473 p += sprintf( p, "</body>\n" );
474 p += sprintf( p, "</html>\n" );
476 *pi_data = strlen( *pp_data );
479 static void ParseExecute( httpd_file_sys_t *p_args, char *p_buffer,
480 int i_buffer, char *p_request,
481 char **pp_data, int *pi_data )
483 int i_request = p_request != NULL ? strlen( p_request ) : 0;
486 char position[4]; /* percentage */
487 char time[12]; /* in seconds */
488 char length[12]; /* in seconds */
489 audio_volume_t i_volume;
493 #define p_sys p_args->p_intf->p_sys
496 var_Get( p_sys->p_input, "position", &val);
497 sprintf( position, "%d" , (int)((val.f_float) * 100.0));
498 var_Get( p_sys->p_input, "time", &val);
499 sprintf( time, "%d" , (int)(val.i_time / 1000000) );
500 var_Get( p_sys->p_input, "length", &val);
501 sprintf( length, "%d" , (int)(val.i_time / 1000000) );
503 var_Get( p_sys->p_input, "state", &val );
504 if( val.i_int == PLAYING_S )
506 sprintf( state, "playing" );
508 else if( val.i_int == PAUSE_S )
510 sprintf( state, "paused" );
514 sprintf( state, "stop" );
519 sprintf( position, "%d", 0 );
520 sprintf( time, "%d", 0 );
521 sprintf( length, "%d", 0 );
522 sprintf( state, "stop" );
526 aout_VolumeGet( p_args->p_intf, &i_volume );
527 sprintf( volume, "%d", (int)i_volume );
529 p_args->vars = E_(mvar_New)( "variables", "" );
530 E_(mvar_AppendNewVar)( p_args->vars, "url_param",
531 i_request > 0 ? "1" : "0" );
532 E_(mvar_AppendNewVar)( p_args->vars, "url_value", p_request );
533 E_(mvar_AppendNewVar)( p_args->vars, "version", VLC_Version() );
534 E_(mvar_AppendNewVar)( p_args->vars, "copyright", COPYRIGHT_MESSAGE );
535 E_(mvar_AppendNewVar)( p_args->vars, "vlc_compile_by", VLC_CompileBy() );
536 E_(mvar_AppendNewVar)( p_args->vars, "vlc_compile_host",
538 E_(mvar_AppendNewVar)( p_args->vars, "vlc_compile_domain",
539 VLC_CompileDomain() );
540 E_(mvar_AppendNewVar)( p_args->vars, "vlc_compiler", VLC_Compiler() );
541 #ifndef HAVE_SHARED_LIBVLC
542 E_(mvar_AppendNewVar)( p_args->vars, "vlc_changeset", VLC_Changeset() );
544 E_(mvar_AppendNewVar)( p_args->vars, "stream_position", position );
545 E_(mvar_AppendNewVar)( p_args->vars, "stream_time", time );
546 E_(mvar_AppendNewVar)( p_args->vars, "stream_length", length );
547 E_(mvar_AppendNewVar)( p_args->vars, "volume", volume );
548 E_(mvar_AppendNewVar)( p_args->vars, "stream_state", state );
549 E_(mvar_AppendNewVar)( p_args->vars, "charset", ((intf_sys_t *)p_args->p_intf->p_sys)->psz_charset );
551 E_(SSInit)( &p_args->stack );
553 /* allocate output */
554 *pi_data = i_buffer + 1000;
555 dst = *pp_data = malloc( *pi_data );
557 /* we parse executing all <vlc /> macros */
558 E_(Execute)( p_args, p_request, i_request, pp_data, pi_data, &dst,
559 &p_buffer[0], &p_buffer[i_buffer] );
562 *pi_data = dst - *pp_data;
564 E_(SSClean)( &p_args->stack );
565 E_(mvar_Delete)( p_args->vars );
568 int E_(HttpCallback)( httpd_file_sys_t *p_args,
569 httpd_file_t *p_file,
571 uint8_t **_pp_data, int *pi_data )
573 char *p_request = (char *)_p_request;
574 char **pp_data = (char **)_pp_data;
577 /* FIXME: do we need character encoding translation here? */
578 if( ( f = fopen( p_args->file, "r" ) ) == NULL )
580 Callback404( p_args, pp_data, pi_data );
584 if( !p_args->b_html )
586 E_(FileLoad)( f, pp_data, pi_data );
593 /* first we load in a temporary buffer */
594 E_(FileLoad)( f, &p_buffer, &i_buffer );
596 ParseExecute( p_args, p_buffer, i_buffer, p_request, pp_data, pi_data );
606 /****************************************************************************
608 ****************************************************************************
609 * call the external handler and parse vlc macros if Content-Type is HTML
610 ****************************************************************************/
611 int E_(HandlerCallback)( httpd_handler_sys_t *p_args,
612 httpd_handler_t *p_handler, char *_p_url,
613 uint8_t *_p_request, int i_type,
614 uint8_t *_p_in, int i_in,
615 char *psz_remote_addr, char *psz_remote_host,
616 uint8_t **_pp_data, int *pi_data )
618 char *p_url = (char *)_p_url;
619 char *p_request = (char *)_p_request;
620 char **pp_data = (char **)_pp_data;
621 char *p_in = (char *)p_in;
622 int i_request = p_request != NULL ? strlen( p_request ) : 0;
625 char **ppsz_env = NULL;
630 char *psz_cwd, *psz_file = NULL;
639 /* Create environment for the CGI */
640 TAB_APPEND( i_env, ppsz_env, strdup("GATEWAY_INTERFACE=CGI/1.1") );
641 TAB_APPEND( i_env, ppsz_env, strdup("SERVER_PROTOCOL=HTTP/1.1") );
642 TAB_APPEND( i_env, ppsz_env, strdup("SERVER_SOFTWARE=" COPYRIGHT_MESSAGE) );
647 TAB_APPEND( i_env, ppsz_env, strdup("REQUEST_METHOD=GET") );
650 TAB_APPEND( i_env, ppsz_env, strdup("REQUEST_METHOD=POST") );
653 TAB_APPEND( i_env, ppsz_env, strdup("REQUEST_METHOD=HEAD") );
661 psz_tmp = malloc( sizeof("QUERY_STRING=") + i_request );
662 sprintf( psz_tmp, "QUERY_STRING=%s", p_request );
663 TAB_APPEND( i_env, ppsz_env, psz_tmp );
665 psz_tmp = malloc( sizeof("REQUEST_URI=?") + strlen(p_url)
667 sprintf( psz_tmp, "REQUEST_URI=%s?%s", p_url, p_request );
668 TAB_APPEND( i_env, ppsz_env, psz_tmp );
672 psz_tmp = malloc( sizeof("REQUEST_URI=") + strlen(p_url) );
673 sprintf( psz_tmp, "REQUEST_URI=%s", p_url );
674 TAB_APPEND( i_env, ppsz_env, psz_tmp );
677 psz_tmp = malloc( sizeof("SCRIPT_NAME=") + strlen(p_url) );
678 sprintf( psz_tmp, "SCRIPT_NAME=%s", p_url );
679 TAB_APPEND( i_env, ppsz_env, psz_tmp );
681 #define p_sys p_args->file.p_intf->p_sys
682 psz_tmp = malloc( sizeof("SERVER_NAME=") + strlen(p_sys->psz_address) );
683 sprintf( psz_tmp, "SERVER_NAME=%s", p_sys->psz_address );
684 TAB_APPEND( i_env, ppsz_env, psz_tmp );
686 psz_tmp = malloc( sizeof("SERVER_PORT=") + 5 );
687 sprintf( psz_tmp, "SERVER_PORT=%u", p_sys->i_port );
688 TAB_APPEND( i_env, ppsz_env, psz_tmp );
691 p = getenv( "PATH" );
694 psz_tmp = malloc( sizeof("PATH=") + strlen(p) );
695 sprintf( psz_tmp, "PATH=%s", p );
696 TAB_APPEND( i_env, ppsz_env, psz_tmp );
700 p = getenv( "windir" );
703 psz_tmp = malloc( sizeof("SYSTEMROOT=") + strlen(p) );
704 sprintf( psz_tmp, "SYSTEMROOT=%s", p );
705 TAB_APPEND( i_env, ppsz_env, psz_tmp );
709 if( psz_remote_addr != NULL && *psz_remote_addr )
711 psz_tmp = malloc( sizeof("REMOTE_ADDR=") + strlen(psz_remote_addr) );
712 sprintf( psz_tmp, "REMOTE_ADDR=%s", psz_remote_addr );
713 TAB_APPEND( i_env, ppsz_env, psz_tmp );
716 if( psz_remote_host != NULL && *psz_remote_host )
718 psz_tmp = malloc( sizeof("REMOTE_HOST=") + strlen(psz_remote_host) );
719 sprintf( psz_tmp, "REMOTE_HOST=%s", psz_remote_host );
720 TAB_APPEND( i_env, ppsz_env, psz_tmp );
728 if( !strncasecmp( p, "Content-Type: ", strlen("Content-Type: ") ) )
730 char *end = strchr( p, '\r' );
734 psz_tmp = malloc( sizeof("CONTENT_TYPE=") + strlen(p) );
735 sprintf( psz_tmp, "CONTENT_TYPE=%s", p );
736 TAB_APPEND( i_env, ppsz_env, psz_tmp );
739 if( !strncasecmp( p, "Content-Length: ",
740 strlen("Content-Length: ") ) )
742 char *end = strchr( p, '\r' );
746 psz_tmp = malloc( sizeof("CONTENT_LENGTH=") + strlen(p) );
747 sprintf( psz_tmp, "CONTENT_LENGTH=%s", p );
748 TAB_APPEND( i_env, ppsz_env, psz_tmp );
752 p = strchr( p, '\n' );
753 if( p == NULL || p[1] == '\r' )
762 psz_file = strrchr( p_args->file.file, sep );
763 if( psz_file != NULL )
766 psz_tmp = malloc( sizeof("SCRIPT_FILENAME=") + strlen(psz_file) );
767 sprintf( psz_tmp, "SCRIPT_FILENAME=%s", psz_file );
768 TAB_APPEND( i_env, ppsz_env, psz_tmp );
770 TAB_APPEND( p_args->p_association->i_argc,
771 p_args->p_association->ppsz_argv, psz_file );
774 TAB_APPEND( i_env, ppsz_env, NULL );
776 TAB_APPEND( p_args->p_association->i_argc, p_args->p_association->ppsz_argv,
779 psz_tmp = strdup( p_args->file.file );
780 p = strrchr( psz_tmp, sep );
792 i_ret = vlc_execve( p_args->file.p_intf, p_args->p_association->i_argc,
793 p_args->p_association->ppsz_argv, ppsz_env, psz_cwd,
794 (char *)p_in, i_in, &p_buffer, &i_buffer );
795 TAB_REMOVE( p_args->p_association->i_argc, p_args->p_association->ppsz_argv,
797 TAB_REMOVE( p_args->p_association->i_argc, p_args->p_association->ppsz_argv,
799 if( psz_cwd != NULL )
802 TAB_REMOVE( i_env, ppsz_env, ppsz_env[0] );
806 Callback404( (httpd_file_sys_t *)p_args, pp_data, pi_data );
810 while( strncasecmp( p, "Content-Type: text/html",
811 strlen("Content-Type: text/html") ) )
813 p = strchr( p, '\n' );
814 if( p == NULL || p[1] == '\r' )
829 ParseExecute( (httpd_file_sys_t *)p_args, p_buffer, i_buffer,
830 p_request, pp_data, pi_data );