Changeset 6ec205241c296fce247301848ed7116ce44625ef

Show
Ignore:
Timestamp:
10/07/05 12:03:30 (3 years ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1120989810 +0000
git-parent:

[23bdea50631c8cf3af992768559a4c8085d0c5f7]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1120989810 +0000
Message:

Some more cleanup / no more warnings

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/misc/httpd.c

    ra4de52f r6ec2052  
    569569        "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" 
    570570        "<!DOCTYPE html PUBLIC \"-//W3C//DTD  XHTML 1.0 Strict//EN\" " 
    571         "\"http://www.w3.org/TR/xhtml10/DTD/xhtml10transitional.dtd\">\n" 
     571        "\"http://www.w3.org/TR/xhtml10/DTD/xhtml10strict.dtd\">\n" 
    572572        "<html>\n" 
    573573        "<head>\n" 
     
    14011401 
    14021402 
    1403 static int httpd_NetRecv( httpd_client_t *cl, char *p, int i_len ) 
     1403static int httpd_NetRecv( httpd_client_t *cl, uint8_t *p, int i_len ) 
    14041404{ 
    14051405    tls_session_t *p_tls; 
     
    14131413 
    14141414 
    1415 static int httpd_NetSend( httpd_client_t *cl, const char *p, int i_len ) 
     1415static int httpd_NetSend( httpd_client_t *cl, const uint8_t *p, int i_len ) 
    14161416{ 
    14171417    tls_session_t *p_tls; 
     
    14541454                cl->i_buffer      = 0; 
    14551455            } 
    1456             else if( !strncmp( cl->p_buffer, "HTTP", 4 ) ) 
     1456            else if( !memcmp( cl->p_buffer, "HTTP", 4 ) ) 
    14571457            { 
    14581458                cl->query.i_proto = HTTPD_PROTO_HTTP; 
    14591459                cl->query.i_type  = HTTPD_MSG_ANSWER; 
    14601460            } 
    1461             else if( !strncmp( cl->p_buffer, "RTSP", 4 ) ) 
     1461            else if( !memcmp( cl->p_buffer, "RTSP", 4 ) ) 
    14621462            { 
    14631463                cl->query.i_proto = HTTPD_PROTO_RTSP; 
    14641464                cl->query.i_type  = HTTPD_MSG_ANSWER; 
    14651465            } 
    1466             else if( !strncmp( cl->p_buffer, "GET", 3 ) || 
    1467                      !strncmp( cl->p_buffer, "HEAD", 4 ) || 
    1468                      !strncmp( cl->p_buffer, "POST", 4 ) ) 
     1466            else if( !memcmp( cl->p_buffer, "GET", 3 ) || 
     1467                     !memcmp( cl->p_buffer, "HEAD", 4 ) || 
     1468                     !memcmp( cl->p_buffer, "POST", 4 ) ) 
    14691469            { 
    14701470                cl->query.i_proto = HTTPD_PROTO_HTTP; 
     
    15091509                cl->p_buffer = realloc( cl->p_buffer, cl->i_buffer_size ); 
    15101510            } 
    1511             if( ( cl->i_buffer >= 2 && !strncmp( &cl->p_buffer[cl->i_buffer-2], "\n\n", 2 ) )|| 
    1512                 ( cl->i_buffer >= 4 && !strncmp( &cl->p_buffer[cl->i_buffer-4], "\r\n\r\n", 4 ) ) ) 
     1511            if( ( cl->i_buffer >= 2 && !memcmp( &cl->p_buffer[cl->i_buffer-2], "\n\n", 2 ) )|| 
     1512                ( cl->i_buffer >= 4 && !memcmp( &cl->p_buffer[cl->i_buffer-4], "\r\n\r\n", 4 ) ) ) 
    15131513            { 
    15141514                char *p; 
     
    15191519                if( cl->query.i_type == HTTPD_MSG_ANSWER ) 
    15201520                { 
     1521                    /* FIXME: 
     1522                     * assume strlen( "HTTP/1.x" ) = 8 
     1523                     */ 
    15211524                    cl->query.i_status = 
    1522                         strtol( &cl->p_buffer[strlen( "HTTP/1.x" )], &p, 0 ); 
     1525                        strtol( (char *)&cl->p_buffer[8], 
     1526                                &p, 0 ); 
    15231527                    while( *p == ' ' ) 
    15241528                    { 
     
    15591563                    for( i = 0; msg_type[i].name != NULL; i++ ) 
    15601564                    { 
    1561                         if( !strncmp( cl->p_buffer, msg_type[i].name, 
     1565                        if( !strncmp( (char *)cl->p_buffer, msg_type[i].name, 
    15621566                                      strlen( msg_type[i].name ) ) ) 
    15631567                        { 
    1564                             p = &cl->p_buffer[strlen(msg_type[i].name) + 1 ]; 
     1568                            p = (char *)&cl->p_buffer[strlen((char *)msg_type[i].name) + 1 ]; 
    15651569                            cl->query.i_type = msg_type[i].i_type; 
    15661570                            if( cl->query.i_proto != msg_type[i].i_proto ) 
     
    15751579                    if( p == NULL ) 
    15761580                    { 
    1577                         if( strstr( cl->p_buffer, "HTTP/1." ) ) 
     1581                        if( strstr( (char *)cl->p_buffer, "HTTP/1." ) ) 
    15781582                        { 
    15791583                            cl->query.i_proto = HTTPD_PROTO_HTTP; 
    15801584                        } 
    1581                         else if( strstr( cl->p_buffer, "RTSP/1." ) ) 
     1585                        else if( strstr( (char *)cl->p_buffer, "RTSP/1." ) ) 
    15821586                        { 
    15831587                            cl->query.i_proto = HTTPD_PROTO_RTSP; 
     
    16091613                        { 
    16101614                            *p3++ = '\0'; 
    1611                             cl->query.psz_args = strdup( p3 ); 
     1615                            cl->query.psz_args = (uint8_t *)strdup( p3 ); 
    16121616                        } 
    16131617                        if( p2 ) 
     
    17791783            cl->p_buffer = malloc( i_size ); 
    17801784        } 
    1781         p = cl->p_buffer; 
     1785        p = (char *)cl->p_buffer; 
    17821786 
    17831787        p += sprintf( p, "%s/1.%d %d %s\r\n", 
     
    20452049                        p = answer->p_body = malloc( 1000 ); 
    20462050 
    2047                         p += sprintf( p, "<html>\n" ); 
    2048                         p += sprintf( p, "<head>\n" ); 
    2049                         p += sprintf( p, "<title>Error 501</title>\n" ); 
    2050                         p += sprintf( p, "</head>\n" ); 
    2051                         p += sprintf( p, "<body>\n" ); 
    2052                         p += sprintf( p, "<h1><center> 501 Unimplemented</center></h1>\n" ); 
    2053                         p += sprintf( p, "<hr />\n" ); 
    2054                         p += sprintf( p, "<a href=\"http://www.videolan.org\">VideoLAN</a>\n" ); 
    2055                         p += sprintf( p, "</body>\n" ); 
    2056                         p += sprintf( p, "</html>\n" ); 
     2051                        p += sprintf( (char *)p, 
     2052                            "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" 
     2053                            "<!DOCTYPE html PUBLIC \"-//W3C//DTD  XHTML 1.0 Strict//EN\" " 
     2054                            "\"http://www.w3.org/TR/xhtml10/DTD/xhtml10strict.dtd\">\n" 
     2055                            "<html>\n" 
     2056                            "<head>\n" 
     2057                            "<title>Error 501</title>\n" 
     2058                            "</head>\n" 
     2059                            "<body>\n" 
     2060                            "<h1>501 Unimplemented</h1>\n" 
     2061                            "<hr />\n" 
     2062                            "<a href=\"http://www.videolan.org\">VideoLAN</a>\n" 
     2063                            "</body>\n" 
     2064                            "</html>\n" ); 
    20572065 
    20582066                        answer->i_body = p - answer->p_body; 
     
    21582166                            answer->psz_status = strdup( "Forbidden" ); 
    21592167 
    2160                             p += sprintf( p, "<html>\n" ); 
    2161                             p += sprintf( p, "<head>\n" ); 
    2162                             p += sprintf( p, "<title>Error 403</title>\n" ); 
    2163                             p += sprintf( p, "</head>\n" ); 
    2164                             p += sprintf( p, "<body>\n" ); 
    2165                             p += sprintf( p, "<h1><center> 403 Forbidden (%s)</center></h1>\n", query->psz_url ); 
    2166                             p += sprintf( p, "<hr />\n" ); 
    2167                             p += sprintf( p, "<a href=\"http://www.videolan.org\">VideoLAN</a>\n" ); 
    2168                             p += sprintf( p, "</body>\n" ); 
    2169                             p += sprintf( p, "</html>\n" ); 
     2168                            /* FIXME: lots of code duplication */ 
     2169                            p += sprintf( (char *)p, 
     2170                                "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" 
     2171                                "<!DOCTYPE html PUBLIC \"-//W3C//DTD  XHTML 1.0 Strict//EN\" " 
     2172                                "\"http://www.w3.org/TR/xhtml10/DTD/xhtml10strict.dtd\">\n" 
     2173                                "<html>\n" 
     2174                                "<head>\n" 
     2175                                "<title>Error 403</title>\n" 
     2176                                "</head>\n" 
     2177                                "<body>\n" 
     2178                                "<h1>403 Forbidden (%s)</h1>\n" 
     2179                                "<hr />\n" 
     2180                                "<a href=\"http://www.videolan.org\">VideoLAN</a>\n" 
     2181                                "</body>\n" 
     2182                                "</html>\n", query->psz_url ); 
    21702183                        } 
    21712184                        else if( b_auth_failed ) 
     
    21742187                            answer->psz_status = strdup( "Authorization Required" ); 
    21752188 
    2176                             p += sprintf( p, "<html>\n" ); 
    2177                             p += sprintf( p, "<head>\n" ); 
    2178                             p += sprintf( p, "<title>Error 401</title>\n" ); 
    2179                             p += sprintf( p, "</head>\n" ); 
    2180                             p += sprintf( p, "<body>\n" ); 
    2181                             p += sprintf( p, "<h1><center> 401 Authorization Required (%s)</center></h1>\n", query->psz_url ); 
    2182                             p += sprintf( p, "<hr />\n" ); 
    2183                             p += sprintf( p, "<a href=\"http://www.videolan.org\">VideoLAN</a>\n" ); 
    2184                             p += sprintf( p, "</body>\n" ); 
    2185                             p += sprintf( p, "</html>\n" ); 
     2189                            p += sprintf( (char *)p, 
     2190                                "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" 
     2191                                "<!DOCTYPE html PUBLIC \"-//W3C//DTD  XHTML 1.0 Strict//EN\" " 
     2192                                "\"http://www.w3.org/TR/xhtml10/DTD/xhtml10strict.dtd\">\n" 
     2193                                "<html>\n" 
     2194                                "<head>\n" 
     2195                                "<title>Error 401</title>\n" 
     2196                                "</head>\n" 
     2197                                "<body>\n" 
     2198                                "<h1>401 Authorization Required (%s)</h1>\n" 
     2199                                "<hr />\n" 
     2200                                "<a href=\"http://www.videolan.org\">VideoLAN</a>\n" 
     2201                                "</body>\n" 
     2202                                "</html>\n", query->psz_url ); 
    21862203                        } 
    21872204                        else 
     
    21912208                            answer->psz_status = strdup( "Not found" ); 
    21922209 
    2193                             p += sprintf( p, "<html>\n" ); 
    2194                             p += sprintf( p, "<head>\n" ); 
    2195                             p += sprintf( p, "<title>Error 404</title>\n" ); 
    2196                             p += sprintf( p, "</head>\n" ); 
    2197                             p += sprintf( p, "<body>\n" ); 
    2198                             p += sprintf( p, "<h1><center> 404 Resource not found(%s)</center></h1>\n", query->psz_url ); 
    2199                             p += sprintf( p, "<hr />\n" ); 
    2200                             p += sprintf( p, "<a href=\"http://www.videolan.org\">VideoLAN</a>\n" ); 
    2201                             p += sprintf( p, "</body>\n" ); 
    2202                             p += sprintf( p, "</html>\n" ); 
     2210                            p += sprintf( (char *)p, 
     2211                                "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" 
     2212                                "<!DOCTYPE html PUBLIC \"-//W3C//DTD  XHTML 1.0 Strict//EN\" " 
     2213                                "\"http://www.w3.org/TR/xhtml10/DTD/xhtml10strict.dtd\">\n" 
     2214                                "<html>\n" 
     2215                                "<head>\n" 
     2216                                "<title>Error 404</title>\n" 
     2217                                "</head>\n" 
     2218                                "<body>\n" 
     2219                                "<h1><center> 404 Resource not found(%s)</center></h1>\n" 
     2220                                "<hr />\n" 
     2221                                "<a href=\"http://www.videolan.org\">VideoLAN</a>\n" 
     2222                                "</body>\n" 
     2223                                "</html>\n", query->psz_url ); 
    22032224                        } 
    22042225 
     
    23282349            if( FD_ISSET( fd, &fds_read ) ) 
    23292350            { 
    2330                 int    i_sock_size = sizeof( struct sockaddr_storage ); 
     2351                socklen_t i_sock_size = sizeof( struct sockaddr_storage ); 
    23312352                struct  sockaddr_storage sock; 
    23322353