* 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.
*
*/
W_Interp w_interp;
GW_DB gw_db;
GwRes shRes;
-#if 0
+#if 1
struct rlimit rlim;
rlim.rlim_cur = RLIM_INFINITY;
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);
{
char *p;
int r;
+ int raw_mode = 0;
r = wproto_process (wcl, timeout);
if (r <= 0)
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])
*p = '\0';
break;
}
+#else
+ p = script;
+ while (*p)
+ {
+ if (*p == ';') /* ";" or ";<date>" */
+ {
+ 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 == '+') /* "+<name>=<value>" or "+<name>" */
+ {
+ 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 = ' ';
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, "<html><head><title>wsh error</title></head>\n");
wo_printf (wcl, "<body>Couldn't execute script %s</body></html>",
script);