*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "http.h"
add_string ( "http-host", NULL, NULL, HOST_TEXT, HOST_LONGTEXT, VLC_TRUE );
add_string ( "http-src", NULL, NULL, SRC_TEXT, SRC_LONGTEXT, VLC_TRUE );
add_string ( "http-charset", "UTF-8", NULL, CHARSET_TEXT, CHARSET_LONGTEXT, VLC_TRUE );
-#if defined( HAVE_FORK )
+#if defined( HAVE_FORK ) || defined( WIN32 )
add_string ( "http-handlers", NULL, NULL, HANDLERS_TEXT, HANDLERS_LONGTEXT, VLC_TRUE );
#endif
set_section( N_("HTTP SSL" ), 0 );
/*****************************************************************************
* Local functions
*****************************************************************************/
-#if !defined(SYS_DARWIN) && !defined(SYS_BEOS) && !defined(WIN32)
+#if !defined(__APPLE__) && !defined(SYS_BEOS) && !defined(WIN32)
static int DirectoryCheck( char *psz_dir )
{
DIR *p_dir;
*psz_crl = NULL;
int i_port = 0;
char *psz_src;
+ char psz_tmp[10];
psz_address = config_GetPsz( p_intf, "http-host" );
if( psz_address != NULL )
/* determine file handler associations */
p_sys->i_handlers = 0;
p_sys->pp_handlers = NULL;
-#if defined( HAVE_FORK )
+#if defined( HAVE_FORK ) || defined( WIN32 )
psz_src = config_GetPsz( p_intf, "http-handlers" );
if( psz_src != NULL && *psz_src )
{
i_port= 8080;
}
+ /* Ugly hack to allow to run several HTTP servers on different ports. */
+ sprintf( psz_tmp, ":%d", i_port + 1 );
+ config_PutPsz( p_intf, "http-host", psz_tmp );
+
msg_Dbg( p_intf, "base %s:%d", psz_address, i_port );
p_sys->p_httpd_host = httpd_TLSHostNew( VLC_OBJECT(p_intf), psz_address,
p_sys->i_files = 0;
p_sys->pp_files = NULL;
-#if defined(SYS_DARWIN) || defined(SYS_BEOS) || defined(WIN32)
+#if defined(__APPLE__) || defined(SYS_BEOS) || defined(WIN32)
if ( ( psz_src = config_GetPsz( p_intf, "http-src" )) == NULL )
{
char * psz_vlcpath = p_intf->p_libvlc->psz_vlcpath;
E_(mvar_AppendNewVar)( p_args->vars, "copyright", COPYRIGHT_MESSAGE );
E_(mvar_AppendNewVar)( p_args->vars, "vlc_compile_by", VLC_CompileBy() );
E_(mvar_AppendNewVar)( p_args->vars, "vlc_compile_host",
- VLC_CompileHost() );
+ VLC_CompileHost() );
E_(mvar_AppendNewVar)( p_args->vars, "vlc_compile_domain",
- VLC_CompileDomain() );
+ VLC_CompileDomain() );
E_(mvar_AppendNewVar)( p_args->vars, "vlc_compiler", VLC_Compiler() );
E_(mvar_AppendNewVar)( p_args->vars, "vlc_changeset", VLC_Changeset() );
E_(mvar_AppendNewVar)( p_args->vars, "stream_position", position );
char sep;
int i_buffer;
char *p_buffer;
- char *psz_cwd;
+ char *psz_cwd, *psz_file = NULL;
int i_ret;
#ifdef WIN32
sprintf( psz_tmp, "SCRIPT_NAME=%s", p_url );
TAB_APPEND( i_env, ppsz_env, psz_tmp );
- psz_tmp = malloc( sizeof("SCRIPT_FILENAME=") + strlen(p_args->file.file) );
- sprintf( psz_tmp, "SCRIPT_FILENAME=%s", p_args->file.file );
- TAB_APPEND( i_env, ppsz_env, psz_tmp );
-
#define p_sys p_args->file.p_intf->p_sys
psz_tmp = malloc( sizeof("SERVER_NAME=") + strlen(p_sys->psz_address) );
sprintf( psz_tmp, "SERVER_NAME=%s", p_sys->psz_address );
TAB_APPEND( i_env, ppsz_env, psz_tmp );
#undef p_sys
+ p = getenv( "PATH" );
+ if( p != NULL )
+ {
+ psz_tmp = malloc( sizeof("PATH=") + strlen(p) );
+ sprintf( psz_tmp, "PATH=%s", p );
+ TAB_APPEND( i_env, ppsz_env, psz_tmp );
+ }
+
+#ifdef WIN32
+ p = getenv( "windir" );
+ if( p != NULL )
+ {
+ psz_tmp = malloc( sizeof("SYSTEMROOT=") + strlen(p) );
+ sprintf( psz_tmp, "SYSTEMROOT=%s", p );
+ TAB_APPEND( i_env, ppsz_env, psz_tmp );
+ }
+#endif
+
if( psz_remote_addr != NULL && *psz_remote_addr )
{
psz_tmp = malloc( sizeof("REMOTE_ADDR=") + strlen(psz_remote_addr) );
}
}
+ psz_file = strrchr( p_args->file.file, sep );
+ if( psz_file != NULL )
+ {
+ psz_file++;
+ psz_tmp = malloc( sizeof("SCRIPT_FILENAME=") + strlen(psz_file) );
+ sprintf( psz_tmp, "SCRIPT_FILENAME=%s", psz_file );
+ TAB_APPEND( i_env, ppsz_env, psz_tmp );
+
+ TAB_APPEND( p_args->p_association->i_argc,
+ p_args->p_association->ppsz_argv, psz_file );
+ }
+
TAB_APPEND( i_env, ppsz_env, NULL );
- TAB_APPEND( p_args->p_association->i_argc, p_args->p_association->ppsz_argv,
- p_args->file.file );
TAB_APPEND( p_args->p_association->i_argc, p_args->p_association->ppsz_argv,
NULL );
TAB_REMOVE( p_args->p_association->i_argc, p_args->p_association->ppsz_argv,
NULL );
TAB_REMOVE( p_args->p_association->i_argc, p_args->p_association->ppsz_argv,
- p_args->file.file );
+ psz_file );
if( psz_cwd != NULL )
free( psz_cwd );
while( i_env )