From a6f3beb071fe8c894ee6c846c86296c84f48e3d4 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 27 Oct 1995 15:12:02 +0000 Subject: [PATCH] IrTcl incorporated in the gateway. Better separation of script types. Z39.50 gateway scripts entered. --- www/Makefile | 18 ++++- www/egwindex.html | 4 +- www/query.egw | 41 ++++++---- www/targets.egw | 15 +++- www/whtml.c | 10 ++- www/whtml.h | 58 ++++++++++++++ www/winterp.h | 10 ++- www/wirtcl.c | 224 +++++++++++++++++++++++++++++++++++++++++++++++++++++ www/wirtcl.h | 60 ++++++++++++++ www/wproto.c | 9 ++- www/wproto.h | 17 +++- www/wsh.c | 15 +++- www/wtcl.c | 60 ++++++++++---- www/wtcl.h | 61 +++++++++++++++ www/ztargets.conf | 8 +- 15 files changed, 560 insertions(+), 50 deletions(-) create mode 100644 www/whtml.h create mode 100644 www/wirtcl.c create mode 100644 www/wirtcl.h create mode 100644 www/wtcl.h diff --git a/www/Makefile b/www/Makefile index 8d73a0e..e2efd2b 100644 --- a/www/Makefile +++ b/www/Makefile @@ -2,7 +2,12 @@ # Europagate, 1995 # # $Log: Makefile,v $ -# Revision 1.4 1995/10/23 17:04:16 adam +# Revision 1.5 1995/10/27 15:12:02 adam +# IrTcl incorporated in the gateway. +# Better separation of script types. +# Z39.50 gateway scripts entered. +# +# Revision 1.4 1995/10/23 17:04:16 adam # Added some initial z39 gateway scripts. # # Revision 1.3 1995/10/23 16:55:33 adam @@ -16,9 +21,13 @@ # SHELL=/bin/sh INCLUDE=-I../include +# +MOSILIB=../../xtimosi/src/libmosi.a ../../yaz/lib/librfc.a +LIBIRTCL=/usr/local/lib/libirtcl.a ../../yaz/lib/libyaz.a $(MOSILIB) +# #CFLAGS=-g -Wall -pedantic -ansi OLIB=../lib/libres+log.a -TCLLIB=/usr/local/lib/libtcl7.5.a +TCLLIB=/usr/local/lib/libtcl7.4.a WSCRIPTS=egwscript targets.egw query.egw search.egw HSCRIPTS=egwindex.html CONFFILES=ztargets.conf @@ -27,7 +36,7 @@ TPROG1=egwcgi TPROG2=egwsh TPROG3=wtest P1=wcgi.o -P2=wproto.o winterp.o wsh.o wtcl.o whtml.o +P2=wproto.o winterp.o wsh.o wtcl.o whtml.o wirtcl.o P3=wproto.o wtest.o CPP=$(CC) -E DEFS=$(INCLUDE) @@ -44,7 +53,7 @@ $(TPROG1): $(P1) $(CC) $(CFLAGS) -o $(TPROG1) $(P1) $(OLIB) $(TPROG2): $(P2) - $(CC) $(CFLAGS) -o $(TPROG2) $(P2) $(OLIB) $(TCLLIB) -lm + $(CC) $(CFLAGS) -o $(TPROG2) $(P2) $(OLIB) $(LIBIRTCL) $(TCLLIB) -lm $(TPROG3): $(P3) $(CC) $(CFLAGS) -o $(TPROG3) $(P3) $(OLIB) @@ -56,6 +65,7 @@ install: $(TPROG1) $(TPROG2) chmod +x $(CGIBIN)/$$x; \ done; \ ln -f $(CGIBIN)/$(TPROG2) $(CGIBIN)/egwtcl; \ + ln -f $(CGIBIN)/$(TPROG2) $(CGIBIN)/egwirtcl; \ ln -f $(CGIBIN)/$(TPROG2) $(CGIBIN)/egwhtml @for x in $(WSCRIPTS); do \ echo Installing $$x; \ diff --git a/www/egwindex.html b/www/egwindex.html index 9f8535f..7aa486f 100644 --- a/www/egwindex.html +++ b/www/egwindex.html @@ -3,13 +3,13 @@ Europagate WWW index -

Europagate WWW index, $Id: egwindex.html,v 1.3 1995/10/23 17:04:16 adam Exp $

+

Europagate WWW index, $Id: egwindex.html,v 1.4 1995/10/27 15:12:04 adam Exp $

egwcgi ref: egwcgi

z39 targets: - targets.egw + targets.egw diff --git a/www/query.egw b/www/query.egw index c1f3b4c..e188c71 100644 --- a/www/query.egw +++ b/www/query.egw @@ -1,25 +1,31 @@ { -# $Id: query.egw,v 1.1 1995/10/23 17:04:16 adam Exp $ - source /usr/local/etc/httpd/conf/ztargets.conf - set tmp [expr 1 + [string first / $sessionParms]] - set t [string range $sessionParms $tmp end] +# $Id: query.egw,v 1.2 1995/10/27 15:12:04 adam Exp $ +proc init-response {} { + global sessionWait + htmlr {Init ok
} + htmlr {} + htmlr {} + set sessionWait 0 +} + + set t $sessionParms set databases [lindex $targets($t) 1] + ir z39 + set sessionWait 1 + z39 connect $t + z39 callback init-response + z39 init } WWW/Z39.50 Gateway Query Form -sessionId: {html $sessionId}
-sessionParms: {html $sessionParms}
-form: {html [form]}
-target: {html $t}
-databases: {html $databases}

Search in databases

Not Functional Yet

-
{ + html {} set nodb [llength $databases] if {$nodb > 1} { if {$nodb > 2} { @@ -86,5 +92,14 @@ This page is maintained by Peter Wad Hansen . Last modified 29. september 1995.
This and the following pages are under construction and will continue to be so until the end of December 1995. - - +
+sessionId: {html $sessionId}
+sessionParms: {html $sessionParms}
+{ + foreach e {SERVER_NAME PATH_INFO SCRIPT_NAME} { + htmlr $e {: } $env($e) {
} + } +} +form: {html [form]}
+target: {html $t}
+databases: {html $databases}
diff --git a/www/targets.egw b/www/targets.egw index 2a64c20..16ad730 100644 --- a/www/targets.egw +++ b/www/targets.egw @@ -1,6 +1,7 @@ { -# $Id: targets.egw,v 1.1 1995/10/23 17:04:17 adam Exp $ +# $Id: targets.egw,v 1.2 1995/10/27 15:12:05 adam Exp $ + source /usr/local/etc/httpd/conf/ztargets.conf } Europagate, WWW/Z39.50 Gateway @@ -22,9 +23,9 @@ Consejo Superior de Investigaciones Científicas
Choose a Z39.50 target:
{ - source /usr/local/etc/httpd/conf/ztargets.conf foreach t [array names targets] { - htmlr "
$t " + html {
} $t {} htmlr "
" [lindex $targets($t) 0] } } @@ -34,5 +35,13 @@ This page is maintained by Peter Wad Hansen . Last modified 25. september 1995.
This and the following pages are under construction and will continue to be so until the end of December 1995. +
+sessionId: {html $sessionId}
+sessionParms: {html $sessionParms}
+{ + foreach e {SERVER_NAME PATH_INFO SCRIPT_NAME} { + htmlr $e {: } $env($e) {
} + } +} diff --git a/www/whtml.c b/www/whtml.c index e111ee5..5a74db3 100644 --- a/www/whtml.c +++ b/www/whtml.c @@ -41,7 +41,12 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. * * $Log: whtml.c,v $ - * Revision 1.2 1995/10/23 16:55:37 adam + * Revision 1.3 1995/10/27 15:12:06 adam + * IrTcl incorporated in the gateway. + * Better separation of script types. + * Z39.50 gateway scripts entered. + * + * 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 @@ -55,8 +60,7 @@ #include #include -#include "wproto.h" -#include "winterp.h" +#include "whtml.h" static void *do_create (WCLIENT wcl, void *args); static int do_exec (const char *fname, char *parms, void *mydata); diff --git a/www/whtml.h b/www/whtml.h new file mode 100644 index 0000000..c97bc4b --- /dev/null +++ b/www/whtml.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 1995, the EUROPAGATE consortium (see below). + * + * The EUROPAGATE consortium members are: + * + * University College Dublin + * Danmarks Teknologiske Videnscenter + * An Chomhairle Leabharlanna + * Consejo Superior de Investigaciones Cientificas + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation, in whole or in part, for any purpose, is hereby granted, + * provided that: + * + * 1. This copyright and permission notice appear in all copies of the + * software and its documentation. Notices of copyright or attribution + * which appear at the beginning of any file must remain unchanged. + * + * 2. The names of EUROPAGATE or the project partners may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * 3. Users of this software (implementors and gateway operators) agree to + * inform the EUROPAGATE consortium of their use of the software. This + * information will be used to evaluate the EUROPAGATE project and the + * software, and to plan further developments. The consortium may use + * the information in later publications. + * + * 4. Users of this software agree to make their best efforts, when + * documenting their use of the software, to acknowledge the EUROPAGATE + * consortium, and the role played by the software in their work. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * IN NO EVENT SHALL THE EUROPAGATE CONSORTIUM OR ITS MEMBERS BE LIABLE + * FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF + * ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA + * OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND + * ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * USE OR PERFORMANCE OF THIS SOFTWARE. + * + * $Log: whtml.h,v $ + * Revision 1.1 1995/10/27 15:12:07 adam + * IrTcl incorporated in the gateway. + * Better separation of script types. + * Z39.50 gateway scripts entered. + * + */ + +#ifndef WHTML_H +#define WHTML_H + +#include "winterp.h" + +W_Interp_Type w_interp_html; + +#endif diff --git a/www/winterp.h b/www/winterp.h index fec5d39..1519e48 100644 --- a/www/winterp.h +++ b/www/winterp.h @@ -41,7 +41,12 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. * * $Log: winterp.h,v $ - * Revision 1.2 1995/10/23 16:55:39 adam + * Revision 1.3 1995/10/27 15:12:07 adam + * IrTcl incorporated in the gateway. + * Better separation of script types. + * Z39.50 gateway scripts entered. + * + * Revision 1.2 1995/10/23 16:55:39 adam * A lot of changes - really. * * Revision 1.1 1995/10/20 14:02:42 adam @@ -69,7 +74,4 @@ W_Interp w_interp_create (W_Interp_Type type, WCLIENT wcl, void *args); #define w_interp_exec(w,f,p) (*(w)->ctrl->exec)((f),(p), (w)->mydata) #define w_interp_name(w) ((w)->ctrl.name) -W_Interp_Type w_interp_tcl; -W_Interp_Type w_interp_html; - #endif diff --git a/www/wirtcl.c b/www/wirtcl.c new file mode 100644 index 0000000..c6548ce --- /dev/null +++ b/www/wirtcl.c @@ -0,0 +1,224 @@ +/* + * Copyright (c) 1995, the EUROPAGATE consortium (see below). + * + * The EUROPAGATE consortium members are: + * + * University College Dublin + * Danmarks Teknologiske Videnscenter + * An Chomhairle Leabharlanna + * Consejo Superior de Investigaciones Cientificas + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation, in whole or in part, for any purpose, is hereby granted, + * provided that: + * + * 1. This copyright and permission notice appear in all copies of the + * software and its documentation. Notices of copyright or attribution + * which appear at the beginning of any file must remain unchanged. + * + * 2. The names of EUROPAGATE or the project partners may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * 3. Users of this software (implementors and gateway operators) agree to + * inform the EUROPAGATE consortium of their use of the software. This + * information will be used to evaluate the EUROPAGATE project and the + * software, and to plan further developments. The consortium may use + * the information in later publications. + * + * 4. Users of this software agree to make their best efforts, when + * documenting their use of the software, to acknowledge the EUROPAGATE + * consortium, and the role played by the software in their work. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * IN NO EVENT SHALL THE EUROPAGATE CONSORTIUM OR ITS MEMBERS BE LIABLE + * FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF + * ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA + * OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND + * ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * USE OR PERFORMANCE OF THIS SOFTWARE. + * + * $Log: wirtcl.c,v $ + * Revision 1.1 1995/10/27 15:12:08 adam + * IrTcl incorporated in the gateway. + * Better separation of script types. + * Z39.50 gateway scripts entered. + * + */ + +#include +#include +#include +#include +#include +#ifdef AIX +#include +#endif +#include +#include +#include + +#include "wtcl.h" +#include "wirtcl.h" + +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 = { + "irtcl", + do_create, + do_exec +}; + +W_Interp_Type w_interp_irtcl = &w_interp_t; + + +static char *mod = "wirtcl"; + +struct tcl_info { + W_Interp w_interp; + Tcl_Interp *interp; + WCLIENT wcl; +}; + +static void *do_create (WCLIENT wcl, void *args) +{ + struct tcl_info *p; + + if (!(p = malloc (sizeof(*p)))) + { + gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, mod, "malloc: irtcl_info"); + exit (1); + } + if (!(p->w_interp = w_interp_create (w_interp_tcl, wcl, NULL))) + { + gw_log (GW_LOG_FATAL, mod, "Cannot make Tcl_Interp"); + exit (1); + } + p->wcl = wcl; + p->interp = w_interp_tcl_get (p->w_interp); + if (Irtcl_Init(p->interp) == TCL_ERROR) + { + gw_log (GW_LOG_FATAL, mod, "Cannot make Irtcl_Interp"); + exit (1); + } + /* initialize irtcl */ + return p; +} + +/* select(2) callbacks */ +struct callback { + void (*r_handle)(ClientData); + void (*w_handle)(ClientData); + void (*x_handle)(ClientData); + void *obj; +}; +#define MAX_CALLBACK 200 + +static struct callback callback_table[MAX_CALLBACK]; +static int max_fd = 3; /* don't worry: it will grow... */ + +static int do_exec (const char *fname, char *parms, void *mydata) +{ + struct tcl_info *p = mydata; + int i, r, min_fd = 0; + const char *cp; + static fd_set fdset_tcl_r; + static fd_set fdset_tcl_w; + static fd_set fdset_tcl_x; + + for (i=0; iw_interp, fname, parms))) + return r; + while (1) + { + FD_ZERO (&fdset_tcl_r); + FD_ZERO (&fdset_tcl_w); + FD_ZERO (&fdset_tcl_x); + for (r=0, i=min_fd; i<=max_fd; i++) + { + if (callback_table[i].w_handle) + { + FD_SET (i, &fdset_tcl_w); + r++; + } + if (callback_table[i].r_handle) + { + FD_SET (i, &fdset_tcl_r); + r++; + } + if (callback_table[i].x_handle) + { + FD_SET (i, &fdset_tcl_x); + r++; + } + } + if (!r) + return 0; + if ((r = select(max_fd+1, &fdset_tcl_r, &fdset_tcl_w, + &fdset_tcl_x, 0)) < 0) + { + perror("select"); + exit(1); + } + if (!r) + continue; + for (i=min_fd; i<=max_fd; i++) + { + if (FD_ISSET (i, &fdset_tcl_r)) + { + assert (callback_table[i].r_handle); + (*callback_table[i].r_handle) (callback_table[i].obj); + } + if (FD_ISSET (i, &fdset_tcl_w)) + { + assert (callback_table[i].w_handle); + (*callback_table[i].w_handle) (callback_table[i].obj); + } + if (FD_ISSET (i, &fdset_tcl_x)) + { + assert (callback_table[i].x_handle); + (*callback_table[i].x_handle) (callback_table[i].obj); + } + } + if ((cp=Tcl_GetVar (p->interp, "sessionWait", 0)) && !strcmp (cp, "0")) + return 0; + } + return 0; +} + +void ir_select_add (int fd, void *obj) +{ + callback_table[fd].obj = obj; + callback_table[fd].r_handle = ir_select_read; + callback_table[fd].w_handle = NULL; + callback_table[fd].x_handle = NULL; + if (fd > max_fd) + max_fd = fd; +} + +void ir_select_add_write (int fd, void *obj) +{ + callback_table[fd].w_handle = ir_select_write; + if (fd > max_fd) + max_fd = fd; +} + +void ir_select_remove_write (int fd, void *obj) +{ + callback_table[fd].w_handle = NULL; +} + +void ir_select_remove (int fd, void *obj) +{ + callback_table[fd].r_handle = NULL; + callback_table[fd].w_handle = NULL; + callback_table[fd].x_handle = NULL; +} diff --git a/www/wirtcl.h b/www/wirtcl.h new file mode 100644 index 0000000..6e158a2 --- /dev/null +++ b/www/wirtcl.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 1995, the EUROPAGATE consortium (see below). + * + * The EUROPAGATE consortium members are: + * + * University College Dublin + * Danmarks Teknologiske Videnscenter + * An Chomhairle Leabharlanna + * Consejo Superior de Investigaciones Cientificas + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation, in whole or in part, for any purpose, is hereby granted, + * provided that: + * + * 1. This copyright and permission notice appear in all copies of the + * software and its documentation. Notices of copyright or attribution + * which appear at the beginning of any file must remain unchanged. + * + * 2. The names of EUROPAGATE or the project partners may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * 3. Users of this software (implementors and gateway operators) agree to + * inform the EUROPAGATE consortium of their use of the software. This + * information will be used to evaluate the EUROPAGATE project and the + * software, and to plan further developments. The consortium may use + * the information in later publications. + * + * 4. Users of this software agree to make their best efforts, when + * documenting their use of the software, to acknowledge the EUROPAGATE + * consortium, and the role played by the software in their work. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * IN NO EVENT SHALL THE EUROPAGATE CONSORTIUM OR ITS MEMBERS BE LIABLE + * FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF + * ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA + * OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND + * ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * USE OR PERFORMANCE OF THIS SOFTWARE. + * + * $Log: wirtcl.h,v $ + * Revision 1.1 1995/10/27 15:12:09 adam + * IrTcl incorporated in the gateway. + * Better separation of script types. + * Z39.50 gateway scripts entered. + * + */ + +#ifndef WIRTCL_H +#define WIRTCL_H + +#include "winterp.h" +#include +#include + +W_Interp_Type w_interp_irtcl; + +#endif diff --git a/www/wproto.c b/www/wproto.c index 1a41b72..a258df9 100644 --- a/www/wproto.c +++ b/www/wproto.c @@ -41,7 +41,12 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. * * $Log: wproto.c,v $ - * Revision 1.2 1995/10/23 16:55:39 adam + * Revision 1.3 1995/10/27 15:12:10 adam + * IrTcl incorporated in the gateway. + * Better separation of script types. + * Z39.50 gateway scripts entered. + * + * Revision 1.2 1995/10/23 16:55:39 adam * A lot of changes - really. * * Revision 1.1 1995/10/20 11:49:26 adam @@ -249,6 +254,7 @@ int wproto_process(WCLIENT wc, int timeout) top = 0; FD_ZERO(&input); FD_SET(wc->linein, &input); + /* go through select handle list */ while ((rs = select(wc->linein + 1, &input, 0, 0, top)) < 0 && errno == EINTR) ; @@ -264,6 +270,7 @@ int wproto_process(WCLIENT wc, int timeout) timeout); return 0; } + /* determine handle (fifo or user) */ if (read(wc->linein, &toread, sizeof(toread)) < sizeof(toread)) { gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, mod, "wp_proc:len read failed"); diff --git a/www/wproto.h b/www/wproto.h index 266a713..8f35e3a 100644 --- a/www/wproto.h +++ b/www/wproto.h @@ -41,7 +41,12 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. * * $Log: wproto.h,v $ - * Revision 1.2 1995/10/23 16:55:41 adam + * Revision 1.3 1995/10/27 15:12:11 adam + * IrTcl incorporated in the gateway. + * Better separation of script types. + * Z39.50 gateway scripts entered. + * + * Revision 1.2 1995/10/23 16:55:41 adam * A lot of changes - really. * * Revision 1.1 1995/10/20 11:49:27 adam @@ -73,6 +78,15 @@ typedef struct cache_data char path[256]; } cache_data; +struct w_select_handle { + int fd; + struct { + void (*sproc)(int, void *); + void *obj; + } rwx[3]; + struct w_select_handle *next; +}; + typedef struct wclient_data { int id; @@ -88,6 +102,7 @@ typedef struct wclient_data int cache_level; cache_data cache[20]; int cache_fd; + struct w_select_handle *select_list; } *WCLIENT, wclient_data; #define wo_putc(wc, ch) \ diff --git a/www/wsh.c b/www/wsh.c index 990d141..a67590a 100644 --- a/www/wsh.c +++ b/www/wsh.c @@ -41,7 +41,12 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. * * $Log: wsh.c,v $ - * Revision 1.3 1995/10/23 16:55:41 adam + * Revision 1.4 1995/10/27 15:12:12 adam + * IrTcl incorporated in the gateway. + * Better separation of script types. + * Z39.50 gateway scripts entered. + * + * Revision 1.3 1995/10/23 16:55:41 adam * A lot of changes - really. * * Revision 1.2 1995/10/20 14:02:42 adam @@ -59,7 +64,9 @@ #include #include -#include "winterp.h" +#include "whtml.h" +#include "wtcl.h" +#include "wirtcl.h" #define TIMEOUT_SHORT 60 #define TIMEOUT_MEDIUM 1800 @@ -88,6 +95,8 @@ int main (int argc, char **argv) gw_log_session (wcl->id); if (!strcmp (*argv, "egwtcl")) w_interp = w_interp_create (w_interp_tcl, wcl, NULL); + else if (!strcmp (*argv, "egwirtcl")) + w_interp = w_interp_create (w_interp_irtcl, wcl, NULL); else if (!strcmp (*argv, "egwhtml")) w_interp = w_interp_create (w_interp_html, wcl, NULL); else @@ -103,7 +112,7 @@ int main (int argc, char **argv) script = parms = parms_buf; while (*parms && *parms != '/') parms++; - if (*parms == '/') + if (*parms) *parms++ = '\0'; if (*script) { diff --git a/www/wtcl.c b/www/wtcl.c index 59fda21..c724b02 100644 --- a/www/wtcl.c +++ b/www/wtcl.c @@ -41,7 +41,12 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. * * $Log: wtcl.c,v $ - * Revision 1.2 1995/10/23 16:55:43 adam + * Revision 1.3 1995/10/27 15:12:14 adam + * IrTcl incorporated in the gateway. + * Better separation of script types. + * Z39.50 gateway scripts entered. + * + * Revision 1.2 1995/10/23 16:55:43 adam * A lot of changes - really. * * Revision 1.1 1995/10/20 14:02:42 adam @@ -55,10 +60,7 @@ #include #include -#include - -#include "wproto.h" -#include "winterp.h" +#include "wtcl.h" static void *do_create (WCLIENT wcl, void *args); static int do_exec (const char *fname, char *parms, void *mydata); @@ -82,13 +84,25 @@ struct tcl_info { WCLIENT wcl; }; +Tcl_Interp *w_interp_tcl_get (W_Interp w_interp) +{ + struct tcl_info *p; + + if (strcmp (w_interp->ctrl->name, "tcl")) + { + gw_log (GW_LOG_FATAL, mod, "Internal failure"); + assert (0); + } + p = (struct tcl_info*) w_interp->mydata; + return p->interp; +} + static int proc_html_invoke (ClientData clientData, Tcl_Interp *interp, int argc, char **argv) { struct tcl_info *p = (struct tcl_info*) clientData; int i; - gw_log (GW_LOG_DEBUG, mod, "proc html"); for (i = 1; iwcl, argv[i]); return TCL_OK; @@ -125,6 +139,13 @@ static int proc_form_invoke (ClientData clientData, Tcl_Interp *interp, return TCL_OK; } +int Tcl_AppInit (Tcl_Interp *interp) +{ + if (Tcl_Init (interp) == TCL_ERROR) + return TCL_ERROR; + return TCL_OK; +} + static void *do_create (WCLIENT wcl, void *args) { struct tcl_info *p; @@ -147,6 +168,7 @@ static void *do_create (WCLIENT wcl, void *args) gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, mod, "malloc: tcl_info fbuf"); exit (1); } + Tcl_AppInit (p->interp); Tcl_CreateCommand (p->interp, "html", proc_html_invoke, p, NULL); Tcl_CreateCommand (p->interp, "htmlr", proc_htmlr_invoke, p, NULL); Tcl_CreateCommand (p->interp, "form", proc_form_invoke, p, NULL); @@ -155,6 +177,15 @@ static void *do_create (WCLIENT wcl, void *args) return p; } +static void report_error (struct tcl_info *p, int errorLine, + const char *pre, const char *msg) +{ + gw_log (GW_LOG_WARN, "%s %d\%s", pre, errorLine, msg); + wo_printf (p->wcl, "\n

\n" + "%s %d
\n", pre, errorLine); + wo_printf (p->wcl, "\n%s\n
\n", msg); +} + static int tcl_exec (const char *fname, char *parms, struct tcl_info *p, FILE *inf, int *lineno) { @@ -162,7 +193,6 @@ static int tcl_exec (const char *fname, char *parms, int r, fbuf_ptr = 0; int local_line = 0; - Tcl_SetVar (p->interp, "sessionParms", p->wcl->wf_parms, TCL_GLOBAL_ONLY); while (1) { if (fbuf_ptr == p->fbuf_size-1) @@ -181,7 +211,8 @@ static int tcl_exec (const char *fname, char *parms, c = getc (inf); if (c == EOF) { - gw_log (GW_LOG_WARN, mod, "Unexpected EOF: unbalanced braces"); + report_error (p, *lineno, "Error in Tcl script starting at line", + "Unexpected EOF (missing right brace)"); return -1; } if (c == '\\') @@ -207,17 +238,15 @@ static int tcl_exec (const char *fname, char *parms, } p->fbuf[fbuf_ptr] = '\0'; r = Tcl_Eval (p->interp, p->fbuf); - if (r != TCL_OK) - { - gw_log (GW_LOG_WARN, mod, "Error in Tcl script starting on line %d", - *lineno); - } + if (r == TCL_ERROR) + report_error (p, p->interp->errorLine + *lineno - 1, + "Error in Tcl script in line", + Tcl_GetVar (p->interp, "errorInfo", 0)); (*lineno) += local_line; return 0; } -static int do_exec (const char *fname, char *parms, - void *mydata) +static int do_exec (const char *fname, char *parms, void *mydata) { struct tcl_info *p = mydata; int c, escape = 0; @@ -230,6 +259,7 @@ static int do_exec (const char *fname, char *parms, gw_log (GW_LOG_WARN|GW_LOG_ERRNO, mod, "open %s", fname); return -1; } + Tcl_SetVar (p->interp, "sessionParms", parms, TCL_GLOBAL_ONLY); while ((c = getc(inf)) != EOF) { if (c == '\\') diff --git a/www/wtcl.h b/www/wtcl.h new file mode 100644 index 0000000..5653f94 --- /dev/null +++ b/www/wtcl.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 1995, the EUROPAGATE consortium (see below). + * + * The EUROPAGATE consortium members are: + * + * University College Dublin + * Danmarks Teknologiske Videnscenter + * An Chomhairle Leabharlanna + * Consejo Superior de Investigaciones Cientificas + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation, in whole or in part, for any purpose, is hereby granted, + * provided that: + * + * 1. This copyright and permission notice appear in all copies of the + * software and its documentation. Notices of copyright or attribution + * which appear at the beginning of any file must remain unchanged. + * + * 2. The names of EUROPAGATE or the project partners may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * 3. Users of this software (implementors and gateway operators) agree to + * inform the EUROPAGATE consortium of their use of the software. This + * information will be used to evaluate the EUROPAGATE project and the + * software, and to plan further developments. The consortium may use + * the information in later publications. + * + * 4. Users of this software agree to make their best efforts, when + * documenting their use of the software, to acknowledge the EUROPAGATE + * consortium, and the role played by the software in their work. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * IN NO EVENT SHALL THE EUROPAGATE CONSORTIUM OR ITS MEMBERS BE LIABLE + * FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF + * ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA + * OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND + * ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * USE OR PERFORMANCE OF THIS SOFTWARE. + * + * $Log: wtcl.h,v $ + * Revision 1.1 1995/10/27 15:12:15 adam + * IrTcl incorporated in the gateway. + * Better separation of script types. + * Z39.50 gateway scripts entered. + * + */ + +#ifndef WTCL_H +#define WTCL_H + +#include "winterp.h" +#include + +Tcl_Interp *w_interp_tcl_get (W_Interp w_interp); + +W_Interp_Type w_interp_tcl; + +#endif diff --git a/www/ztargets.conf b/www/ztargets.conf index a2428e5..b9e2002 100644 --- a/www/ztargets.conf +++ b/www/ztargets.conf @@ -1,4 +1,4 @@ -# $Id: ztargets.conf,v 1.1 1995/10/23 17:04:17 adam Exp $ +# $Id: ztargets.conf,v 1.2 1995/10/27 15:12:15 adam Exp $ set commonFields { { Title {@attr 1=4} } { Author {@attr 1=1003} } @@ -43,3 +43,9 @@ set targets(ir.dbc.bib.dk) [list \ $commonFields \ ] +set targets(localhost:9999) [list \ + ztest9999 \ + Default \ + $commonFields \ +] + -- 1.7.10.4