Removed away include of system headers in comstack.h. Instead
[yaz-moved-to-github.git] / src / tcpip.c
index 689b0d5..f13b90b 100644 (file)
@@ -1,22 +1,49 @@
 /*
- * 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.14 2005-01-16 21:51:50 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);
@@ -776,7 +797,7 @@ int tcpip_get(COMSTACK h, char **buf, int *bufsize)
 #endif
        }
        else if (!res)
-           return 0;
+           return hasread;
         hasread += res;
     }
     TRC (fprintf (stderr, "  Out of read loop with hasread=%d, berlen=%d\n",