]> git.sesse.net Git - vlc/blobdiff - modules/control/http/http.c
* Got rid of SYS_DARWIN everywhere.
[vlc] / modules / control / http / http.c
index af6f0aa17ffd95b29bffa4e2a09986f8e7b69474..ee53459b3c2a18f92304add38eec3b2f7c3ebac9 100644 (file)
@@ -20,7 +20,7 @@
  *
  * 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"
@@ -62,7 +62,7 @@ vlc_module_begin();
         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 );
@@ -83,7 +83,7 @@ static void Run          ( intf_thread_t *p_intf );
 /*****************************************************************************
  * 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;
@@ -120,6 +120,7 @@ static int Open( vlc_object_t *p_this )
                   *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 )
@@ -189,7 +190,7 @@ static int Open( vlc_object_t *p_this )
     /* 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 )
     {
@@ -249,6 +250,10 @@ static int Open( vlc_object_t *p_this )
             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,
@@ -266,7 +271,7 @@ static int Open( vlc_object_t *p_this )
     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;
@@ -529,9 +534,9 @@ static void ParseExecute( httpd_file_sys_t *p_args, char *p_buffer,
     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 );
@@ -618,7 +623,7 @@ int  E_(HandlerCallback)( httpd_handler_sys_t *p_args,
     char sep;
     int  i_buffer;
     char *p_buffer;
-    char *psz_cwd;
+    char *psz_cwd, *psz_file = NULL;
     int i_ret;
 
 #ifdef WIN32
@@ -669,10 +674,6 @@ int  E_(HandlerCallback)( httpd_handler_sys_t *p_args,
     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 );
@@ -683,6 +684,24 @@ int  E_(HandlerCallback)( httpd_handler_sys_t *p_args,
     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) );
@@ -735,10 +754,20 @@ int  E_(HandlerCallback)( httpd_handler_sys_t *p_args,
         }
     }
 
+    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 );
 
@@ -761,7 +790,7 @@ int  E_(HandlerCallback)( httpd_handler_sys_t *p_args,
     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 )