head 1.45; access; symbols LMTP2NNTP_1_4_1:1.44 LMTP2NNTP_1_4_0:1.44 SIO_0_9_3:1.44 SA_1_2_6:1.44 SA_1_2_5:1.43 SA_1_2_4:1.42 SA_1_2_3:1.42 LMTP2NNTP_1_3_0:1.40 LMTP2NNTP_1_3b2:1.40 SA_1_2_2:1.40 LMTP2NNTP_1_3b1:1.39 SA_1_2_1:1.39 LMTP2NNTP_1_3a3:1.39 LMTP2NNTP_1_3a2:1.39 LMTP2NNTP_1_3a1:1.39 SA_1_2_0:1.39 SA_1_1_0:1.37 SIO_0_9_2:1.37 SIO_0_9_1:1.37 LMTP2NNTP_1_2_0:1.37 LMTP2NNTP_1_2b4:1.37 LMTP2NNTP_1_2b3:1.37 LMTP2NNTP_1_2b2:1.37 LMTP2NNTP_1_2b1:1.37 LMTP2NNTP_1_2a8:1.37 SIO_0_9_0:1.37 LMTP2NNTP_1_2a7:1.37 SA_1_0_5:1.37 SA_1_0_4:1.37 SA_1_0_3:1.36 SA_1_0_2:1.35 SA_1_0_1:1.34 SA_1_0_0:1.34 SA_0_9_3:1.33 SA_0_9_2:1.31 LMTP2NNTP_1_2a6:1.30 LMTP2NNTP_1_2a5:1.30 SA_0_9_1:1.30 LMTP2NNTP_1_2a4:1.29 LMTP2NNTP_1_2a3:1.29 SA_0_9_0:1.29 LMTP2NNTP_1_2a1:1.24 LMTP2NNTP_1_1_1:1.24 LMTP2NNTP_1_1_0:1.24 LMTP2NNTP_1_1b4:1.24 LMTP2NNTP_1_1b3:1.24 LMTP2NNTP_1_1b2:1.23 LMTP2NNTP_1_1b1:1.23 SA_0_0_0:1.1.1.1 VENDOR:1.1.1; locks; strict; comment @ * @; 1.45 date 2006.06.10.10.00.17; author rse; state Exp; branches; next 1.44; commitid JpcJR7gM5uNpwrAr; 1.44 date 2005.10.03.08.16.56; author rse; state Exp; branches; next 1.43; 1.43 date 2005.03.29.19.24.29; author rse; state Exp; branches; next 1.42; 1.42 date 2005.01.24.15.10.09; author rse; state Exp; branches; next 1.41; 1.41 date 2004.10.03.14.00.23; author rse; state Exp; branches; next 1.40; 1.40 date 2004.06.26.11.38.20; author rse; state Exp; branches; next 1.39; 1.39 date 2004.04.02.18.21.07; author rse; state Exp; branches; next 1.38; 1.38 date 2004.03.26.16.57.14; author thl; state Exp; branches; next 1.37; 1.37 date 2003.01.23.16.21.06; author thl; state Exp; branches; next 1.36; 1.36 date 2003.01.06.13.11.23; author rse; state Exp; branches; next 1.35; 1.35 date 2002.11.28.15.42.41; author rse; state Exp; branches; next 1.34; 1.34 date 2002.10.30.20.22.06; author rse; state Exp; branches; next 1.33; 1.33 date 2002.10.30.19.09.35; author rse; state Exp; branches; next 1.32; 1.32 date 2002.10.30.08.42.16; author rse; state Exp; branches; next 1.31; 1.31 date 2002.10.11.15.27.39; author rse; state Exp; branches; next 1.30; 1.30 date 2002.03.15.10.47.36; author rse; state Exp; branches; next 1.29; 1.29 date 2002.01.30.16.43.00; author rse; state Exp; branches; next 1.28; 1.28 date 2002.01.02.13.44.48; author rse; state Exp; branches; next 1.27; 1.27 date 2002.01.02.13.35.36; author rse; state Exp; branches; next 1.26; 1.26 date 2002.01.02.12.43.50; author rse; state Exp; branches; next 1.25; 1.25 date 2001.11.30.09.50.44; author rse; state Exp; branches; next 1.24; 1.24 date 2001.10.31.12.41.53; author rse; state Exp; branches; next 1.23; 1.23 date 2001.10.11.08.00.37; author thl; state Exp; branches; next 1.22; 1.22 date 2001.10.10.09.21.27; author rse; state Exp; branches; next 1.21; 1.21 date 2001.10.10.07.42.26; author rse; state Exp; branches; next 1.20; 1.20 date 2001.10.09.20.19.58; author rse; state Exp; branches; next 1.19; 1.19 date 2001.10.09.18.55.22; author rse; state Exp; branches; next 1.18; 1.18 date 2001.10.09.18.34.12; author rse; state Exp; branches; next 1.17; 1.17 date 2001.10.09.14.05.55; author rse; state Exp; branches; next 1.16; 1.16 date 2001.10.09.13.19.25; author rse; state Exp; branches; next 1.15; 1.15 date 2001.10.08.15.01.26; author rse; state Exp; branches; next 1.14; 1.14 date 2001.10.08.14.47.30; author rse; state dead; branches; next 1.13; 1.13 date 2001.10.08.10.03.54; author rse; state Exp; branches; next 1.12; 1.12 date 2001.10.07.15.21.17; author rse; state Exp; branches; next 1.11; 1.11 date 2001.10.07.14.16.47; author rse; state Exp; branches; next 1.10; 1.10 date 2001.10.06.16.01.48; author rse; state Exp; branches; next 1.9; 1.9 date 2001.10.06.11.05.43; author rse; state Exp; branches; next 1.8; 1.8 date 2001.10.05.21.11.22; author rse; state Exp; branches; next 1.7; 1.7 date 2001.10.05.20.52.15; author rse; state Exp; branches; next 1.6; 1.6 date 2001.10.05.11.49.10; author rse; state Exp; branches; next 1.5; 1.5 date 2001.10.05.11.40.22; author rse; state Exp; branches; next 1.4; 1.4 date 2001.10.04.11.25.44; author rse; state Exp; branches; next 1.3; 1.3 date 2001.10.03.19.40.31; author rse; state Exp; branches; next 1.2; 1.2 date 2001.10.02.14.12.27; author thl; state Exp; branches; next 1.1; 1.1 date 2001.10.02.13.27.45; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2001.10.02.13.27.45; author rse; state Exp; branches; next ; desc @@ 1.45 log @Adjusted all copyright messages for year 2006 @ text @/* ** OSSP sa - Socket Abstraction ** Copyright (c) 2001-2006 Ralf S. Engelschall ** Copyright (c) 2001-2006 The OSSP Project ** Copyright (c) 2001-2005 Cable & Wireless ** ** 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 #include #include /* 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_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 (const sa_addr_t *__saa, char **__uri); extern sa_rc_t sa_addr_a2s (const sa_addr_t *__saa, struct sockaddr **__sabuf, socklen_t *__salen); extern sa_rc_t sa_addr_match (const sa_addr_t *__saa1, const 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, const sa_addr_t *__laddr); extern sa_rc_t sa_connect (sa_t *__sa, const 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, const 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__ */ @ 1.44 log @Removed SA_SYSCALL_GETHOSTBYNAME because gethostbyname(3) cannot be overridden as at is use point (function sa_addr_u2a) the sa_t object is not available. Additionally, for IPv6 getaddrinfo(3) would have been overridden, too. This fixed compilation on platforms without IPv6 APIs. @ text @d3 2 a4 2 ** Copyright (c) 2001-2005 Ralf S. Engelschall ** Copyright (c) 2001-2005 The OSSP Project @ 1.43 log @Follow FlexeLint suggestions and "constify" some API function parameters. @ text @d159 1 a159 2 SA_SYSCALL_SENDTO, SA_SYSCALL_GETHOSTBYNAME @ 1.42 log @welcome 2005 in OSSP sa, too @ text @d171 5 a175 5 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); d189 2 a190 2 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); d196 1 a196 1 extern sa_rc_t sa_shutdown (sa_t *__sa, char *__flags); @ 1.41 log @Added SA_SYSCALL_GETHOSTBYNAME for supporting the overloading of gethostbyname(2) system calls. @ text @d3 3 a5 3 ** Copyright (c) 2001-2004 Ralf S. Engelschall ** Copyright (c) 2001-2004 The OSSP Project ** Copyright (c) 2001-2004 Cable & Wireless @ 1.40 log @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). o Remove "#undef socklen_t" from sa.h because the socklen_t fallback is a "typedef" since a longer time. @ text @d159 2 a160 1 SA_SYSCALL_SENDTO @ 1.39 log @Adjusted all copyright messages for new year 2004. @ text @a211 5 /* cleanup */ #if defined(HAVE_CONFIG_H) && !defined(HAVE_SOCKLEN_T) #undef socklen_t #endif @ 1.38 log @add more compiler warning options and fix prototype declarations found by -Wstrict-prototypes @ text @d3 3 a5 3 ** Copyright (c) 2001-2003 Ralf S. Engelschall ** Copyright (c) 2001-2003 The OSSP Project ** Copyright (c) 2001-2003 Cable & Wireless Deutschland @ 1.37 log @fix embedding support @ text @d185 1 a185 1 extern sa_rc_t sa_syscall (sa_t *__sa, sa_syscall_t __id, void (*__fptr)(), void *__fctx); @ 1.36 log @- Adjusted all copyright messages for new year 2003. - Fixed generated owner in distribution tarball. - Prepare for 1.0.3 release @ text @d92 2 @ 1.35 log @fix a few bugs, remove a lot of warnings; all found by splint @ text @d3 3 a5 3 ** Copyright (c) 2001-2002 Ralf S. Engelschall ** Copyright (c) 2001-2002 The OSSP Project ** Copyright (c) 2001-2002 Cable & Wireless Deutschland @ 1.34 log @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}. @ text @d119 2 @ 1.33 log @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. @ text @d162 2 a163 2 sa_rc_t sa_addr_create (sa_addr_t **saa); sa_rc_t sa_addr_destroy (sa_addr_t *saa); d166 5 a170 5 sa_rc_t sa_addr_u2a (sa_addr_t *saa, const char *uri, ...); sa_rc_t sa_addr_s2a (sa_addr_t *saa, const struct sockaddr *sabuf, socklen_t salen); sa_rc_t sa_addr_a2u (sa_addr_t *saa, char **uri); sa_rc_t sa_addr_a2s (sa_addr_t *saa, struct sockaddr **sabuf, socklen_t *salen); sa_rc_t sa_addr_match (sa_addr_t *saa1, sa_addr_t *saa2, int prefixlen); d173 2 a174 2 sa_rc_t sa_create (sa_t **sa); sa_rc_t sa_destroy (sa_t *sa); d177 5 a181 5 sa_rc_t sa_type (sa_t *sa, sa_type_t type); sa_rc_t sa_timeout (sa_t *sa, sa_timeout_t id, long sec, long usec); sa_rc_t sa_buffer (sa_t *sa, sa_buffer_t id, size_t size); sa_rc_t sa_option (sa_t *sa, sa_option_t id, ...); sa_rc_t sa_syscall (sa_t *sa, sa_syscall_t id, void (*fptr)(), void *fctx); d184 8 a191 8 sa_rc_t sa_bind (sa_t *sa, sa_addr_t *laddr); sa_rc_t sa_connect (sa_t *sa, sa_addr_t *raddr); sa_rc_t sa_listen (sa_t *sa, int backlog); sa_rc_t sa_accept (sa_t *sa, sa_addr_t **caddr, sa_t **csa); sa_rc_t sa_getremote (sa_t *sa, sa_addr_t **raddr); sa_rc_t sa_getlocal (sa_t *sa, sa_addr_t **laddr); sa_rc_t sa_getfd (sa_t *sa, int *fd); sa_rc_t sa_shutdown (sa_t *sa, char *flags); d194 5 a198 5 sa_rc_t sa_read (sa_t *sa, char *buf, size_t buflen, size_t *bufdone); sa_rc_t sa_readln (sa_t *sa, char *buf, size_t buflen, size_t *bufdone); sa_rc_t sa_write (sa_t *sa, const char *buf, size_t buflen, size_t *bufdone); sa_rc_t sa_writef (sa_t *sa, const char *fmt, ...); sa_rc_t sa_flush (sa_t *sa); d201 3 a203 3 sa_rc_t sa_recv (sa_t *sa, char *buf, size_t buflen, size_t *bufdone, sa_addr_t **raddr); sa_rc_t sa_send (sa_t *sa, const char *buf, size_t buflen, size_t *bufdone, sa_addr_t *raddr); sa_rc_t sa_sendf (sa_t *sa, sa_addr_t *raddr, const char *fmt, ...); d206 1 a206 1 char *sa_error (sa_rc_t rv); @ 1.32 log @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(). @ text @d203 1 @ 1.31 log @- fix inet_ntoa(3) usage - fallback to usage of inet_addr(3) if inet_aton(3) does not exists - add casts for arguments to [gs]etsockopt(3) to shut down warnings (This especially gets OSSP sa running under dead Solaris 2.6...) @ text @d140 5 a144 5 SA_OPTION_NAGLE, SA_OPTION_LINGER, SA_OPTION_REUSEADDR, SA_OPTION_REUSEPORT, SA_OPTION_NONBLOCK @ 1.30 log @polishing for release @ text @d46 1 a46 1 #define socklen_t int @ 1.29 log @add optional OSSP ex based exception handling support @ text @d2 1 a2 1 ** SA - OSSP Socket Abstraction Library d7 2 a8 2 ** This file is part of OSSP SA, a socket abstraction library which ** can be found at http://www.ossp.org/pkg/sa/. @ 1.28 log @add support for lingering on close @ text @d158 3 @ 1.27 log @add support for reusability of address or port @ text @d141 1 @ 1.26 log @bump copyright year @ text @d141 2 @ 1.25 log @add missing API function call namespace protector @ text @d3 3 a5 3 ** Copyright (c) 2001 Ralf S. Engelschall ** Copyright (c) 2001 The OSSP Project ** Copyright (c) 2001 Cable & Wireless Deutschland @ 1.24 log @- provide additional SA_ERR_IMP result code for indicating that an implementation part is not available on the current platform. - provide new sa_option() function for setting various socket options. - implement SA_OPTION_NAGLE (for enabling/disabling Nagle's Algorithm) and SA_OPTION_NONBLOCK (for enabling/disabling non-blocking I/O mode). @ text @d75 1 @ 1.23 log @updated embedding support for new and renamed functions @ text @d110 10 a119 9 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_INT /* Internal Error */ d137 6 d173 1 @ 1.22 log @Revert my idea of using an L2-style error handling also in SA, because this is not possible in a consistent way due to the multiple objects and the fact that we cannot remember anything without an object (in L2 an environment object will be introduced soon, so there is it is a different game). So we use a plain sa_error() which is now similar to strerror(3). @ text @d69 1 d74 2 a75 1 #define sa_buffers SA_CONCAT(SA_PREFIX,sa_buffers) d91 1 @ 1.21 log @Change sa_rc_t sa_buffers (sa_t *sa, size_t rsize, size_t wsize); to sa_rc_t sa_buffer (sa_t *sa, sa_buffer_t id, size_t size); in order to make this API function more flexible. @ text @d107 9 a115 9 SA_OK, /* everything ok */ SA_ERR_ARG, /* invalid argument */ SA_ERR_USE, /* invalid use or context */ SA_ERR_MEM, /* not enough memory available */ SA_ERR_MTC, /* matching operation failed */ SA_ERR_EOF, /* communication end */ SA_ERR_TMT, /* communication timeout */ SA_ERR_SYS, /* operating system error */ SA_ERR_INT /* internal error */ d187 1 a187 1 sa_rc_t sa_error (sa_t *sa, sa_rc_t rv, char **str); @ 1.20 log @[still untested stuff] - Remove SA_TIMEOUT_RECV and SA_TIMEOUT_SEND, because SA_TIMEOUT_READ and SA_TIMEOUT_WRITE are sufficient because you cannot use datagram and stream communication at the same time anyway. So there is no need to distinguish between the two communications in timeouts. Additionally this enables the next point from being able to be implemented at all. - Implement the read/write timeouts alternatively in kernel-space through the newer SO_RCVTIMEO and SO_SNDTIMEO socket options. This means a select(2) system call less for each read/write operation. @ text @d127 6 d162 1 a162 1 sa_rc_t sa_buffers (sa_t *sa, size_t rsize, size_t wsize); @ 1.19 log @- error text cleanup - allow "sa_t *" to be NULL @ text @d124 1 a124 3 SA_TIMEOUT_WRITE = 3, SA_TIMEOUT_RECV = 4, SA_TIMEOUT_SEND = 5 @ 1.18 log @Change return code semantic for timeouts from "rv == SA_ERR_SYS && errno == ETIMEDOUT" to a dedicated timeout return value "rv == SA_ERR_TMT". @ text @d107 9 a115 9 SA_OK, /* everything ok */ SA_ERR_ARG, /* invalid argument (wrong parameter) */ SA_ERR_USE, /* invalid use (wrong context) */ SA_ERR_MEM, /* out of memory */ SA_ERR_SYS, /* system error (see errno) */ SA_ERR_EOF, /* end of file/socket communication */ SA_ERR_MTC, /* error in match */ SA_ERR_TMT, /* operation timeout */ SA_ERR_INT /* internal error */ a139 3 /* error handling operations */ sa_rc_t sa_error (sa_t *sa, sa_rc_t rv, char **str); d181 3 @ 1.17 log @Support prefixlen == 0 for an "always matches" and instead use prefixlen == -1 for "full match". Credits to Thomas ;) @ text @d114 1 @ 1.16 log @Implement new sa_addr_match() function which can be used for Access Control List (ACL) implementations. It is capable of matching Unix Domain and Internet Addresses (both IPv4 and IPv6) with prefix lengths. @ text @d151 1 a151 1 sa_rc_t sa_addr_match (sa_addr_t *saa1, sa_addr_t *saa2, size_t prefixlen); @ 1.15 log @Revert my idea of fixing the socklen_t stuff with a fallback substitution in sa.h, because this is nasty for the inclusion in L2. Do it with a less-heavy #define on-the-fly in sa.h @ text @d113 1 d151 1 @ 1.14 log @make SA more portable (now also works under Tru64 5.0) @ text @d39 10 d181 5 @ 1.13 log @Various cleanups @ text @@ 1.12 log @Implement (still fully untested!) system call overriding support through a new function sa_syscall(). Anybody here who finds predestinated to test this out in depth? @ text @d3 3 a5 2 ** Copyright (c) 2001 The OSSP Project (http://www.ossp.org/) ** Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/) @ 1.11 log @Provide distinct timeouts, i.e., an own timeout for each individual I/O function. This is especially useful because an accept(2) timeout is usually something totally different than a connect(2) timeout. @ text @d116 11 d148 1 @ 1.10 log @Add sa_error() function. @ text @d105 11 d135 1 a135 1 sa_rc_t sa_timeout (sa_t *sa, long sec, long usec); @ 1.9 log @reflect recent changes @ text @d105 3 @ 1.8 log @more documentation @ text @a62 2 #define sa_getoption SA_CONCAT(SA_PREFIX,sa_getoption) #define sa_setoption SA_CONCAT(SA_PREFIX,sa_setoption) d72 1 a72 2 #define sa_readfrom SA_CONCAT(SA_PREFIX,sa_readfrom) #define sa_readline SA_CONCAT(SA_PREFIX,sa_readline) d74 1 a74 2 #define sa_writeto SA_CONCAT(SA_PREFIX,sa_writeto) #define sa_printf SA_CONCAT(SA_PREFIX,sa_printf) d76 2 @ 1.7 log @Woohhhooo: Second major revamp of Socket Abstraction (SA) library. This time is gets really close to a 100% clean and polished library. @ text @d98 1 a98 1 SA_OK, @ 1.6 log @update to reflect latest changes @ text @d33 1 a33 1 /* system definitions of "size_t", "socklen_t", "struct sockaddr" */ d99 6 a104 5 SA_ERR_ARG, SA_ERR_USE, SA_ERR_MEM, SA_ERR_SYS, SA_ERR_INT a124 2 sa_rc_t sa_getoption (sa_t *sa, int optname, void *optval, socklen_t *optlen); sa_rc_t sa_setoption (sa_t *sa, int optname, const void *optval, socklen_t optlen); d136 1 a136 1 /* socket input/output operations */ d138 1 a138 2 sa_rc_t sa_readfrom (sa_t *sa, char *buf, size_t buflen, size_t *bufdone, sa_addr_t **raddr); sa_rc_t sa_readline (sa_t *sa, char *buf, size_t buflen, size_t *bufdone); a139 1 sa_rc_t sa_writeto (sa_t *sa, const char *buf, size_t buflen, size_t *bufdone, sa_addr_t *raddr); d142 4 @ 1.5 log @Major revamp of SA library in order to support Unix Domain sockets. - "{tcp,udp}://host:port" addresses are now "inet://host:port" addresses - "unix:/path/to/socket" is the address for Unix Domain sockets - sa_type() was introduced which sets socket type to stream or datagram @ text @d47 33 a79 28 #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_u2a SA_CONCAT(SA_PREFIX,sa_u2a) #define sa_s2a SA_CONCAT(SA_PREFIX,sa_s2a) #define sa_a2u SA_CONCAT(SA_PREFIX,sa_a2u) #define sa_a2s SA_CONCAT(SA_PREFIX,sa_a2s) #define sa_create SA_CONCAT(SA_PREFIX,sa_create) #define sa_destroy SA_CONCAT(SA_PREFIX,sa_destroy) #define sa_timeout SA_CONCAT(SA_PREFIX,sa_timeout) #define sa_buffers SA_CONCAT(SA_PREFIX,sa_buffers) #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_readfrom SA_CONCAT(SA_PREFIX,sa_readfrom) #define sa_readline SA_CONCAT(SA_PREFIX,sa_readline) #define sa_write SA_CONCAT(SA_PREFIX,sa_write) #define sa_writeto SA_CONCAT(SA_PREFIX,sa_writeto) #define sa_printf SA_CONCAT(SA_PREFIX,sa_printf) #define sa_flush SA_CONCAT(SA_PREFIX,sa_flush) @ 1.4 log @Change sa_addr_t API: - there is now a constructor and destructor - renamed sa_x2x functions to sa_addr_x2x @ text @d85 6 d116 1 @ 1.3 log @- Use an own minimal snprintf(3) - Rename sa_printf to sa_writef @ text @d95 4 d100 4 a103 4 sa_rc_t sa_u2a (sa_addr_t **saa, const char *uri, ...); sa_rc_t sa_s2a (sa_addr_t **saa, const struct sockaddr *sabuf, socklen_t salen); sa_rc_t sa_a2u (const sa_addr_t *saa, char **uri); sa_rc_t sa_a2s (const sa_addr_t *saa, struct sockaddr **sabuf, socklen_t *salen); d105 3 a107 3 /* object operations */ sa_rc_t sa_create (sa_t **sa); sa_rc_t sa_destroy (sa_t *sa); d109 5 a113 5 /* parameter operations */ sa_rc_t sa_timeout (sa_t *sa, long sec, long usec); sa_rc_t sa_buffers (sa_t *sa, size_t rsize, size_t wsize); sa_rc_t sa_getoption(sa_t *sa, int optname, void *optval, socklen_t *optlen); sa_rc_t sa_setoption(sa_t *sa, int optname, const void *optval, socklen_t optlen); d115 9 a123 9 /* connection operations */ sa_rc_t sa_bind (sa_t *sa, sa_addr_t *laddr); sa_rc_t sa_connect (sa_t *sa, sa_addr_t *raddr); sa_rc_t sa_listen (sa_t *sa, int backlog); sa_rc_t sa_accept (sa_t *sa, sa_addr_t **caddr, sa_t **csa); sa_rc_t sa_getremote(sa_t *sa, sa_addr_t **raddr); sa_rc_t sa_getlocal (sa_t *sa, sa_addr_t **laddr); sa_rc_t sa_getfd (sa_t *sa, int *fd); sa_rc_t sa_shutdown (sa_t *sa, char *flags); d125 8 a132 8 /* input/output operations */ sa_rc_t sa_read (sa_t *sa, char *buf, size_t buflen, size_t *bufdone); sa_rc_t sa_readfrom (sa_t *sa, char *buf, size_t buflen, size_t *bufdone, sa_addr_t **raddr); sa_rc_t sa_readline (sa_t *sa, char *buf, size_t buflen, size_t *bufdone); sa_rc_t sa_write (sa_t *sa, const char *buf, size_t buflen, size_t *bufdone); sa_rc_t sa_writeto (sa_t *sa, const char *buf, size_t buflen, size_t *bufdone, sa_addr_t *raddr); sa_rc_t sa_writef (sa_t *sa, const char *fmt, ...); sa_rc_t sa_flush (sa_t *sa); @ 1.2 log @provide embedding support @ text @d108 2 d127 1 a127 1 sa_rc_t sa_printf (sa_t *sa, const char *fmt, ...); @ 1.1 log @Initial revision @ text @d38 39 @ 1.1.1.1 log @Import first cut of OSSP SA @ text @@