/*
- * Copyright (c) 1995-2004, Index Data
+ * Copyright (C) 1995-2005, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: tcpip.c,v 1.9 2004-05-10 11:40:51 adam Exp $
+ * $Id: tcpip.c,v 1.15 2005-02-01 14:37:47 adam Exp $
+ */
+/**
+ * \file tcpip.c
+ * \brief Implements TCP/IP + SSL COMSTACK.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#if HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
#ifdef WIN32
+#include <winsock.h>
#else
-#include <unistd.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <arpa/inet.h>
+#include <netinet/tcp.h>
+#endif
+
+#if HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#if HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#endif
+#if HAVE_SYS_WAIT_H
+#include <sys/wait.h>
#endif
-#include <errno.h>
-#include <fcntl.h>
-#include <signal.h>
#if HAVE_OPENSSL_SSL_H
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <yaz/comstack.h>
#include <yaz/tcpip.h>
-#include <yaz/log.h>
#include <yaz/nmem.h>
-#ifdef WIN32
-#else
-#include <netinet/tcp.h>
-#endif
-
static int tcpip_close(COMSTACK h);
static int tcpip_put(COMSTACK h, char *buf, int size);
static int tcpip_get(COMSTACK h, char **buf, int *bufsize);
p->event = CS_NONE;
p->cerrno = 0;
p->stackerr = 0;
+ p->user = 0;
#if HAVE_OPENSSL_SSL_H
sp->ctx = sp->ctx_alloc = 0;
#endif
}
else if (!res)
- return 0;
+ return hasread;
hasread += res;
}
TRC (fprintf (stderr, " Out of read loop with hasread=%d, berlen=%d\n",