From 7326b1166b618ddc6b3eb9e9224b1f5ded5515a5 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 23 Sep 2007 20:45:30 +0000 Subject: Partial implementation of accept() and listen() git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@354 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/netutils/webserver/httpd.c | 61 +++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 14 deletions(-) (limited to 'nuttx/netutils/webserver/httpd.c') 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 * - * 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 * - * Copyright (c) 2004, Adam Dunkels. - * All rights reserved. + * This is a leverage of similar logic from uIP: + * + * Author: Adam Dunkels + * 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 #include +#include #include #include @@ -44,7 +56,9 @@ #include "httpd-cgi.h" #include "netutil-strings.h" -#include +/**************************************************************************** + * 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) { -- cgit v1.2.3