X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=www%2Fwsh.c;h=55eb3d8f0f7d35bcb9955c521b36235666d6deb8;hb=3871eda3b3a1518d4d18c1ffc0ed0375cb88bdf5;hp=990d141120803af48f27ed9841e2e9e3d9d73ef0;hpb=5414eafed41a60ef3625cfc6770184b36016186e;p=egate.git diff --git a/www/wsh.c b/www/wsh.c index 990d141..55eb3d8 100644 --- a/www/wsh.c +++ b/www/wsh.c @@ -41,7 +41,42 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. * * $Log: wsh.c,v $ - * Revision 1.3 1995/10/23 16:55:41 adam + * Revision 1.12 1996/02/19 15:45:00 adam + * Sort of targets in multiple-targets selection. + * + * Revision 1.11 1996/02/12 10:10:32 adam + * Resource/config system used by the gateway. + * + * Revision 1.10 1996/01/12 10:05:22 adam + * If script name ends with ';' HTTP/GET/Expires will be defined. + * The cgi interface only reads final handshake if response from + * server (shell) was zero-terminated [If it isn't it probably died]. + * + * Revision 1.9 1996/01/09 10:46:51 adam + * New defines: LOGDIR/EGWDIR/CGIDIR set in Makefile. + * + * Revision 1.8 1995/12/20 16:31:33 adam + * Bug fix: shell might terminate even though new request was initiated + * by the cgi interface program. + * Work on more simple user interface and Europagate buttons. + * + * Revision 1.7 1995/11/06 17:44:23 adam + * State reestablised when shell restarts. History of previous + * result sets. + * + * Revision 1.6 1995/11/06 10:51:19 adam + * End of response marker in response from wsh/wproto to wcgi. + * Shells are respawned when necessary. + * + * Revision 1.5 1995/11/01 16:15:48 adam + * Better presentation of records. Query/set number persistent. + * + * 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,11 +94,14 @@ #include #include -#include "winterp.h" +#include +#include -#define TIMEOUT_SHORT 60 -#define TIMEOUT_MEDIUM 1800 -#define TIMEOUT_LONG 7200 +#include +#include +#include "whtml.h" +#include "wtcl.h" +#include "wirtcl.h" static WCLIENT wcl; static char *mod = "wsh"; @@ -71,16 +109,33 @@ static char *mod = "wsh"; int main (int argc, char **argv) { char *script, *parms, parms_buf[512]; - int timeout = TIMEOUT_SHORT; + int timeout; W_Interp w_interp; + GW_DB gw_db; + GwRes shRes; +#if 0 + struct rlimit rlim; + + rlim.rlim_cur = RLIM_INFINITY; + rlim.rlim_max = RLIM_INFINITY; + setrlimit (RLIMIT_CORE, &rlim); +#endif - chdir("/usr/local/etc/httpd/cgi-bin"); gw_log_init (*argv); - gw_log_file (GW_LOG_ALL, "/usr/local/etc/httpd/logs/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); @@ -88,6 +143,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 @@ -96,19 +153,39 @@ int main (int argc, char **argv) *argv); exit (1); } - while (wproto_process(wcl, timeout) > 0) + w_interp_load_state (w_interp, NULL); + timeout = atoi (gw_res_get (shRes, "timeout", "120")); + if (timeout < 1) + timeout = 1; + while (1) { - wo_clear (wcl, "text/html"); + char *p; + int r; + + r = wproto_process (wcl, timeout); + if (r <= 0) + { + gw_db = gw_db_open ("www.db", 0, 0); + if (gw_db) + break; + gw_log (GW_LOG_DEBUG, mod, "Cannot terminate - new request"); + timeout = 10; + continue; + } + 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; while (*parms && *parms != '/') parms++; - if (*parms == '/') + if (*parms) *parms++ = '\0'; if (*script) { - char *p = script + strlen(script) - 1; - while (*p && p != script) + p = script + strlen(script); + while (*--p && p != script) switch (*p) { case '+': @@ -127,12 +204,19 @@ int main (int argc, char **argv) wproto_cache (wcl, atoi(p+1)); *p = '\0'; break; - default: - --p; + case ';': + wo_printf (wcl, "Expires: %s\n", p[1] ? p+1 : "0"); + gw_log (GW_LOG_DEBUG, mod, "Expires: %s", p[1] ?p+1:"0"); + *p = '\0'; + break; } } - gw_log (GW_LOG_DEBUG, mod, "script: %s", script); - gw_log (GW_LOG_DEBUG, mod, "parms: %s", parms); + wo_printf (wcl, "Content-type: text/html\n\n"); + for (p = parms; *p; p++) + if (*p == '+') + *p = ' '; + 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"); @@ -141,6 +225,7 @@ int main (int argc, char **argv) } wo_finish(wcl); } + w_interp_save_state (w_interp, NULL); wproto_terminate(wcl); return 0; }