X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=www%2Fwshmain.c;h=a3120bdaeb8516e9a2cae8d0170bbd5374d782ff;hb=1140389ab96fc8ca7bc9c8dc642adbcec625f4a6;hp=680d0fcb4e3e610686d84931f08cdcae2fad61fc;hpb=0869c05bd5a456f027823ca0783216acf4424b65;p=egate.git diff --git a/www/wshmain.c b/www/wshmain.c index 680d0fc..a3120bd 100644 --- a/www/wshmain.c +++ b/www/wshmain.c @@ -41,7 +41,26 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. * * $Log: wshmain.c,v $ - * Revision 1.1 1996/02/29 15:36:34 adam + * Revision 1.6 1997/01/27 11:27:16 adam + * Implemented a new command, egw_clear, to clear http output cache. + * Changed prototype for function wo_clear. + * + * Revision 1.5 1997/01/24 13:13:12 adam + * Implemnted egw_source and added a "raw" option to the URL. + * Fixed a bug in the buffering system of wproto; the macro wo_putc could + * override memory if it was the first HTML generating function called. + * + * Revision 1.4 1996/05/23 15:53:12 adam + * Bug fix: egw_enc failed on 8-bit chars. + * New command: egw_parms. + * + * Revision 1.3 1996/03/14 11:48:39 adam + * New function egw_prog that returns name of shell. + * + * Revision 1.2 1996/03/08 16:47:06 adam + * Logs of changes. + * + * Revision 1.1 1996/02/29 15:36:34 adam * Main shell loop implemented as a separate function called wshmain. * */ @@ -70,7 +89,7 @@ void wshmain (int argc, char **argv, W_Interp_Type w_interp_type) W_Interp w_interp; GW_DB gw_db; GwRes shRes; -#if 0 +#if 1 struct rlimit rlim; rlim.rlim_cur = RLIM_INFINITY; @@ -92,7 +111,8 @@ void wshmain (int argc, char **argv, W_Interp_Type w_interp_type) 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")))) + if (!(wcl = wproto_init (gw_res_get (shRes, "fifo.dir", "/tmp/egw"), + *argv))) { gw_log (GW_LOG_FATAL, mod, "init"); exit(1); @@ -109,6 +129,7 @@ void wshmain (int argc, char **argv, W_Interp_Type w_interp_type) { char *p; int r; + int raw_mode = 0; r = wproto_process (wcl, timeout); if (r <= 0) @@ -123,22 +144,21 @@ void wshmain (int argc, char **argv, W_Interp_Type w_interp_type) timeout = atoi (gw_res_get (shRes, "timeout", "120")); if (timeout < 1) timeout = 1; - wo_clear (wcl, NULL); + wo_clear (wcl); strcpy (parms_buf, wcl->wf_parms); - script = parms = parms_buf; - while (*parms && *parms != '/') - parms++; - if (*parms) - *parms++ = '\0'; + parms = parms_buf; + + script = wcl->wf_script; + if (*script) { +#if 0 p = script + strlen(script); while (*--p && p != script) switch (*p) { case '+': wproto_cache (wcl, wcl->cache_level+1); - *p = '\0'; break; case '-': if (p[1]) @@ -158,8 +178,53 @@ void wshmain (int argc, char **argv, W_Interp_Type w_interp_type) *p = '\0'; break; } +#else + p = script; + while (*p) + { + if (*p == ';') /* ";" or ";" */ + { + 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; + } + else if (*p == '+') /* "+=" or "+" */ + { + const char *name1 = NULL; + const char *name2 = NULL; + const char *value1 = NULL; + const char *value2 = NULL; + int len; + *p = '\0'; + name1 = ++p; + while (*p && *p != ';' && *p != '+') + { + if (*p == '=') + { + name2 = p++; + value1 = p; + while (*p && *p != ';' && *p != '+') + p++; + value2 = p; + break; + } + p++; + } + if (!name2) + name2 = p; + len = name2 - name1; + if (len == 3 && !memcmp (name1, "raw", len)) + raw_mode = 1; + } + else + p++; + } + *p = '\0'; +#endif } - wo_printf (wcl, "Content-type: text/html\n\n"); + if (!raw_mode) + wo_printf (wcl, "Content-type: text/html\n\n"); for (p = parms; *p; p++) if (*p == '+') *p = ' '; @@ -167,6 +232,8 @@ void wshmain (int argc, char **argv, W_Interp_Type w_interp_type) gw_log (GW_LOG_STAT, mod, "parms: %s", parms); if (w_interp_exec (w_interp, script, parms)) { + if (raw_mode) + wo_printf (wcl, "Content-type: text/html\n\n"); wo_printf (wcl, "wsh error\n"); wo_printf (wcl, "Couldn't execute script %s", script);