Minor changes.
[egate.git] / www / wwaistcl.c
1 /*
2  * NWI - Nordic Web Index 
3  * Technical Knowledge Centre & Library of Denmark (DTV)
4  *
5  * Wais extension to Europagate/IrTcl
6  *
7  * $Log: wwaistcl.c,v $
8  * Revision 1.1  1996/02/29 15:32:21  adam
9  * First kick of NWI extension to the Europgate WWW-Z39.50 gateway.
10  *
11  */
12
13 #include <log.h>
14 #include "wirtcl.h"
15 #include "wwaistcl.h"
16
17 static void *do_create (WCLIENT wcl, void *args);
18 static int do_exec (const char *fname, char *parms, void *mydata);
19 static int do_load (char *parms, void *mydata);
20 static int do_save (char *parms, void *mydata);
21
22 static struct w_interp_type w_interp_t = {
23     "waistcl",
24     do_create,
25     do_exec,
26     do_load,
27     do_save
28 };
29
30 W_Interp_Type w_interp_waistcl = &w_interp_t;
31
32 static char *mod = "wwaistcl";
33
34 struct waistcl_info {
35     W_Interp w_interp;
36     Tcl_Interp *interp;
37     WCLIENT wcl;
38 };
39
40 static void *do_create (WCLIENT wcl, void *args)
41 {
42     struct waistcl_info *p;
43
44     if (!(p = malloc (sizeof(*p))))
45     {
46         gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, mod, "malloc: waistcl_info");
47         exit (1);
48     }
49     if (!(p->w_interp = w_interp_create (w_interp_irtcl, wcl, NULL)))
50     {
51         gw_log (GW_LOG_FATAL, mod, "Cannot make IrTcl_Interp");
52         exit (1);
53     }
54     p->wcl = wcl;
55     p->interp = w_interp_irtcl_get (p->w_interp);
56     if (Waistcl_Init(p->interp) == TCL_ERROR)
57     {
58         gw_log (GW_LOG_FATAL, mod, "Cannot make Waistcl_Interp");
59         exit (1);
60     }
61     return p;
62 }
63
64 static int do_exec (const char *fname, char *parms, void *mydata)
65 {
66     struct waistcl_info *p = mydata;
67     int r;
68     if ((r = w_interp_exec (p->w_interp, fname, parms)))
69         return r;
70     return 0;
71 }
72
73 static int do_load (char *parms, void *mydata)
74 {
75     struct waistcl_info *p = mydata;
76
77     return w_interp_load_state (p->w_interp, parms);
78 }
79
80 static int do_save (char *parms, void *mydata)
81 {
82     struct waistcl_info *p = mydata;
83
84     return w_interp_save_state (p->w_interp, parms);
85 }
86
87
88
89