netutils/webserver: Fix a few complaints from nutts/tools/nxstyle.
This commit is contained in:
parent
0b352178c1
commit
39ad02f72e
@ -14,7 +14,6 @@ config NETUTILS_WEBSERVER
|
|||||||
|
|
||||||
if NETUTILS_WEBSERVER
|
if NETUTILS_WEBSERVER
|
||||||
|
|
||||||
|
|
||||||
config NETUTILS_HTTPD_SINGLECONNECT
|
config NETUTILS_HTTPD_SINGLECONNECT
|
||||||
bool "Single Connection"
|
bool "Single Connection"
|
||||||
default n if !DISABLE_PTHREAD
|
default n if !DISABLE_PTHREAD
|
||||||
@ -179,5 +178,4 @@ config NETUTILS_HTTPD_DIRLIST
|
|||||||
depends on NETUTILS_HTTPD_SENDFILE
|
depends on NETUTILS_HTTPD_SENDFILE
|
||||||
default n
|
default n
|
||||||
|
|
||||||
|
|
||||||
endif # NETUTILS_WEBSERVER
|
endif # NETUTILS_WEBSERVER
|
||||||
|
@ -331,7 +331,7 @@ static int handle_script(struct httpd_state *pstate)
|
|||||||
if (httpd_open(pstate->ht_scriptptr + 1,
|
if (httpd_open(pstate->ht_scriptptr + 1,
|
||||||
&pstate->ht_file) != OK)
|
&pstate->ht_file) != OK)
|
||||||
{
|
{
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = httpd_send_datachunk(pstate->ht_sockfd,
|
status = httpd_send_datachunk(pstate->ht_sockfd,
|
||||||
@ -444,7 +444,10 @@ static int send_headers(struct httpd_state *pstate, int status, int len)
|
|||||||
{
|
{
|
||||||
const char *mime;
|
const char *mime;
|
||||||
const char *ptr;
|
const char *ptr;
|
||||||
char contentlen[HTTPD_MAX_CONTENTLEN] = { 0 };
|
char contentlen[HTTPD_MAX_CONTENTLEN] =
|
||||||
|
{
|
||||||
|
0
|
||||||
|
};
|
||||||
char header[HTTPD_MAX_HEADERLEN];
|
char header[HTTPD_MAX_HEADERLEN];
|
||||||
int hdrlen;
|
int hdrlen;
|
||||||
int i;
|
int i;
|
||||||
@ -456,19 +459,36 @@ static int send_headers(struct httpd_state *pstate, int status, int len)
|
|||||||
} a[] =
|
} a[] =
|
||||||
{
|
{
|
||||||
#ifndef CONFIG_NETUTILS_HTTPD_SCRIPT_DISABLE
|
#ifndef CONFIG_NETUTILS_HTTPD_SCRIPT_DISABLE
|
||||||
{ "shtml", "text/html" },
|
{
|
||||||
|
"shtml", "text/html"
|
||||||
|
},
|
||||||
#endif
|
#endif
|
||||||
{ "html", "text/html" },
|
{
|
||||||
{ "css", "text/css" },
|
"html", "text/html"
|
||||||
{ "txt", "text/plain" },
|
},
|
||||||
{ "js", "text/javascript" },
|
{
|
||||||
|
"css", "text/css"
|
||||||
{ "png", "image/png" },
|
},
|
||||||
{ "gif", "image/gif" },
|
{
|
||||||
{ "jpeg", "image/jpeg" },
|
"txt", "text/plain"
|
||||||
{ "jpg", "image/jpeg" },
|
},
|
||||||
|
{
|
||||||
{ "mp3", "audio/mpeg" }
|
"js", "text/javascript"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"png", "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"gif", "image/gif"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"jpeg", "image/jpeg"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"jpg", "image/jpeg"
|
||||||
|
},
|
||||||
|
{ "mp3", "audio/mpeg"
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ptr = strrchr(pstate->ht_filename, ISO_period);
|
ptr = strrchr(pstate->ht_filename, ISO_period);
|
||||||
@ -647,7 +667,7 @@ static int httpd_sendfile(struct httpd_state *pstate)
|
|||||||
#endif
|
#endif
|
||||||
if (send_headers(pstate, 200, -1) != OK)
|
if (send_headers(pstate, 200, -1) != OK)
|
||||||
{
|
{
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = handle_script(pstate);
|
ret = handle_script(pstate);
|
||||||
|
@ -54,18 +54,6 @@
|
|||||||
|
|
||||||
#include "httpd.h"
|
#include "httpd.h"
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -85,27 +73,27 @@ int httpd_sendfile_open(const char *name, struct httpd_fs_file *file)
|
|||||||
|
|
||||||
if (-1 == stat(file->path, &st))
|
if (-1 == stat(file->path, &st))
|
||||||
{
|
{
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef CONFIG_NETUTILS_HTTPD_DIRLIST
|
#ifndef CONFIG_NETUTILS_HTTPD_DIRLIST
|
||||||
if (S_ISDIR(st.st_mode))
|
if (S_ISDIR(st.st_mode))
|
||||||
{
|
{
|
||||||
errno = EISDIR;
|
errno = EISDIR;
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!S_ISREG(st.st_mode))
|
if (!S_ISREG(st.st_mode))
|
||||||
{
|
{
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (st.st_size > INT_MAX || st.st_size > SIZE_MAX)
|
if (st.st_size > INT_MAX || st.st_size > SIZE_MAX)
|
||||||
{
|
{
|
||||||
errno = EFBIG;
|
errno = EFBIG;
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
file->len = (int) st.st_size;
|
file->len = (int) st.st_size;
|
||||||
@ -115,7 +103,7 @@ int httpd_sendfile_open(const char *name, struct httpd_fs_file *file)
|
|||||||
#ifndef CONFIG_NETUTILS_HTTPD_DIRLIST
|
#ifndef CONFIG_NETUTILS_HTTPD_DIRLIST
|
||||||
if (file->fd == -1)
|
if (file->fd == -1)
|
||||||
{
|
{
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user