summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2007-07-12 19:05:08 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2007-07-12 19:05:08 +0000
commitd51420e73bb4a1998a0ebf130ecd4aae2f12c0ab (patch)
treeeef7d0150989978a75ebac8686dd8f824cae0995
parent2007-07-11 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadnetwork-demos-d51420e73bb4a1998a0ebf130ecd4aae2f12c0ab.tar.bz2
2007-07-12 Joel Sherrill <joel.sherrill@oarcorp.com>
* ChangeLog, Makefile, init.c: No switchable from GoAhead to SHTTPD but defaults to SHTTPD. The displayed index.html will indicate which httpd implementation is enabled. The user should edit the Makefile to switch settings. * index.html.in: New file. * rootfs/index.html: Removed.
-rw-r--r--http/ChangeLog18
-rw-r--r--http/Makefile45
-rw-r--r--http/index.html.in (renamed from http/rootfs/index.html)6
-rw-r--r--http/init.c96
4 files changed, 125 insertions, 40 deletions
diff --git a/http/ChangeLog b/http/ChangeLog
index 991fd24..6afe83c 100644
--- a/http/ChangeLog
+++ b/http/ChangeLog
@@ -1,3 +1,21 @@
+2007-07-12 Joel Sherrill <joel.sherrill@oarcorp.com>
+
+ * ChangeLog, Makefile, init.c: No switchable from GoAhead to SHTTPD but
+ defaults to SHTTPD. The displayed index.html will indicate which
+ httpd implementation is enabled. The user should edit the Makefile to
+ switch settings.
+ * index.html.in: New file.
+ * rootfs/index.html: Removed.
+
+2007-07-12 Joel Sherrill <joel.sherrill@oarcorp.com>
+
+ * Makefile, init.c: No switchable from GoAhead to SHTTPD but defaults
+ to SHTTPD. The displayed index.html will indicate which httpd
+ implementation is enabled. The user should edit the Makefile to
+ switch settings.
+ * index.html.in: New file.
+ * rootfs/index.html: Removed.
+
2007-07-11 Joel Sherrill <joel.sherrill@oarcorp.com>
* Makefile: Make slightly smarter on LD arguments. Do not pick
diff --git a/http/Makefile b/http/Makefile
index 0c092f1..3265b73 100644
--- a/http/Makefile
+++ b/http/Makefile
@@ -18,7 +18,7 @@ DOCTYPES=
DOCS=$(DOCTYPES:%=$(SAMPLE).%)
SRCS=$(DOCS) $(C_FILES) $(CC_FILES) $(H_FILES) $(S_FILES)
-OBJS=$(C_O_FILES) $(CC_O_FILES) $(S_O_FILES)
+OBJS=$(C_O_FILES) $(CC_O_FILES) $(S_O_FILES) $(ARCH)/tarfile.o
PRINT_SRCS=$(DOCS)
@@ -34,17 +34,35 @@ include $(PROJECT_ROOT)/make/leaf.cfg
DEFINES +=
CPPFLAGS +=
-CFLAGS += -DWEBS -DUEMF
CFLAGS_LD += -Wl,--defsym -Wl,HeapSize=0xC0000
CFLAGS_OPTIMIZE_V +=
CFLAGS_DEBUG_V += -v -qrtems_debug
LD_PATHS +=
-LD_LIBS += -lhttpd
-LD_LIBS += -lftpd
+
#NATIVE_OBJ = $(shell $(OBJCOPY) 2>&1 | grep copy: | cut -d':' -f3 | cut -d' ' -f2)
OBJDUMP=$(OBJCOPY:copy=dump)
+USE_GOHEAD=no
+USE_SIMPLE=yes
+USE_FTPD=yes
+ifeq ($(USE_GOHEAD),yes)
+ HTTPD = GoAhead Web Server
+ CFLAGS += -DWEBS -DUEMF -DUSE_GOAHEAD_HTTPD
+ LD_LIBS += -lhttpd
+endif
+
+ifeq ($(USE_SIMPLE),yes)
+ HTTPD = Simple HTTPD Web Server
+ CFLAGS += -DUSE_SIMPLE_HTTPD
+ LD_LIBS += -lshttpd
+endif
+
+ifeq ($(USE_FTPD),yes)
+ CFLAGS += -DUSE_FTPD
+ LD_LIBS += -lftpd
+endif
+
#
# Add your list of files to delete here. The config files
# already know how to delete some stuff, so you may want
@@ -52,7 +70,7 @@ OBJDUMP=$(OBJCOPY:copy=dump)
# 'make clobber' already includes 'make clean'
#
-CLEAN_ADDITIONS += tarfile obj_format
+CLEAN_ADDITIONS += tarfile obj_format stamp-index-html rootfs/index.html
CLOBBER_ADDITIONS +=
# strip out flags gcc knows but LD doesn't like -- add as needed
@@ -64,15 +82,20 @@ obj_format:
$(OBJDUMP) -f $(ARCH)/init.o | grep .o: | \
sed -e 's/^.*format //' >obj_format
-${PGM}: $(OBJS) obj_format $(LINK_FILES)
+${PGM}: $(OBJS) $(LINK_FILES)
+ $(make-exe)
+
+$(ARCH)/tarfile.o: $(ARCH) stamp-index-html obj_format
cd rootfs ; tar cf ../$(ARCH)/tarfile --exclude CVS .
cp $(ARCH)/tarfile .
$(OBJCOPY) -I binary -O `cat obj_format` tarfile $(ARCH)/tarfile.o
- $(LD) $(LD_CPU_CFLAGS) -r -o $(ARCH)/temp.o \
- $(ARCH)/init.o $(ARCH)/tarfile.o
- $(MV) $(ARCH)/temp.o $(ARCH)/init.o
- $(RM) $(ARCH)/temp.o
- $(make-exe)
+ $(LD) $(LD_CPU_CFLAGS) -r -o $(ARCH)/temp.o $(ARCH)/tarfile.o
+
+stamp-index-html: index.html.in
+ifneq ($(HTTPD),)
+ sed -e 's/@SERVER@/$(HTTPD)/' <index.html.in >rootfs/index.html
+endif
+ touch stamp-index-html
# Install the program(s), appending _g or _p as appropriate.
# for include files, just use $(INSTALL)
diff --git a/http/rootfs/index.html b/http/index.html.in
index 2642b58..9c14022 100644
--- a/http/rootfs/index.html
+++ b/http/index.html.in
@@ -1,12 +1,12 @@
<HTML>
-<HEAD><TITLE>RTEMS GoAhead Test Page</TITLE></HEAD>
+<HEAD><TITLE>RTEMS @SERVER@ Test Page</TITLE></HEAD>
<BODY BGCOLOR="FFFFFF">
<center>
-<H1>RTEMS GoAhead Web Server Test Page</H1>
+<H1>RTEMS @SERVER@ Test Page</H1>
<A HREF="http://www.rtems.org">
<IMG align=center BORDER=0 SRC="rtems_logo.jpg" ALT="RTEMS"> </A>
<P><big>Congratulations, you have successfully loaded your first page
-from the GoAhead Web Server running on RTEMS.</big></P>
+from the @SERVER@ running on RTEMS.</big></P>
</center>
</BODY></HTML>
diff --git a/http/init.c b/http/init.c
index f70cfee..86ee455 100644
--- a/http/init.c
+++ b/http/init.c
@@ -5,10 +5,6 @@
* Don't forget to change the IP addresses
*/
-#define USE_HTTPD
-#define USE_FTPD
-#define TEST_INIT
-
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
@@ -72,20 +68,39 @@ extern int SYM(binary_tarfile_size);
#define TARFILE_SIZE SYM(binary_tarfile_size)
#if defined(USE_FTPD)
-struct rtems_ftpd_configuration rtems_ftpd_configuration = {
- 10, /* FTPD task priority */
- 1024, /* Maximum buffersize for hooks */
- 21, /* Well-known port */
- NULL /* List of hooks */
-};
+ boolean FTPD_enabled = TRUE;
+ struct rtems_ftpd_configuration rtems_ftpd_configuration = {
+ 10, /* FTPD task priority */
+ 1024, /* Maximum buffersize for hooks */
+ 21, /* Well-known port */
+ NULL /* List of hooks */
+ };
+#else
+ boolean FTPD_enabled = FALSE;
#endif
-/* GoAhead Trace Handler */
-#include <goahead/uemf.h>
-void quietTraceHandler(int level, char *buf)
-{
- /* do nothing */
-}
+#if defined(USE_GOAHEAD_HTTPD)
+ boolean GoAhead_HTTPD_enabled = TRUE;
+
+ /* GoAhead Trace Handler */
+ #include <goahead/uemf.h>
+ void quietTraceHandler(int level, char *buf)
+ {
+ /* do nothing */
+ }
+#else
+ boolean GoAhead_HTTPD_enabled = FALSE;
+#endif
+
+#if defined(USE_SIMPLE_HTTPD)
+ boolean Simple_HTTPD_enabled = TRUE;
+
+ #include <shttpd/shttpd.h>
+#else
+ boolean Simple_HTTPD_enabled = FALSE;
+#endif
+
+#define bool2string(_b) ((_b) ? "true" : "false")
rtems_task Init(
rtems_task_argument argument
@@ -94,20 +109,49 @@ rtems_task Init(
rtems_status_code status;
printf("\n\n*** HTTP TEST ***\n\r" );
-
+ printf("GoAhead HTTPD Enabled: %s\n", bool2string(GoAhead_HTTPD_enabled) );
+ printf("Simple HTTPD Enabled: %s\n", bool2string(Simple_HTTPD_enabled) );
+ printf("FTPD Enabled: %s\n", bool2string(FTPD_enabled) );
+ printf("\n");
+
+ /*
+ * Load filesystem image
+ */
+ printf("Loading filesystem image");
status = Untar_FromMemory((void *)(&TARFILE_START), (size_t)&TARFILE_SIZE);
+ printf("Initializing Network");
rtems_bsdnet_initialize_network ();
-#if defined(USE_FTPD)
- rtems_initialize_ftpd();
-#endif
-#if defined(USE_HTTPD)
- if ( rtems_initialize_webserver() )
- printf( "ERROR -- failed to initialize webserver\n" );
-
- traceSetHandler( quietTraceHandler );
-#endif
+ #if defined(USE_FTPD)
+ printf( "Initializing FTPD\n" );
+ rtems_initialize_ftpd();
+ #endif
+
+ #if defined(USE_GOAHEAD_HTTPD)
+ printf( "Initializing GoAhead HTTPD\n" );
+ status = rtems_initialize_webserver();
+ if ( status )
+ printf( "ERROR -- failed to initialize webserver\n" );
+
+ traceSetHandler( quietTraceHandler );
+ #endif
+
+ #if defined(USE_SIMPLE_HTTPD)
+ printf( "Initializing Simple HTTPD\n" );
+ status = rtems_initialize_webserver(
+ 100, /* initial priority */
+ RTEMS_MINIMUM_STACK_SIZE * 2, /* stack size */
+ RTEMS_DEFAULT_MODES, /* initial modes */
+ RTEMS_DEFAULT_ATTRIBUTES, /* attributes */
+ NULL, /* init_callback */
+ NULL, /* addpages_callback */
+ "/" /* initial priority */
+ );
+ if ( status )
+ printf( "ERROR -- failed to initialize webserver\n" );
+
+ #endif
status = rtems_task_delete( RTEMS_SELF );
}