Better separation of script types.
Z39.50 gateway scripts entered.
# 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
#
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
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)
$(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)
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; \
<title>Europagate WWW index</title>
</head>
<body>
-<h2>Europagate WWW index, $Id: egwindex.html,v 1.3 1995/10/23 17:04:16 adam Exp $</h2>
+<h2>Europagate WWW index, $Id: egwindex.html,v 1.4 1995/10/27 15:12:04 adam Exp $</h2>
<p>
egwcgi ref:
<a href="http://localhost/cgi-bin/egwcgi/egwtcl/egwscript">egwcgi</a>
<p>
z39 targets:
- <a href="http://localhost/cgi-bin/egwcgi/egwtcl/targets.egw">targets.egw</a>
+ <a href="http://localhost/cgi-bin/egwcgi/egwirtcl/targets.egw">targets.egw</a>
</body>
</html>
<html>
{
-# $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 <br>}
+ htmlr {</body>}
+ htmlr {</html>}
+ 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
}
<head>
<title> WWW/Z39.50 Gateway Query Form</title>
</head>
<body>
-sessionId: {html $sessionId} <br>
-sessionParms: {html $sessionParms} <br>
-form: {html [form]} <br>
-target: {html $t} <br>
-databases: {html $databases} <br>
<h2> Search in databases </h2>
<h1> <blink> Not Functional Yet </blink> </h1>
-<form action="http://localhost/cgi-bin/egwcgi/{html $sessionId}/search.egw"
- method=post>
{
+ html {<form action="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
+ htmlr / $sessionId {/search.egw" method=post>}
set nodb [llength $databases]
if {$nodb > 1} {
if {$nodb > 2} {
Last modified 29. september 1995. <br>
<em> This and the following pages are under construction and will continue to be so
until the end of December 1995.</em>
-</body>
-</html>
+<hr>
+sessionId: {html $sessionId} <br>
+sessionParms: {html $sessionParms} <br>
+{
+ foreach e {SERVER_NAME PATH_INFO SCRIPT_NAME} {
+ htmlr $e {: } $env($e) {<br>}
+ }
+}
+form: {html [form]} <br>
+target: {html $t} <br>
+databases: {html $databases} <br>
<html>
{
-# $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
}
<head>
<title> Europagate, WWW/Z39.50 Gateway </title>
<strong> Choose a Z39.50 target: </strong> <br>
<dl>
{
- source /usr/local/etc/httpd/conf/ztargets.conf
foreach t [array names targets] {
- htmlr "<dt> <a href=\"http://localhost/cgi-bin/egwcgi/egwtcl/query.egw/$t\"> $t </a>"
+ html {<dt> <a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME) /
+ htmlr ${sessionId} {/query.egw/} $t {"> } $t {</a>}
htmlr "<dd> " [lindex $targets($t) 0]
}
}
Last modified 25. september 1995. <br>
<em> This and the following pages are under construction and will continue to be so
until the end of December 1995.</em>
+<hr>
+sessionId: {html $sessionId} <br>
+sessionParms: {html $sessionParms} <br>
+{
+ foreach e {SERVER_NAME PATH_INFO SCRIPT_NAME} {
+ htmlr $e {: } $env($e) {<br>}
+ }
+}
</body>
</html>
* 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
#include <assert.h>
#include <ctype.h>
-#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);
--- /dev/null
+/*
+ * 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
* 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
#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
--- /dev/null
+/*
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#ifdef AIX
+#include <sys/select.h>
+#endif
+#include <string.h>
+#include <assert.h>
+#include <ctype.h>
+
+#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; i<MAX_CALLBACK; i++)
+ {
+ callback_table[i].r_handle = NULL;
+ callback_table[i].w_handle = NULL;
+ callback_table[i].x_handle = NULL;
+ }
+ if ((r = w_interp_exec (p->w_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;
+}
--- /dev/null
+/*
+ * 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 <tcl.h>
+#include <ir-tcl.h>
+
+W_Interp_Type w_interp_irtcl;
+
+#endif
* 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
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)
;
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");
* 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
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;
int cache_level;
cache_data cache[20];
int cache_fd;
+ struct w_select_handle *select_list;
} *WCLIENT, wclient_data;
#define wo_putc(wc, ch) \
* 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
#include <unistd.h>
#include <ctype.h>
-#include "winterp.h"
+#include "whtml.h"
+#include "wtcl.h"
+#include "wirtcl.h"
#define TIMEOUT_SHORT 60
#define TIMEOUT_MEDIUM 1800
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
script = parms = parms_buf;
while (*parms && *parms != '/')
parms++;
- if (*parms == '/')
+ if (*parms)
*parms++ = '\0';
if (*script)
{
* 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
#include <assert.h>
#include <ctype.h>
-#include <tcl.h>
-
-#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);
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; i<argc; i++)
wo_puts (p->wcl, argv[i]);
return TCL_OK;
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;
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);
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<br><hr>\n<strong>"
+ "%s %d</strong><br>\n", pre, errorLine);
+ wo_printf (p->wcl, "<xmp>\n%s</xmp>\n<hr>\n", msg);
+}
+
static int tcl_exec (const char *fname, char *parms,
struct tcl_info *p, FILE *inf, int *lineno)
{
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)
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 == '\\')
}
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;
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 == '\\')
--- /dev/null
+/*
+ * 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.h>
+
+Tcl_Interp *w_interp_tcl_get (W_Interp w_interp);
+
+W_Interp_Type w_interp_tcl;
+
+#endif
-# $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} }
$commonFields \
]
+set targets(localhost:9999) [list \
+ ztest9999 \
+ Default \
+ $commonFields \
+]
+