mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
Add framework for THTTPD example
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1989 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
+10
-14
@@ -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; \
|
||||
|
||||
@@ -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/.
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
############################################################################
|
||||
# netutils/thttpd/Make.defs
|
||||
#
|
||||
# Copyright (C) 2009 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# 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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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\
|
||||
</BODY></HTML>\n");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -869,7 +869,7 @@ static void read_file(FILE *instream, char *vfilename, char *filename)
|
||||
break;
|
||||
}
|
||||
|
||||
putcchar((char)ich);
|
||||
putchar((char)ich);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -892,7 +892,7 @@ int main(int argc, char **argv)
|
||||
|
||||
/* The MIME type has to be text/html. */
|
||||
|
||||
(voidfputs("Content-type: text/html\n\n");
|
||||
(void)puts("Content-type: text/html\n\n");
|
||||
|
||||
/* Get the name that we were run as. */
|
||||
|
||||
|
||||
@@ -743,6 +743,9 @@ int thttpd_main(int argc, char **argv)
|
||||
struct sockaddr_in sa;
|
||||
#endif
|
||||
struct timeval tv;
|
||||
#ifdef CONFIG_THTTPD_DIR
|
||||
int ret;
|
||||
#endif
|
||||
|
||||
/* Setup host address */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user