]> git.sesse.net Git - vlc/blobdiff - src/misc/httpd.c
Fix compilation. Thanks bigben
[vlc] / src / misc / httpd.c
index 0b75bf57df520eacfb8ca8e505e7cf07e394f39a..66c4bc2afd6bce5cc8bdd0c3716b3745b2e2fc52 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * httpd.c
  *****************************************************************************
- * Copyright (C) 2004-2005 VideoLAN
+ * Copyright (C) 2004-2005 the VideoLAN team
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
@@ -30,6 +30,7 @@
 #include "vlc_httpd.h"
 #include "network.h"
 #include "vlc_tls.h"
+#include "vlc_acl.h"
 
 #include <string.h>
 #include <errno.h>
@@ -234,11 +235,10 @@ struct httpd_url_t
 
     vlc_mutex_t lock;
 
-    char    *psz_url;
-    char    *psz_user;
-    char    *psz_password;
-    char    **ppsz_hosts;
-    int     i_hosts;
+    char      *psz_url;
+    char      *psz_user;
+    char      *psz_password;
+    vlc_acl_t *p_acl;
 
     struct
     {
@@ -466,7 +466,7 @@ static int httpd_FileCallBack( httpd_callback_sys_t *p_sys, httpd_client_t *cl,
 
     if( query->i_type != HTTPD_MSG_HEAD )
     {
-        char *psz_args = query->psz_args;
+        uint8_t *psz_args = query->psz_args;
         if( query->i_type == HTTPD_MSG_POST )
         {
             /* Check that */
@@ -491,14 +491,13 @@ static int httpd_FileCallBack( httpd_callback_sys_t *p_sys, httpd_client_t *cl,
 httpd_file_t *httpd_FileNew( httpd_host_t *host,
                              char *psz_url, char *psz_mime,
                              char *psz_user, char *psz_password,
-                             char **ppsz_hosts, int i_hosts,
-                             httpd_file_callback_t pf_fill,
+                             const vlc_acl_t *p_acl, httpd_file_callback_t pf_fill,
                              httpd_file_sys_t *p_sys )
 {
     httpd_file_t *file = malloc( sizeof( httpd_file_t ) );
 
     if( ( file->url = httpd_UrlNewUnique( host, psz_url, psz_user,
-                                          psz_password, ppsz_hosts, i_hosts )
+                                          psz_password, p_acl )
         ) == NULL )
     {
         free( file );
@@ -565,16 +564,22 @@ static int httpd_RedirectCallBack( httpd_callback_sys_t *p_sys,
     answer->psz_status = strdup( "Moved Permanently" );
 
     p = answer->p_body = malloc( 1000 + strlen( rdir->psz_dst ) );
-    p += sprintf( p, "<html>\n" );
-    p += sprintf( p, "<head>\n" );
-    p += sprintf( p, "<title>Redirection</title>\n" );
-    p += sprintf( p, "</head>\n" );
-    p += sprintf( p, "<body>\n" );
-    p += sprintf( p, "<h1><center>You should be <a href=\"%s\">redirected</a></center></h1>\n", rdir->psz_dst );
-    p += sprintf( p, "<hr />\n" );
-    p += sprintf( p, "<a href=\"http://www.videolan.org\">VideoLAN</a>\n" );
-    p += sprintf( p, "</body>\n" );
-    p += sprintf( p, "</html>\n" );
+    p += sprintf( (char *)p,
+        "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
+        "<!DOCTYPE html PUBLIC \"-//W3C//DTD  XHTML 1.0 Strict//EN\" "
+        "\"http://www.w3.org/TR/xhtml10/DTD/xhtml10strict.dtd\">\n"
+        "<html>\n"
+        "<head>\n"
+        "<title>Redirection</title>\n"
+        "</head>\n"
+        "<body>\n"
+        "<h1>You should be "
+        "<a href=\"%s\">redirected</a></h1>\n"
+        "<hr />\n"
+        "<p><a href=\"http://www.videolan.org\">VideoLAN</a>\n</p>"
+        "<hr />\n"
+        "</body>\n"
+        "</html>\n", rdir->psz_dst );
     answer->i_body = p - answer->p_body;
 
     /* XXX check if it's ok or we need to set an absolute url */
@@ -590,8 +595,7 @@ httpd_redirect_t *httpd_RedirectNew( httpd_host_t *host, char *psz_url_dst,
 {
     httpd_redirect_t *rdir = malloc( sizeof( httpd_redirect_t ) );
 
-    if( !( rdir->url = httpd_UrlNewUnique( host, psz_url_src, NULL, NULL,
-                                           NULL, 0 ) ) )
+    if( !( rdir->url = httpd_UrlNewUnique( host, psz_url_src, NULL, NULL, NULL ) ) )
     {
         free( rdir );
         return NULL;
@@ -767,12 +771,12 @@ static int httpd_StreamCallBack( httpd_callback_sys_t *p_sys,
 httpd_stream_t *httpd_StreamNew( httpd_host_t *host,
                                  char *psz_url, char *psz_mime,
                                  char *psz_user, char *psz_password,
-                                 char **ppsz_hosts, int i_hosts )
+                                 const vlc_acl_t *p_acl )
 {
     httpd_stream_t *stream = malloc( sizeof( httpd_stream_t ) );
 
     if( ( stream->url = httpd_UrlNewUnique( host, psz_url, psz_user,
-                                            psz_password, ppsz_hosts, i_hosts )
+                                            psz_password, p_acl )
         ) == NULL )
     {
         free( stream );
@@ -897,6 +901,9 @@ httpd_host_t *httpd_TLSHostNew( vlc_object_t *p_this, const char *psz_hostname,
     vlc_value_t  lockval;
     int i;
 
+    if( psz_hostname == NULL )
+        psz_hostname = "";
+
     psz_host = strdup( psz_hostname );
     if( psz_host == NULL )
     {
@@ -1097,8 +1104,7 @@ void httpd_HostDelete( httpd_host_t *host )
 /* register a new url */
 static httpd_url_t *httpd_UrlNewPrivate( httpd_host_t *host, char *psz_url,
                                          char *psz_user, char *psz_password,
-                                         char **ppsz_hosts, int i_hosts,
-                                         vlc_bool_t b_check )
+                                         const vlc_acl_t *p_acl, vlc_bool_t b_check )
 {
     httpd_url_t *url;
     int         i;
@@ -1125,12 +1131,7 @@ static httpd_url_t *httpd_UrlNewPrivate( httpd_host_t *host, char *psz_url,
     url->psz_url = strdup( psz_url );
     url->psz_user = strdup( psz_user ? psz_user : "" );
     url->psz_password = strdup( psz_password ? psz_password : "" );
-    url->i_hosts = 0;
-    url->ppsz_hosts = NULL;
-    for( i = 0; i < i_hosts; i++ )
-    {
-        TAB_APPEND( url->i_hosts, url->ppsz_hosts, strdup(ppsz_hosts[i]) );
-    }
+    url->p_acl = ACL_Duplicate( host, p_acl );
     for( i = 0; i < HTTPD_MSG_MAX; i++ )
     {
         url->catch[i].cb = NULL;
@@ -1145,18 +1146,18 @@ static httpd_url_t *httpd_UrlNewPrivate( httpd_host_t *host, char *psz_url,
 
 httpd_url_t *httpd_UrlNew( httpd_host_t *host, char *psz_url,
                            char *psz_user, char *psz_password,
-                           char **ppsz_hosts, int i_hosts )
+                           const vlc_acl_t *p_acl )
 {
     return httpd_UrlNewPrivate( host, psz_url, psz_user,
-                                psz_password, ppsz_hosts, i_hosts, VLC_FALSE );
+                                psz_password, p_acl, VLC_FALSE );
 }
 
 httpd_url_t *httpd_UrlNewUnique( httpd_host_t *host, char *psz_url,
                                  char *psz_user, char *psz_password,
-                                 char **ppsz_hosts, int i_hosts )
+                                 const vlc_acl_t *p_acl )
 {
     return httpd_UrlNewPrivate( host, psz_url, psz_user,
-                                psz_password, ppsz_hosts, i_hosts, VLC_TRUE );
+                                psz_password, p_acl, VLC_TRUE );
 }
 
 /* register callback on a url */
@@ -1185,10 +1186,7 @@ void httpd_UrlDelete( httpd_url_t *url )
     free( url->psz_url );
     free( url->psz_user );
     free( url->psz_password );
-    for( i = 0; i < url->i_hosts; i++ )
-    {
-        TAB_REMOVE( url->i_hosts, url->ppsz_hosts, url->ppsz_hosts[0] );
-    }
+    ACL_Destroy( url->p_acl );
 
     for( i = 0; i < host->i_client; i++ )
     {
@@ -1331,50 +1329,14 @@ void httpd_ClientModeBidir( httpd_client_t *cl )
     cl->i_mode   = HTTPD_CLIENT_BIDIR;
 }
 
-char* httpd_ClientIP( httpd_client_t *cl )
+char* httpd_ClientIP( httpd_client_t *cl, char *psz_ip )
 {
-    int i;
-    char *psz_ip;
-
-    psz_ip = (char *)malloc( NI_MAXNUMERICHOST + 2 );
-#ifdef HAVE_GETNAMEINFO /* FIXME not very good check */
-    if( (cl->sock.ss_family == AF_INET6) &&
-        IN6_IS_ADDR_V4MAPPED( &((const struct sockaddr_in6 *)
-                              &cl->sock)->sin6_addr) )
-    {
-        /* If client is using IPv4 but server is using IPv6 */
-        struct sockaddr_in a;
-        
-        memset( &a, 0, sizeof( a ) );
-        a.sin_family = AF_INET;
-        a.sin_port = ((const struct sockaddr_in6 *)&cl->sock)->sin6_port;
-        a.sin_addr.s_addr = ((const uint32_t *)&((const struct sockaddr_in6 *)
-                            &cl->sock)->sin6_addr)[3];
-        i = vlc_getnameinfo( (const struct sockaddr *)&a, sizeof( a ),
-                             psz_ip + 1, NI_MAXNUMERICHOST, NULL,
-                             NI_NUMERICHOST );
-    }
-    else
-#endif
-        i = vlc_getnameinfo( (const struct sockaddr *)&cl->sock,
-                             cl->i_sock_size, psz_ip + 1, NI_MAXNUMERICHOST,
-                             NULL, NI_NUMERICHOST );
-
-    if( i != 0 )
-        return NULL;
-
-    /* semi-colon in address => must add bracket for HTTP */        
-    if( strchr( psz_ip + 1, ':' ) != NULL )
-    {
-        psz_ip[0] = '[';
-        i = strlen( psz_ip );
-        psz_ip[i++] = ']';
-        psz_ip[i] = '\0';
+    return net_GetPeerAddress( cl->fd, psz_ip, NULL ) ? NULL : psz_ip;
+}
 
-        return psz_ip;
-    }
-    
-    return psz_ip + 1;
+char* httpd_ServerIP( httpd_client_t *cl, char *psz_ip )
+{
+    return net_GetSockAddress( cl->fd, psz_ip, NULL ) ? NULL : psz_ip;
 }
 
 static void httpd_ClientClean( httpd_client_t *cl )
@@ -1415,7 +1377,7 @@ static httpd_client_t *httpd_ClientNew( int fd, struct sockaddr_storage *sock,
 }
 
 
-static int httpd_NetRecv( httpd_client_t *cl, char *p, int i_len )
+static int httpd_NetRecv( httpd_client_t *cl, uint8_t *p, int i_len )
 {
     tls_session_t *p_tls;
     
@@ -1427,7 +1389,7 @@ static int httpd_NetRecv( httpd_client_t *cl, char *p, int i_len )
 }
 
 
-static int httpd_NetSend( httpd_client_t *cl, const char *p, int i_len )
+static int httpd_NetSend( httpd_client_t *cl, const uint8_t *p, int i_len )
 {
     tls_session_t *p_tls;
 
@@ -1468,19 +1430,19 @@ static void httpd_ClientRecv( httpd_client_t *cl )
 
                 cl->i_buffer      = 0;
             }
-            else if( !strncmp( cl->p_buffer, "HTTP", 4 ) )
+            else if( !memcmp( cl->p_buffer, "HTTP", 4 ) )
             {
                 cl->query.i_proto = HTTPD_PROTO_HTTP;
                 cl->query.i_type  = HTTPD_MSG_ANSWER;
             }
-            else if( !strncmp( cl->p_buffer, "RTSP", 4 ) )
+            else if( !memcmp( cl->p_buffer, "RTSP", 4 ) )
             {
                 cl->query.i_proto = HTTPD_PROTO_RTSP;
                 cl->query.i_type  = HTTPD_MSG_ANSWER;
             }
-            else if( !strncmp( cl->p_buffer, "GET", 3 ) ||
-                     !strncmp( cl->p_buffer, "HEAD", 4 ) ||
-                     !strncmp( cl->p_buffer, "POST", 4 ) )
+            else if( !memcmp( cl->p_buffer, "GET", 3 ) ||
+                     !memcmp( cl->p_buffer, "HEAD", 4 ) ||
+                     !memcmp( cl->p_buffer, "POST", 4 ) )
             {
                 cl->query.i_proto = HTTPD_PROTO_HTTP;
                 cl->query.i_type  = HTTPD_MSG_NONE;
@@ -1523,8 +1485,8 @@ static void httpd_ClientRecv( httpd_client_t *cl )
                 cl->i_buffer_size += 1024;
                 cl->p_buffer = realloc( cl->p_buffer, cl->i_buffer_size );
             }
-            if( ( cl->i_buffer >= 2 && !strncmp( &cl->p_buffer[cl->i_buffer-2], "\n\n", 2 ) )||
-                ( cl->i_buffer >= 4 && !strncmp( &cl->p_buffer[cl->i_buffer-4], "\r\n\r\n", 4 ) ) )
+            if( ( cl->i_buffer >= 2 && !memcmp( &cl->p_buffer[cl->i_buffer-2], "\n\n", 2 ) )||
+                ( cl->i_buffer >= 4 && !memcmp( &cl->p_buffer[cl->i_buffer-4], "\r\n\r\n", 4 ) ) )
             {
                 char *p;
 
@@ -1533,8 +1495,12 @@ static void httpd_ClientRecv( httpd_client_t *cl )
 
                 if( cl->query.i_type == HTTPD_MSG_ANSWER )
                 {
+                    /* FIXME:
+                     * assume strlen( "HTTP/1.x" ) = 8
+                     */
                     cl->query.i_status =
-                        strtol( &cl->p_buffer[strlen( "HTTP/1.x" )], &p, 0 );
+                        strtol( (char *)&cl->p_buffer[8],
+                                &p, 0 );
                     while( *p == ' ' )
                     {
                         p++;
@@ -1573,10 +1539,10 @@ static void httpd_ClientRecv( httpd_client_t *cl )
 
                     for( i = 0; msg_type[i].name != NULL; i++ )
                     {
-                        if( !strncmp( cl->p_buffer, msg_type[i].name,
+                        if( !strncmp( (char *)cl->p_buffer, msg_type[i].name,
                                       strlen( msg_type[i].name ) ) )
                         {
-                            p = &cl->p_buffer[strlen(msg_type[i].name) + 1 ];
+                            p = (char *)&cl->p_buffer[strlen((char *)msg_type[i].name) + 1 ];
                             cl->query.i_type = msg_type[i].i_type;
                             if( cl->query.i_proto != msg_type[i].i_proto )
                             {
@@ -1589,11 +1555,11 @@ static void httpd_ClientRecv( httpd_client_t *cl )
                     }
                     if( p == NULL )
                     {
-                        if( strstr( cl->p_buffer, "HTTP/1." ) )
+                        if( strstr( (char *)cl->p_buffer, "HTTP/1." ) )
                         {
                             cl->query.i_proto = HTTPD_PROTO_HTTP;
                         }
-                        else if( strstr( cl->p_buffer, "RTSP/1." ) )
+                        else if( strstr( (char *)cl->p_buffer, "RTSP/1." ) )
                         {
                             cl->query.i_proto = HTTPD_PROTO_RTSP;
                         }
@@ -1623,7 +1589,7 @@ static void httpd_ClientRecv( httpd_client_t *cl )
                         if( ( p3 = strchr( cl->query.psz_url, '?' ) )  )
                         {
                             *p3++ = '\0';
-                            cl->query.psz_args = strdup( p3 );
+                            cl->query.psz_args = (uint8_t *)strdup( p3 );
                         }
                         if( p2 )
                         {
@@ -1793,7 +1759,7 @@ static void httpd_ClientSend( httpd_client_t *cl )
             free( cl->p_buffer );
             cl->p_buffer = malloc( i_size );
         }
-        p = cl->p_buffer;
+        p = (char *)cl->p_buffer;
 
         p += sprintf( p, "%s/1.%d %d %s\r\n",
                       cl->answer.i_proto ==  HTTPD_PROTO_HTTP ? "HTTP" : "RTSP",
@@ -2059,16 +2025,20 @@ static void httpd_HostThread( httpd_host_t *host )
 
                         p = answer->p_body = malloc( 1000 );
 
-                        p += sprintf( p, "<html>\n" );
-                        p += sprintf( p, "<head>\n" );
-                        p += sprintf( p, "<title>Error 501</title>\n" );
-                        p += sprintf( p, "</head>\n" );
-                        p += sprintf( p, "<body>\n" );
-                        p += sprintf( p, "<h1><center> 501 Unimplemented</center></h1>\n" );
-                        p += sprintf( p, "<hr />\n" );
-                        p += sprintf( p, "<a href=\"http://www.videolan.org\">VideoLAN</a>\n" );
-                        p += sprintf( p, "</body>\n" );
-                        p += sprintf( p, "</html>\n" );
+                        p += sprintf( (char *)p,
+                            "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"
+                            "<!DOCTYPE html PUBLIC \"-//W3C//DTD  XHTML 1.0 Strict//EN\" "
+                            "\"http://www.w3.org/TR/xhtml10/DTD/xhtml10strict.dtd\">\n"
+                            "<html>\n"
+                            "<head>\n"
+                            "<title>Error 501</title>\n"
+                            "</head>\n"
+                            "<body>\n"
+                            "<h1>501 Unimplemented</h1>\n"
+                            "<hr />\n"
+                            "<a href=\"http://www.videolan.org\">VideoLAN</a>\n"
+                            "</body>\n"
+                            "</html>\n" );
 
                         answer->i_body = p - answer->p_body;
                         httpd_MsgAdd( answer, "Content-Length", "%d", answer->i_body );
@@ -2092,21 +2062,20 @@ static void httpd_HostThread( httpd_host_t *host )
                         {
                             if( url->catch[i_msg].cb )
                             {
-                                if( answer && url->i_hosts )
+                                if( answer && ( url->p_acl != NULL ) )
                                 {
-                                    char *ip = httpd_ClientIP( cl );
-                                    if( ip != NULL )
+                                    char ip[NI_MAXNUMERICHOST];
+
+                                    if( httpd_ClientIP( cl, ip ) != NULL )
                                     {
-                                        if( net_CheckIP( host, ip,
-                                                         url->ppsz_hosts,
-                                                         url->i_hosts ) <= 0 )
+                                        if( ACL_Check( url->p_acl, ip ) )
                                         {
                                             b_hosts_failed = VLC_TRUE;
-                                            free( ip );
                                             break;
                                         }
-                                        free( ip );
                                     }
+                                    else
+                                        b_hosts_failed = VLC_TRUE;
                                 }
 
                                 if( answer && ( *url->psz_user || *url->psz_password ) )
@@ -2172,32 +2141,41 @@ static void httpd_HostThread( httpd_host_t *host )
                             answer->i_status = 403;
                             answer->psz_status = strdup( "Forbidden" );
 
-                            p += sprintf( p, "<html>\n" );
-                            p += sprintf( p, "<head>\n" );
-                            p += sprintf( p, "<title>Error 403</title>\n" );
-                            p += sprintf( p, "</head>\n" );
-                            p += sprintf( p, "<body>\n" );
-                            p += sprintf( p, "<h1><center> 403 Forbidden (%s)</center></h1>\n", query->psz_url );
-                            p += sprintf( p, "<hr />\n" );
-                            p += sprintf( p, "<a href=\"http://www.videolan.org\">VideoLAN</a>\n" );
-                            p += sprintf( p, "</body>\n" );
-                            p += sprintf( p, "</html>\n" );
+                            /* FIXME: lots of code duplication */
+                            p += sprintf( (char *)p,
+                                "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"
+                                "<!DOCTYPE html PUBLIC \"-//W3C//DTD  XHTML 1.0 Strict//EN\" "
+                                "\"http://www.w3.org/TR/xhtml10/DTD/xhtml10strict.dtd\">\n"
+                                "<html>\n"
+                                "<head>\n"
+                                "<title>Error 403</title>\n"
+                                "</head>\n"
+                                "<body>\n"
+                                "<h1>403 Forbidden (%s)</h1>\n"
+                                "<hr />\n"
+                                "<a href=\"http://www.videolan.org\">VideoLAN</a>\n"
+                                "</body>\n"
+                                "</html>\n", query->psz_url );
                         }
                         else if( b_auth_failed )
                         {
                             answer->i_status = 401;
                             answer->psz_status = strdup( "Authorization Required" );
 
-                            p += sprintf( p, "<html>\n" );
-                            p += sprintf( p, "<head>\n" );
-                            p += sprintf( p, "<title>Error 401</title>\n" );
-                            p += sprintf( p, "</head>\n" );
-                            p += sprintf( p, "<body>\n" );
-                            p += sprintf( p, "<h1><center> 401 Authorization Required (%s)</center></h1>\n", query->psz_url );
-                            p += sprintf( p, "<hr />\n" );
-                            p += sprintf( p, "<a href=\"http://www.videolan.org\">VideoLAN</a>\n" );
-                            p += sprintf( p, "</body>\n" );
-                            p += sprintf( p, "</html>\n" );
+                            p += sprintf( (char *)p,
+                                "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"
+                                "<!DOCTYPE html PUBLIC \"-//W3C//DTD  XHTML 1.0 Strict//EN\" "
+                                "\"http://www.w3.org/TR/xhtml10/DTD/xhtml10strict.dtd\">\n"
+                                "<html>\n"
+                                "<head>\n"
+                                "<title>Error 401</title>\n"
+                                "</head>\n"
+                                "<body>\n"
+                                "<h1>401 Authorization Required (%s)</h1>\n"
+                                "<hr />\n"
+                                "<a href=\"http://www.videolan.org\">VideoLAN</a>\n"
+                                "</body>\n"
+                                "</html>\n", query->psz_url );
                         }
                         else
                         {
@@ -2205,16 +2183,20 @@ static void httpd_HostThread( httpd_host_t *host )
                             answer->i_status = 404;
                             answer->psz_status = strdup( "Not found" );
 
-                            p += sprintf( p, "<html>\n" );
-                            p += sprintf( p, "<head>\n" );
-                            p += sprintf( p, "<title>Error 404</title>\n" );
-                            p += sprintf( p, "</head>\n" );
-                            p += sprintf( p, "<body>\n" );
-                            p += sprintf( p, "<h1><center> 404 Resource not found(%s)</center></h1>\n", query->psz_url );
-                            p += sprintf( p, "<hr />\n" );
-                            p += sprintf( p, "<a href=\"http://www.videolan.org\">VideoLAN</a>\n" );
-                            p += sprintf( p, "</body>\n" );
-                            p += sprintf( p, "</html>\n" );
+                            p += sprintf( (char *)p,
+                                "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"
+                                "<!DOCTYPE html PUBLIC \"-//W3C//DTD  XHTML 1.0 Strict//EN\" "
+                                "\"http://www.w3.org/TR/xhtml10/DTD/xhtml10strict.dtd\">\n"
+                                "<html>\n"
+                                "<head>\n"
+                                "<title>Error 404</title>\n"
+                                "</head>\n"
+                                "<body>\n"
+                                "<h1>404 Resource not found(%s)</h1>\n"
+                                "<hr />\n"
+                                "<a href=\"http://www.videolan.org\">VideoLAN</a>\n"
+                                "</body>\n"
+                                "</html>\n", query->psz_url );
                         }
 
                         answer->i_body = p - answer->p_body;
@@ -2324,7 +2306,11 @@ static void httpd_HostThread( httpd_host_t *host )
 
         if( i_ret == -1 && errno != EINTR )
         {
-            msg_Warn( host, "cannot select sockets" );
+#if defined(WIN32) || defined(UNDER_CE)
+            msg_Warn( host, "cannot select sockets (%d)", WSAGetLastError( ) );
+#else
+            msg_Warn( host, "cannot select sockets : %s", strerror( errno ) );
+#endif
             msleep( 1000 );
             continue;
         }
@@ -2338,7 +2324,7 @@ static void httpd_HostThread( httpd_host_t *host )
         {
             if( FD_ISSET( fd, &fds_read ) )
             {
-                int     i_sock_size = sizeof( struct sockaddr_storage );
+                socklen_t i_sock_size = sizeof( struct sockaddr_storage );
                 struct  sockaddr_storage sock;
     
                 fd = accept( fd, (struct sockaddr *)&sock, &i_sock_size );
@@ -2444,10 +2430,21 @@ httpd_host_t *httpd_HostNew( vlc_object_t *a, char *b, int c )
     msg_Err( a, "HTTP daemon support is disabled" );
     return 0;
 }
-void httpd_HostDelete( httpd_host_t *a ){}
-httpd_url_t *httpd_UrlNew( httpd_host_t *a, char *b ){ return 0; }
-httpd_url_t *httpd_UrlNewUnique( httpd_host_t *a, char *b, char *c,
-                                 char *d ){ return 0; }
+void httpd_HostDelete( httpd_host_t *a )
+{
+}
+httpd_url_t *httpd_UrlNew( httpd_host_t *host, char *psz_url,
+                           char *psz_user, char *psz_password,
+                           const vlc_acl_t *p_acl )
+{
+    return NULL;
+}
+httpd_url_t *httpd_UrlNewUnique( httpd_host_t *host, char *psz_url,
+                                 char *psz_user, char *psz_password,
+                                 const vlc_acl_t *p_acl )
+{
+    return NULL;
+}
 int httpd_UrlCatch( httpd_url_t *a, int b, httpd_callback_t c,
                     httpd_callback_sys_t *d ){ return 0; }
 void httpd_UrlDelete( httpd_url_t *a ){}