Minor changes.
[egate.git] / www / wproto.c
index ff283de..4cba04c 100644 (file)
  * USE OR PERFORMANCE OF THIS SOFTWARE.
  *
  * $Log: wproto.c,v $
- * Revision 1.8  1995/11/13 15:41:45  adam
+ * Revision 1.12  1996/01/05 16:35:02  adam
+ * Minor changes.
+ *
+ * Revision 1.11  1996/01/05  16:21:21  adam
+ * Bug fix: shell (wproto) sometimes closed server FIFO before cgi
+ * program opened it - solution: cgi sends OK when response has been read.
+ *
+ * Revision 1.10  1995/12/22  14:21:16  adam
+ * More work on scan. The search.egw script takes care of cached
+ * query page (doesn't always increment nextSetNo). To make new search set
+ * either 'New query' must be selected or the query page must be reloaded.
+ * The msearch script doesn't do this yet, however.
+ *
+ * Revision 1.9  1995/11/14  16:31:36  adam
+ * Temporary remove of ccl entry.
+ *
+ * Revision 1.8  1995/11/13  15:41:45  adam
  * Arrow gifs.
  * Gateway uses record element set names B(rief) and F(ull).
  * Bug fix. Didn't save idAuthentication correctly.
@@ -75,6 +91,7 @@
  */
 
 #include <stdio.h>
+#include <string.h>
 #include <stdlib.h>
 #include <sys/time.h>
 #include <sys/types.h>
@@ -123,7 +140,11 @@ void wo_clear (WCLIENT wc, 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
 }
 
 int wo_puthtml (WCLIENT wc, char *name)
@@ -196,11 +217,19 @@ int wo_overflow(WCLIENT wc, char ch)
 
 int wo_finish(WCLIENT wc)
 {
+    char buf[4];
     gw_log (GW_LOG_DEBUG, mod, "wo_finish");
-  
+
     wo_putc (wc, 0);
     if (wo_flush(wc) < 0)
        return -1;
+#if 1
+    gw_log (GW_LOG_DEBUG, mod, "reading ack");
+    if (read(wc->linein, buf, 2) != 2)
+    {
+        gw_log (GW_LOG_DEBUG, mod, "read ack");
+    }
+#endif
     close(wc->lineout);
     wc->lineout = -1;
     if (wc->cache_fd >= 0)
@@ -330,18 +359,24 @@ int wproto_process(WCLIENT wc, int timeout)
        p++;
        p++;         /* we don't deal with envvars yet */
        decode_form(wc->wf_data, p);
-       if (wc->lineout < 0 && (wc->lineout = open(wc->wf_serverp, O_WRONLY))
-           < 0)
-       {
-           gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, mod, "open %s", wc->wf_serverp);
-           exit(1);
-       }
+       if (wc->lineout < 0)
+        {
+            gw_log (GW_LOG_DEBUG, mod, "open %s", wc->wf_serverp);
+            if ((wc->lineout = open(wc->wf_serverp, O_WRONLY)) < 0)
+           {
+               gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, mod, "open %s", 
+                        wc->wf_serverp);
+               exit(1);
+           }
+        }
        /* look in cache only if request carries no forms data. */
        if (!*wc->wf_data[0].name && (level = wproto_findcache(wc,
            wc->wf_parms)) >= 0)
        {
+           gw_log (GW_LOG_DEBUG, mod, "wproto_dumpcache");
            wproto_dumpcache(wc, level);
            wo_finish(wc);
+            
        }
        else
         {