From 7c2d86a77557592c7dd8d5415d8345f9bb74661c Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 12 Feb 1996 10:10:27 +0000 Subject: [PATCH] Resource/config system used by the gateway. --- www/Makefile | 33 +++++++++++++++++++++------------ www/egw.res | 13 +++++++++++++ www/wcgi.c | 43 ++++++++++++++++++++++++++++++------------- www/wirtcl.c | 7 +++++-- www/wsh.c | 37 ++++++++++++++++++++++++++----------- www/wtest.c | 10 ++++++---- 6 files changed, 101 insertions(+), 42 deletions(-) create mode 100644 www/egw.res diff --git a/www/Makefile b/www/Makefile index 2512b12..dc58610 100644 --- a/www/Makefile +++ b/www/Makefile @@ -1,25 +1,26 @@ # Makefile for www gateway utility # Europagate, 1995 # -# $Id: Makefile,v 1.28 1996/01/31 16:01:45 adam Exp $ +# $Id: Makefile,v 1.29 1996/02/12 10:10:27 adam Exp $ # SHELL=/bin/sh # ZDEFS= -ZINC=-I../../yaz/include +#ZINC=-I../../yaz/include ZLIB=../../yaz/lib/libyaz.a -MOSILIB=../../xtimosi/src/libmosi.a -lrfc +#ZLIB=-lyaz +MOSILIB=../../xtimosi/src/libmosi.a ../../yaz/lib/librfc.a LIBIRTCL=../../ir-tcl/libirtcl.a $(ZLIB) $(MOSILIB) #NETLIB=-lnsl -lsocket # OLIB=../lib/util.a ../lib/libres+log.a -TCLLIB=/usr/local/lib/libtcl7.4.a -TCLINC=-I/usr/local/include +TCLLIB=/usr/local/lib/libtcl7.5.a +TCLINC=-I../../ir-tcl -I/usr/local/include # WSCRIPTS=egwscript targets.egw query.egw search.egw showfull.egw z39util.tcl \ mtargets.egw mquery.egw msearch.egw history.egw tform.egw tdefine.egw HSCRIPTS=egwindex.html -CONFFILES=ztargets.conf +CONFFILES=egw.res ztargets.conf TPROG1=egwcgi TPROG2=egwsh TPROG3=wtest @@ -43,8 +44,7 @@ GIFDIR=$(HTDOCS)/egwgif #GIFDIR=/data2/html/egw/gif INCLUDE=-I../include $(ZINC) $(TCLINC) -DEFS=$(INCLUDE) $(ZDEFS) -DCGIDIR=\"$(CGIDIR)\" -DEGWDIR=\"$(EGWDIR)\" \ - -DLOGDIR=\"$(LOGDIR)\" +DEFS=$(INCLUDE) $(ZDEFS) -DEGWDIR=\"$(EGWDIR)\" all: $(TPROG1) $(TPROG2) @@ -65,14 +65,23 @@ install.prog: $(TPROG1) $(TPROG2) echo "Making directory $(CGIDIR)"; \ mkdir $(CGIDIR); \ fi - @for x in $(TPROG1) $(TPROG2); do \ + @if [ ! -d $(EGWDIR) ]; then \ + echo "Making directory $(EGWDIR)"; \ + mkdir $(EGWDIR); \ + fi + @for x in $(TPROG1); do \ echo Installing $$x; \ cp $$x $(CGIDIR); \ chmod a+x $(CGIDIR)/$$x; \ done; \ + for x in $(TPROG2); do \ + echo Installing $$x; \ + cp $$x $(EGWDIR); \ + chmod a+x $(EGWDIR)/$$x; \ + done; \ for p in egwtcl egwirtcl egwhtml; do \ - rm -f $(CGIDIR)/$$p; \ - ln $(CGIDIR)/$(TPROG2) $(CGIDIR)/$$p; \ + rm -f $(EGWDIR)/$$p; \ + ln $(EGWDIR)/$(TPROG2) $(EGWDIR)/$$p; \ done install.script: @@ -80,7 +89,7 @@ install.script: echo "Making directory $(EGWDIR)"; \ mkdir $(EGWDIR); \ fi - @if [ ! -d $(HTDOCS); then \ + @if [ ! -d $(HTDOCS) ]; then \ echo "Making directory $(HTDOCS)"; \ mkdir $(HTDOCS); \ fi diff --git a/www/egw.res b/www/egw.res new file mode 100644 index 0000000..2b33294 --- /dev/null +++ b/www/egw.res @@ -0,0 +1,13 @@ +# WWW-Z39.50 Gateway configuration file +# +# $Id: egw.res,v 1.1 1996/02/12 10:10:28 adam Exp $ + +# FIFO file directory +fifo.dir: /tmp/egw + +# Idle time in seconds before the shell terminates +timeout: 30 + +# Log level +log.level: default + diff --git a/www/wcgi.c b/www/wcgi.c index f6ae643..09b1ff9 100644 --- a/www/wcgi.c +++ b/www/wcgi.c @@ -41,7 +41,10 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. * * $Log: wcgi.c,v $ - * Revision 1.15 1996/01/26 09:02:20 adam + * Revision 1.16 1996/02/12 10:10:29 adam + * Resource/config system used by the gateway. + * + * Revision 1.15 1996/01/26 09:02:20 adam * Open of client FIFO called with O_NDELAY when reconnecting to shell * in order to prevent serious lock if previous shell died without * unlinking client FIFO. @@ -116,6 +119,7 @@ the server, please reload the server's 'front page'." #include +#include #include "wproto.h" static char *prog = "cgi"; @@ -145,7 +149,7 @@ static int spawn (char *sprog, int id) sprintf (envstr, "GWID=%d", id); putenv (envstr); - sprintf(path, "%s/%s", CGIDIR, sprog); + sprintf(path, "%s/%s", EGWDIR, sprog); switch(r = fork()) { case -1: @@ -183,27 +187,40 @@ static void print_environ (void) */ int main() { - char clientp[256], tmp[256], *path_info, *p, *operation, *t; + char clientp[256], *path_info, *p, *operation, *t; char combuf[COMBUF]; + const char *fifoDir; + GwRes cgiRes; int serverf_fd = -1; int linein = -1, lineout, data, gw_id; - chdir ("/usr/local/etc/httpd/cgi-bin"); + if (chdir (EGWDIR)) + fatal ("Couldn't change directory to " EGWDIR); gw_log_init ("egw"); - gw_log_file (GW_LOG_ALL, LOGDIR "/egwcgi_log"); + gw_log_file (GW_LOG_ALL, "egwcgi_log"); +#if 0 gw_log_level (GW_LOG_ALL); +#endif gw_log_session (getpid()); gw_log (GW_LOG_STAT, prog, "Europagate www cgi server"); + cgiRes = gw_res_init (); + gw_res_merge (cgiRes, "egw.res"); +#if 1 + gw_log_level (gw_log_mask_str ( + gw_res_get (cgiRes, "log.level", "default"))); +#endif + fifoDir = gw_res_get (cgiRes, "fifo.dir", "/tmp/egw"); + /* Create fifo directory if it doesn't exist already */ - sprintf(tmp, "%s/%s", FIFOROOT, FIFODIR); - if (access(tmp, R_OK|W_OK) < 0 && mkdir(tmp, 0777) < 0) + if (access(fifoDir, R_OK|W_OK) < 0 && mkdir(fifoDir, 0777) < 0) { - gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, prog, "Failed to create %s", tmp); + gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, prog, "Failed to create %s", + fifoDir); fatal("Internal error in server."); } /* Delete server FIFO if it does exist */ - sprintf(serverp, "%s/srv%d", tmp, getpid()); + sprintf(serverp, "%s/srv%d", fifoDir, getpid()); if (access(serverp, R_OK|W_OK) == 0) { if (unlink(serverp) < 0) @@ -229,7 +246,7 @@ int main() } /* Create lock file that ensures the server (shell) doesn't */ /* terminate before we have read the whole response */ - sprintf (serverf, "%s/srf%d", tmp, getpid ()); + sprintf (serverf, "%s/srf%d", fifoDir, getpid ()); gw_log (GW_LOG_DEBUG, prog, "open w %s", serverf); serverf_fd = open (serverf, O_WRONLY|O_CREAT|O_TRUNC, 0666); if (serverf_fd == -1) @@ -292,13 +309,13 @@ int main() fatal("Internal error in server"); } gw_log (GW_LOG_DEBUG, prog, "Synchronized"); - sprintf(clientp, "%s/clt%d", tmp, gw_id); + sprintf(clientp, "%s/clt%d", fifoDir, gw_id); gw_log (GW_LOG_DEBUG, prog, "open w %s", clientp); lineout = open (clientp, O_WRONLY); } else /* A session is continued */ { - sprintf(clientp, "%s/clt%d", tmp, gw_id); + sprintf(clientp, "%s/clt%d", fifoDir, gw_id); gw_log (GW_LOG_DEBUG, prog, "open w|n %s", clientp); /* Open the FIFO in O_NDELAY-mode: This prevents blocking */ /* even though the shell died without unlinking the FIFO */ @@ -351,7 +368,7 @@ int main() strcpy (p, serverf); p += strlen (p) + 1; strcpy (p, path_info); - gw_log (GW_LOG_DEBUG, prog, "P:%s", p); + gw_log (GW_LOG_STAT, prog, "P:%s", p); p += strlen(p) + 1; *(p++) = '\0'; /* no envvars tranferred at present */ if ((t = getenv("CONTENT_LENGTH")) && (data = atoi(t)) > 0) diff --git a/www/wirtcl.c b/www/wirtcl.c index c0ae80e..f70cbcb 100644 --- a/www/wirtcl.c +++ b/www/wirtcl.c @@ -41,7 +41,10 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. * * $Log: wirtcl.c,v $ - * Revision 1.13 1996/01/24 08:26:54 adam + * Revision 1.14 1996/02/12 10:10:31 adam + * Resource/config system used by the gateway. + * + * Revision 1.13 1996/01/24 08:26:54 adam * All tcl commands prefixed with egw_ (except the html command). * * Revision 1.12 1996/01/12 10:05:18 adam @@ -180,7 +183,7 @@ static void *do_create (WCLIENT wcl, void *args) gw_log (GW_LOG_FATAL, mod, "Cannot make Irtcl_Interp"); exit (1); } - log_init(LOG_ALL, "irtcl", LOGDIR "/irtcl_log"); + log_init(LOG_ALL, "irtcl", "irtcl_log"); /* initialize irtcl */ Tcl_CreateCommand (p->interp, "egw_wait", proc_zwait_invoke, p, NULL); for (i=0; i #include +#include #include "whtml.h" #include "wtcl.h" #include "wirtcl.h" -#define TIMEOUT 60 - static WCLIENT wcl; static char *mod = "wsh"; @@ -104,14 +106,23 @@ int main (int argc, char **argv) int timeout; W_Interp w_interp; GW_DB gw_db; + GwRes shRes; - chdir (EGWDIR); gw_log_init (*argv); - gw_log_file (GW_LOG_ALL, LOGDIR "/egwsh_log"); + gw_log_file (GW_LOG_ALL, "egwsh_log"); +#if 0 gw_log_level (GW_LOG_ALL); +#endif gw_log (GW_LOG_STAT, mod, "Europagate www shell: %s", *argv); - - if (!(wcl = wproto_init())) + shRes = gw_res_init (); + gw_res_merge (shRes, "egw.res"); + gw_res_merge (shRes, "shell.res"); + +#if 1 + gw_log_level (gw_log_mask_str ( + gw_res_get (shRes, "log.level", "default"))); +#endif + if (!(wcl = wproto_init (gw_res_get (shRes, "fifo.dir", "/tmp/egw")))) { gw_log (GW_LOG_FATAL, mod, "init"); exit(1); @@ -130,7 +141,9 @@ int main (int argc, char **argv) exit (1); } w_interp_load_state (w_interp, NULL); - timeout = TIMEOUT; + timeout = atoi (gw_res_get (shRes, "timeout", "120")); + if (timeout < 1) + timeout = 1; while (1) { char *p; @@ -146,7 +159,9 @@ int main (int argc, char **argv) timeout = 10; continue; } - timeout = TIMEOUT; + timeout = atoi (gw_res_get (shRes, "timeout", "120")); + if (timeout < 1) + timeout = 1; wo_clear (wcl, NULL); strcpy (parms_buf, wcl->wf_parms); script = parms = parms_buf; @@ -187,8 +202,8 @@ int main (int argc, char **argv) for (p = parms; *p; p++) if (*p == '+') *p = ' '; - gw_log (GW_LOG_DEBUG, mod, "script: %s", script); - gw_log (GW_LOG_DEBUG, mod, "parms: %s", parms); + gw_log (GW_LOG_STAT, mod, "script: %s", script); + gw_log (GW_LOG_STAT, mod, "parms: %s", parms); if (w_interp_exec (w_interp, script, parms)) { wo_printf (wcl, "wsh error\n"); diff --git a/www/wtest.c b/www/wtest.c index c59c79d..acc5658 100644 --- a/www/wtest.c +++ b/www/wtest.c @@ -41,7 +41,10 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. * * $Log: wtest.c,v $ - * Revision 1.2 1996/01/09 10:46:51 adam + * Revision 1.3 1996/02/12 10:10:33 adam + * Resource/config system used by the gateway. + * + * Revision 1.2 1996/01/09 10:46:51 adam * New defines: LOGDIR/EGWDIR/CGIDIR set in Makefile. * * Revision 1.1 1995/10/20 11:49:28 adam @@ -64,13 +67,12 @@ int main() int counter = 0; int i; - chdir (CGIDIR); gw_log_init ("egw"); gw_log_level (GW_LOG_ALL); - gw_log_file (GW_LOG_ALL, LOGDIR "/wtest_log"); + gw_log_file (GW_LOG_ALL, "wtest_log"); gw_log (GW_LOG_STAT, mod, "Europagate www test"); - if (!(wcl = wproto_init ())) + if (!(wcl = wproto_init ("/tmp/egw"))) { gw_log (GW_LOG_FATAL, mod, "init"); exit (1); -- 1.7.10.4