OSSP CVS Repository

ossp - Check-in [4998]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 4998
Date: 2005-Feb-02 13:26:44 (local)
2005-Feb-02 12:26:44 (UTC)
User:thl
Branch:
Comment: import OSSP sa 1.2.4
Tickets:
Inspections:
Files:
ossp-pkg/l2/ChangeLog      1.19 -> 1.20     4 inserted, 1 deleted
ossp-pkg/l2/l2_ut_sa.ac      added-> 1.11
ossp-pkg/l2/l2_ut_sa.c      1.26 -> 1.27     57 inserted, 44 deleted
ossp-pkg/l2/l2_ut_sa.h      1.23 -> 1.24     2 inserted, 6 deleted

ossp-pkg/l2/ChangeLog 1.19 -> 1.20

--- ChangeLog    2005/01/24 15:05:36     1.19
+++ ChangeLog    2005/02/02 12:26:44     1.20
@@ -9,8 +9,11 @@
   ChangeLog
   =========
 
-  Changes between 0.9.8 and 0.9.9 (22-Apr-2004 to 24-Jan-2005)
+  Changes between 0.9.8 and 0.9.9 (24-Apr-2004 to 01-Feb-2005)
   
+    *) import OSSP sa 1.2.4
+       [Thomas Lotterer <thomas@lotterer.net>]
+
     *) Upgraded build environment to GNU shtool 2.0.1 and
        GNU libtool 1.5.10.
        [Ralf S. Engelschall <rse@engelschall.com>]


ossp-pkg/l2/l2_ut_sa.ac -> 1.11

*** /dev/null    Tue Oct 26 10:55:00 2021
--- -    Tue Oct 26 10:56:53 2021
***************
*** 0 ****
--- 1,238 ----
+ dnl ##
+ dnl ##  OSSP sa - Socket Abstraction
+ dnl ##  Copyright (c) 2001-2005 Ralf S. Engelschall <rse@engelschall.com>
+ dnl ##  Copyright (c) 2001-2005 The OSSP Project <http://www.ossp.org/>
+ dnl ##  Copyright (c) 2001-2005 Cable & Wireless <http://www.cw.com/>
+ dnl ##
+ dnl ##  This file is part of OSSP sa, a socket abstraction library which
+ dnl ##  can be found at http://www.ossp.org/pkg/lib/sa/.
+ dnl ##
+ dnl ##  Permission to use, copy, modify, and distribute this software for
+ dnl ##  any purpose with or without fee is hereby granted, provided that
+ dnl ##  the above copyright notice and this permission notice appear in all
+ dnl ##  copies.
+ dnl ##
+ dnl ##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ dnl ##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ dnl ##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ dnl ##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+ dnl ##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ dnl ##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ dnl ##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ dnl ##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ dnl ##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ dnl ##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ dnl ##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ dnl ##  SUCH DAMAGE.
+ dnl ##
+ dnl ##  sa.ac: socket abstraction Autoconf checks
+ dnl ##
+ 
+ dnl #   Check for an ANSI C typedef in a header
+ dnl #   configure.in:
+ dnl #     SA_CHECK_TYPEDEF(<typedef>, <header>)
+ dnl #   acconfig.h:
+ dnl #     #undef HAVE_<typedef>
+ 
+ AC_DEFUN(SA_CHECK_TYPEDEF,[dnl
+     AC_REQUIRE([AC_HEADER_STDC])dnl
+     AC_MSG_CHECKING(for typedef $1)
+     AC_CACHE_VAL(ac_cv_typedef_$1,[
+         AC_EGREP_CPP(dnl
+ changequote(<<,>>)dnl
+ <<(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]>>dnl
+ changequote([,]), [
+ #include <$2>],
+             ac_cv_typedef_$1=yes,
+             ac_cv_typedef_$1=no
+         )
+     ])dnl
+     AC_MSG_RESULT($ac_cv_typedef_$1)
+     if test $ac_cv_typedef_$1 = yes; then
+         AC_DEFINE(HAVE_[]translit($1, [a-z], [A-Z]), 1, [Define to 1 if $1 exists])
+     fi
+ ])
+ 
+ dnl #  Check whether to use SO_RCVTIMEO|SO_SNDTIMEO with setsockopt(2)
+ dnl #   configure.ac:
+ dnl #     SA_CHECK_SOCKOPT(SO_RCVTIMEO)
+ dnl #     SA_CHECK_SOCKOPT(SO_SNDTIMEO)
+ dnl #   config.h:
+ dnl #     #undef USE_SO_RCVTIMEO or #define USE_SO_RCVTIMEO 1
+ dnl #     #undef USE_SO_SNDTIMEO or #define USE_SO_SNDTIMEO 1
+ 
+ AC_DEFUN(SA_CHECK_SOCKOPT, [
+ AC_MSG_CHECKING(whether to use $1 with setsockopt(2))
+ AC_TRY_RUN([
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ #include <sys/time.h>
+ 
+ int main(void)
+ {
+     int s;
+     struct timeval timeo;
+     timeo.tv_sec  = 3;
+     timeo.tv_usec = 3;
+ 
+ #ifndef $1
+     exit(3);
+ #else
+     if ((s = socket(PF_INET, SOCK_STREAM, 0)) == -1)
+         exit(2);
+ 
+     /* fails on Solaris 2.6,8,9,10 and Debian 2.2 because
+        SO_RCVTIMEO|SO_SNDTIMEO are defined but not implemented */
+     if (setsockopt(s, SOL_SOCKET, $1, (void *)&timeo, sizeof(timeo)) == -1)
+         exit(1);
+ 
+     exit(0);
+ #endif
+ }
+ ]
+ , [ AC_MSG_RESULT([yes]) AC_DEFINE(USE_$1, 1, [Define to use $1 with setsockopt(2)]) ]
+ , [ AC_MSG_RESULT([no]) ]
+ )
+ ])dnl
+ 
+ dnl ##
+ dnl ##  Check for C99 va_copy() implementation
+ dnl ##  (and provide fallback implementation if neccessary)
+ dnl ##
+ dnl ##  configure.in:
+ dnl ##    SA_CHECK_VA_COPY
+ dnl ##  foo.c:
+ dnl ##    #include "config.h"
+ dnl ##    [...]
+ dnl ##    va_copy(d,s)
+ dnl ##
+ dnl ##  This check is rather complex: first because we really have to
+ dnl ##  try various possible implementations in sequence and second, we
+ dnl ##  cannot define a macro in config.h with parameters directly.
+ dnl ##
+ 
+ dnl #   test program for va_copy() implementation
+ changequote(<<,>>)
+ m4_define(__va_copy_test, <<[
+ #include <stdlib.h>
+ #include <stdarg.h>
+ #include <string.h>
+ #define DO_VA_COPY(d, s) $1
+ void test(char *str, ...)
+ {
+     va_list ap, ap2;
+     int i;
+     va_start(ap, str);
+     DO_VA_COPY(ap2, ap);
+     for (i = 1; i <= 9; i++) {
+         int k = (int)va_arg(ap, int);
+         if (k != i)
+             abort();
+     }
+     DO_VA_COPY(ap, ap2);
+     for (i = 1; i <= 9; i++) {
+         int k = (int)va_arg(ap, int);
+         if (k != i)
+             abort();
+     }
+     va_end(ap);
+ }
+ int main(int argc, char *argv[])
+ {
+     test("test", 1, 2, 3, 4, 5, 6, 7, 8, 9);
+     exit(0);
+ }
+ ]>>)
+ changequote([,])
+ 
+ dnl #   test driver for va_copy() implementation
+ m4_define(__va_copy_check, [
+     AH_VERBATIM($1,
+ [/* Predefined possible va_copy() implementation (id: $1) */
+ #define __VA_COPY_USE_$1(d, s) $2])
+     if test ".$ac_cv_va_copy" = .; then
+         AC_TRY_RUN(__va_copy_test($2), [ac_cv_va_copy="$1"])
+     fi
+ ])
+ 
+ dnl #   Autoconf check for va_copy() implementation checking
+ AC_DEFUN(SA_CHECK_VA_COPY,[
+   dnl #   provide Autoconf display check message
+   AC_MSG_CHECKING(for va_copy() function)
+   dnl #   check for various implementations in priorized sequence   
+   AC_CACHE_VAL(ac_cv_va_copy, [
+     ac_cv_va_copy=""
+     dnl #   1. check for standardized C99 macro
+     __va_copy_check(C99, [va_copy((d), (s))])
+     dnl #   2. check for alternative/deprecated GCC macro
+     __va_copy_check(GCM, [VA_COPY((d), (s))])
+     dnl #   3. check for internal GCC macro (high-level define)
+     __va_copy_check(GCH, [__va_copy((d), (s))])
+     dnl #   4. check for internal GCC macro (built-in function)
+     __va_copy_check(GCB, [__builtin_va_copy((d), (s))])
+     dnl #   5. check for assignment approach (assuming va_list is a struct)
+     __va_copy_check(ASS, [do { (d) = (s); } while (0)])
+     dnl #   6. check for assignment approach (assuming va_list is a pointer)
+     __va_copy_check(ASP, [do { *(d) = *(s); } while (0)])
+     dnl #   7. check for memory copying approach (assuming va_list is a struct)
+     __va_copy_check(CPS, [memcpy((void *)&(d), (void *)&(s)), sizeof((s))])
+     dnl #   8. check for memory copying approach (assuming va_list is a pointer)
+     __va_copy_check(CPP, [memcpy((void *)(d), (void *)(s)), sizeof(*(s))])
+     if test ".$ac_cv_va_copy" = .; then
+         AC_ERROR([no working implementation found])
+     fi
+   ])
+   dnl #   optionally activate the fallback implementation
+   if test ".$ac_cv_va_copy" = ".C99"; then
+       AC_DEFINE(HAVE_VA_COPY, 1, [Define if va_copy() macro exists (and no fallback implementation is required)])
+   fi
+   dnl #   declare which fallback implementation to actually use
+   AC_DEFINE_UNQUOTED([__VA_COPY_USE], [__VA_COPY_USE_$ac_cv_va_copy],
+       [Define to id of used va_copy() implementation])
+   dnl #   provide activation hook for fallback implementation
+   AH_VERBATIM([__VA_COPY_ACTIVATION],
+ [/* Optional va_copy() implementation activation */
+ #ifndef HAVE_VA_COPY
+ #define va_copy(d, s) __VA_COPY_USE(d, s)
+ #endif
+ ])
+   dnl #   provide Autoconf display result message
+   if test ".$ac_cv_va_copy" = ".C99"; then
+       AC_MSG_RESULT([yes])
+   else
+       AC_MSG_RESULT([no (using fallback implementation)])
+   fi
+ ])
+ 
+ 
+ dnl #   Check for anything OSSP SA wants to know
+ dnl #   configure.in:
+ dnl #     SA_CHECK_ALL
+ 
+ AC_DEFUN(SA_CHECK_ALL,[
+     #   make sure libnsl and libsocket are linked in if they exist
+     AC_CHECK_LIB(nsl, gethostname)
+     if test ".`echo $LIBS | grep nsl`" = .; then
+         AC_CHECK_LIB(nsl, gethostbyname)
+     fi
+     AC_CHECK_LIB(socket, accept)
+ 
+     #   make sure some platforms find their IPv6 library
+     AC_CHECK_LIB(inet6, getaddrinfo)
+ 
+     #   check for system headers
+     AC_CHECK_HEADERS(string.h sys/types.h sys/socket.h netdb.h netinet/in.h)
+ 
+     #   check for system functions
+     AC_CHECK_FUNCS(inet_addr inet_aton inet_pton inet_ntoa inet_ntop snprintf getaddrinfo)
+ 
+     dnl # check for network/socket size type
+     SA_CHECK_TYPEDEF(socklen_t, sys/socket.h)
+     SA_CHECK_TYPEDEF(ssize_t, sys/types.h)
+     SA_CHECK_SOCKOPT(SO_RCVTIMEO)
+     SA_CHECK_SOCKOPT(SO_SNDTIMEO)
+ 
+     dnl # check for va_copy()
+     SA_CHECK_VA_COPY
+ ])
+ 


ossp-pkg/l2/l2_ut_sa.c 1.26 -> 1.27

--- l2_ut_sa.c   2005/01/24 15:03:18     1.26
+++ l2_ut_sa.c   2005/02/02 12:26:44     1.27
@@ -210,13 +210,14 @@
 
 /* system call table */
 typedef struct {
-    SA_SC_DECLARE_3(int,     connect,  int, const struct sockaddr *, socklen_t)
-    SA_SC_DECLARE_3(int,     accept,   int, struct sockaddr *, socklen_t *)
-    SA_SC_DECLARE_5(int,     select,   int, fd_set *, fd_set *, fd_set *, struct timeval *)
-    SA_SC_DECLARE_3(ssize_t, read,     int, void *, size_t)
-    SA_SC_DECLARE_3(ssize_t, write,    int, const void *, size_t)
-    SA_SC_DECLARE_6(ssize_t, recvfrom, int, void *, size_t, int, struct sockaddr *, socklen_t *)
-    SA_SC_DECLARE_6(ssize_t, sendto,   int, const void *, size_t, int, const struct sockaddr *, socklen_t)
+    SA_SC_DECLARE_3(int,              connect,       int, const struct sockaddr *, socklen_t)
+    SA_SC_DECLARE_3(int,              accept,        int, struct sockaddr *, socklen_t *)
+    SA_SC_DECLARE_5(int,              select,        int, fd_set *, fd_set *, fd_set *, struct timeval *)
+    SA_SC_DECLARE_3(ssize_t,          read,          int, void *, size_t)
+    SA_SC_DECLARE_3(ssize_t,          write,         int, const void *, size_t)
+    SA_SC_DECLARE_6(ssize_t,          recvfrom,      int, void *, size_t, int, struct sockaddr *, socklen_t *)
+    SA_SC_DECLARE_6(ssize_t,          sendto,        int, const void *, size_t, int, const struct sockaddr *, socklen_t)
+    SA_SC_DECLARE_1(struct hostent *, gethostbyname, const char *name)
 } sa_syscall_tab_t;
 
 /* socket option information */
@@ -497,8 +498,8 @@
     struct servent *se;
     int bIPv6;
     int bNumeric;
-    char *cpHost;
-    char *cpPort;
+    const char *cpHost;
+    const char *cpPort;
     char *cpProto;
     unsigned int nPort;
     const char *cpPath;
@@ -559,7 +560,7 @@
     }
     else if (strncmp(uri, "inet://", 7) == 0) {
         /* parse URI into host, port and protocol parts */
-        cpHost = (char *)(uri+7);
+        cpHost = uri+7;
         bIPv6 = FALSE;
         if (cpHost[0] == '[') {
             /* IPv6 address (see RFC2732) */
@@ -652,7 +653,7 @@
             sf = AF_INET6;
         }
 #endif
-        else if ((he = gethostbyname(cpHost)) != NULL) {
+        else if ((he = SA_SC_CALL_1(sa, gethostbyname, cpHost)) != NULL) {
             if (he->h_addrtype == AF_INET) {
                 sa4.sin_family = AF_INET;
                 sa4.sin_port = htons(nPort);
@@ -940,13 +941,13 @@
         return SA_OK;
 
 #if defined(SO_RCVTIMEO) && defined(USE_SO_RCVTIMEO) && defined(SO_SNDTIMEO) && defined(USE_SO_SNDTIMEO)
-    if (SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_READ])) {
+    if (!SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_READ])) {
         if (setsockopt(sa->fdSocket, SOL_SOCKET, SO_RCVTIMEO,
                        (const void *)(&sa->tvTimeout[SA_TIMEOUT_READ]),
                        (socklen_t)(sizeof(sa->tvTimeout[SA_TIMEOUT_READ]))) < 0)
             return SA_RC(SA_ERR_SYS);
     }
-    if (SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_WRITE])) {
+    if (!SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_WRITE])) {
         if (setsockopt(sa->fdSocket, SOL_SOCKET, SO_SNDTIMEO,
                        (const void *)(&sa->tvTimeout[SA_TIMEOUT_WRITE]),
                        (socklen_t)(sizeof(sa->tvTimeout[SA_TIMEOUT_WRITE]))) < 0)
@@ -989,7 +990,7 @@
 #if defined(SO_LINGER)
                     struct linger linger;
                     linger.l_onoff  = (sa->optInfo[i].value == 0 ? 0 : 1);
-                    linger.l_linger = sa->optInfo[i].value;
+                    linger.l_linger = (sa->optInfo[i].value <= 0 ? 0 : sa->optInfo[i].value);
                     if (setsockopt(sa->fdSocket, SOL_SOCKET, SO_LINGER,
                                    (const void *)&linger,
                                    (socklen_t)sizeof(struct linger)) < 0)
@@ -1175,13 +1176,14 @@
     }
 
     /* init syscall object attributes */
-    SA_SC_ASSIGN(sa, connect,  connect,  NULL);
-    SA_SC_ASSIGN(sa, accept,   accept,   NULL);
-    SA_SC_ASSIGN(sa, select,   select,   NULL);
-    SA_SC_ASSIGN(sa, read,     read,     NULL);
-    SA_SC_ASSIGN(sa, write,    write,    NULL);
-    SA_SC_ASSIGN(sa, recvfrom, recvfrom, NULL);
-    SA_SC_ASSIGN(sa, sendto,   sendto,   NULL);
+    SA_SC_ASSIGN(sa, connect,       connect,       NULL);
+    SA_SC_ASSIGN(sa, accept,        accept,        NULL);
+    SA_SC_ASSIGN(sa, select,        select,        NULL);
+    SA_SC_ASSIGN(sa, read,          read,          NULL);
+    SA_SC_ASSIGN(sa, write,         write,         NULL);
+    SA_SC_ASSIGN(sa, recvfrom,      recvfrom,      NULL);
+    SA_SC_ASSIGN(sa, sendto,        sendto,        NULL);
+    SA_SC_ASSIGN(sa, gethostbyname, gethostbyname, NULL);
 
     /* pass object to caller */
     *sap = sa;
@@ -1339,7 +1341,7 @@
         }
         case SA_OPTION_LINGER: {
 #if defined(SO_LINGER)
-            int amount = ((int)va_arg(ap, int) ? 1 : 0);
+            int amount = (int)va_arg(ap, int);
             sa->optInfo[SA_OPTION_LINGER].value = amount;
             sa->optInfo[SA_OPTION_LINGER].todo = TRUE;
 #else
@@ -1404,13 +1406,14 @@
     /* assign system call */
     rv = SA_OK;
     switch (id) {
-        case SA_SYSCALL_CONNECT:  SA_SC_ASSIGN(sa, connect,  fptr, fctx); break;
-        case SA_SYSCALL_ACCEPT:   SA_SC_ASSIGN(sa, accept,   fptr, fctx); break;
-        case SA_SYSCALL_SELECT:   SA_SC_ASSIGN(sa, select,   fptr, fctx); break;
-        case SA_SYSCALL_READ:     SA_SC_ASSIGN(sa, read,     fptr, fctx); break;
-        case SA_SYSCALL_WRITE:    SA_SC_ASSIGN(sa, write,    fptr, fctx); break;
-        case SA_SYSCALL_RECVFROM: SA_SC_ASSIGN(sa, recvfrom, fptr, fctx); break;
-        case SA_SYSCALL_SENDTO:   SA_SC_ASSIGN(sa, sendto,   fptr, fctx); break;
+        case SA_SYSCALL_CONNECT:       SA_SC_ASSIGN(sa, connect,       fptr, fctx); break;
+        case SA_SYSCALL_ACCEPT:        SA_SC_ASSIGN(sa, accept,        fptr, fctx); break;
+        case SA_SYSCALL_SELECT:        SA_SC_ASSIGN(sa, select,        fptr, fctx); break;
+        case SA_SYSCALL_READ:          SA_SC_ASSIGN(sa, read,          fptr, fctx); break;
+        case SA_SYSCALL_WRITE:         SA_SC_ASSIGN(sa, write,         fptr, fctx); break;
+        case SA_SYSCALL_RECVFROM:      SA_SC_ASSIGN(sa, recvfrom,      fptr, fctx); break;
+        case SA_SYSCALL_SENDTO:        SA_SC_ASSIGN(sa, sendto,        fptr, fctx); break;
+        case SA_SYSCALL_GETHOSTBYNAME: SA_SC_ASSIGN(sa, gethostbyname, fptr, fctx); break;
         default: rv = SA_ERR_ARG;
     }
 
@@ -1453,6 +1456,7 @@
     socklen_t len;
     sa_rc_t rv;
     struct timeval *tv;
+    struct timeval tv_buf;
 
     /* argument sanity check(s) */
     if (sa == NULL || raddr == NULL)
@@ -1509,12 +1513,14 @@
     FD_ZERO(&wset);
     FD_SET(sa->fdSocket, &rset);
     FD_SET(sa->fdSocket, &wset);
-    if (!SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_CONNECT]))
-        tv = &sa->tvTimeout[SA_TIMEOUT_CONNECT];
+    if (!SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_CONNECT])) {
+        memcpy(&tv_buf, &sa->tvTimeout[SA_TIMEOUT_CONNECT], sizeof(struct timeval));
+        tv = &tv_buf;
+    }
     else
         tv = NULL;
     do {
-        n = SA_SC_CALL_5(sa, select, sa->fdSocket+1, &rset, &wset, NULL, tv);
+        n = SA_SC_CALL_5(sa, select, sa->fdSocket+1, &rset, &wset, (fd_set *)NULL, tv);
     } while (n == -1 && errno == EINTR);
 
     /* decide on return semantic */
@@ -1588,6 +1594,7 @@
 #endif
     } sa_buf;
     socklen_t sa_size;
+    struct timeval tv;
     int s;
     int i;
 
@@ -1607,9 +1614,9 @@
     if (!SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_ACCEPT])) {
         FD_ZERO(&fds);
         FD_SET(sa->fdSocket, &fds);
+        memcpy(&tv, &sa->tvTimeout[SA_TIMEOUT_ACCEPT], sizeof(struct timeval));
         do {
-            n = SA_SC_CALL_5(sa, select, sa->fdSocket+1, &fds, NULL, NULL,
-                             &sa->tvTimeout[SA_TIMEOUT_ACCEPT]);
+            n = SA_SC_CALL_5(sa, select, sa->fdSocket+1, &fds, (fd_set *)NULL, (fd_set *)NULL, &tv);
         } while (n == -1 && errno == EINTR);
         if (n == 0)
             return SA_RC(SA_ERR_TMT);
@@ -1650,6 +1657,7 @@
     SA_SC_COPY((*csa), sa, write);
     SA_SC_COPY((*csa), sa, recvfrom);
     SA_SC_COPY((*csa), sa, sendto);
+    SA_SC_COPY((*csa), sa, gethostbyname);
 
     /* copy-over original timeout values */
     for (i = 0; i < (int)(sizeof(sa->tvTimeout)/sizeof(sa->tvTimeout[0])); i++) {
@@ -1759,6 +1767,7 @@
     int rv;
 #if !(defined(SO_RCVTIMEO) && defined(USE_SO_RCVTIMEO) && defined(SO_SNDTIMEO) && defined(USE_SO_SNDTIMEO))
     fd_set fds;
+    struct timeval tv;
 #endif
 
     /* if timeout is enabled, perform explicit/smart blocking instead
@@ -1767,9 +1776,9 @@
     if (!SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_READ])) {
         FD_ZERO(&fds);
         FD_SET(sa->fdSocket, &fds);
+        memcpy(&tv, &sa->tvTimeout[SA_TIMEOUT_READ], sizeof(struct timeval));
         do {
-            rv = SA_SC_CALL_5(sa, select, sa->fdSocket+1, &fds, NULL, NULL,
-                              &sa->tvTimeout[SA_TIMEOUT_READ]);
+            rv = SA_SC_CALL_5(sa, select, sa->fdSocket+1, &fds, (fd_set *)NULL, (fd_set *)NULL, &tv);
         } while (rv == -1 && errno == EINTR);
         if (rv == 0) {
             errno = ETIMEDOUT;
@@ -1938,6 +1947,7 @@
     int rv;
 #if !(defined(SO_RCVTIMEO) && defined(USE_SO_RCVTIMEO) && defined(SO_SNDTIMEO) && defined(USE_SO_SNDTIMEO))
     fd_set fds;
+    struct timeval tv;
 #endif
 
     /* if timeout is enabled, perform explicit/smart blocking instead
@@ -1946,9 +1956,9 @@
     if (!SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_WRITE])) {
         FD_ZERO(&fds);
         FD_SET(sa->fdSocket, &fds);
+        memcpy(&tv, &sa->tvTimeout[SA_TIMEOUT_WRITE], sizeof(struct timeval));
         do {
-            rv = SA_SC_CALL_5(sa, select, sa->fdSocket+1, NULL, &fds, NULL,
-                              &sa->tvTimeout[SA_TIMEOUT_WRITE]);
+            rv = SA_SC_CALL_5(sa, select, sa->fdSocket+1, (fd_set *)NULL, &fds, (fd_set *)NULL, &tv);
         } while (rv == -1 && errno == EINTR);
         if (rv == 0) {
             errno = ETIMEDOUT;
@@ -2173,6 +2183,7 @@
     ssize_t n;
     int k;
     fd_set fds;
+    struct timeval tv;
 
     /* argument sanity check(s) */
     if (sa == NULL || buf == NULL || buflen == 0 || raddr == NULL)
@@ -2191,9 +2202,9 @@
     if (!SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_READ])) {
         FD_ZERO(&fds);
         FD_SET(sa->fdSocket, &fds);
+        memcpy(&tv, &sa->tvTimeout[SA_TIMEOUT_READ], sizeof(struct timeval));
         do {
-            k = SA_SC_CALL_5(sa, select, sa->fdSocket+1, &fds, NULL, NULL,
-                             &sa->tvTimeout[SA_TIMEOUT_READ]);
+            k = SA_SC_CALL_5(sa, select, sa->fdSocket+1, &fds, (fd_set *)NULL, (fd_set *)NULL, &tv);
         } while (k == -1 && errno == EINTR);
         if (k == 0)
             errno = ETIMEDOUT;
@@ -2229,6 +2240,7 @@
     int k;
     fd_set fds;
     sa_rc_t rv;
+    struct timeval tv;
 
     /* argument sanity check(s) */
     if (sa == NULL || buf == NULL || buflen == 0 || raddr == NULL)
@@ -2248,9 +2260,9 @@
     if (!SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_WRITE])) {
         FD_ZERO(&fds);
         FD_SET(sa->fdSocket, &fds);
+        memcpy(&tv, &sa->tvTimeout[SA_TIMEOUT_WRITE], sizeof(struct timeval));
         do {
-            k = SA_SC_CALL_5(sa, select, sa->fdSocket+1, NULL, &fds, NULL,
-                             &sa->tvTimeout[SA_TIMEOUT_WRITE]);
+            k = SA_SC_CALL_5(sa, select, sa->fdSocket+1, (fd_set *)NULL, &fds, (fd_set *)NULL, &tv);
         } while (k == -1 && errno == EINTR);
         if (k == 0)
             errno = ETIMEDOUT;
@@ -2273,6 +2285,7 @@
 sa_rc_t sa_sendf(sa_t *sa, sa_addr_t *raddr, const char *cpFmt, ...)
 {
     va_list ap;
+    va_list apbak;
     int nBuf;
     char *cpBuf;
     sa_rc_t rv;
@@ -2284,9 +2297,10 @@
 
     /* format string into temporary buffer */
     va_start(ap, cpFmt);
+    va_copy(apbak, ap);
     if ((nBuf = sa_mvsnprintf(NULL, 0, cpFmt, ap)) == -1)
         return SA_RC(SA_ERR_FMT);
-    va_end(ap);
+    va_copy(ap, apbak);
     if ((nBuf+1) > (int)sizeof(caBuf)) {
         /* requires a larger buffer, so allocate dynamically */
         if ((cpBuf = (char *)malloc((size_t)(nBuf+1))) == NULL)
@@ -2296,7 +2310,6 @@
         /* fits into small buffer, so allocate statically */
         cpBuf = caBuf;
     }
-    va_start(ap, cpFmt);
     rv = SA_OK;
     if (sa_mvsnprintf(cpBuf, (size_t)(nBuf+1), cpFmt, ap) == -1)
         rv = SA_ERR_FMT;


ossp-pkg/l2/l2_ut_sa.h 1.23 -> 1.24

--- l2_ut_sa.h   2005/01/24 15:03:18     1.23
+++ l2_ut_sa.h   2005/02/02 12:26:44     1.24
@@ -157,7 +157,8 @@
     SA_SYSCALL_READ,
     SA_SYSCALL_WRITE,
     SA_SYSCALL_RECVFROM,
-    SA_SYSCALL_SENDTO
+    SA_SYSCALL_SENDTO,
+    SA_SYSCALL_GETHOSTBYNAME
 } sa_syscall_t;
 
 /* unique library identifier */
@@ -210,10 +211,5 @@
 /* error handling operations */
 extern char   *sa_error        (sa_rc_t __rv);
 
-/* cleanup */
-#if defined(HAVE_CONFIG_H) && !defined(HAVE_SOCKLEN_T)
-#undef socklen_t
-#endif
-
 #endif /* __SA_H__ */
 

CVSTrac 2.0.1