Improve check for type of socket length (socklen_t).
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 20 Sep 2002 22:23:13 +0000 (22:23 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 20 Sep 2002 22:23:13 +0000 (22:23 +0000)
comstack/tcpip.c
comstack/unix.c
configure.in

index 2d56db1..a7d33d2 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1995-2002, Index Data
  * See the file LICENSE for details.
  *
- * $Id: tcpip.c,v 1.48 2002-09-10 20:56:34 adam Exp $
+ * $Id: tcpip.c,v 1.49 2002-09-20 22:23:13 adam Exp $
  */
 
 #include <stdio.h>
@@ -53,14 +53,8 @@ void *tcpip_straddr(COMSTACK h, const char *str);
 #define TRC(X)
 #endif
 
-#if HAVE_SOCKLEN_T
-#define NET_LEN_T socklen_t
-#else
-#if GETPEERNAME_ACCEPTS_SIZE_T_FOR_THIRD_ARGUMENT
-#define NET_LEN_T size_t
-#else
-#define NET_LEN_T int
-#endif
+#ifndef YAZ_SOCKLEN_T
+#define YAZ_SOCKLEN_T int
 #endif
 
 /* this state is used for both SSL and straight TCP/IP */
@@ -459,7 +453,7 @@ int tcpip_listen(COMSTACK h, char *raddr, int *addrlen,
                 void *cd)
 {
     struct sockaddr_in addr;
-    NET_LEN_T len = sizeof(addr);
+    YAZ_SOCKLEN_T len = sizeof(addr);
 
     TRC(fprintf(stderr, "tcpip_listen pid=%d\n", getpid()));
     if (h->state != CS_ST_IDLE)
@@ -974,7 +968,7 @@ char *tcpip_addrstr(COMSTACK h)
     struct sockaddr_in addr;
     tcpip_state *sp = (struct tcpip_state *)h->cprivate;
     char *r, *buf = sp->buf;
-    NET_LEN_T len;
+    YAZ_SOCKLEN_T len;
     struct hostent *host;
     
     len = sizeof(addr);
index edfa830..0cccf5f 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1995-2002, Index Data
  * See the file LICENSE for details.
  *
- * $Id: unix.c,v 1.5 2002-09-10 20:56:34 adam Exp $
+ * $Id: unix.c,v 1.6 2002-09-20 22:23:13 adam Exp $
  * UNIX socket COMSTACK. By Morten Bøgeskov.
  */
 #ifndef WIN32
 /* Chas added the following, so we get the definition of completeBER */
 #include <yaz/odr.h>
 
-#if HAVE_SOCKLEN_T
-#define NET_LEN_T socklen_t
-#else
-#if GETPEERNAME_ACCEPTS_SIZE_T_FOR_THIRD_ARGUMENT
-#define NET_LEN_T size_t
-#else
-#define NET_LEN_T int
-#endif
+#ifndef YAZ_SOCKLEN_T
+#define YAZ_SOCKLEN_T int
 #endif
 
 int unix_close(COMSTACK h);
@@ -315,7 +309,7 @@ int unix_listen(COMSTACK h, char *raddr, int *addrlen,
                void *cd)
 {
     struct sockaddr_un addr;
-    NET_LEN_T len = SUN_LEN(&addr);
+    YAZ_SOCKLEN_T len = SUN_LEN(&addr);
 
     TRC(fprintf(stderr, "unix_listen pid=%d\n", getpid()));
     if (h->state != CS_ST_IDLE)
index f849147..55076ad 100644 (file)
@@ -1,6 +1,6 @@
 dnl YAZ Toolkit, Index Data 1994-2002
 dnl See the file LICENSE for details.
-dnl $Id: configure.in,v 1.90 2002-09-18 20:55:54 adam Exp $
+dnl $Id: configure.in,v 1.91 2002-09-20 22:23:13 adam Exp $
 AC_INIT(include/yaz/yaz-version.h)
 AM_INIT_AUTOMAKE(yaz, 1.9.1)
 dnl
@@ -179,40 +179,22 @@ if test "$ac_cv_func_poll" = "yes"; then
         AC_CHECK_HEADERS(sys/poll.h)
 fi
 dnl ------ socklen_t
-dnl AC_CHECK_TYPES(socklen_t)
-AC_MSG_CHECKING(for socklen_t)
-AC_CACHE_VAL(ac_cv_check_socklen_t,
-[ac_cv_check_socklen_t=''
-AC_TRY_COMPILE([
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/socket.h>
-],
-       [socklen_t len;],
-       ac_cv_check_socklen_t=yes,
-       ac_cv_check_socklen_t=no)])
-AC_MSG_RESULT($ac_cv_check_socklen_t)
-if test "$ac_cv_check_socklen_t" = "yes"; then
-       AC_DEFINE(HAVE_SOCKLEN_T)
-else
-       AC_MSG_CHECKING(whether net size is of type size_t)
-       AC_CACHE_VAL(ac_cv_check_getpeername_accepts_size_t,
-       [ac_cv_check_getpeername_accepts_size_t=''
+AC_MSG_CHECKING([for socklen_t])
+AC_CACHE_VAL(ac_cv_check_socklen_t,[ac_cv_check_socklen_t=''
        AC_TRY_COMPILE([
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/socket.h>
-],
-       [size_t mylen; getpeername(0, (struct sockaddr *)NULL, &mylen);],
-       ac_cv_check_getpeername_accepts_size_t=yes,
-       ac_cv_check_getpeername_accepts_size_t=no)])
-       AC_MSG_RESULT($ac_cv_check_getpeername_accepts_size_t)
-       if test "$ac_cv_check_getpeername_accepts_size_t" = yes; then
-               AC_DEFINE(GETPEERNAME_ACCEPTS_SIZE_T_FOR_THIRD_ARGUMENT)
-       fi
-fi
+       #include <sys/types.h>
+       #include <sys/socket.h>
+       extern accept(int, struct sockaddr *, socklen_t *);
+       ],,[ac_cv_check_socklen_t=socklen_t],[
+               AC_TRY_COMPILE([
+               #include <sys/types.h>
+               #include <sys/socket.h>
+               extern accept(int, struct sockaddr *, size_t t *);
+               ],,[ac_cv_check_socklen_t=size_t],[ac_cv_check_socklen_t=int])
+       ])
+])
+AC_MSG_RESULT($ac_cv_check_socklen_t)
+AC_DEFINE_UNQUOTED(YAZ_SOCKLEN_T,$ac_cv_check_socklen_t)
 dnl
 dnl ------ tcpd
 AC_ARG_ENABLE(tcpd,[  --enable-tcpd[=PREFIX]  enable TCP wrapper for server if available])