diff --git a/ChangeLog b/ChangeLog
index 1ae0fd8ffb6..97f299ae93b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -820,3 +820,9 @@
when creating test threads (16Kb stacksize). The stack size should
be controlled by the .config file or the OSTest won't work on platforms
with memory constraints.
+ * netutils/thttpd: An initial port of Jef Poskanzer's THTTPD HTPPD server.
+ See http://acme.com/software/thttpd/.
+ * examples/thttpd: A basic test program for THTTPD
+ * configs/eagle100/thttpd: A build configuration for THTTPD on the Micromint
+ Eagle-100 LMS6918 (Cortex-M3) board.
+
diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html
index a8a546ca0f3..e0a815934a0 100644
--- a/Documentation/NuttX.html
+++ b/Documentation/NuttX.html
@@ -8,7 +8,7 @@
NuttX RTOS
- Last Updated: July 13, 2009
+ Last Updated: July 18, 2009
|
@@ -1493,6 +1493,11 @@ nuttx-0.4.10 2009-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
when creating test threads (16Kb stacksize). The stack size should
be controlled by the .config file or the OSTest won't work on platforms
with memory constraints.
+ * netutils/thttpd: An initial port of Jef Poskanzer's THTTPD HTPPD server.
+ See http://acme.com/software/thttpd/.
+ * examples/thttpd: A basic test program for THTTPD
+ * configs/eagle100/thttpd: A build configuration for THTTPD on the Micromint
+ Eagle-100 LMS6918 (Cortex-M3) board.
nuttx-0.4.10 2009-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
diff --git a/Makefile b/Makefile
index c0b73406f8b..eba340467ec 100644
--- a/Makefile
+++ b/Makefile
@@ -116,7 +116,7 @@ endif
# Add libraries for network support
ifeq ($(CONFIG_NET),y)
-LINKLIBS += net/libnet$(LIBEXT) netutils/libnetutils$(LIBEXT) netutils/libthttpd$(LIBEXT)
+LINKLIBS += net/libnet$(LIBEXT) netutils/libnetutils$(LIBEXT)
endif
# Add libraries for file system support
@@ -226,9 +226,6 @@ net/libnet$(LIBEXT): context
netutils/libnetutils$(LIBEXT): context
@$(MAKE) -C netutils TOPDIR="$(TOPDIR)" libnetutils$(LIBEXT)
-netutils/libthttpd$(LIBEXT): context
- @$(MAKE) -C netutils TOPDIR="$(TOPDIR)" libthttpd$(LIBEXT)
-
fs/libfs$(LIBEXT): context
@$(MAKE) -C fs TOPDIR="$(TOPDIR)" libfs$(LIBEXT)
diff --git a/configs/eagle100/thttpd/defconfig b/configs/eagle100/thttpd/defconfig
index 49dd962c932..e6ca1ba7a86 100644
--- a/configs/eagle100/thttpd/defconfig
+++ b/configs/eagle100/thttpd/defconfig
@@ -254,7 +254,7 @@ CONFIG_HAVE_LIBM=n
# desciptors by task_create() when a new task is started. If
# set, all sockets will appear to be closed in the new task.
#
-CONFIG_EXAMPLE=nxflat
+CONFIG_EXAMPLE=thttpd
CONFIG_DEBUG=n
CONFIG_DEBUG_VERBOSE=n
CONFIG_DEBUG_NET=y
@@ -556,6 +556,13 @@ CONFIG_THTTPD_TILDE_MAP2=n
CONFIG_THTTPD_GENERATE_INDICES=n
CONFIG_THTTPD_URLPATTERN=n
+#
+# Additional settings for examples/thttpd
+#
+CONFIG_EXAMPLE_THTTPD_NOMAC=n
+CONFIG_EXAMPLE_THTTPD_DRIPADDR=(10<<24|0<<16|0<<8|1)
+CONFIG_EXAMPLE_THTTPD_NETMASK=(255<<24|255<<16|255<<8|0)
+
#
# Settings for examples/uip
#
diff --git a/examples/README.txt b/examples/README.txt
index e228de2070a..78d5ca764bc 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -293,6 +293,17 @@ examples/serloop
Use C buffered I/O (getchar/putchar) vs. raw console I/O
(read/read).
+examples/thttpd
+^^^^^^^^^^^^^^^
+
+ An example that builds netutils/thttpd with some simple NXFLAT
+ CGI programs. see configs/README.txt for most THTTPD settings.
+ In addition to those, this example accepts:
+
+ CONFIG_EXAMPLE_THTTPD_NOMAC - (May be defined to use software assigned MAC)
+ CONFIG_EXAMPLE_THTTPD_DRIPADDR - Default router IP addess
+ CONFIG_EXAMPLE_THTTPD_NETMASK - Network mask
+
examples/udp
^^^^^^^^^^^^
diff --git a/examples/thttpd/Makefile b/examples/thttpd/Makefile
new file mode 100644
index 00000000000..321cccde53e
--- /dev/null
+++ b/examples/thttpd/Makefile
@@ -0,0 +1,75 @@
+############################################################################
+# examples/thttpd/Makefile
+#
+# Copyright (C) 2009 Gregory Nutt. All rights reserved.
+# Author: Gregory Nutt
+#
+# 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
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# 3. Neither the name NuttX nor the names of its contributors may be
+# used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# 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.
+#
+############################################################################
+
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+
+ASRCS =
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+CSRCS = main.c
+COBJS = $(CSRCS:.c=$(OBJEXT))
+
+SRCS = $(ASRCS) $(CSRCS)
+OBJS = $(AOBJS) $(COBJS)
+
+BIN = lib$(CONFIG_EXAMPLE)$(LIBEXT)
+
+all: $(BIN)
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+$(BIN): $(OBJS)
+ @( for obj in $(OBJS) ; do \
+ $(call ARCHIVE, $@, $${obj}); \
+ done ; )
+
+.depend: Makefile $(SRCS)
+ @$(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
+ @touch $@
+
+depend: .depend
+
+clean:
+ @rm -f $(BIN) *~ .*.swp
+ $(call CLEAN)
+
+distclean: clean
+ @rm -f Make.dep .depend
+
+-include Make.dep
diff --git a/examples/thttpd/main.c b/examples/thttpd/main.c
new file mode 100644
index 00000000000..93596a3a192
--- /dev/null
+++ b/examples/thttpd/main.c
@@ -0,0 +1,135 @@
+/****************************************************************************
+ * examples/thttpd/main.c
+ *
+ * Copyright (C) 2009 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * 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
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name Gregory Nutt nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * 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
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+/****************************************************************************
+ * Definitions
+ ****************************************************************************/
+
+#ifdef CONFIG_CPP_HAVE_VARARGS
+# ifdef CONFIG_DEBUG
+# define message(...) lib_lowprintf(__VA_ARGS__)
+# else
+# define message(...) printf(__VA_ARGS__)
+# endif
+#else
+# ifdef CONFIG_DEBUG
+# define message lib_lowprintf
+# else
+# define message (void)
+# endif
+#endif
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * user_initialize
+ ****************************************************************************/
+
+#ifndef CONFIG_HAVE_WEAKFUNCTIONS
+void user_initialize(void)
+{
+ /* Stub that must be provided only if the toolchain does not support weak
+ * functions.
+ */
+}
+#endif
+
+/****************************************************************************
+ * user_start
+ ****************************************************************************/
+
+int user_start(int argc, char *argv[])
+{
+ struct in_addr addr;
+#ifdef CONFIG_EXAMPLE_UIP_NOMAC
+ uint8 mac[IFHWADDRLEN];
+#endif
+ char *thttpd_argv = "thttpd";
+
+/* Many embedded network interfaces must have a software assigned MAC */
+
+#ifdef CONFIG_EXAMPLE_UIP_NOMAC
+ mac[0] = 0x00;
+ mac[1] = 0xe0;
+ mac[2] = 0xb0;
+ mac[3] = 0x0b;
+ mac[4] = 0xba;
+ mac[5] = 0xbe;
+ uip_setmacaddr("eth0", mac);
+#endif
+
+ /* Set up our host address */
+
+ addr.s_addr = HTONL(CONFIG_THTTPD_IPADDR);
+ uip_sethostaddr("eth0", &addr);
+
+ /* Set up the default router address */
+
+ addr.s_addr = HTONL(CONFIG_EXAMPLE_THTTPD_DRIPADDR);
+ uip_setdraddr("eth0", &addr);
+
+ /* Setup the subnet mask */
+
+ addr.s_addr = HTONL(CONFIG_EXAMPLE_THTTPD_NETMASK);
+ uip_setnetmask("eth0", &addr);
+
+
+ printf("Starting THTTPD\n");
+ thttpd_main(1, &thttpd_argv);
+ return 0;
+}
diff --git a/netutils/Makefile b/netutils/Makefile
index a7a9ec2ac01..9f95a7d22af 100644
--- a/netutils/Makefile
+++ b/netutils/Makefile
@@ -42,6 +42,7 @@ include smtp/Make.defs
include telnetd/Make.defs
include webclient/Make.defs
include webserver/Make.defs
+include thttpd/Make.defs
endif
ifeq ($(CONFIG_NET_UDP),y)
include dhcpc/Make.defs
@@ -53,16 +54,16 @@ endif
endif
endif
-SUBDIRS = uiplib dhcpc dhcpd resolv smtp telnetd webclient webserver tftpc
+SUBDIRS = uiplib dhcpc dhcpd resolv smtp telnetd webclient webserver tftpc thttpd
ASRCS = $(UIPLIB_ASRCS) $(DHCPC_ASRCS) $(DHCPD_ASRCS) $(RESOLV_ASRCS) \
$(SMTP_ASRCS) $(TELNETD_ASRCS) $(WEBCLIENT_ASRCS) $(WEBSERVER_ASRCS) \
- $(TFTPC_ASRCS)
+ $(TFTPC_ASRCS) $(THTTPD_ASRCS)
AOBJS = $(ASRCS:.S=$(OBJEXT))
CSRCS = $(UIPLIB_CSRCS) $(DHCPC_CSRCS) $(DHCPD_CSRCS) $(RESOLV_CSRCS) \
$(SMTP_CSRCS) $(TELNETD_CSRCS) $(WEBCLIENT_CSRCS) $(WEBSERVER_CSRCS) \
- $(TFTPC_CSRCS)
+ $(TFTPC_CSRCS) $(THTTPD_CSRCS)
COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS)
@@ -70,9 +71,9 @@ OBJS = $(AOBJS) $(COBJS)
BIN = libnetutils$(LIBEXT)
-VPATH = uiplib:dhcpc:dhcpd:resolv:smtp:telnetd:webclient:webserver:tftpc
+VPATH = uiplib:dhcpc:dhcpd:resolv:smtp:telnetd:webclient:webserver:tftpc:thttpd
-all: $(BIN) libthttpd$(LIBEXT)
+all: $(BIN)
$(AOBJS): %$(OBJEXT): %.S
$(call ASSEMBLE, $<, $@)
@@ -85,17 +86,12 @@ $(BIN): $(OBJS)
$(call ARCHIVE, $@, $${obj}); \
done ; )
-thttpd/libthttpd$(LIBEXT):
- @$(MAKE) -C thttpd libthttpd$(LIBEXT) TOPDIR="$(TOPDIR)"
-
-libthttpd$(LIBEXT): thttpd/libthttpd$(LIBEXT)
- @cp -a thttpd/libthttpd$(LIBEXT) .
-
.depend: Makefile $(SRCS)
+ @$(MAKE) -C thttpd all TOPDIR="$(TOPDIR)"
ifeq ($(CONFIG_NET),y)
@$(MKDEP) --dep-path . --dep-path uiplib --dep-path dhcpc --dep-path dhcpd \
- --dep-path smtp --dep-path webclient --dep-path resolv \
- --dep-path telnetd --dep-path webserver --dep-path tftpc \
+ --dep-path smtp --dep-path webclient --dep-path resolv --dep-path telnetd \
+ --dep-path webserver --dep-path tftpc --dep-path thttpd \
$(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
endif
@touch $@
@@ -104,7 +100,7 @@ depend: .depend
@$(MAKE) -C thttpd depend TOPDIR="$(TOPDIR)"
clean:
- @rm -f $(BIN) libthttpd$(LIBEXT) *~ .*.swp
+ @rm -f $(BIN) *~ .*.swp
$(call CLEAN)
@( for dir in $(SUBDIRS); do \
rm -f $${dir}/*~ $${dir}/.*.swp; \
diff --git a/netutils/README b/netutils/README
index 2f30bb48f73..a28270715ea 100644
--- a/netutils/README
+++ b/netutils/README
@@ -18,4 +18,7 @@ highly influenced by uIP) include:
dhcpd - Dynamic Host Configuration Protocol (DHCP) server
tftpc - TFTP client
+ thttpd - This is a port of Jef Poskanzer's THTTPD HTPPD server.
+ See http://acme.com/software/thttpd/.
+
diff --git a/netutils/thttpd/Make.defs b/netutils/thttpd/Make.defs
new file mode 100644
index 00000000000..a80d36abfe6
--- /dev/null
+++ b/netutils/thttpd/Make.defs
@@ -0,0 +1,38 @@
+############################################################################
+# netutils/thttpd/Make.defs
+#
+# Copyright (C) 2009 Gregory Nutt. All rights reserved.
+# Author: Gregory Nutt
+#
+# 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
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# 3. Neither the name NuttX nor the names of its contributors may be
+# used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# 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.
+#
+############################################################################
+
+THTTPD_ASRCS =
+THTTPD_CSRCS = thttpd.c libhttpd.c timers.c fdwatch.c tdate_parse.c
+
diff --git a/netutils/thttpd/Makefile b/netutils/thttpd/Makefile
index 6ff882dc455..f317e40a74d 100644
--- a/netutils/thttpd/Makefile
+++ b/netutils/thttpd/Makefile
@@ -47,29 +47,8 @@ SUBDIR_BIN3 = ssi
SUBDIR_BIN += cgi-bin/$(SUBDIR_BIN1) cgi-bin/$(SUBDIR_BIN2) cgi-bin/$(SUBDIR_BIN3)
endif
-ASRCS =
-AOBJS = $(ASRCS:.S=$(OBJEXT))
-
-CSRCS = thttpd.c libhttpd.c timers.c fdwatch.c tdate_parse.c
-COBJS = $(CSRCS:.c=$(OBJEXT))
-
-SRCS = $(ASRCS) $(CSRCS)
-OBJS = $(AOBJS) $(COBJS)
-
-BIN = libthttpd$(LIBEXT)
-
-all: $(BIN) $(SUBDIR_BIN)
-
-$(AOBJS): %$(OBJEXT): %.S
- $(call ASSEMBLE, $<, $@)
-
-$(COBJS): %$(OBJEXT): %.c
- $(call COMPILE, $<, $@)
-
-$(BIN): $(OBJS)
- @( for obj in $(OBJS) ; do \
- $(call ARCHIVE, $@, $${obj}); \
- done ; )
+all: $(SUBDIR_BIN)
+.PHONY: depend clean distclean
ifeq ($(CONFIG_NXFLAT),y)
cgi-bin:
@@ -94,22 +73,15 @@ cgi-bin/$(SUBDIR_BIN3): cgi-bin cgi-src/$(SUBDIR_BIN3)
@cp -a cgi-src/$(SUBDIR_BIN3) $@
endif
-.depend: Makefile $(SRCS)
- @$(MKDEP) --dep-path . $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
- @touch $@
-
-depend: .depend
+depend:
clean:
- @rm -f $(BIN) *~ .*.swp
+ @rm -f *~ .*.swp
@rm -rf cgi-bin
- $(call CLEAN)
- @( for dir in $(SUBDIRS); do \
- rm -f $${dir}/*~ $${dir}/.*.swp; \
- done ; )
+ @$(MAKE) -C cgi-src clean
distclean: clean
- @rm -f Make.dep .depend
+ @$(MAKE) -C cgi-src distclean
-include Make.dep
diff --git a/netutils/thttpd/cgi-src/phf.c b/netutils/thttpd/cgi-src/phf.c
index a108468a83d..2541481c4c9 100644
--- a/netutils/thttpd/cgi-src/phf.c
+++ b/netutils/thttpd/cgi-src/phf.c
@@ -63,7 +63,7 @@ int main(int argc, char *argv[])
{
fprintf(stderr, "phf CGI probe from %s\n", getenv("REMOTE_ADDR"));
- (void)printf("\
+ (void)printf("\
Content-type: text/html\n\
Status: 404/html\n\
\n\
@@ -73,7 +73,5 @@ The requested object does not exist on this server.\n\
The link you followed is either outdated, inaccurate,\n\
or the server has been instructed not to let you have it.\n\