Index: http/ChangeLog
===================================================================
--- http/ChangeLog	(revision 6ecabe8cc7158bb86de5e1252db735e74a30d1d2)
+++ http/ChangeLog	(revision 0fe6b0d99b3ac102a1c4e6adbe2e54a290e5a5ba)
@@ -1,2 +1,8 @@
+2009-11-23	Joel Sherrill <joel.sherrill@oarcorp.com>
+
+	* Makefile, goahead_index.html, init.c, shttpd_ext.c,
+	shttpd_index.html: Add Mongoose HTTPD support.
+	* mongoose_ext.c, mongoose_index.html: New files.
+
 2009-05-13	Joel Sherrill <joel.sherrill@oarcorp.com>
 
Index: http/Makefile
===================================================================
--- http/Makefile	(revision 6ecabe8cc7158bb86de5e1252db735e74a30d1d2)
+++ http/Makefile	(revision 0fe6b0d99b3ac102a1c4e6adbe2e54a290e5a5ba)
@@ -9,5 +9,5 @@
 
 # C source names, if any, go here -- minus the .c
-C_PIECES=init FilesystemImage shttpd_ext
+C_PIECES=init FilesystemImage shttpd_ext mongoose_ext
 C_FILES=$(C_PIECES:%=%.c)
 C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
@@ -43,5 +43,6 @@
 ## FYI GoAhead requires POSIX to be enabled
 USE_GOAHEAD=no
-USE_SIMPLE=yes
+USE_SIMPLE=no
+USE_MONGOOSE=yes
 USE_FTPD=yes
 ifeq ($(USE_GOAHEAD),yes)
@@ -55,4 +56,10 @@
   CFLAGS   += -DUSE_SIMPLE_HTTPD
   override LD_LIBS  += -lshttpd
+endif
+
+ifeq ($(USE_MONGOOSE),yes)
+  HTTPD     = Mongoose HTTPD Web Server
+  CFLAGS   += -DUSE_MONGOOSE_HTTPD
+  override LD_LIBS  += -lmghttpd
 endif
 
@@ -88,5 +95,5 @@
 	$(PROJECT_ROOT)/bin/rtems-bin2c FilesystemImage FilesystemImage
 
-rootfs/index.html: shttpd_index.html goahead_index.html 
+rootfs/index.html: shttpd_index.html goahead_index.html mongoose_index.html
 ifeq ($(USE_SIMPLE),yes)
 	cp shttpd_index.html rootfs/index.html
@@ -94,4 +101,7 @@
 ifeq ($(USE_GOHEAD),yes)
 	cp goahead_index.html rootfs/index.html
+endif
+ifeq ($(USE_MONGOOSE),yes)
+	cp mongoose_index.html rootfs/index.html
 endif
 
Index: http/goahead_index.html
===================================================================
--- http/goahead_index.html	(revision 6ecabe8cc7158bb86de5e1252db735e74a30d1d2)
+++ http/goahead_index.html	(revision 0fe6b0d99b3ac102a1c4e6adbe2e54a290e5a5ba)
@@ -1,4 +1,4 @@
 <HTML>
-<HEAD><TITLE>RTEMS @SERVER@ Test Page</TITLE></HEAD>
+<HEAD><TITLE>RTEMS GoAhead Test Page</TITLE></HEAD>
 <BODY BGCOLOR="FFFFFF">
 <center>
Index: http/init.c
===================================================================
--- http/init.c	(revision 6ecabe8cc7158bb86de5e1252db735e74a30d1d2)
+++ http/init.c	(revision 0fe6b0d99b3ac102a1c4e6adbe2e54a290e5a5ba)
@@ -81,4 +81,12 @@
 #else
   bool Simple_HTTPD_enabled = false;
+#endif
+
+#if defined(USE_MONGOOSE_HTTPD)
+  #include <mghttpd/mongoose.h>
+
+  void example_mongoose_addpages(
+    struct mg_context *server
+  );
 #endif
 
@@ -146,4 +154,16 @@
   #endif
 
+  #if defined(USE_MONGOOSE_HTTPD)
+    {
+      struct mg_context *WebServer;
+      printf( "Initializing Mongoose HTTPD\n" );
+      WebServer = mg_start();
+
+      mg_set_option(WebServer, "root", "/" );
+      mg_set_option(WebServer, "ports", "80" );
+      example_mongoose_addpages( WebServer );
+
+    }
+  #endif
   status = rtems_task_delete( RTEMS_SELF );
 }
@@ -163,4 +183,12 @@
 #define CONFIGURE_MAXIMUM_TASKS		20
 
+#if defined(USE_MONGOOSE_HTTPD)
+#define CONFIGURE_MAXIMUM_POSIX_THREADS 10
+#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 30
+#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 10
+#define CONFIGURE_MINIMUM_TASK_STACK_SIZE (32 * 1024)
+#define CONFIGURE_UNIFIED_WORK_AREAS
+#endif
+
 #define CONFIGURE_MICROSECONDS_PER_TICK	10000
 
Index: http/mongoose_ext.c
===================================================================
--- http/mongoose_ext.c	(revision 0fe6b0d99b3ac102a1c4e6adbe2e54a290e5a5ba)
+++ http/mongoose_ext.c	(revision 0fe6b0d99b3ac102a1c4e6adbe2e54a290e5a5ba)
@@ -0,0 +1,77 @@
+/*  SHTTPD Extensions
+ *
+ *  $Id$
+ */
+
+
+#if defined(USE_MONGOOSE_HTTPD)
+
+#include <rtems.h>
+#include <stdio.h>
+#include <mghttpd/mongoose.h>
+#include <rtems/cpuuse.h>
+#include <rtems/stackchk.h>
+
+#include <stdio.h>
+
+#define START_HTML_BODY \
+      "HTTP/1.1 200 OK\r\n" \
+      "Content-Type: text/html\r\n\r\n" \
+      "<html><body>\r\n"
+
+#define END_HTML_BODY \
+      "</html></body>\r\n"
+
+void example_mongoose_callback(
+  struct mg_connection         *conn,
+  const struct mg_request_info *request_info,
+  void                         *user_data
+)
+{
+  const char *query;
+
+  query = mg_get_var(conn, "action" );
+  if ( !query )
+    query = "";
+  /* fprintf( stderr, "RTEMS Request -%s-\n", query ); */
+
+  mg_printf( conn, START_HTML_BODY "<pre>" );
+  if ( !strcmp( query, "cpuuse_report" ) ) {
+    rtems_cpu_usage_report_with_plugin(
+      conn,
+      (rtems_printk_plugin_t) mg_printf
+    );
+  } else if ( !strcmp( query, "cpuuse_reset" ) ) {
+    rtems_cpu_usage_reset();
+    mg_printf(
+      conn,
+      " <p><big>CPU Usage data reset -- return to the previous page</big></p>"
+    );
+  } else if ( !strcmp( query, "stackuse_report" ) ) {
+    rtems_stack_checker_report_usage_with_plugin(
+      conn,
+      (rtems_printk_plugin_t) mg_printf
+    );
+  } else {
+    mg_printf(
+      conn,
+      START_HTML_BODY
+      " <h2>Unknown Request</h2>"
+      " <h3>URI: %s</br>"
+      "  Arguments: %s</h3>",
+      mg_get_var(conn, "REQUEST_URI"),
+      query
+    );
+  }
+  mg_printf( conn, "</pre>" END_HTML_BODY );
+  /*arg->flags |= SHTTPD_END_OF_OUTPUT; */
+}
+
+void example_mongoose_addpages(
+  struct mg_context *server
+)
+{
+  mg_set_uri_callback( server, "/queries*", example_mongoose_callback, NULL );
+}
+
+#endif
Index: http/mongoose_index.html
===================================================================
--- http/mongoose_index.html	(revision 0fe6b0d99b3ac102a1c4e6adbe2e54a290e5a5ba)
+++ http/mongoose_index.html	(revision 0fe6b0d99b3ac102a1c4e6adbe2e54a290e5a5ba)
@@ -0,0 +1,22 @@
+<HTML>
+<HEAD><TITLE>RTEMS Mongoose Server Test Page</TITLE></HEAD>
+<BODY BGCOLOR="FFFFFF">
+<center>
+<H1>RTEMS Mongoose Test Page</H1>
+</center>
+<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 Mongoose webserver running on RTEMS.</big></P>
+</P>
+This RTEMS program includes some dynamic web pages.  Check
+out the following links for examples:
+</P>
+<UL>
+  <LI><A HREF="queries?action=cpuuse_report">CPU Usage -- Report</LI>
+  <LI><A HREF="queries?action=cpuuse_reset">CPU Usage -- Reset</LI>
+  <LI><A HREF="queries?action=stackuse_report">Stack Usage -- Report</LI>
+</UL>
+
+</BODY></HTML>
Index: http/shttpd_ext.c
===================================================================
--- http/shttpd_ext.c	(revision 6ecabe8cc7158bb86de5e1252db735e74a30d1d2)
+++ http/shttpd_ext.c	(revision 0fe6b0d99b3ac102a1c4e6adbe2e54a290e5a5ba)
@@ -31,8 +31,11 @@
 
   if ( !strcmp( query, "cpuuse_report" ) ) {
+
+    shttpd_printf( arg, "<pre>" );
     rtems_cpu_usage_report_with_plugin(
       arg,
       (rtems_printk_plugin_t) shttpd_printf
     );
+    shttpd_printf( arg, "</pre>" );
   } else if ( !strcmp( query, "cpuuse_reset" ) ) {
     rtems_cpu_usage_reset();
@@ -44,8 +47,10 @@
     );
   } else if ( !strcmp( query, "stackuse_report" ) ) {
+    shttpd_printf( arg, "<pre>" );
     rtems_stack_checker_report_usage_with_plugin(
       arg,
       (rtems_printk_plugin_t) shttpd_printf
     );
+    shttpd_printf( arg, "</pre>" );
   } else {
     shttpd_printf(
Index: http/shttpd_index.html
===================================================================
--- http/shttpd_index.html	(revision 6ecabe8cc7158bb86de5e1252db735e74a30d1d2)
+++ http/shttpd_index.html	(revision 0fe6b0d99b3ac102a1c4e6adbe2e54a290e5a5ba)
@@ -30,5 +30,4 @@
   <LI><A HREF="queries?stackuse_report">Stack Usage -- Report</LI>
 </UL>
-</big>
 
 </BODY></HTML>
