summaryrefslogtreecommitdiff
path: root/nuttx/netutils/webserver/httpd.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-09-23 20:45:30 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-09-23 20:45:30 +0000
commit7326b1166b618ddc6b3eb9e9224b1f5ded5515a5 (patch)
treeaac340a4c4cc123213e08b83d1c452a67f333a35 /nuttx/netutils/webserver/httpd.c
parent1b15ed82bb5f48d8a03366af769331eac73c9993 (diff)
downloadpx4-nuttx-7326b1166b618ddc6b3eb9e9224b1f5ded5515a5.tar.gz
px4-nuttx-7326b1166b618ddc6b3eb9e9224b1f5ded5515a5.tar.bz2
px4-nuttx-7326b1166b618ddc6b3eb9e9224b1f5ded5515a5.zip
Partial implementation of accept() and listen()
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@354 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/netutils/webserver/httpd.c')
-rw-r--r--nuttx/netutils/webserver/httpd.c61
1 files changed, 47 insertions, 14 deletions
diff --git a/nuttx/netutils/webserver/httpd.c b/nuttx/netutils/webserver/httpd.c
index dfccdef6c..7c3271fd6 100644
--- a/nuttx/netutils/webserver/httpd.c
+++ b/nuttx/netutils/webserver/httpd.c
@@ -1,17 +1,24 @@
-/* httpd
+/****************************************************************************
+ * httpd
* httpd Web server
- * Author: Adam Dunkels <adam@sics.se>
*
- * The uIP web server is a very simplistic implementation of an HTTP
- * server. It can serve web pages and files from a read-only ROM
- * filesystem, and provides a very small scripting language.
+ * Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
- * Copyright (c) 2004, Adam Dunkels.
- * All rights reserved.
+ * This is a leverage of similar logic from uIP:
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * The uIP web server is a very simplistic implementation of an HTTP
+ * server. It can serve web pages and files from a read-only ROM
+ * filesystem, and provides a very small scripting language.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
+ *
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
@@ -32,10 +39,15 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- */
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
#include <stdlib.h>
#include <sys/socket.h>
+#include <string.h>
#include <net/uip/uip.h>
#include <net/uip/httpd.h>
@@ -44,7 +56,9 @@
#include "httpd-cgi.h"
#include "netutil-strings.h"
-#include <string.h>
+/****************************************************************************
+ * Definitions
+ ****************************************************************************/
#define STATE_WAITING 0
#define STATE_OUTPUT 1
@@ -59,6 +73,10 @@
#define SEND_STR(psock, str) psock_send(psock, str, strlen(str))
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
static inline int send_file(struct httpd_state *pstate)
{
return send(pstate->sockout, pstate->file.data, pstate->file.len, 0);
@@ -256,16 +274,31 @@ static void handle_connection(struct httpd_state *pstate)
}
}
-void httpd_listen(void)
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+/****************************************************************************
+ * Name: httpd_listen
+ *
+ * Description:
+ * This is the main processing thread for the webserver. It never returns
+ * unless an error occurs
+ *
+ ****************************************************************************/
+
+int httpd_listen(void)
{
#warning "this is all very broken at the moment"
}
-/* Initialize the web server
+/****************************************************************************
+ * Name: httpd_init
+ *
+ * Description:
+ * This function initializes the web server and should be called at system
+ * boot-up.
*
- * This function initializes the web server and should be
- * called at system boot-up.
- */
+ ****************************************************************************/
void httpd_init(void)
{