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:
patacongo
2009-07-18 19:47:08 +00:00
parent 8c17e7f6d0
commit 22fa6bdfb3
14 changed files with 306 additions and 60 deletions
+38
View File
@@ -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
+6 -34
View File
@@ -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
+2 -4
View File
@@ -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;
}
+2 -2
View File
@@ -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. */
+3
View File
@@ -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 */