Added some initial z39 gateway scripts.
[egate.git] / www / whtml.c
index 3c1e080..e111ee5 100644 (file)
  * USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  * $Log: whtml.c,v $
- * Revision 1.1  1995/10/20 14:02:41  adam
+ * Revision 1.2  1995/10/23 16:55:37  adam
+ * A lot of changes - really.
+ *
+ * Revision 1.1  1995/10/20  14:02:41  adam
  * First version of WWW gateway with embedded Tcl.
  *
  */
@@ -55,8 +58,8 @@
 #include "wproto.h"
 #include "winterp.h"
 
-static void *do_create (void *args);
-static int do_exec (WCLIENT wcl, const char *fname, char *parms, void *mydata);
+static void *do_create (WCLIENT wcl, void *args);
+static int do_exec (const char *fname, char *parms, void *mydata);
 
 static struct w_interp_type w_interp_t = {
     "html",
@@ -68,14 +71,28 @@ W_Interp_Type w_interp_html = &w_interp_t;
 
 static char *mod = "whtml";
 
-static void *do_create (void *args)
+struct html_info {
+    WCLIENT wcl;
+};
+
+static void *do_create (WCLIENT wcl, void *args)
 {
-    return NULL;
+    struct html_info *p;
+
+    p = malloc (sizeof(*p));
+    if (!p)
+    {
+        gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, mod, "malloc: html_info");
+        exit (1);
+    }
+    p->wcl = wcl;
+    return p;
 }
 
-static int do_exec (WCLIENT wcl, const char *fname, char *parms, void *mydata)
+static int do_exec (const char *fname, char *parms, void *mydata)
 {
     int c;
+    struct html_info *p = mydata;
     FILE *inf = fopen (fname, "r");
 
     gw_log (GW_LOG_DEBUG, mod, "executing %s", fname);
@@ -85,7 +102,7 @@ static int do_exec (WCLIENT wcl, const char *fname, char *parms, void *mydata)
         return -1;
     }
     while ((c = getc (inf)) != EOF)
-        wo_putc (wcl, c);
+        wo_putc (p->wcl, c);
     fclose (inf);
     return 0;
 }