Implemented cs_rcvconnect and cs_look as described in the documentation.
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 22 Oct 2001 13:57:24 +0000 (13:57 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 22 Oct 2001 13:57:24 +0000 (13:57 +0000)
comstack/comstack.c
comstack/tcpip.c
doc/yaz.xml
doc/yazhtml.dsl
doc/yazphp.dsl
doc/yazprint.dsl
include/yaz/comstack.h

index 6a4cc05..b15eb5f 100644 (file)
@@ -3,7 +3,10 @@
  * See the file LICENSE for details.
  *
  * $Log: comstack.c,v $
- * Revision 1.8  2001-07-19 19:49:02  adam
+ * Revision 1.9  2001-10-22 13:57:24  adam
+ * Implemented cs_rcvconnect and cs_look as described in the documentation.
+ *
+ * Revision 1.8  2001/07/19 19:49:02  adam
  * Added include of string.h.
  *
  * Revision 1.7  2001/03/21 12:43:36  adam
@@ -100,3 +103,8 @@ COMSTACK cs_create_host(const char *type_and_host, int blocking, void **vp)
     }    
     return cs;
 }
+
+int cs_look (COMSTACK cs)
+{
+    return cs->event;
+}
index 9347e04..d3ddb3f 100644 (file)
@@ -3,7 +3,10 @@
  * See the file LICENSE for details.
  *
  * $Log: tcpip.c,v $
- * Revision 1.41  2001-10-12 21:49:26  adam
+ * Revision 1.42  2001-10-22 13:57:24  adam
+ * Implemented cs_rcvconnect and cs_look as described in the documentation.
+ *
+ * Revision 1.41  2001/10/12 21:49:26  adam
  * For accept/recv/send check for EAGAIN if it's differs from EWOULDBLOCK.
  *
  * Revision 1.40  2001/08/23 09:02:46  adam
@@ -495,6 +498,7 @@ int tcpip_connect(COMSTACK h, void *address)
 #ifdef WIN32
            if (WSAGetLastError() == WSAEWOULDBLOCK)
            {
+               h->event = CS_CONNECT;
                h->state = CS_CONNECTING;
                h->io_pending = CS_WANT_WRITE;
                return 1;
@@ -502,6 +506,7 @@ int tcpip_connect(COMSTACK h, void *address)
 #else
            if (errno == EINPROGRESS)
            {
+               h->event = CS_CONNECT;
                h->state = CS_CONNECTING;
                h->io_pending = CS_WANT_WRITE|CS_WANT_READ;
                return 1;
@@ -510,6 +515,7 @@ int tcpip_connect(COMSTACK h, void *address)
            h->cerrno = CSYSERR;
            return -1;
        }
+       h->event = CS_CONNECT;
        h->state = CS_CONNECTING;
     }
     if (h->state != CS_CONNECTING)
@@ -548,6 +554,7 @@ int tcpip_connect(COMSTACK h, void *address)
        }
     }
 #endif
+    h->event = CS_DATA;
     h->state = CS_DATAXFER;
     return 0;
 }
@@ -555,10 +562,39 @@ int tcpip_connect(COMSTACK h, void *address)
 /*
  * nop
  */
-int tcpip_rcvconnect(COMSTACK h)
+int tcpip_rcvconnect(COMSTACK cs)
 {
     TRC(fprintf(stderr, "tcpip_rcvconnect\n"));
-    return 0;
+
+    if (cs->event == CS_CONNECT)
+    {
+       int fd = cs->iofile;
+       fd_set input, output;
+       struct timeval tv;
+       int r;
+       
+       tv.tv_sec = 0;
+       tv.tv_usec = 1;
+       
+       FD_ZERO(&input);
+       FD_ZERO(&output);
+       FD_SET (fd, &input);
+       FD_SET (fd, &output);
+       
+       r = select (fd+1, &input, &output, 0, &tv);
+       if (r > 0)
+       {
+           if (FD_ISSET(cs->iofile, &output))
+           {
+               cs->state = CS_DATA;
+               return 0;   /* write OK, we're OK */
+           }
+           else
+               return -1;  /* an error, for sure */
+       }
+       return 0;  /* timeout - incomplete */
+    }
+    return -1;    /* wrong state */
 }
 
 #define CERTF "ztest.pem"
@@ -629,6 +665,7 @@ int tcpip_bind(COMSTACK h, void *address, int mode)
         return -1;
     }
     h->state = CS_IDLE;
+    h->event = CS_LISTEN;
     return 0;
 }
 
@@ -807,6 +844,7 @@ COMSTACK tcpip_accept(COMSTACK h)
     }
     h->io_pending = 0;
     h->state = CS_DATAXFER;
+    h->event = CS_DATA;
     return h;
 }
 
@@ -1008,6 +1046,7 @@ int tcpip_put(COMSTACK h, char *buf, int size)
 
     TRC(fprintf(stderr, "tcpip_put: size=%d\n", size));
     h->io_pending = 0;
+    h->event = CS_DATA;
     if (state->towrite < 0)
     {
         state->towrite = size;
@@ -1020,8 +1059,15 @@ int tcpip_put(COMSTACK h, char *buf, int size)
     }
     while (state->towrite > state->written)
     {
-       if ((res = send(h->iofile, buf + state->written, size -
-                       state->written, 0)) < 0)
+       if ((res =
+            send(h->iofile, buf + state->written, size -
+                 state->written, 
+#ifdef MSG_NOSIGNAL
+                 MSG_NOSIGNAL
+#else
+                 0
+#endif
+                )) < 0)
        {
            if (
 #ifdef WIN32
@@ -1066,6 +1112,7 @@ int ssl_put(COMSTACK h, char *buf, int size)
 
     TRC(fprintf(stderr, "ssl_put: size=%d\n", size));
     h->io_pending = 0;
+    h->event = CS_DATA;
     if (state->towrite < 0)
     {
         state->towrite = size;
index faff797..e89335c 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" standalone="no"?>
 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
-                    "../../docbook/docbookx.dtd" [
+                    "/usr/share/sgml/docbook/dtd/xml/4.1.2/docbookx.dtd" [
 
      <!ENTITY oslash "&#x00F8;"> <!-- CIRCLED DIVISION SLASH -->
      <!ENTITY yaz "YAZ">
@@ -19,7 +19,7 @@
      <!ENTITY odr "<acronym>ODR</acronym>">
      <!ENTITY comstack "<acronym>COMSTACK</acronym>">
 ]>
-<!-- $Id: yaz.xml,v 1.5 2001-08-08 19:33:21 adam Exp $ -->
+<!-- $Id: yaz.xml,v 1.6 2001-10-22 13:57:24 adam Exp $ -->
 <book>
  <bookinfo>
   <title>YAZ User's Guide and Reference</title>
index b7e89ea..8e71d9e 100644 (file)
@@ -1,9 +1,9 @@
 <!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
-<!ENTITY docbook.dsl SYSTEM "../../docbook-dsssl/html/docbook.dsl"
+<!ENTITY docbook.dsl SYSTEM "/usr/share/sgml/docbook/stylesheet/dsssl/modular/html/docbook.dsl"
   CDATA DSSSL>
 ]>
 <!--
-  $Id: yazhtml.dsl,v 1.4 2001-08-14 11:50:07 adam Exp $
+  $Id: yazhtml.dsl,v 1.5 2001-10-22 13:57:24 adam Exp $
 -->
 <style-sheet>
 <style-specification use="docbook">
index e0c2fda..ad25e61 100644 (file)
@@ -1,9 +1,9 @@
 <!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
-<!ENTITY docbook.dsl SYSTEM "../../docbook-dsssl/html/docbook.dsl"
+<!ENTITY docbook.dsl SYSTEM "/usr/share/sgml/docbook/stylesheet/dsssl/modular/html/docbook.dsl"
   CDATA DSSSL>
 ]>
 <!--
-  $Id: yazphp.dsl,v 1.3 2001-08-14 11:50:07 adam Exp $
+  $Id: yazphp.dsl,v 1.4 2001-10-22 13:57:24 adam Exp $
 -->
 <style-sheet>
 <style-specification use="docbook">
index 8736d92..3b65687 100644 (file)
@@ -1,9 +1,9 @@
 <!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
-<!ENTITY docbook.dsl SYSTEM "../../docbook-dsssl/print/docbook.dsl"
+<!ENTITY docbook.dsl SYSTEM "/usr/share/sgml/docbook/stylesheet/dsssl/modular/print/docbook.dsl"
   CDATA DSSSL>
 ]>
 <!--
-  $Id: yazprint.dsl,v 1.4 2001-08-14 11:50:07 adam Exp $
+  $Id: yazprint.dsl,v 1.5 2001-10-22 13:57:24 adam Exp $
 -->
 <style-sheet>
 <style-specification use="docbook">
index f7a5121..aa8da82 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: comstack.h,v 1.5 2001-03-21 12:43:36 adam Exp $
+ * $Id: comstack.h,v 1.6 2001-10-22 13:57:24 adam Exp $
  */
 
 #ifndef COMSTACK_H
@@ -138,18 +138,18 @@ struct comstack
 #define cs_want_read(handle) ((handle)->io_pending & CS_WANT_READ)
 #define cs_want_write(handle) ((handle)->io_pending & CS_WANT_WRITE)
 #define cs_set_blocking(handle,blocking) ((handle)->f_set_blocking(handle, blocking)
-
+                                         
 #define CS_WANT_READ 1
 #define CS_WANT_WRITE 2
+YAZ_EXPORT int cs_look (COMSTACK);
 YAZ_EXPORT const char *cs_strerror(COMSTACK h);
 YAZ_EXPORT const char *cs_errmsg(int n);
 YAZ_EXPORT COMSTACK cs_create_host(const char *type_and_host, 
                                   int blocking, void **vp);
-
 /*
  * error management.
  */
-
+                                         
 #define CSNONE     0
 #define CSYSERR    1
 #define CSOUTSTATE 2