First version of WWW gateway with embedded Tcl.
[egate.git] / www / wsh.c
index f36d42e..4bd4257 100644 (file)
--- a/www/wsh.c
+++ b/www/wsh.c
  * USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  * $Log: wsh.c,v $
- * Revision 1.1  1995/10/20 11:49:28  adam
+ * Revision 1.2  1995/10/20 14:02:42  adam
+ * First version of WWW gateway with embedded Tcl.
+ *
+ * Revision 1.1  1995/10/20  11:49:28  adam
  * First version of www gateway.
  *
  */
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <strings.h>
+#include <string.h>
 #include <assert.h>
 #include <unistd.h>
 #include <ctype.h>
 
-#include "wproto.h"
+#include "winterp.h"
 
-#define TIMEOUT_SHORT 300
+#define TIMEOUT_SHORT 60
 #define TIMEOUT_MEDIUM 1800
 #define TIMEOUT_LONG 7200
 
@@ -64,8 +67,9 @@ static char *mod = "wsh";
 
 int main (int argc, char **argv)
 {
-    char *argument, *p, parms[512];
+    char *script, *p, parms[512];
     int timeout = TIMEOUT_SHORT;
+    W_Interp tcl_interp, html_interp;
 
     chdir("/usr/local/etc/httpd/cgi-bin");
     gw_log_init ("egw");
@@ -78,20 +82,28 @@ int main (int argc, char **argv)
        gw_log (GW_LOG_FATAL, mod, "init");
        exit(1);
     }
+    tcl_interp = w_interp_create (w_interp_tcl, NULL);
+    html_interp = w_interp_create (w_interp_html, NULL);
     while (wproto_process(wcl, timeout) > 0)
     {
        wo_clear(wcl, "text/html");
-       wo_printf(wcl, "<HTML><TITLE>INDEX</TITLE>\n");
        strcpy(parms, wcl->wf_parms);
-       argument = p = parms;
+       script = p = parms;
        while (*p && *p != '/')
            p++;
        if (*p == '/')
            *(p++) = '\0';
-       gw_log (GW_LOG_DEBUG, mod, "command: %s", argument);
-        wo_printf (wcl, "<BODY>hej - %s</BODY>\n", argument);
+       gw_log (GW_LOG_DEBUG, mod, "script: %s", script);
+       gw_log (GW_LOG_DEBUG, mod, "parms: %s", p);
+        if (w_interp_exec (tcl_interp, wcl, script, p))
+        {
+            wo_printf (wcl, "<html><head><title>wsh error</title></head>\n");
+            wo_printf (wcl, "<body>Couldn't execute script %s</body></html>",
+                       script);
+        }
        wo_finish(wcl);
     }
     wproto_terminate(wcl);
     return 0;
 }
+