]> git.sesse.net Git - vlc/blobdiff - modules/control/http/http.c
- Don't assume builddir = srcdir
[vlc] / modules / control / http / http.c
index cdcd4758a4c9aac7452de7e50f0695b9406a0840..6472c1042814d804f59345668c358b66af204bda 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * http.c : HTTP/HTTPS Remote control interface
  *****************************************************************************
- * Copyright (C) 2001-2005 the VideoLAN team
+ * Copyright (C) 2001-2006 the VideoLAN team
  * $Id$
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
@@ -33,7 +33,10 @@ static void Close( vlc_object_t * );
 
 #define HOST_TEXT N_( "Host address" )
 #define HOST_LONGTEXT N_( \
-    "You can set the address and port the http interface will bind to." )
+    "Address and port the HTTP interface will listen on. It defaults to " \
+    "all network interfaces (0.0.0.0)." \
+    " If you want the telnet interface to be available only on the local " \
+    "machine, enter 127.0.0.1" )
 #define SRC_TEXT N_( "Source directory" )
 #define SRC_LONGTEXT N_( "Source directory" )
 #define CHARSET_TEXT N_( "Charset" )
@@ -41,18 +44,18 @@ static void Close( vlc_object_t * );
         "Charset declared in Content-Type header (default UTF-8)." )
 #define HANDLERS_TEXT N_( "Handlers" )
 #define HANDLERS_LONGTEXT N_( \
-        "List of extensions and executable paths (for instance: " \
+        "List of handler extensions and executable paths (for instance: " \
         "php=/usr/bin/php,pl=/usr/bin/perl)." )
 #define CERT_TEXT N_( "Certificate file" )
 #define CERT_LONGTEXT N_( "HTTP interface x509 PEM certificate file " \
-                          "(enables SSL)" )
+                          "(enables SSL)." )
 #define KEY_TEXT N_( "Private key file" )
-#define KEY_LONGTEXT N_( "HTTP interface x509 PEM private key file" )
+#define KEY_LONGTEXT N_( "HTTP interface x509 PEM private key file." )
 #define CA_TEXT N_( "Root CA file" )
 #define CA_LONGTEXT N_( "HTTP interface x509 PEM trusted root CA " \
-                        "certificates file" )
+                        "certificates file." )
 #define CRL_TEXT N_( "CRL file" )
-#define CRL_LONGTEXT N_( "HTTP interace Certificates Revocation List file" )
+#define CRL_LONGTEXT N_( "HTTP interace Certificates Revocation List file." )
 
 vlc_module_begin();
     set_shortname( _("HTTP"));
@@ -84,14 +87,15 @@ static void Run          ( intf_thread_t *p_intf );
  * Local functions
  *****************************************************************************/
 #if !defined(__APPLE__) && !defined(SYS_BEOS) && !defined(WIN32)
-static int DirectoryCheck( char *psz_dir )
+static int DirectoryCheck( const char *psz_dir )
 {
     DIR           *p_dir;
 
 #ifdef HAVE_SYS_STAT_H
     struct stat   stat_info;
 
-    if( utf8_stat( psz_dir, &stat_info ) == -1 || !S_ISDIR( stat_info.st_mode ) )
+    if( ( utf8_stat( psz_dir, &stat_info ) == -1 )
+      || !S_ISDIR( stat_info.st_mode ) )
     {
         return VLC_EGENERIC;
     }
@@ -290,22 +294,34 @@ static int Open( vlc_object_t *p_this )
 #else
     psz_src = config_GetPsz( p_intf, "http-src" );
 
-    if( !psz_src || *psz_src == '\0' )
+    if( ( psz_src == NULL ) || ( *psz_src == '\0' ) )
     {
-        if( !DirectoryCheck( "share/http" ) )
-        {
-            psz_src = strdup( "share/http" );
-        }
-        else if( !DirectoryCheck( DATA_PATH "/http" ) )
+        static char const* ppsz_paths[] = {
+            "share/http",
+            "../share/http",
+            DATA_PATH"/http",
+            NULL
+        };
+        unsigned i;
+
+        if( psz_src != NULL )
         {
-            psz_src = strdup( DATA_PATH "/http" );
+            free( psz_src );
+            psz_src = NULL;
         }
+
+        for( i = 0; ppsz_paths[i] != NULL; i++ )
+            if( !DirectoryCheck( ppsz_paths[i] ) )
+            {
+                psz_src = strdup( ppsz_paths[i] );
+                break;
+            }
     }
 #endif
 
     if( !psz_src || *psz_src == '\0' )
     {
-        msg_Err( p_intf, "invalid src dir" );
+        msg_Err( p_intf, "invalid web interface source directory" );
         goto failed;
     }
 
@@ -321,7 +337,7 @@ static int Open( vlc_object_t *p_this )
 
     if( p_sys->i_files <= 0 )
     {
-        msg_Err( p_intf, "cannot find any files (%s)", psz_src );
+        msg_Err( p_intf, "cannot find any file in directory %s", psz_src );
         goto failed;
     }
     p_intf->pf_run = Run;