OSSP CVS Repository

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

Check-in Number: 4734
Date: 2004-Oct-03 16:00:23 (local)
2004-Oct-03 14:00:23 (UTC)
User:rse
Branch:
Comment: Added SA_SYSCALL_GETHOSTBYNAME for supporting the overloading of gethostbyname(2) system calls.
Tickets:
Inspections:
Files:
ossp-pkg/sa/ChangeLog      added-> 1.41
ossp-pkg/sa/sa.c      1.85 -> 1.86     29 inserted, 25 deleted
ossp-pkg/sa/sa.h      added-> 1.41

ossp-pkg/sa/ChangeLog -> 1.41

*** /dev/null    Sat Nov 23 01:23:21 2024
--- -    Sat Nov 23 01:23:26 2024
***************
*** 0 ****
--- 1,229 ----
+    _        ___  ____ ____  ____
+   |_|_ _   / _ \/ ___/ ___||  _ \   ___  __ _
+   _|_||_| | | | \___ \___ \| |_) | / __|/ _` |
+  |_||_|_| | |_| |___) |__) |  __/  \__ \ (_| |
+   |_|_|_|  \___/|____/____/|_|     |___/\__,_|
+ 
+   OSSP sa - Socket Abstraction
+ 
+   CHANGELOG
+ 
+   This is a list of all changes to OSSP sa.
+   For a more brief summary please have a look at the NEWS file.
+ 
+   Changes between 1.2.2 and 1.2.3 (26-Jun-2004 to xx-xxx-2004)
+ 
+    o Added SA_SYSCALL_GETHOSTBYNAME for supporting the overloading
+      of gethostbyname(2) system calls.
+      [Ralf S. Engelschall <rse@engelschall.com>]
+ 
+    o Upgrade build environment to GNU libtool 1.5.10
+      and GNU shtool 2.0.1
+      [Ralf S. Engelschall <rse@engelschall.com>]
+ 
+   Changes between 1.2.1 and 1.2.2 (11-Jun-2004 to 26-Jun-2004)
+ 
+    o Allow negative values for SA_OPTION_LINGER to cover the
+      special case of l_onoff=1/l_linger=0 where a TCP RST
+      based connection termination is performed on close(2).
+      [Alexandre Balaban <abalaban@free.fr>]
+ 
+    o Provide Autoconf check (AC_CHECK_VA_COPY) for va_copy(d,s) macro
+      and fallback implementations and now that we can be sure that
+      va_copy() exists for us, use it in var_formatv() and ts.c instead
+      of the direct assignments (which are not sufficiently portable).
+      [Ralf S. Engelschall <rse@engelschall.com>]
+ 
+    o Remove "#undef socklen_t" from sa.h because the socklen_t
+      fallback is a "typedef" since a longer time.
+      [Ralf S. Engelschall <rse@engelschall.com>]
+ 
+   Changes between 1.2.0 and 1.2.1 (02-Apr-2003 to 11-Jun-2004)
+ 
+    o Fix timeout implementation related to SO_RCVTIMEO/SO_SNDTIMEO.
+      [Ralf S. Engelschall <rse@engelschall.com>,
+       Thomas Lotterer <thomas@lotterer.net>]
+ 
+    o Upgrade build environment to GNU libtool 1.5.6
+      [Ralf S. Engelschall <rse@engelschall.com>]
+ 
+   Changes between 1.1.0 and 1.2.0 (10-Nov-2003 to 02-Apr-2004)
+ 
+    o In sa_connect() also select(2) on the socket if EINTR was
+      returned similar to what is done already for EINPROGRESS, because
+      one is not allowed to re-start connect(2) according to STEVENS
+      (Unix Network Programming, volume 1, section 5.9) but instead have
+      to perform the same post-processing under EINTR (under both timeout
+      and non-timeout situations) what we already did for EINPROGRESS (in
+      timeout-aware situation).
+      [Ralf S. Engelschall]
+ 
+    o Adjusted all copyright messages for new year 2004.
+      [Ralf S. Engelschall]
+ 
+    o Restart accept(2) after interrupted system call.
+      OSSP lmtp2nntp daemon failed to accept a connection after a signal
+      handler was run on Solaris which caused the system call to be
+      interrupted. Issue was found and reported by Amos Gouaux.
+      [Thomas Lotterer <thl@dev.de.cw.net>]
+ 
+    o Add SA_CHECK_SOCKOPT autoconf check to detect setsockopt failing
+      under run-time on Solaris 2.6,8,9,10 and Debian 2.2 because
+      SO_RCVTIMEO|SO_SNDTIMEO are defined but not implemented.
+      Issue was found and reported by Amos Gouaux.
+      [Thomas Lotterer <thl@dev.de.cw.net>, Amos Gouaux <amos@utdallas.edu>]
+ 
+    o Upgrade and unify build environment devtool and devtool.func.
+      Change devtool.conf to require current versions of
+      shtool, libtool and autoconf; correct spelling
+      [Thomas Lotterer <thl@dev.de.cw.net>]
+ 
+   Changes between 1.0.5 and 1.1.0 (31-Jan-2003 to 10-Nov-2003)
+    
+    o Upgrade build environment to GNU autoconf 2.58.
+      [Ralf S. Engelschall <rse@engelschall.com>]
+ 
+    o Upgrade build environment to GNU libtool 1.5.
+      [Ralf S. Engelschall <rse@engelschall.com>]
+ 
+    o Fix memory leak in test suite (sa_test.c).
+      [Ralf S. Engelschall <rse@engelschall.com>]
+ 
+    o Added internal address resolving support via the new IEEE Std
+      1003.1g-2000 ("POSIX.1") getaddrinfo(3) API. This especially
+      provides more portable IPv6 address resolving.
+      [Ralf S. Engelschall <rse@engelschall.com>]
+ 
+   Changes between 1.0.4 and 1.0.5 (28-Jan-2003 to 31-Jan-2003)
+ 
+    o Fixed test suite library (ts.c): the ts_suite_free()
+      function performed an illegal iteration for freeing elements (they
+      were freed but still references for traversing to next element).
+      This is now solved by a look-ahead traversion.
+      [Ralf S. Engelschall, Brian T. Egleston <brian@egleston.com>]
+ 
+    o Fixed test suite (sa_test.c): an sa_addr_t was destroyed
+      too early and this way crashed the test suite.
+      [Brian T. Egleston <brian@egleston.com>]
+ 
+   Changes between 1.0.3 and 1.0.4 (06-Jan-2003 to 28-Jan-2003)
+ 
+    o Fixed embedding support: mappings for symbols sa_sendf and sa_id
+      were missing.
+      [Thomas Lotterer <thl@dev.de.cw.net>]
+ 
+   Changes between 1.0.2 and 1.0.3 (04-Dec-2002 to 06-Jan-2003)
+ 
+    o Adjusted all copyright messages for new year 2003.
+      [Ralf S. Engelschall]
+ 
+    o Fixed generated owner in distribution tarball.
+      [Ralf S. Engelschall]
+ 
+    o Fixed two compile-time warnings in sa_test.c.
+      [Ralf S. Engelschall]
+ 
+   Changes between 1.0.1 and 1.0.2 (07-Nov-2002 to 04-Dec-2002)
+ 
+    o Fixed a few bugs and lots of internal type inconsistencies,
+      all found by splint(1).
+      [Ralf S. Engelschall]
+ 
+    o Upgraded build environment to GNU autoconf 2.57.
+      [Ralf S. Engelschall]
+ 
+   Changes between 1.0.0 and 1.0.1 (01-Nov-2002 to 07-Nov-2002)
+ 
+    o Make sure that "va_list" variables are not compared against NULL
+      because this is not possible on all platforms.
+      [Ralf S. Engelschall]
+ 
+    o Ported to brain-dead OpenUNIX where shutdown(3)'s SHUT_XX values
+      are not easily available and where variables named sa_len conflict
+      with structure fields in vendor headers.
+      [Ralf S. Engelschall]
+ 
+    o Fixed two compile-time warnings.
+      [Alvaro Lopez Ortega <alvaro@alobbs.com>]
+ 
+    o Upgraded build environment to GNU shtool 1.6.2
+      [Ralf S. Engelschall]
+ 
+   Changes between 0.9.3 and 1.0.0 (30-Oct-2002 to 01-Nov-2002)
+    
+    o Consistently return SA_ERR_MEM instead of SA_ERR_SYS
+      if memory allocations failed.
+      [Ralf S. Engelschall]
+ 
+    o Various source tree cleanups.
+      [Ralf S. Engelschall]
+ 
+    o Cleanup markup in manual page (sa.pod)
+      [Ralf S. Engelschall]
+ 
+    o API Cleanups: use politically correct use "extern" keyword in sa.h;
+      use leading underscores for variables names in prototypes; move
+      "raddr" argument to second position in sa_{send,recv,sendf}.
+      [Ralf S. Engelschall]
+ 
+   Changes between 0.9.2 and 0.9.3 (11-Oct-2002 to 30-Oct-2002)
+ 
+    o Added a function sa_sendf(3) which is a convience wrapper
+      to sa_send(3) for sending formatted data. This is similar to what
+      sa_writef(3) does for sa_write(3). The difference is just that
+      sa_writef(3) does not need a temporary buffer (because can use the
+      stream I/O write buffer) while sa_sendf(3) requires a temporary
+      buffer for its operation. Nevertheless the temporary buffer is
+      allocated only if the formatted data is large. For small formatted
+      data a fast stack-based buffer is used for higher performance.
+      [Ralf S. Engelschall]
+ 
+    o Finished implementation of test suite in order to cover
+      mostly all functionality of the API.
+      [Ralf S. Engelschall]
+ 
+    o Rewrote the implementation of sa_option(3) in order to make options
+      configurable _before_ the underlying socket is implicitly
+      allocated. This fixes especially sa_option(sa, SA_OPTION_REUSEADDR, 1)
+      before sa_bind().
+      [Ralf S. Engelschall, Michael van Elst <mlelstv@dev.de.cw.net>]
+ 
+    o Finished writing the documentation (manual page sa.pod).
+      [Ralf S. Engelschall]
+ 
+    o Fixed return code and error handling in sa_read(3).
+      [Ulrich Dessauer <udessauer@agnitas.de>]
+ 
+    o Upgraded build environment to GNU autoconf 2.54 and GNU libtool 1.4.3.
+      [Ralf S. Engelschall]
+ 
+    o Source tree cleanups and polishing.
+      [Ralf S. Engelschall]
+ 
+   Changes between 0.9.1 and 0.9.2 (15-Mar-2002 to 11-Oct-2002)
+ 
+    o Check for inet_addr, inet_aton, inet_pton, inet_ntoa and inet_ntop
+      under configure time and use this to use reasonable fallbacks for
+      the underlying usage of address manipulation functions.
+      [Ralf S. Engelschall]
+ 
+    o Upgraded build environment to GNU shtool 1.6.1.
+      [Ralf S. Engelschall]
+ 
+    o Fixed "make realclean" target.
+      [Ralf S. Engelschall]
+ 
+   Changes between 0.9.0 and 0.9.1 (31-Jan-2002 to 15-Mar-2002)
+ 
+    o Removed gcc -ggdb3 option under --enable-debug.
+      [Ralf S. Engelschall]
+ 
+    o Upgraded build environment to GNU autoconf 2.53 and GNU shtool 1.6.0.
+      [Ralf S. Engelschall]
+ 
+    o Fixed internal snprintf implementation
+      [Ralf S. Engelschall]
+ 
+    o Fixed internal test suite library
+      [Ralf S. Engelschall]
+ 


ossp-pkg/sa/sa.c 1.85 -> 1.86

--- sa.c 2004/06/26 11:38:20     1.85
+++ sa.c 2004/10/03 14:00:23     1.86
@@ -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);
@@ -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;
@@ -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;
     }
 
@@ -1650,6 +1653,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++) {


ossp-pkg/sa/sa.h -> 1.41

*** /dev/null    Sat Nov 23 01:23:21 2024
--- -    Sat Nov 23 01:23:26 2024
***************
*** 0 ****
--- 1,214 ----
+ /*
+ **  OSSP sa - Socket Abstraction
+ **  Copyright (c) 2001-2004 Ralf S. Engelschall <rse@engelschall.com>
+ **  Copyright (c) 2001-2004 The OSSP Project <http://www.ossp.org/>
+ **  Copyright (c) 2001-2004 Cable & Wireless <http://www.cw.com/>
+ **
+ **  This file is part of OSSP sa, a socket abstraction library which
+ **  can be found at http://www.ossp.org/pkg/lib/sa/.
+ **
+ **  Permission to use, copy, modify, and distribute this software for
+ **  any purpose with or without fee is hereby granted, provided that
+ **  the above copyright notice and this permission notice appear in all
+ **  copies.
+ **
+ **  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ **  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ **  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ **  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+ **  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ **  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ **  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ **  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ **  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ **  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ **  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ **  SUCH DAMAGE.
+ **
+ **  sa.h: socket abstraction API
+ */
+ 
+ #ifndef __SA_H__
+ #define __SA_H__
+ 
+ /* system definitions of "size_t", "socklen_t", "struct sockaddr *" */
+ #include <string.h>
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ 
+ /* include optional Autoconf header */
+ #ifdef HAVE_CONFIG_H
+ #include "config.h"
+ #endif
+ 
+ /* fallback for POSIX socklen_t */
+ #if defined(HAVE_CONFIG_H) && !defined(HAVE_SOCKLEN_T)
+ typedef int socklen_t;
+ #endif
+ 
+ /* embedding support */
+ #ifdef SA_PREFIX
+ #if defined(__STDC__) || defined(__cplusplus)
+ #define __SA_CONCAT(x,y) x ## y
+ #define SA_CONCAT(x,y) __SA_CONCAT(x,y)
+ #else
+ #define __SA_CONCAT(x) x
+ #define SA_CONCAT(x,y) __SA_CONCAT(x)y
+ #endif
+ #define sa_addr_st      SA_CONCAT(SA_PREFIX,sa_addr_st)
+ #define sa_addr_t       SA_CONCAT(SA_PREFIX,sa_addr_t)
+ #define sa_rc_t         SA_CONCAT(SA_PREFIX,sa_rc_t)
+ #define sa_st           SA_CONCAT(SA_PREFIX,sa_st)
+ #define sa_t            SA_CONCAT(SA_PREFIX,sa_t)
+ #define sa_addr_create  SA_CONCAT(SA_PREFIX,sa_addr_create)
+ #define sa_addr_destroy SA_CONCAT(SA_PREFIX,sa_addr_destroy)
+ #define sa_addr_u2a     SA_CONCAT(SA_PREFIX,sa_addr_u2a)
+ #define sa_addr_s2a     SA_CONCAT(SA_PREFIX,sa_addr_s2a)
+ #define sa_addr_a2u     SA_CONCAT(SA_PREFIX,sa_addr_a2u)
+ #define sa_addr_a2s     SA_CONCAT(SA_PREFIX,sa_addr_a2s)
+ #define sa_addr_match   SA_CONCAT(SA_PREFIX,sa_addr_match)
+ #define sa_create       SA_CONCAT(SA_PREFIX,sa_create)
+ #define sa_destroy      SA_CONCAT(SA_PREFIX,sa_destroy)
+ #define sa_type         SA_CONCAT(SA_PREFIX,sa_type)
+ #define sa_timeout      SA_CONCAT(SA_PREFIX,sa_timeout)
+ #define sa_buffer       SA_CONCAT(SA_PREFIX,sa_buffer)
+ #define sa_option       SA_CONCAT(SA_PREFIX,sa_option)
+ #define sa_syscall      SA_CONCAT(SA_PREFIX,sa_syscall)
+ #define sa_bind         SA_CONCAT(SA_PREFIX,sa_bind)
+ #define sa_connect      SA_CONCAT(SA_PREFIX,sa_connect)
+ #define sa_listen       SA_CONCAT(SA_PREFIX,sa_listen)
+ #define sa_accept       SA_CONCAT(SA_PREFIX,sa_accept)
+ #define sa_getremote    SA_CONCAT(SA_PREFIX,sa_getremote)
+ #define sa_getlocal     SA_CONCAT(SA_PREFIX,sa_getlocal)
+ #define sa_getfd        SA_CONCAT(SA_PREFIX,sa_getfd)
+ #define sa_shutdown     SA_CONCAT(SA_PREFIX,sa_shutdown)
+ #define sa_read         SA_CONCAT(SA_PREFIX,sa_read)
+ #define sa_readln       SA_CONCAT(SA_PREFIX,sa_readln)
+ #define sa_write        SA_CONCAT(SA_PREFIX,sa_write)
+ #define sa_writef       SA_CONCAT(SA_PREFIX,sa_writef)
+ #define sa_flush        SA_CONCAT(SA_PREFIX,sa_flush)
+ #define sa_recv         SA_CONCAT(SA_PREFIX,sa_recv)
+ #define sa_send         SA_CONCAT(SA_PREFIX,sa_send)
+ #define sa_sendf        SA_CONCAT(SA_PREFIX,sa_sendf)
+ #define sa_id           SA_CONCAT(SA_PREFIX,sa_id)
+ #define sa_error        SA_CONCAT(SA_PREFIX,sa_error)
+ #endif
+ 
+ /* socket address abstraction object type */
+ struct sa_addr_st;
+ typedef struct sa_addr_st sa_addr_t;
+ 
+ /* socket abstraction object type */
+ struct sa_st;
+ typedef struct sa_st sa_t;
+ 
+ /* socket connection types */
+ typedef enum {
+     SA_TYPE_STREAM,
+     SA_TYPE_DATAGRAM
+ } sa_type_t;
+ 
+ /* return codes */
+ typedef enum {
+     SA_OK,      /* Everything Ok                */
+     SA_ERR_ARG, /* Invalid Argument             */
+     SA_ERR_USE, /* Invalid Use Or Context       */
+     SA_ERR_MEM, /* Not Enough Memory            */
+     SA_ERR_MTC, /* Matching Failed              */
+     SA_ERR_EOF, /* End Of Communication         */
+     SA_ERR_TMT, /* Communication Timeout        */
+     SA_ERR_SYS, /* Operating System Error       */
+     SA_ERR_NET, /* Networking Error             */
+     SA_ERR_FMT, /* Formatting Error             */
+     SA_ERR_IMP, /* Implementation Not Available */
+     SA_ERR_INT  /* Internal Error               */
+ } sa_rc_t;
+ 
+ /* list of timeouts */
+ typedef enum {
+     SA_TIMEOUT_ALL      = -1,
+     SA_TIMEOUT_ACCEPT   = 0,
+     SA_TIMEOUT_CONNECT  = 1,
+     SA_TIMEOUT_READ     = 2,
+     SA_TIMEOUT_WRITE    = 3
+ } sa_timeout_t;
+ 
+ /* list of buffers */
+ typedef enum {
+     SA_BUFFER_READ,
+     SA_BUFFER_WRITE
+ } sa_buffer_t;
+ 
+ /* list of options */
+ typedef enum {
+     SA_OPTION_NAGLE     = 0,
+     SA_OPTION_LINGER    = 1,
+     SA_OPTION_REUSEADDR = 2,
+     SA_OPTION_REUSEPORT = 3,
+     SA_OPTION_NONBLOCK  = 4
+ } sa_option_t;
+ 
+ /* list of system calls */
+ typedef enum {
+     SA_SYSCALL_CONNECT,
+     SA_SYSCALL_ACCEPT,
+     SA_SYSCALL_SELECT,
+     SA_SYSCALL_READ,
+     SA_SYSCALL_WRITE,
+     SA_SYSCALL_RECVFROM,
+     SA_SYSCALL_SENDTO,
+     SA_SYSCALL_GETHOSTBYNAME
+ } sa_syscall_t;
+ 
+ /* unique library identifier */
+ extern const char sa_id[];
+ 
+ /* address object operations */
+ extern sa_rc_t sa_addr_create  (sa_addr_t **__saa);
+ extern sa_rc_t sa_addr_destroy (sa_addr_t  *__saa);
+ 
+ /* address operations */
+ extern sa_rc_t sa_addr_u2a     (sa_addr_t  *__saa, const char *__uri, ...);
+ extern sa_rc_t sa_addr_s2a     (sa_addr_t  *__saa, const struct sockaddr *__sabuf, socklen_t __salen);
+ extern sa_rc_t sa_addr_a2u     (sa_addr_t  *__saa, char **__uri);
+ extern sa_rc_t sa_addr_a2s     (sa_addr_t  *__saa, struct sockaddr **__sabuf, socklen_t *__salen);
+ extern sa_rc_t sa_addr_match   (sa_addr_t  *__saa1, sa_addr_t *__saa2, int __prefixlen);
+ 
+ /* socket object operations */
+ extern sa_rc_t sa_create       (sa_t **__sa);
+ extern sa_rc_t sa_destroy      (sa_t  *__sa);
+ 
+ /* socket parameter operations */
+ extern sa_rc_t sa_type         (sa_t  *__sa, sa_type_t    __id);
+ extern sa_rc_t sa_timeout      (sa_t  *__sa, sa_timeout_t __id, long __sec, long __usec);
+ extern sa_rc_t sa_buffer       (sa_t  *__sa, sa_buffer_t  __id, size_t __size);
+ extern sa_rc_t sa_option       (sa_t  *__sa, sa_option_t  __id, ...);
+ extern sa_rc_t sa_syscall      (sa_t  *__sa, sa_syscall_t __id, void (*__fptr)(void), void *__fctx);
+ 
+ /* socket connection operations */
+ extern sa_rc_t sa_bind         (sa_t  *__sa, sa_addr_t  *__laddr);
+ extern sa_rc_t sa_connect      (sa_t  *__sa, sa_addr_t  *__raddr);
+ extern sa_rc_t sa_listen       (sa_t  *__sa, int __backlog);
+ extern sa_rc_t sa_accept       (sa_t  *__sa, sa_addr_t **__caddr, sa_t **__csa);
+ extern sa_rc_t sa_getremote    (sa_t  *__sa, sa_addr_t **__raddr);
+ extern sa_rc_t sa_getlocal     (sa_t  *__sa, sa_addr_t **__laddr);
+ extern sa_rc_t sa_getfd        (sa_t  *__sa, int *__fd);
+ extern sa_rc_t sa_shutdown     (sa_t  *__sa, char *__flags);
+ 
+ /* socket input/output operations (stream communication) */
+ extern sa_rc_t sa_read         (sa_t  *__sa, char       *__buf, size_t __buflen, size_t *__bufdone);
+ extern sa_rc_t sa_readln       (sa_t  *__sa, char       *__buf, size_t __buflen, size_t *__bufdone);
+ extern sa_rc_t sa_write        (sa_t  *__sa, const char *__buf, size_t __buflen, size_t *__bufdone);
+ extern sa_rc_t sa_writef       (sa_t  *__sa, const char *__fmt, ...);
+ extern sa_rc_t sa_flush        (sa_t  *__sa);
+ 
+ /* socket input/output operations (datagram communication) */
+ extern sa_rc_t sa_recv         (sa_t  *__sa, sa_addr_t **__raddr, char       *__buf, size_t __buflen, size_t *__bufdone);
+ extern sa_rc_t sa_send         (sa_t  *__sa, sa_addr_t  *__raddr, const char *__buf, size_t __buflen, size_t *__bufdone);
+ extern sa_rc_t sa_sendf        (sa_t  *__sa, sa_addr_t  *__raddr, const char *__fmt, ...);
+ 
+ /* error handling operations */
+ extern char   *sa_error        (sa_rc_t __rv);
+ 
+ #endif /* __SA_H__ */
+ 

CVSTrac 2.0.1