* 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
}
return cs;
}
+
+int cs_look (COMSTACK cs)
+{
+ return cs->event;
+}
* 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
#ifdef WIN32
if (WSAGetLastError() == WSAEWOULDBLOCK)
{
+ h->event = CS_CONNECT;
h->state = CS_CONNECTING;
h->io_pending = CS_WANT_WRITE;
return 1;
#else
if (errno == EINPROGRESS)
{
+ h->event = CS_CONNECT;
h->state = CS_CONNECTING;
h->io_pending = CS_WANT_WRITE|CS_WANT_READ;
return 1;
h->cerrno = CSYSERR;
return -1;
}
+ h->event = CS_CONNECT;
h->state = CS_CONNECTING;
}
if (h->state != CS_CONNECTING)
}
}
#endif
+ h->event = CS_DATA;
h->state = CS_DATAXFER;
return 0;
}
/*
* 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"
return -1;
}
h->state = CS_IDLE;
+ h->event = CS_LISTEN;
return 0;
}
}
h->io_pending = 0;
h->state = CS_DATAXFER;
+ h->event = CS_DATA;
return h;
}
TRC(fprintf(stderr, "tcpip_put: size=%d\n", size));
h->io_pending = 0;
+ h->event = CS_DATA;
if (state->towrite < 0)
{
state->towrite = 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
TRC(fprintf(stderr, "ssl_put: size=%d\n", size));
h->io_pending = 0;
+ h->event = CS_DATA;
if (state->towrite < 0)
{
state->towrite = size;
<?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 "ø"> <!-- CIRCLED DIVISION SLASH -->
<!ENTITY yaz "YAZ">
<!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>
<!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">
<!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">
<!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">
* 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
#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