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/Makefile | 25 ++++++++-------- nuttx/netutils/webserver/httpd.c | 61 +++++++++++++++++++++++++++++++--------- 2 files changed, 60 insertions(+), 26 deletions(-) (limited to 'nuttx/netutils') diff --git a/nuttx/netutils/Makefile b/nuttx/netutils/Makefile index 9c4536ff0..3232dd5f2 100644 --- a/nuttx/netutils/Makefile +++ b/nuttx/netutils/Makefile @@ -72,38 +72,39 @@ $(COBJS): %$(OBJEXT): %.c $(CC) -c $(CFLAGS) $< -o $@ $(BIN): $(OBJS) - ( for obj in $(OBJS) ; do \ + @( for obj in $(OBJS) ; do \ $(AR) $@ $${obj} || \ { echo "$(AR) $@ $obj FAILED!" ; exit 1 ; } ; \ done ; ) makestrings$(EXEEXT): uiplib/makestrings.c - gcc -O2 -Wall -o makestrings$(EXEEXT) uiplib/makestrings.c + @gcc -O2 -Wall $< -o $@ .strings: makestrings$(EXEEXT) uiplib/netutil-strings - ./makestrings uiplib/netutil-strings + @./makestrings uiplib/netutil-strings + @touch $@ Make.str: makestrings$(EXEEXT) uiplib/netutil-strings - ./makestrings -s uiplib/netutil-strings >Make.str + @./makestrings -s uiplib/netutil-strings >Make.str .depend: Makefile $(SRCS) ifeq ($(CONFIG_NET),y) - $(MKDEP) --dep-path . --dep-path uiplib --dep-path dhcpc --dep-path smtp --dep-path webclient \ + @$(MKDEP) --dep-path . --dep-path uiplib --dep-path dhcpc --dep-path smtp --dep-path webclient \ --dep-path resolv --dep-path telnetd --dep-path webserver \ $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep endif - touch $@ + @touch $@ depend: .strings Make.str .depend clean: - rm -f $(BIN) *.o *.rel *.asm *.lst *.sym *.adb *~ - rm -f uiplib/*~ dhcpc/*~ resolv/*~ smtp/*~ telnetd/*~ webclient/*~ webserver/*~ - if [ ! -z "$(OBJEXT)" ]; then rm -f *$(OBJEXT); fi + @rm -f $(BIN) *.o *.rel *.asm *.lst *.sym *.adb *~ + @rm -f uiplib/*~ dhcpc/*~ resolv/*~ smtp/*~ telnetd/*~ webclient/*~ webserver/*~ + @if [ ! -z "$(OBJEXT)" ]; then rm -f *$(OBJEXT); fi distclean: clean - rm -f Make.dep .depend - rm -f $(STRNG_CSRCS) $(STRNG_ASRCS) - rm -f Make.str netutil-strings.h makestrings$(EXEEXT) + @rm -f Make.dep .depend + @rm -f $(STRNG_CSRCS) $(STRNG_ASRCS) + @rm -f Make.str netutil-strings.h makestrings$(EXEEXT) -include Make.dep 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