summaryrefslogtreecommitdiff
path: root/apps/netutils/webserver/httpd.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-09-11 13:19:59 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-09-11 13:19:59 +0000
commit26ef7179b0f6c3be8c76eefdca033392209ee42d (patch)
tree06ea25a4404d94f98a2c42a56c34a9dfeb7a3aac /apps/netutils/webserver/httpd.c
parentff113b400adf80f5bf6f07233a2355e48b00676d (diff)
downloadnuttx-26ef7179b0f6c3be8c76eefdca033392209ee42d.tar.gz
nuttx-26ef7179b0f6c3be8c76eefdca033392209ee42d.tar.bz2
nuttx-26ef7179b0f6c3be8c76eefdca033392209ee42d.zip
AVR corrections from Richard Cochran; uIP webserver enhancements from Kate
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5126 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/netutils/webserver/httpd.c')
-rw-r--r--apps/netutils/webserver/httpd.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/apps/netutils/webserver/httpd.c b/apps/netutils/webserver/httpd.c
index 2fd019157..0c0ee0389 100644
--- a/apps/netutils/webserver/httpd.c
+++ b/apps/netutils/webserver/httpd.c
@@ -69,6 +69,14 @@
* Pre-processor Definitions
****************************************************************************/
+#if !defined(CONFIG_NETUTILS_HTTPD_SCRIPT_DISABLE) && defined(CONFIG_NETUTILS_HTTPD_SENDFILE)
+# error "Script support and CONFIG_NETUTILS_HTTPD_SENDFILE are mutually exclusive"
+#endif
+
+#if defined(CONFIG_NETUTILS_HTTPD_SENDFILE) && defined(CONFIG_NETUTILS_HTTPD_MMAP)
+# error "CONFIG_NETUTILS_HTTPD_SENDFILE and CONFIG_NETUTILS_HTTPD_MMAP are mutually exclusive"
+#endif
+
#define ISO_nl 0x0a
#define ISO_space 0x20
#define ISO_bang 0x21
@@ -131,7 +139,9 @@ static const char g_httpheader404[] =
static int httpd_open(const char *name, struct httpd_fs_file *file)
{
-#ifdef CONFIG_NETUTILS_HTTPD_MMAP
+#if defined(CONFIG_NETUTILS_HTTPD_SENDFILE)
+ return httpd_sendfile_open(name, file);
+#elif defined(CONFIG_NETUTILS_HTTPD_MMAP)
return httpd_mmap_open(name, file);
#else
return httpd_fs_open(name, file);
@@ -140,7 +150,9 @@ static int httpd_open(const char *name, struct httpd_fs_file *file)
static int httpd_close(struct httpd_fs_file *file)
{
-#ifdef CONFIG_NETUTILS_HTTPD_MMAP
+#if defined(CONFIG_NETUTILS_HTTPD_SENDFILE)
+ return httpd_sendfile_close(file);
+#elif defined(CONFIG_NETUTILS_HTTPD_MMAP)
return httpd_mmap_close(file);
#else
return OK;
@@ -424,7 +436,11 @@ static int httpd_sendfile(struct httpd_state *pstate)
if (send_headers(pstate, g_httpheader404, strlen(g_httpheader404)) == OK)
{
+#ifdef CONFIG_NETUTILS_HTTPD_SENDFILE
+ ret = httpd_sendfile_send(pstate->ht_sockfd, &pstate->ht_file);
+#else
ret = httpd_addchunk(pstate, pstate->ht_file.data, pstate->ht_file.len);
+#endif
}
}
else
@@ -447,7 +463,11 @@ static int httpd_sendfile(struct httpd_state *pstate)
else
#endif
{
+#ifdef CONFIG_NETUTILS_HTTPD_SENDFILE
+ ret = httpd_sendfile_send(pstate->ht_sockfd, &pstate->ht_file);
+#else
ret = httpd_addchunk(pstate, pstate->ht_file.data, pstate->ht_file.len);
+#endif
}
}
}
@@ -603,7 +623,7 @@ int httpd_listen(void)
void httpd_init(void)
{
-#ifndef CONFIG_NETUTILS_HTTPD_MMAP
+#if !defined(CONFIG_NETUTILS_HTTPD_MMAP) && !defined(CONFIG_NETUTILS_HTTPD_SENDFILE)
httpd_fs_init();
#endif
}