From 53a28f8f2ab30977f9ee2edffe5809fae61d5a4e Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 12 Jan 1996 10:05:17 +0000 Subject: [PATCH] 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]. --- www/wcgi.c | 90 ++++++---------------------------------------------------- www/wirtcl.c | 9 ++++-- www/wproto.c | 16 ++++++----- www/wproto.h | 9 ++++-- www/wsh.c | 21 ++++++++++---- 5 files changed, 47 insertions(+), 98 deletions(-) diff --git a/www/wcgi.c b/www/wcgi.c index 9653642..0aa0be0 100644 --- a/www/wcgi.c +++ b/www/wcgi.c @@ -41,7 +41,12 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. * * $Log: wcgi.c,v $ - * Revision 1.12 1996/01/09 10:46:49 adam + * Revision 1.13 1996/01/12 10:05:17 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.12 1996/01/09 10:46:49 adam * New defines: LOGDIR/EGWDIR/CGIDIR set in Makefile. * * Revision 1.11 1996/01/08 08:42:19 adam @@ -336,7 +341,6 @@ int main() } gw_log (GW_LOG_DEBUG, prog, "Reading response"); -#if 1 while ((data = read(linein, combuf, COMBUF)) > 0) { gw_log (GW_LOG_DEBUG, prog, "Got %d bytes", data); @@ -361,86 +365,10 @@ int main() gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, prog, "write"); exit (1); } + gw_log (GW_LOG_DEBUG, prog, "writing ack"); + if (write(lineout, "OK", 2) < 2) + gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, prog, "write"); } -#else -# if 1 - fcntl (linein, F_SETFL, O_NONBLOCK); -# endif - while (1) - { - fd_set s_input; - struct timeval t; - int r, eof_flag = 0; - - t.tv_sec = 10; - t.tv_usec = 0; - FD_ZERO(&s_input); - FD_SET(linein, &s_input); -# if 0 - FD_SET(1, &s_input); -# endif - gw_log (GW_LOG_DEBUG, prog, "select"); - r = select (linein + 1, &s_input, NULL, NULL, &t); - if (r < 0) - { - gw_log (GW_LOG_ERRNO|GW_LOG_FATAL, prog, "select"); - exit(1); - } - if (r == 0 || FD_ISSET (linein, &s_input)) - { - if (r == 0) - gw_log (GW_LOG_DEBUG, prog, "poll"); - if ((data = read (linein, combuf, COMBUF)) > 0) - { - if (combuf[data-1] == '\0') - { - --data; - eof_flag = 1; - } - gw_log (GW_LOG_DEBUG, prog, "Got %d bytes", data); - if (data > 0 && write(1, combuf, data) < data) - { - gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, prog, "write"); - exit (1); - } - } - else if (data == -1) - { - if (r > 0) - { - gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, prog, "read"); - exit (1); - } - gw_log (GW_LOG_DEBUG, prog, "poll read"); - } - else - break; - } - if (eof_flag) - break; - if (r > 0 && FD_ISSET (1, &s_input)) - { - data = read (1, combuf, COMBUF); - if (data == -1) - { - gw_log (GW_LOG_DEBUG|GW_LOG_ERRNO, prog, "stdout closed"); - break; - } - if (data == 0) - { - gw_log (GW_LOG_DEBUG, prog, "stdout closed"); - break; - } - gw_log (GW_LOG_DEBUG, prog, "stdout got %d bytes", data); - } - } -#endif - -#if 1 - gw_log (GW_LOG_DEBUG, prog, "writing ack"); - if (write(lineout, "OK", 2) < 2) - gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, prog, "write"); -#endif gw_log (GW_LOG_DEBUG, prog, "Cleaning up."); close(linein); unlink(serverp); diff --git a/www/wirtcl.c b/www/wirtcl.c index b45ec48..4828b89 100644 --- a/www/wirtcl.c +++ b/www/wirtcl.c @@ -41,7 +41,12 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. * * $Log: wirtcl.c,v $ - * Revision 1.11 1996/01/09 16:16:49 adam + * Revision 1.12 1996/01/12 10:05:18 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.11 1996/01/09 16:16:49 adam * Port to OSF/1. Gif references moved from /gif/ to /egwgif/. * * Revision 1.10 1996/01/09 10:46:50 adam @@ -293,7 +298,7 @@ static int events (struct tcl_info *p, char *waitVar, int tout) { if (FD_ISSET (i, &fdset_tcl_r)) { - if (callback_table[i].r_handle); + if (callback_table[i].r_handle) (*callback_table[i].r_handle) (callback_table[i].obj); } if (FD_ISSET (i, &fdset_tcl_w)) diff --git a/www/wproto.c b/www/wproto.c index 4cba04c..799a4d2 100644 --- a/www/wproto.c +++ b/www/wproto.c @@ -41,7 +41,12 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. * * $Log: wproto.c,v $ - * Revision 1.12 1996/01/05 16:35:02 adam + * Revision 1.13 1996/01/12 10:05:20 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.12 1996/01/05 16:35:02 adam * Minor changes. * * Revision 1.11 1996/01/05 16:21:21 adam @@ -135,16 +140,13 @@ void wo_printf (WCLIENT wc, const char *fmt, ...) va_end(ap); } -void wo_clear (WCLIENT wc, char *type) +void wo_clear (WCLIENT wc, const char *type) { if (!wc->outbuffer) wc->outbuffer = malloc(wc->outbuffer_size = OUTBUFFER_CHUNK); wc->outbuffer_offset = 0; -#if 0 - wo_printf(wc, "Expires: 0\nContent-type: %s\n\n", type); -#else - wo_printf(wc, "Content-type: %s\n\n", type); -#endif + if (type) + wo_printf(wc, "Content-type: %s\n\n", type); } int wo_puthtml (WCLIENT wc, char *name) diff --git a/www/wproto.h b/www/wproto.h index 8b203a9..ec71a80 100644 --- a/www/wproto.h +++ b/www/wproto.h @@ -41,7 +41,12 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. * * $Log: wproto.h,v $ - * Revision 1.4 1995/11/06 10:51:18 adam + * Revision 1.5 1996/01/12 10:05:21 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.4 1995/11/06 10:51:18 adam * End of response marker in response from wsh/wproto to wcgi. * Shells are respawned when necessary. * @@ -117,7 +122,7 @@ char *wgetval(WCLIENT wc, char *name); int wproto_process(WCLIENT wc, int timeout); WCLIENT wproto_init(void); void wo_printf(WCLIENT wc, const char *fmt, ...); -void wo_clear(WCLIENT wc, char *type); +void wo_clear(WCLIENT wc, const char *type); int wo_finish(WCLIENT wc); int wo_flush(WCLIENT wc); int wo_overflow(WCLIENT wc, char ch); diff --git a/www/wsh.c b/www/wsh.c index dc9a251..b08bb69 100644 --- a/www/wsh.c +++ b/www/wsh.c @@ -41,7 +41,12 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. * * $Log: wsh.c,v $ - * Revision 1.9 1996/01/09 10:46:51 adam + * 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 @@ -142,7 +147,7 @@ int main (int argc, char **argv) continue; } timeout = TIMEOUT; - wo_clear (wcl, "text/html"); + wo_clear (wcl, NULL); strcpy (parms_buf, wcl->wf_parms); script = parms = parms_buf; while (*parms && *parms != '/') @@ -151,8 +156,8 @@ int main (int argc, char **argv) *parms++ = '\0'; if (*script) { - p = script + strlen(script) - 1; - while (*p && p != script) + p = script + strlen(script); + while (*--p && p != script) switch (*p) { case '+': @@ -171,10 +176,14 @@ 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; } } + wo_printf (wcl, "Content-type: text/html\n\n"); for (p = parms; *p; p++) if (*p == '+') *p = ' '; -- 1.7.10.4