X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=www%2Fwsh.c;h=a67590a45146f60bbe810d73512409d258b4dd53;hb=a6f3beb071fe8c894ee6c846c86296c84f48e3d4;hp=f36d42e7d2eb4ccabcf4ef52c40114ea16606dda;hpb=1938b1fd36e774fa9b6d11a4eb5edfcdaee0267b;p=egate.git diff --git a/www/wsh.c b/www/wsh.c index f36d42e..a67590a 100644 --- a/www/wsh.c +++ b/www/wsh.c @@ -41,21 +41,34 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. * * $Log: wsh.c,v $ - * Revision 1.1 1995/10/20 11:49:28 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 + * First version of WWW gateway with embedded Tcl. + * + * Revision 1.1 1995/10/20 11:49:28 adam * First version of www gateway. * */ #include #include -#include +#include #include #include #include -#include "wproto.h" +#include "whtml.h" +#include "wtcl.h" +#include "wirtcl.h" -#define TIMEOUT_SHORT 300 +#define TIMEOUT_SHORT 60 #define TIMEOUT_MEDIUM 1800 #define TIMEOUT_LONG 7200 @@ -64,34 +77,80 @@ static char *mod = "wsh"; int main (int argc, char **argv) { - char *argument, *p, parms[512]; + char *script, *parms, parms_buf[512]; int timeout = TIMEOUT_SHORT; + W_Interp w_interp; chdir("/usr/local/etc/httpd/cgi-bin"); - gw_log_init ("egw"); + gw_log_init (*argv); gw_log_file (GW_LOG_ALL, "/usr/local/etc/httpd/logs/egwsh_log"); gw_log_level (GW_LOG_ALL); - gw_log (GW_LOG_STAT, mod, "Europagate www shell"); - + gw_log (GW_LOG_STAT, mod, "Europagate www shell: %s", *argv); + if (!(wcl = wproto_init())) { gw_log (GW_LOG_FATAL, mod, "init"); exit(1); } + 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 + { + gw_log (GW_LOG_FATAL, mod, "Cannot determine shell type. prog=%s", + *argv); + exit (1); + } while (wproto_process(wcl, timeout) > 0) { - wo_clear(wcl, "text/html"); - wo_printf(wcl, "INDEX\n"); - strcpy(parms, wcl->wf_parms); - argument = p = parms; - while (*p && *p != '/') - p++; - if (*p == '/') - *(p++) = '\0'; - gw_log (GW_LOG_DEBUG, mod, "command: %s", argument); - wo_printf (wcl, "hej - %s\n", argument); + wo_clear (wcl, "text/html"); + strcpy (parms_buf, wcl->wf_parms); + script = parms = parms_buf; + while (*parms && *parms != '/') + parms++; + if (*parms) + *parms++ = '\0'; + if (*script) + { + char *p = script + strlen(script) - 1; + while (*p && p != script) + switch (*p) + { + case '+': + wproto_cache (wcl, wcl->cache_level+1); + *p = '\0'; + break; + case '-': + if (p[1]) + wproto_cache (wcl, wcl->cache_level-atoi(p+1)); + else + wproto_cache (wcl, wcl->cache_level-1); + *p = '\0'; + break; + case '=': + if (isdigit(p[1])) + wproto_cache (wcl, atoi(p+1)); + *p = '\0'; + break; + default: + --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)) + { + wo_printf (wcl, "wsh error\n"); + wo_printf (wcl, "Couldn't execute script %s", + script); + } wo_finish(wcl); } wproto_terminate(wcl); return 0; } +