Oopps... take #2. Sent out the wrong patch file, should be this one.



-- 
Øyvind Harboe
http://www.zylin.com - eCos ARM & FPGA  developer kit
### Eclipse Workspace Patch 1.0
#P ecos
Index: net/athttpd/current/doc/athttpd.sgml
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/athttpd/current/doc/athttpd.sgml,v
retrieving revision 1.5
diff -u -r1.5 athttpd.sgml
--- net/athttpd/current/doc/athttpd.sgml        12 Nov 2007 11:32:02 -0000      
1.5
+++ net/athttpd/current/doc/athttpd.sgml        12 Nov 2007 15:20:46 -0000
@@ -365,6 +365,40 @@
 </sect2>
 </sect1>
 
+
+<title>tcl hello world</title>
+<sect3 id="athttpd-tcl-hello-world">
+<title>end_chunked</title>
+<programlisting width=72>
+#This will replace print /ram/log as a valid html file w/replacing \n 
w/&lt;br&gt;
+#log.tcl
+start_chunked "html";
+
+set fp [aio.open "/ram/log" r];
+$fp seek 0 end;
+set fsize [$fp tell];
+$fp seek 0 start;
+set data "abcxxx";
+set data [$fp read $fsize];
+$fp close;
+set data [string map {\n <br>} $data];
+
+set datax "";
+append datax "<html><body>" $data "</body></html>";
+
+write_chunked $datax;
+end_chunked;
+</programlisting>
+<para>
+The above is an example of how to convert a log file in /ram/log to
+HTML code. Copy the log.tcl above to a file system on your embedded 
+target and navigate to http://10.0.0.66/cgi-bin/hello.tcl. The tcl script 
+is then executed, where 10.0.0.66 is the IP and "cgi-bin" is the cgi-bin
+directory.
+</para>
+</sect3>
+
+
 <sect1 id="athttpd-authentication">
 <title>Authentication</title>
 <para>
Index: net/athttpd/current/src/forms.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/athttpd/current/src/forms.c,v
retrieving revision 1.3
diff -u -r1.3 forms.c
--- net/athttpd/current/src/forms.c     27 Nov 2006 15:41:56 -0000      1.3
+++ net/athttpd/current/src/forms.c     12 Nov 2007 15:20:46 -0000
@@ -252,16 +252,6 @@
     if (httpstate.mode & CYG_HTTPD_MODE_FORM_DATA)
         cyg_httpd_store_form_data(httpstate.post_data);
 
-    handler h = cyg_httpd_find_handler();
-    if (h != 0)
-    {
-        // A handler was found. We'll call the function associated to it.
-        h(&httpstate);
-        free(httpstate.post_data);
-        httpstate.post_data = NULL;
-        return;
-    }
-
 #if defined(CYGOPT_NET_ATHTTPD_USE_CGIBIN_OBJLOADER) || \
                            defined(CYGOPT_NET_ATHTTPD_USE_CGIBIN_TCL)
     // See if we are trying to execute a CGI via one of the supported methods.
@@ -282,6 +272,17 @@
         return;
     }
 #endif    
+    
+    handler h = cyg_httpd_find_handler();
+    if (h != 0)
+    {
+        // A handler was found. We'll call the function associated to it.
+        h(&httpstate);
+        free(httpstate.post_data);
+        httpstate.post_data = NULL;
+        return;
+    }
+
 
     // No handler of any kind for a post request. Must send 404.
     cyg_httpd_send_error(CYG_HTTPD_STATUS_NOT_FOUND);
Index: net/athttpd/current/src/http.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/athttpd/current/src/http.c,v
retrieving revision 1.3
diff -u -r1.3 http.c
--- net/athttpd/current/src/http.c      27 Nov 2006 15:41:56 -0000      1.3
+++ net/athttpd/current/src/http.c      12 Nov 2007 15:20:47 -0000
@@ -708,15 +708,7 @@
 void
 cyg_httpd_handle_method_GET(void)
 {
-    // Use defined handlers take precedence over other forms of response.
-    handler h = cyg_httpd_find_handler();
-    if (h != 0)
-    {
-        h(&httpstate);
-        return;
-    }
-    
-#ifdef CYGOPT_NET_ATHTTPD_USE_CGIBIN_OBJLOADER
+#if defined(CYGOPT_NET_ATHTTPD_USE_CGIBIN_OBJLOADER) || 
defined(CYGOPT_NET_ATHTTPD_USE_CGIBIN_TCL)
     // If the URL is a CGI script, there is a different directory...
     if (httpstate.url[0] == '/' &&
                     !strncmp(httpstate.url + 1, 
@@ -730,6 +722,15 @@
     //  will likely generate a 404.
 #endif    
 
+    // Use defined handlers take precedence over other forms of response.
+    handler h = cyg_httpd_find_handler();
+    if (h != 0)
+    {
+        h(&httpstate);
+        return;
+    }
+    
+
 #ifdef CYGOPT_NET_ATHTTPD_USE_FS
     // No handler, we'll redirect to the file system.
     cyg_httpd_send_file(httpstate.url);
@@ -940,28 +941,28 @@
             }
             else if (strncasecmp(p, "Digest", 6) == 0)
             {
-                p += 6;
-                while (*p == ' ')
-                   p++;
+                p += 6;
+                while (*p == ' ')
+                   p++;
                 while ((*p != '\r') && (*p != '\n'))
-                {
-                    if (strncasecmp(p, "realm=", 6) == 0)
+                {
+                    if (strncasecmp(p, "realm=", 6) == 0)
                         p = cyg_httpd_digest_skip(p + 6);
-                    else if (strncasecmp(p, "username=", 9) == 0)
+                    else if (strncasecmp(p, "username=", 9) == 0)
                         p = cyg_httpd_digest_skip(p + 9);
                     else if (strncasecmp(p, "nonce=", 6) == 0)
                         p = cyg_httpd_digest_skip(p + 6);
-                    else if (strncasecmp(p, "response=", 9) == 0)
+                    else if (strncasecmp(p, "response=", 9) == 0)
                         p = cyg_httpd_digest_data(cyg_httpd_md5_response, 
                                                   p + 9);
-                    else if (strncasecmp(p, "cnonce=", 7) == 0)
+                    else if (strncasecmp(p, "cnonce=", 7) == 0)
                         p = cyg_httpd_digest_data(cyg_httpd_md5_cnonce, p + 7);
-                    else if (strncasecmp(p, "qop=", 4) == 0)
+                    else if (strncasecmp(p, "qop=", 4) == 0)
                         p = cyg_httpd_digest_skip(p + 4);
-                    else if (strncasecmp(p, "nc=", 3) == 0)
+                    else if (strncasecmp(p, "nc=", 3) == 0)
                         p = cyg_httpd_digest_data(cyg_httpd_md5_noncecount, 
                                                   p + 3);
-                    else if (strncasecmp(p, "algorithm=", 10) == 0)
+                    else if (strncasecmp(p, "algorithm=", 10) == 0)
                         p = cyg_httpd_digest_skip(p + 10);
                     else if (strncasecmp(p, "opaque=", 7) == 0)
                         p = cyg_httpd_digest_skip(p + 7);
Index: net/athttpd/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/athttpd/current/ChangeLog,v
retrieving revision 1.8
diff -u -r1.8 ChangeLog
--- net/athttpd/current/ChangeLog       12 Nov 2007 13:33:12 -0000      1.8
+++ net/athttpd/current/ChangeLog       12 Nov 2007 15:20:45 -0000
@@ -1,7 +1,12 @@
 2007-11-12  Oyvind Harboe  <[EMAIL PROTECTED]>
 
+       * doc/athttpd.sgml: added an example of a tcl script.
+       * src/http.c, forms.c: serve cgi requests before file system requests, 
that 
+       way it isn't possible to download the actual cgi/.o script and cgi works
+       even if the http root directory is above the cgi directory.   
+       * src/http.c: if only tcl cgi is enabled, cgi requests are now 
forwarded to tcl
        * include/jim.h: include file order fix; now compiles again.
-       * doc/athttpd.cdl: Fixed typos in doc. Return value from handler is not 
+       * doc/athttpd.sgml: Fixed typos in doc. Return value from handler is 
not 
        used, recommend returning 0 in doc.
 
 2006-12-03  Anthony Tonizzo  <[EMAIL PROTECTED]>

Reply via email to