On Fri, 2014-01-17 at 10:08 -0600, Joel Sherrill wrote:
> The network-demos do not build now due to API changes
> in mghttpd.
> 
> I don't have time to fix this in the next week.
> 
> Nick updated Mongoose so probably knows what has to be
> updated.

The attached patch *might* do the trick and at least shows the gist of
what would need to happen... The http part at least now compiles, but
these changes are otherwise untested.

> FWIW they are easy to build... build RTEMS with something like this:
> 
> ../rtems/configure --target=${CPU}-rtems4.11 --enable-rtemsbsp=${BSP} \
>   --enable-posix \
>   --enable-networking \
>   --disable-smp \
>   ${DEBUG} \
>   --enable-maintainer-mode \
>   --prefix=/home/joel/rtems-4.11-work/bsp-install \
>   ${TESTS} >c.log 2>&1 && \
> make -j6  >b.log 2>&1
> 
> Then build network-demos like this:
> 
> RTEMS_MAKEFILE_PATH=/home/joel/rtems-4.11-work/bsp-install/sparc-rtems4.11/sis
> make clean all
-- 
Nick Withers

Embedded Systems Programmer
Room 2.26, Building 57
Department of Nuclear Physics
Research School of Physics and Engineering
The Australian National University (CRICOS: 00120C)

eMail: nick.with...@anu.edu.au
Phone: +61 2 6125 2091
Mobile: +61 414 397 446

> On 1/17/2014 9:08 AM, Gedare Bloom wrote:
> > the top 4 commits at
> > https://github.com/chirayudesai/rtems-network-demos/commits/osmonweb
> > appear to be the ones to look at / test.
> >
> > On Fri, Jan 17, 2014 at 10:01 AM, Joel Sherrill
> > <joel.sherr...@oarcorp.com> wrote:
> >> Where is the patch so I can review it?
> >>
> >> On 1/17/2014 8:29 AM, Gedare Bloom wrote:
> >>> Hi,
> >>> I won't support this relocation until the build is confirmed. Thanks!
> >>>
> >>> On Sat, Jan 11, 2014 at 5:34 AM, Chirayu Desai <chirayudes...@gmail.com> 
> >>> wrote:
> >>>> I have moved oswebmonitor to network-demos, preserving commit history.
> >>>> The content of the repository osmonweb.git has been added to a new 
> >>>> directory
> >>>> osmonweb.
> >>>> The tree can be browsed at [1].
> >>>>
> >>>> All commits but the last 2 don't touch anything in the topdir, only add /
> >>>> modify content under the osmonweb directory.
> >>>>
> >>>> It does not build with 4.11 (didn't before this merge, like I said in the
> >>>> original message), and I do not have 4.10 built and installed currently, 
> >>>> so
> >>>> as of now it is untested.
> >>>> I will test it by later today / tomorrow if time permits.
> >>>>
> >>>> Also, looks like the code under http/ (in network-demos) is for "test of
> >>>> GoAhead web server", which is deprecated, so it doesn't build with 4.11
> >>>>
> >>>> [1]: https://github.com/chirayudesai/rtems-network-demos
> >>>>
> >>>>
> >>>> On Tue, Jan 7, 2014 at 2:16 PM, Nick Withers <n...@nickwithers.com> 
> >>>> wrote:
> >>>>> On Mon, 2014-01-06 at 09:44 -0600, Joel Sherrill wrote:
> >>>>>> On 1/5/2014 5:41 AM, Nick Withers wrote:
> >>>>>>> On Sun, 2014-01-05 at 12:01 +0530, Chirayu Desai wrote:
> >>>>>>>> I've uploaded two patches for oswebmonitor, [1] and [2]
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> [1] fixes a minor issue with bin2c being installed as rtems-bin2c
> >>>>>>> I thought that was on purpose...? Not sure it should be installed as
> >>>>>>> bin2c, as that could clash with a host binary.
> >>>>>>>
> >>>>>>> Are there actually any RTEMS-specifics in rtems-bin2c?
> >>>>>> No. It just wasn't packaged and it is a commonly needed utility when
> >>>>>> building
> >>>>>> up filesystem images.
> >>>>> Yeah, fair enough (I'm using it myself).
> >>>>>
> >>>>> It doesn't seem to be packaged on either FreeBSD or Ubuntu, otherwise I
> >>>>> was gonna suggest removing it in favour of the host binary (which still
> >>>>> seems like it'd be optimal in the ideal world).
> >>>>>
> >>>>> P.S., Cheers for the earlier clarification Chirayu :-)
> >>>>>
> >>>>>>>> [2] removes support for GoAhead
> >>>>>>>>
> >>>>>>>> [1]:
> >>>>>>>> https://gist.github.com/chirayudesai/d8e72a999cb02e2d9dcd/raw/a869794c687cfbf9575efe8195245a7a4ac8992d/0001-make-bin2c-is-installed-as-rtems-bin2c.patch
> >>>>>>>> [2]:
> >>>>>>>> https://gist.github.com/chirayudesai/d8e72a999cb02e2d9dcd/raw/55b65f128daf2ad532e83b6d44b976de51cae64c/0001-remove-support-for-GoAhead.patch
> >>>>> --
> >>>>> Nick Withers
> >>>>> email: n...@nickwithers.com
> >>>>> Web: http://www.nickwithers.com
> >>>>> Mobile: +61 414 397 446
> >>>>>
> >>>>> _______________________________________________
> >>>>> rtems-devel mailing list
> >>>>> rtems-devel@rtems.org
> >>>>> http://www.rtems.org/mailman/listinfo/rtems-devel
> >>>>
> >>>> _______________________________________________
> >>>> rtems-devel mailing list
> >>>> rtems-devel@rtems.org
> >>>> http://www.rtems.org/mailman/listinfo/rtems-devel
> >>>>
> >> --
> >> Joel Sherrill, Ph.D.             Director of Research & Development
> >> joel.sherr...@oarcorp.com        On-Line Applications Research
> >> Ask me about RTEMS: a free RTOS  Huntsville AL 35805
> >> Support Available                (256) 722-9985

>From b7776a67257a3e03527ff3651b862ca6eb926fec Mon Sep 17 00:00:00 2001
From: Nick Withers <nick.with...@anu.edu.au>
Date: Sat, 18 Jan 2014 16:09:52 +1100
Subject: [PATCH] Update for Mongoose 3.9.

http/ compiles but the change is otherwise totally untested
---
 http/init.c         | 26 +++++++++++++++++---------
 http/mongoose_ext.c | 34 +++++++++++++++++++---------------
 2 files changed, 36 insertions(+), 24 deletions(-)

diff --git a/http/init.c b/http/init.c
index ff2d847..86a8f13 100644
--- a/http/init.c
+++ b/http/init.c
@@ -83,8 +83,8 @@
 #if defined(USE_MONGOOSE_HTTPD)
   #include <mghttpd/mongoose.h>
 
-  void example_mongoose_addpages(
-    struct mg_context *server
+  int example_mongoose_callback(
+    struct mg_connection *conn
   );
 #endif
 
@@ -111,7 +111,9 @@ rtems_task Init(
    */
   printf("Loading filesystem image\n");
   status = Untar_FromMemory( (char *)FilesystemImage, FilesystemImage_size );
-   
+  if ( status != RTEMS_SUCCESSFUL )
+    printf( "ERROR -- failed to untar filesystem\n" );
+
   printf("Initializing Network\n");
   rtems_bsdnet_initialize_network ();
 
@@ -153,14 +155,20 @@ rtems_task Init(
 
   #if defined(USE_MONGOOSE_HTTPD)
     {
-      struct mg_context *WebServer;
-      printf( "Initializing Mongoose HTTPD\n" );
-      WebServer = mg_start();
+      struct mg_context   *WebServer;
+      struct mg_callbacks callbacks = {NULL};
+      const char          *options[] = {
+        "document_root",            "/",
+        "listening_ports",          "80",
+        NULL
+      };
 
-      mg_set_option(WebServer, "root", "/" );
-      mg_set_option(WebServer, "ports", "80" );
-      example_mongoose_addpages( WebServer );
+      callbacks.begin_request = example_mongoose_callback;
 
+      printf( "Initializing Mongoose HTTPD\n" );
+      WebServer = mg_start(&callbacks, NULL, options);
+      if ( WebServer == NULL )
+        printf( "ERROR -- failed to initialize webserver\n" );
     }
   #endif
   status = rtems_task_delete( RTEMS_SELF );
diff --git a/http/mongoose_ext.c b/http/mongoose_ext.c
index 9545059..1751399 100644
--- a/http/mongoose_ext.c
+++ b/http/mongoose_ext.c
@@ -20,17 +20,26 @@
 #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
+int example_mongoose_callback(
+  struct mg_connection *conn
 )
 {
-  const char *query;
+  static const char query_uri_start[] = "/queries";
 
-  query = mg_get_var(conn, "action" );
-  if ( !query )
-    query = "";
+  const struct mg_request_info *request_info = mg_get_request_info(conn);
+  char query[256] = ""; // Arbitrarily sized...
+
+  if (request_info == NULL)
+    return (0); // Return 0 to have Mongoose process the request
+
+  if (strncmp(request_info->uri, query_uri_start, strlen(query_uri_start)) != 0)
+    return (0);
+
+  if (request_info->query_string)
+  {
+    if (mg_get_var(request_info->query_string, strlen(request_info->query_string), "action", query, sizeof (query)) < 0)
+      *query = '\0';
+  }
   /* fprintf( stderr, "RTEMS Request -%s-\n", query ); */
 
   mg_printf( conn, START_HTML_BODY "<pre>" );
@@ -57,19 +66,14 @@ void example_mongoose_callback(
       " <h2>Unknown Request</h2>"
       " <h3>URI: %s</br>"
       "  Arguments: %s</h3>",
-      mg_get_var(conn, "REQUEST_URI"),
+      request_info->uri != NULL ? request_info->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 );
+  return (1);
 }
 
 #endif
-- 
1.8.5.2

_______________________________________________
rtems-devel mailing list
rtems-devel@rtems.org
http://www.rtems.org/mailman/listinfo/rtems-devel

Reply via email to