[vlc-commits] httpd: URL-parse --http-host and --rtsp-host

Pierre Ynard git at videolan.org
Sun Dec 18 19:19:49 CET 2011


vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Sun Dec 18 18:58:23 2011 +0100| [37eb636261b66b1a8d5cff1b247096a946ff4f65] | committer: Pierre Ynard

httpd: URL-parse --http-host and --rtsp-host

This deals gracefully with and warns about the legacy
--http-host <host>:<port> and --rtsp-host <host>:<port>/<path> syntaxes

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=37eb636261b66b1a8d5cff1b247096a946ff4f65
---

 src/network/httpd.c |   21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/network/httpd.c b/src/network/httpd.c
index b369151..5f0b5e3 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -38,6 +38,7 @@
 #include <vlc_strings.h>
 #include <vlc_rand.h>
 #include <vlc_charset.h>
+#include <vlc_url.h>
 #include "../libvlc.h"
 
 #include <string.h>
@@ -1032,8 +1033,19 @@ static httpd_host_t *httpd_HostCreate( vlc_object_t *p_this,
                                        vlc_tls_creds_t *p_tls )
 {
     httpd_host_t *host;
+    char *hostname = var_InheritString( p_this, hostvar );
     unsigned port = var_InheritInteger( p_this, portvar );
 
+    vlc_url_t url;
+    vlc_UrlParse( &url, hostname, 0 );
+    free( hostname );
+    if( url.i_port != 0 )
+    {
+        msg_Err( p_this, "Ignoring port %d (using %d)", url.i_port, port );
+        msg_Info( p_this, "Specify port %d separately with the "
+                          "%s option instead.", url.i_port, portvar );
+    }
+
     /* to be sure to avoid multiple creation */
     vlc_mutex_lock( &httpd.mutex );
 
@@ -1056,6 +1068,7 @@ static httpd_host_t *httpd_HostCreate( vlc_object_t *p_this,
         vlc_mutex_unlock( &host->lock );
 
         vlc_mutex_unlock( &httpd.mutex );
+        vlc_UrlClean( &url );
         if( p_tls != NULL )
             vlc_tls_ServerDelete( p_tls );
         return host;
@@ -1071,9 +1084,7 @@ static httpd_host_t *httpd_HostCreate( vlc_object_t *p_this,
     vlc_cond_init( &host->wait );
     host->i_ref = 1;
 
-    char *hostname = var_InheritString( p_this, hostvar );
-    host->fds = net_ListenTCP( p_this, hostname, port );
-    free( hostname );
+    host->fds = net_ListenTCP( p_this, url.psz_host, port );
     if( host->fds == NULL )
     {
         msg_Err( p_this, "cannot create socket(s) for HTTP host" );
@@ -1106,6 +1117,8 @@ static httpd_host_t *httpd_HostCreate( vlc_object_t *p_this,
     TAB_APPEND( httpd.i_host, httpd.host, host );
     vlc_mutex_unlock( &httpd.mutex );
 
+    vlc_UrlClean( &url );
+
     return host;
 
 error:
@@ -1119,6 +1132,8 @@ error:
         vlc_object_release( host );
     }
 
+    vlc_UrlClean( &url );
+
     if( p_tls != NULL )
         vlc_tls_ServerDelete( p_tls );
 



More information about the vlc-commits mailing list