X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=www%2Fwsh.c;h=dc9a251d4fd1015fe7e4296bfb8841454d2c7485;hb=2ffd22f0b11ad4c3e2df52a3a5db17046655d8c8;hp=a67590a45146f60bbe810d73512409d258b4dd53;hpb=a6f3beb071fe8c894ee6c846c86296c84f48e3d4;p=egate.git diff --git a/www/wsh.c b/www/wsh.c index a67590a..dc9a251 100644 --- a/www/wsh.c +++ b/www/wsh.c @@ -41,7 +41,26 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. * * $Log: wsh.c,v $ - * Revision 1.4 1995/10/27 15:12:12 adam + * 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. @@ -64,13 +83,12 @@ #include #include +#include #include "whtml.h" #include "wtcl.h" #include "wirtcl.h" -#define TIMEOUT_SHORT 60 -#define TIMEOUT_MEDIUM 1800 -#define TIMEOUT_LONG 7200 +#define TIMEOUT 60 static WCLIENT wcl; static char *mod = "wsh"; @@ -78,12 +96,13 @@ 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; - chdir("/usr/local/etc/httpd/cgi-bin"); + chdir (EGWDIR); gw_log_init (*argv); - gw_log_file (GW_LOG_ALL, "/usr/local/etc/httpd/logs/egwsh_log"); + gw_log_file (GW_LOG_ALL, LOGDIR "/egwsh_log"); gw_log_level (GW_LOG_ALL); gw_log (GW_LOG_STAT, mod, "Europagate www shell: %s", *argv); @@ -105,8 +124,24 @@ int main (int argc, char **argv) *argv); exit (1); } - while (wproto_process(wcl, timeout) > 0) + w_interp_load_state (w_interp, NULL); + timeout = TIMEOUT; + while (1) { + 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 = TIMEOUT; wo_clear (wcl, "text/html"); strcpy (parms_buf, wcl->wf_parms); script = parms = parms_buf; @@ -116,7 +151,7 @@ int main (int argc, char **argv) *parms++ = '\0'; if (*script) { - char *p = script + strlen(script) - 1; + p = script + strlen(script) - 1; while (*p && p != script) switch (*p) { @@ -140,6 +175,9 @@ int main (int argc, char **argv) --p; } } + 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); if (w_interp_exec (w_interp, script, parms)) @@ -150,6 +188,7 @@ int main (int argc, char **argv) } wo_finish(wcl); } + w_interp_save_state (w_interp, NULL); wproto_terminate(wcl); return 0; }