Home | History | Annotate | Line # | Download | only in roken
      1  1.1     elric /* -*- C -*- */
      2  1.1     elric /*
      3  1.1     elric  * Copyright (c) 1995-2005 Kungliga Tekniska Hgskolan
      4  1.1     elric  * (Royal Institute of Technology, Stockholm, Sweden).
      5  1.1     elric  * All rights reserved.
      6  1.4  christos  *
      7  1.1     elric  * Redistribution and use in source and binary forms, with or without
      8  1.1     elric  * modification, are permitted provided that the following conditions
      9  1.1     elric  * are met:
     10  1.4  christos  *
     11  1.1     elric  * 1. Redistributions of source code must retain the above copyright
     12  1.1     elric  *    notice, this list of conditions and the following disclaimer.
     13  1.4  christos  *
     14  1.1     elric  * 2. Redistributions in binary form must reproduce the above copyright
     15  1.1     elric  *    notice, this list of conditions and the following disclaimer in the
     16  1.1     elric  *    documentation and/or other materials provided with the distribution.
     17  1.4  christos  *
     18  1.1     elric  * 3. Neither the name of the Institute nor the names of its contributors
     19  1.1     elric  *    may be used to endorse or promote products derived from this software
     20  1.1     elric  *    without specific prior written permission.
     21  1.4  christos  *
     22  1.1     elric  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
     23  1.1     elric  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24  1.1     elric  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25  1.1     elric  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
     26  1.1     elric  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27  1.1     elric  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28  1.1     elric  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29  1.1     elric  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30  1.1     elric  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31  1.1     elric  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32  1.1     elric  * SUCH DAMAGE.
     33  1.1     elric  */
     34  1.1     elric 
     35  1.4  christos #if defined(_WIN32) && _MSC_VER >= 1400
     36  1.4  christos /* _CRT_RAND_S must be defined before including stdlib.h */
     37  1.4  christos # define _CRT_RAND_S
     38  1.4  christos # define HAVE_WIN32_RAND_S 1
     39  1.4  christos #endif
     40  1.4  christos 
     41  1.1     elric #include <stdio.h>
     42  1.1     elric #include <stdlib.h>
     43  1.1     elric #include <stdarg.h>
     44  1.1     elric #ifdef HAVE_STDINT_H
     45  1.1     elric #include <stdint.h>
     46  1.1     elric #endif
     47  1.1     elric #include <string.h>
     48  1.4  christos #include <limits.h>
     49  1.1     elric #include <signal.h>
     50  1.1     elric 
     51  1.1     elric #ifndef ROKEN_LIB_FUNCTION
     52  1.1     elric #ifdef _WIN32
     53  1.1     elric #  define ROKEN_LIB_CALL     __cdecl
     54  1.1     elric #  ifdef ROKEN_LIB_DYNAMIC
     55  1.1     elric #    define ROKEN_LIB_FUNCTION __declspec(dllimport)
     56  1.1     elric #    define ROKEN_LIB_VARIABLE __declspec(dllimport)
     57  1.1     elric #  else
     58  1.1     elric #    define ROKEN_LIB_FUNCTION
     59  1.1     elric #    define ROKEN_LIB_VARIABLE
     60  1.1     elric #  endif
     61  1.1     elric #else
     62  1.1     elric #define ROKEN_LIB_FUNCTION
     63  1.1     elric #define ROKEN_LIB_CALL
     64  1.1     elric #define ROKEN_LIB_VARIABLE
     65  1.1     elric #endif
     66  1.1     elric #endif
     67  1.1     elric 
     68  1.1     elric #ifdef HAVE_WINSOCK
     69  1.1     elric /* Declarations for Microsoft Windows */
     70  1.1     elric 
     71  1.1     elric #include <winsock2.h>
     72  1.1     elric #include <ws2tcpip.h>
     73  1.1     elric 
     74  1.1     elric /*
     75  1.4  christos  * error codes for inet_ntop/inet_pton
     76  1.1     elric  */
     77  1.1     elric typedef SOCKET rk_socket_t;
     78  1.1     elric 
     79  1.1     elric #define rk_closesocket(x) closesocket(x)
     80  1.1     elric #define rk_INVALID_SOCKET INVALID_SOCKET
     81  1.1     elric #define rk_IS_BAD_SOCKET(s) ((s) == INVALID_SOCKET)
     82  1.1     elric #define rk_IS_SOCKET_ERROR(rv) ((rv) == SOCKET_ERROR)
     83  1.1     elric #define rk_SOCK_ERRNO WSAGetLastError()
     84  1.1     elric 
     85  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_SOCK_IOCTL(SOCKET s, long cmd, int * argp);
     86  1.1     elric 
     87  1.1     elric #define rk_SOCK_INIT() rk_WSAStartup()
     88  1.1     elric #define rk_SOCK_EXIT() rk_WSACleanup()
     89  1.1     elric 
     90  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_WSAStartup(void);
     91  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_WSACleanup(void);
     92  1.1     elric 
     93  1.1     elric #else  /* not WinSock */
     94  1.1     elric 
     95  1.1     elric typedef int rk_socket_t;
     96  1.1     elric 
     97  1.1     elric #define rk_closesocket(x) close(x)
     98  1.1     elric #define rk_SOCK_IOCTL(s,c,a) ioctl((s),(c),(a))
     99  1.1     elric #define rk_IS_BAD_SOCKET(s) ((s) < 0)
    100  1.1     elric #define rk_IS_SOCKET_ERROR(rv) ((rv) < 0)
    101  1.1     elric #define rk_SOCK_ERRNO errno
    102  1.1     elric #define rk_INVALID_SOCKET (-1)
    103  1.1     elric 
    104  1.1     elric #define rk_SOCK_INIT() 0
    105  1.1     elric #define rk_SOCK_EXIT() do { } while(0)
    106  1.1     elric 
    107  1.4  christos #endif  /* WinSock */
    108  1.1     elric 
    109  1.3    pettai #ifndef IN_LOOPBACKNET
    110  1.3    pettai #define IN_LOOPBACKNET 127
    111  1.3    pettai #endif
    112  1.3    pettai 
    113  1.1     elric #ifdef _MSC_VER
    114  1.4  christos #ifndef HAVE_STDINT_H
    115  1.4  christos #include <intsafe.h>
    116  1.4  christos #endif
    117  1.4  christos 
    118  1.1     elric /* Declarations for Microsoft Visual C runtime on Windows */
    119  1.1     elric 
    120  1.1     elric #include<process.h>
    121  1.1     elric 
    122  1.1     elric #include<io.h>
    123  1.1     elric 
    124  1.1     elric #ifndef __BIT_TYPES_DEFINED__
    125  1.1     elric #define __BIT_TYPES_DEFINED__
    126  1.1     elric 
    127  1.1     elric typedef __int8             int8_t;
    128  1.1     elric typedef __int16            int16_t;
    129  1.1     elric typedef __int32            int32_t;
    130  1.1     elric typedef __int64            int64_t;
    131  1.1     elric typedef unsigned __int8    uint8_t;
    132  1.1     elric typedef unsigned __int16   uint16_t;
    133  1.1     elric typedef unsigned __int32   uint32_t;
    134  1.1     elric typedef unsigned __int64   uint64_t;
    135  1.1     elric typedef uint8_t            u_int8_t;
    136  1.1     elric typedef uint16_t           u_int16_t;
    137  1.1     elric typedef uint32_t           u_int32_t;
    138  1.1     elric typedef uint64_t           u_int64_t;
    139  1.1     elric 
    140  1.1     elric #endif  /* __BIT_TYPES_DEFINED__ */
    141  1.1     elric 
    142  1.1     elric #define UNREACHABLE(x) x
    143  1.1     elric #define UNUSED_ARGUMENT(x) ((void) x)
    144  1.1     elric 
    145  1.1     elric #define RETSIGTYPE void
    146  1.1     elric 
    147  1.1     elric #define VOID_RETSIGTYPE 1
    148  1.1     elric 
    149  1.1     elric #ifdef VOID_RETSIGTYPE
    150  1.1     elric #define SIGRETURN(x) return
    151  1.1     elric #else
    152  1.1     elric #define SIGRETURN(x) return (RETSIGTYPE)(x)
    153  1.1     elric #endif
    154  1.1     elric 
    155  1.1     elric #ifndef CPP_ONLY
    156  1.1     elric 
    157  1.1     elric typedef int pid_t;
    158  1.1     elric 
    159  1.1     elric typedef unsigned int gid_t;
    160  1.1     elric 
    161  1.1     elric typedef unsigned int uid_t;
    162  1.1     elric 
    163  1.1     elric typedef unsigned short mode_t;
    164  1.1     elric 
    165  1.1     elric #endif
    166  1.1     elric 
    167  1.1     elric #ifndef __cplusplus
    168  1.1     elric #define inline __inline
    169  1.1     elric #endif
    170  1.1     elric 
    171  1.1     elric #else
    172  1.1     elric 
    173  1.1     elric #define UNREACHABLE(x)
    174  1.1     elric #define UNUSED_ARGUMENT(x)
    175  1.1     elric 
    176  1.1     elric #endif
    177  1.1     elric 
    178  1.1     elric #ifdef _AIX
    179  1.1     elric struct ether_addr;
    180  1.1     elric struct sockaddr_dl;
    181  1.1     elric #endif
    182  1.1     elric #ifdef HAVE_SYS_PARAM_H
    183  1.1     elric #include <sys/param.h>
    184  1.1     elric #endif
    185  1.1     elric #ifdef HAVE_INTTYPES_H
    186  1.1     elric #include <inttypes.h>
    187  1.1     elric #endif
    188  1.1     elric #ifdef HAVE_SYS_TYPES_H
    189  1.1     elric #include <sys/types.h>
    190  1.1     elric #endif
    191  1.4  christos #ifdef HAVE_SYS_ERRNO_H
    192  1.4  christos #include <sys/errno.h>
    193  1.4  christos #endif
    194  1.1     elric #ifdef HAVE_SYS_BITYPES_H
    195  1.1     elric #include <sys/bitypes.h>
    196  1.1     elric #endif
    197  1.1     elric #ifdef HAVE_BIND_BITYPES_H
    198  1.1     elric #include <bind/bitypes.h>
    199  1.1     elric #endif
    200  1.1     elric #ifdef HAVE_NETINET_IN6_MACHTYPES_H
    201  1.1     elric #include <netinet/in6_machtypes.h>
    202  1.1     elric #endif
    203  1.1     elric #ifdef HAVE_UNISTD_H
    204  1.1     elric #include <unistd.h>
    205  1.1     elric #endif
    206  1.1     elric #ifdef HAVE_SYS_SOCKET_H
    207  1.1     elric #include <sys/socket.h>
    208  1.1     elric #endif
    209  1.1     elric #ifdef HAVE_SYS_UIO_H
    210  1.1     elric #include <sys/uio.h>
    211  1.1     elric #endif
    212  1.1     elric #ifdef HAVE_GRP_H
    213  1.1     elric #include <grp.h>
    214  1.1     elric #endif
    215  1.1     elric #ifdef HAVE_SYS_STAT_H
    216  1.1     elric #include <sys/stat.h>
    217  1.1     elric #endif
    218  1.1     elric #ifdef HAVE_NETINET_IN_H
    219  1.1     elric #include <netinet/in.h>
    220  1.1     elric #endif
    221  1.1     elric #ifdef HAVE_NETINET_IN6_H
    222  1.1     elric #include <netinet/in6.h>
    223  1.1     elric #endif
    224  1.1     elric #ifdef HAVE_NETINET6_IN6_H
    225  1.1     elric #include <netinet6/in6.h>
    226  1.1     elric #endif
    227  1.1     elric #ifdef HAVE_ARPA_INET_H
    228  1.1     elric #include <arpa/inet.h>
    229  1.1     elric #endif
    230  1.1     elric #ifdef HAVE_NETDB_H
    231  1.1     elric #include <netdb.h>
    232  1.1     elric #endif
    233  1.1     elric #ifdef HAVE_ARPA_NAMESER_H
    234  1.1     elric #include <arpa/nameser.h>
    235  1.1     elric #endif
    236  1.1     elric #ifdef HAVE_RESOLV_H
    237  1.1     elric #include <resolv.h>
    238  1.1     elric #endif
    239  1.1     elric #ifdef HAVE_SYSLOG_H
    240  1.1     elric #include <syslog.h>
    241  1.1     elric #endif
    242  1.1     elric #ifdef HAVE_FCNTL_H
    243  1.1     elric #include <fcntl.h>
    244  1.1     elric #endif
    245  1.1     elric #ifdef HAVE_ERRNO_H
    246  1.1     elric #include <errno.h>
    247  1.1     elric #endif
    248  1.1     elric #include <err.h>
    249  1.1     elric #ifdef HAVE_TERMIOS_H
    250  1.1     elric #include <termios.h>
    251  1.1     elric #endif
    252  1.1     elric #ifdef HAVE_SYS_IOCTL_H
    253  1.1     elric #include <sys/ioctl.h>
    254  1.1     elric #endif
    255  1.1     elric #ifdef TIME_WITH_SYS_TIME
    256  1.1     elric #include <sys/time.h>
    257  1.1     elric #include <time.h>
    258  1.1     elric #elif defined(HAVE_SYS_TIME_H)
    259  1.1     elric #include <sys/time.h>
    260  1.1     elric #else
    261  1.1     elric #include <time.h>
    262  1.1     elric #endif
    263  1.1     elric 
    264  1.1     elric #ifdef HAVE_PATHS_H
    265  1.1     elric #include <paths.h>
    266  1.1     elric #endif
    267  1.1     elric 
    268  1.1     elric #ifdef HAVE_DIRENT_H
    269  1.1     elric #include <dirent.h>
    270  1.1     elric #endif
    271  1.1     elric 
    272  1.4  christos #ifdef HAVE_DIRECT_H
    273  1.4  christos #include <direct.h>
    274  1.4  christos #endif
    275  1.4  christos 
    276  1.1     elric #ifdef BACKSLASH_PATH_DELIM
    277  1.1     elric #define rk_PATH_DELIM '\\'
    278  1.1     elric #endif
    279  1.1     elric 
    280  1.1     elric #ifndef HAVE_SSIZE_T
    281  1.1     elric #ifndef SSIZE_T_DEFINED
    282  1.1     elric #ifdef ssize_t
    283  1.1     elric #undef ssize_t
    284  1.1     elric #endif
    285  1.1     elric #ifdef _WIN64
    286  1.1     elric typedef __int64 ssize_t;
    287  1.1     elric #else
    288  1.1     elric typedef int ssize_t;
    289  1.1     elric #endif
    290  1.1     elric #define SSIZE_T_DEFINED
    291  1.1     elric #endif  /* SSIZE_T_DEFINED */
    292  1.1     elric #endif  /* HAVE_SSIZE_T */
    293  1.1     elric 
    294  1.6  christos #include <krb5/roken-common.h>
    295  1.1     elric 
    296  1.1     elric ROKEN_CPP_START
    297  1.1     elric 
    298  1.1     elric #ifdef HAVE_UINTPTR_T
    299  1.1     elric #define rk_UNCONST(x) ((void *)(uintptr_t)(const void *)(x))
    300  1.1     elric #else
    301  1.1     elric #define rk_UNCONST(x) ((void *)(unsigned long)(const void *)(x))
    302  1.1     elric #endif
    303  1.1     elric 
    304  1.1     elric #if !defined(HAVE_SETSID) && defined(HAVE__SETSID)
    305  1.1     elric #define setsid _setsid
    306  1.1     elric #endif
    307  1.1     elric 
    308  1.1     elric #ifdef _MSC_VER
    309  1.1     elric /* Additional macros for Visual C/C++ runtime */
    310  1.1     elric 
    311  1.1     elric #define close	_close
    312  1.1     elric 
    313  1.1     elric #define getpid	_getpid
    314  1.1     elric 
    315  1.1     elric #define open	_open
    316  1.1     elric 
    317  1.1     elric #define chdir   _chdir
    318  1.1     elric 
    319  1.1     elric #define fsync   _commit
    320  1.1     elric 
    321  1.7  christos #define timezone    _timezone
    322  1.7  christos 
    323  1.7  christos #define tzname  _tzname
    324  1.7  christos 
    325  1.7  christos #define _PIPE_BUFFER_SZ 8192
    326  1.7  christos #define pipe(fds) _pipe((fds), _PIPE_BUFFER_SZ, O_BINARY);
    327  1.7  christos 
    328  1.7  christos #define ftruncate(fd, sz) _chsize((fd), (sz))
    329  1.7  christos 
    330  1.7  christos #if !defined(HAVE_UCRT)
    331  1.1     elric #define snprintf    rk_snprintf
    332  1.1     elric #define vsnprintf   rk_vsnprintf
    333  1.1     elric #define vasnprintf  rk_vasnprintf
    334  1.1     elric #define vasprintf   rk_vasprintf
    335  1.1     elric #define asnprintf   rk_asnprintf
    336  1.1     elric #define asprintf    rk_asprintf
    337  1.1     elric 
    338  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    339  1.1     elric rk_snprintf (char *str, size_t sz, const char *format, ...);
    340  1.1     elric 
    341  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    342  1.1     elric rk_asprintf (char **ret, const char *format, ...);
    343  1.1     elric 
    344  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    345  1.1     elric rk_asnprintf (char **ret, size_t max_sz, const char *format, ...);
    346  1.1     elric 
    347  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    348  1.1     elric rk_vasprintf (char **ret, const char *format, va_list args);
    349  1.1     elric 
    350  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    351  1.1     elric rk_vasnprintf (char **ret, size_t max_sz, const char *format, va_list args);
    352  1.1     elric 
    353  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    354  1.1     elric rk_vsnprintf (char *str, size_t sz, const char *format, va_list args);
    355  1.7  christos #endif /* !defined(HAVE_UCRT) */
    356  1.1     elric 
    357  1.1     elric /* missing stat.h predicates */
    358  1.1     elric 
    359  1.1     elric #define S_ISREG(m) (((m) & _S_IFREG) == _S_IFREG)
    360  1.1     elric 
    361  1.1     elric #define S_ISDIR(m) (((m) & _S_IFDIR) == _S_IFDIR)
    362  1.1     elric 
    363  1.1     elric #define S_ISCHR(m) (((m) & _S_IFCHR) == _S_IFCHR)
    364  1.1     elric 
    365  1.1     elric #define S_ISFIFO(m) (((m) & _S_IFIFO) == _S_IFIFO)
    366  1.1     elric 
    367  1.1     elric /* The following are not implemented:
    368  1.1     elric 
    369  1.1     elric  S_ISLNK(m)
    370  1.1     elric  S_ISSOCK(m)
    371  1.1     elric  S_ISBLK(m)
    372  1.1     elric */
    373  1.1     elric 
    374  1.4  christos /* The following symbolic constants are provided for rk_mkdir mode */
    375  1.4  christos 
    376  1.4  christos #define S_IRWXU 00700 /* user (file owner) has read, write and execute permission */
    377  1.4  christos #define S_IRUSR 00400 /* user has read permission */
    378  1.4  christos #define S_IWUSR 00200 /* user has write permission */
    379  1.4  christos #define S_IXUSR 00100 /* user has execute permission */
    380  1.4  christos #define S_IRWXG 00070 /* group has read, write and execute permission */
    381  1.4  christos #define S_IRGRP 00040 /* group has read permission */
    382  1.4  christos #define S_IWGRP 00020 /* group has write permission */
    383  1.4  christos #define S_IXGRP 00010 /* group has execute permission */
    384  1.4  christos #define S_IRWXO 00007 /* others have read, write and execute permission */
    385  1.4  christos #define S_IROTH 00004 /* others have read permission */
    386  1.4  christos #define S_IWOTH 00002 /* others have write permission */
    387  1.4  christos #define S_IXOTH 00001 /* others have execute permission */
    388  1.4  christos 
    389  1.4  christos #if !defined(ROKEN_NO_DEFINE_ALLOCATORS)
    390  1.4  christos /* Ensure that a common memory allocator is used by all */
    391  1.4  christos #define calloc  rk_calloc
    392  1.4  christos #define free    rk_free
    393  1.4  christos #define malloc  rk_malloc
    394  1.4  christos #define realloc rk_realloc
    395  1.4  christos #define strdup  rk_strdup
    396  1.4  christos #define wcsdup  rk_wcsdup
    397  1.4  christos #endif
    398  1.4  christos 
    399  1.4  christos ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
    400  1.4  christos rk_calloc(size_t, size_t);
    401  1.4  christos 
    402  1.4  christos ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    403  1.4  christos rk_free(void *);
    404  1.4  christos 
    405  1.4  christos ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
    406  1.4  christos rk_malloc(size_t);
    407  1.4  christos 
    408  1.4  christos ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
    409  1.4  christos rk_realloc(void *, size_t);
    410  1.4  christos 
    411  1.4  christos ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
    412  1.4  christos rk_strdup(const char *);
    413  1.4  christos 
    414  1.4  christos ROKEN_LIB_FUNCTION unsigned short * ROKEN_LIB_CALL
    415  1.4  christos rk_wcsdup(const unsigned short *);
    416  1.4  christos 
    417  1.1     elric #endif  /* _MSC_VER */
    418  1.1     elric 
    419  1.1     elric #ifdef HAVE_WINSOCK
    420  1.1     elric 
    421  1.1     elric /* While we are at it, define WinSock specific scatter gather socket
    422  1.1     elric    I/O. */
    423  1.1     elric 
    424  1.1     elric #define iovec    _WSABUF
    425  1.1     elric #define iov_base buf
    426  1.1     elric #define iov_len  len
    427  1.1     elric 
    428  1.1     elric struct msghdr {
    429  1.1     elric     void           *msg_name;
    430  1.1     elric     socklen_t       msg_namelen;
    431  1.1     elric     struct iovec   *msg_iov;
    432  1.1     elric     size_t          msg_iovlen;
    433  1.1     elric     void           *msg_control;
    434  1.1     elric     socklen_t       msg_controllen;
    435  1.1     elric     int             msg_flags;
    436  1.1     elric };
    437  1.1     elric 
    438  1.1     elric #define sendmsg sendmsg_w32
    439  1.1     elric 
    440  1.1     elric ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
    441  1.1     elric sendmsg_w32(rk_socket_t s, const struct msghdr * msg, int flags);
    442  1.1     elric 
    443  1.1     elric #endif	/* HAVE_WINSOCK */
    444  1.1     elric 
    445  1.1     elric #ifndef HAVE_PUTENV
    446  1.1     elric #define putenv rk_putenv
    447  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL putenv(const char *);
    448  1.1     elric #endif
    449  1.1     elric 
    450  1.1     elric #if !defined(HAVE_SETENV) || defined(NEED_SETENV_PROTO)
    451  1.1     elric #ifndef HAVE_SETENV
    452  1.1     elric #define setenv rk_setenv
    453  1.1     elric #endif
    454  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL setenv(const char *, const char *, int);
    455  1.1     elric #endif
    456  1.1     elric 
    457  1.1     elric #if !defined(HAVE_UNSETENV) || defined(NEED_UNSETENV_PROTO)
    458  1.1     elric #ifndef HAVE_UNSETENV
    459  1.1     elric #define unsetenv rk_unsetenv
    460  1.1     elric #endif
    461  1.1     elric ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL unsetenv(const char *);
    462  1.1     elric #endif
    463  1.1     elric 
    464  1.1     elric #if !defined(HAVE_GETUSERSHELL) || defined(NEED_GETUSERSHELL_PROTO)
    465  1.1     elric #ifndef HAVE_GETUSERSHELL
    466  1.1     elric #define getusershell rk_getusershell
    467  1.1     elric #define endusershell rk_endusershell
    468  1.1     elric #endif
    469  1.1     elric ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL getusershell(void);
    470  1.1     elric ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL endusershell(void);
    471  1.1     elric #endif
    472  1.1     elric 
    473  1.1     elric #if !defined(HAVE_SNPRINTF) || defined(NEED_SNPRINTF_PROTO)
    474  1.1     elric #ifndef HAVE_SNPRINTF
    475  1.1     elric #define snprintf rk_snprintf
    476  1.1     elric #endif
    477  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    478  1.1     elric      rk_snprintf (char *, size_t, const char *, ...)
    479  1.4  christos      __attribute__ ((__format__ (__printf__, 3, 4)));
    480  1.1     elric #endif
    481  1.1     elric 
    482  1.1     elric #if !defined(HAVE_VSNPRINTF) || defined(NEED_VSNPRINTF_PROTO)
    483  1.1     elric #ifndef HAVE_VSNPRINTF
    484  1.1     elric #define vsnprintf rk_vsnprintf
    485  1.1     elric #endif
    486  1.4  christos ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    487  1.1     elric      rk_vsnprintf (char *, size_t, const char *, va_list)
    488  1.4  christos      __attribute__ ((__format__ (__printf__, 3, 0)));
    489  1.1     elric #endif
    490  1.1     elric 
    491  1.1     elric #if !defined(HAVE_ASPRINTF) || defined(NEED_ASPRINTF_PROTO)
    492  1.1     elric #ifndef HAVE_ASPRINTF
    493  1.1     elric #define asprintf rk_asprintf
    494  1.1     elric #endif
    495  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    496  1.1     elric      rk_asprintf (char **, const char *, ...)
    497  1.4  christos      __attribute__ ((__format__ (__printf__, 2, 3)));
    498  1.1     elric #endif
    499  1.1     elric 
    500  1.1     elric #if !defined(HAVE_VASPRINTF) || defined(NEED_VASPRINTF_PROTO)
    501  1.1     elric #ifndef HAVE_VASPRINTF
    502  1.1     elric #define vasprintf rk_vasprintf
    503  1.1     elric #endif
    504  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    505  1.1     elric     rk_vasprintf (char **, const char *, va_list)
    506  1.4  christos      __attribute__ ((__format__ (__printf__, 2, 0)));
    507  1.1     elric #endif
    508  1.1     elric 
    509  1.1     elric #if !defined(HAVE_ASNPRINTF) || defined(NEED_ASNPRINTF_PROTO)
    510  1.1     elric #ifndef HAVE_ASNPRINTF
    511  1.1     elric #define asnprintf rk_asnprintf
    512  1.1     elric #endif
    513  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    514  1.1     elric     rk_asnprintf (char **, size_t, const char *, ...)
    515  1.4  christos      __attribute__ ((__format__ (__printf__, 3, 4)));
    516  1.1     elric #endif
    517  1.1     elric 
    518  1.1     elric #if !defined(HAVE_VASNPRINTF) || defined(NEED_VASNPRINTF_PROTO)
    519  1.1     elric #ifndef HAVE_VASNPRINTF
    520  1.1     elric #define vasnprintf rk_vasnprintf
    521  1.1     elric #endif
    522  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    523  1.1     elric     vasnprintf (char **, size_t, const char *, va_list)
    524  1.4  christos      __attribute__ ((__format__ (__printf__, 3, 0)));
    525  1.1     elric #endif
    526  1.1     elric 
    527  1.1     elric #ifndef HAVE_STRDUP
    528  1.1     elric #define strdup rk_strdup
    529  1.1     elric ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strdup(const char *);
    530  1.1     elric #endif
    531  1.1     elric 
    532  1.1     elric #if !defined(HAVE_STRNDUP) || defined(NEED_STRNDUP_PROTO)
    533  1.1     elric #ifndef HAVE_STRNDUP
    534  1.1     elric #define strndup rk_strndup
    535  1.1     elric #endif
    536  1.1     elric ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strndup(const char *, size_t);
    537  1.1     elric #endif
    538  1.1     elric 
    539  1.1     elric #ifndef HAVE_STRLWR
    540  1.1     elric #define strlwr rk_strlwr
    541  1.1     elric ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strlwr(char *);
    542  1.1     elric #endif
    543  1.1     elric 
    544  1.1     elric #ifndef HAVE_STRNLEN
    545  1.1     elric #define strnlen rk_strnlen
    546  1.1     elric ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL strnlen(const char*, size_t);
    547  1.1     elric #endif
    548  1.1     elric 
    549  1.1     elric #if !defined(HAVE_STRSEP) || defined(NEED_STRSEP_PROTO)
    550  1.1     elric #ifndef HAVE_STRSEP
    551  1.1     elric #define strsep rk_strsep
    552  1.1     elric #endif
    553  1.1     elric ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strsep(char**, const char*);
    554  1.1     elric #endif
    555  1.1     elric 
    556  1.1     elric #if !defined(HAVE_STRSEP_COPY) || defined(NEED_STRSEP_COPY_PROTO)
    557  1.1     elric #ifndef HAVE_STRSEP_COPY
    558  1.1     elric #define strsep_copy rk_strsep_copy
    559  1.1     elric #endif
    560  1.1     elric ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL strsep_copy(const char**, const char*, char*, size_t);
    561  1.1     elric #endif
    562  1.1     elric 
    563  1.1     elric #ifndef HAVE_STRCASECMP
    564  1.1     elric #define strcasecmp rk_strcasecmp
    565  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL strcasecmp(const char *, const char *);
    566  1.1     elric #endif
    567  1.1     elric 
    568  1.1     elric #ifdef NEED_FCLOSE_PROTO
    569  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL fclose(FILE *);
    570  1.1     elric #endif
    571  1.1     elric 
    572  1.1     elric #ifdef NEED_STRTOK_R_PROTO
    573  1.1     elric ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strtok_r(char *, const char *, char **);
    574  1.1     elric #endif
    575  1.1     elric 
    576  1.1     elric #ifndef HAVE_STRUPR
    577  1.1     elric #define strupr rk_strupr
    578  1.1     elric ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strupr(char *);
    579  1.1     elric #endif
    580  1.1     elric 
    581  1.1     elric #ifndef HAVE_STRLCPY
    582  1.1     elric #define strlcpy rk_strlcpy
    583  1.1     elric ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL strlcpy (char *, const char *, size_t);
    584  1.1     elric #endif
    585  1.1     elric 
    586  1.1     elric #ifndef HAVE_STRLCAT
    587  1.1     elric #define strlcat rk_strlcat
    588  1.1     elric ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL strlcat (char *, const char *, size_t);
    589  1.1     elric #endif
    590  1.1     elric 
    591  1.1     elric #ifndef HAVE_GETDTABLESIZE
    592  1.1     elric #define getdtablesize rk_getdtablesize
    593  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL getdtablesize(void);
    594  1.1     elric #endif
    595  1.1     elric 
    596  1.1     elric #if !defined(HAVE_STRERROR) && !defined(strerror)
    597  1.1     elric #define strerror rk_strerror
    598  1.1     elric ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strerror(int);
    599  1.1     elric #endif
    600  1.1     elric 
    601  1.1     elric #if (!defined(HAVE_STRERROR_R) && !defined(strerror_r)) || (!defined(STRERROR_R_PROTO_COMPATIBLE) && defined(HAVE_STRERROR_R))
    602  1.1     elric int ROKEN_LIB_FUNCTION rk_strerror_r(int, char *, size_t);
    603  1.1     elric #else
    604  1.1     elric #define rk_strerror_r strerror_r
    605  1.1     elric #endif
    606  1.1     elric 
    607  1.1     elric #if !defined(HAVE_HSTRERROR) || defined(NEED_HSTRERROR_PROTO)
    608  1.1     elric #ifndef HAVE_HSTRERROR
    609  1.1     elric #define hstrerror rk_hstrerror
    610  1.1     elric #endif
    611  1.1     elric /* This causes a fatal error under Psoriasis */
    612  1.1     elric #ifndef SunOS
    613  1.1     elric ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL hstrerror(int);
    614  1.1     elric #endif
    615  1.1     elric #endif
    616  1.1     elric 
    617  1.1     elric #if !HAVE_DECL_H_ERRNO
    618  1.1     elric extern int h_errno;
    619  1.1     elric #endif
    620  1.1     elric 
    621  1.1     elric #if !defined(HAVE_INET_ATON) || defined(NEED_INET_ATON_PROTO)
    622  1.1     elric #ifndef HAVE_INET_ATON
    623  1.1     elric #define inet_aton rk_inet_aton
    624  1.1     elric #endif
    625  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL inet_aton(const char *, struct in_addr *);
    626  1.1     elric #endif
    627  1.1     elric 
    628  1.1     elric #ifndef HAVE_INET_NTOP
    629  1.1     elric #define inet_ntop rk_inet_ntop
    630  1.1     elric ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
    631  1.1     elric inet_ntop(int af, const void *src, char *dst, size_t size);
    632  1.1     elric #endif
    633  1.1     elric 
    634  1.1     elric #ifndef HAVE_INET_PTON
    635  1.1     elric #define inet_pton rk_inet_pton
    636  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    637  1.1     elric inet_pton(int, const char *, void *);
    638  1.1     elric #endif
    639  1.1     elric 
    640  1.1     elric #ifndef HAVE_GETCWD
    641  1.1     elric #define getcwd rk_getcwd
    642  1.1     elric ROKEN_LIB_FUNCTION char* ROKEN_LIB_CALL getcwd(char *, size_t);
    643  1.1     elric #endif
    644  1.1     elric 
    645  1.1     elric #ifdef HAVE_PWD_H
    646  1.1     elric #include <pwd.h>
    647  1.1     elric ROKEN_LIB_FUNCTION struct passwd * ROKEN_LIB_CALL k_getpwnam (const char *);
    648  1.1     elric ROKEN_LIB_FUNCTION struct passwd * ROKEN_LIB_CALL k_getpwuid (uid_t);
    649  1.1     elric #endif
    650  1.1     elric 
    651  1.4  christos #ifdef POSIX_GETPWNAM_R
    652  1.4  christos #define rk_getpwnam_r(_n, _pw, _b, _sz, _pwd) getpwnam_r(_n, _pw, _b, _sz, _pwd)
    653  1.4  christos #else
    654  1.4  christos ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    655  1.4  christos rk_getpwnam_r(const char *, struct passwd *, char *, size_t, struct passwd **);
    656  1.4  christos #endif
    657  1.4  christos 
    658  1.5  christos #ifdef POSIX_GETPWUID_R
    659  1.5  christos #define rk_getpwuid_r(_u, _pw, _b, _sz, _pwd) getpwuid_r(_u, _pw, _b, _sz, _pwd)
    660  1.5  christos #else
    661  1.5  christos ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    662  1.5  christos rk_getpwuid_r(uid_t, struct passwd *, char *, size_t, struct passwd **);
    663  1.5  christos #endif
    664  1.5  christos 
    665  1.1     elric ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL get_default_username (void);
    666  1.1     elric 
    667  1.1     elric #ifndef HAVE_SETEUID
    668  1.1     elric #define seteuid rk_seteuid
    669  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL seteuid(uid_t);
    670  1.1     elric #endif
    671  1.1     elric 
    672  1.1     elric #ifndef HAVE_SETEGID
    673  1.1     elric #define setegid rk_setegid
    674  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL setegid(gid_t);
    675  1.1     elric #endif
    676  1.1     elric 
    677  1.1     elric #ifndef HAVE_LSTAT
    678  1.1     elric #define lstat rk_lstat
    679  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL lstat(const char *, struct stat *);
    680  1.1     elric #endif
    681  1.1     elric 
    682  1.1     elric #if !defined(HAVE_MKSTEMP) || defined(NEED_MKSTEMP_PROTO)
    683  1.1     elric #ifndef HAVE_MKSTEMP
    684  1.1     elric #define mkstemp rk_mkstemp
    685  1.1     elric #endif
    686  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL mkstemp(char *);
    687  1.1     elric #endif
    688  1.1     elric 
    689  1.1     elric #ifndef HAVE_CGETENT
    690  1.1     elric #define cgetent rk_cgetent
    691  1.1     elric #define cgetstr rk_cgetstr
    692  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetent(char **, char **, const char *);
    693  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetstr(char *, const char *, char **);
    694  1.1     elric #endif
    695  1.1     elric 
    696  1.1     elric #ifndef HAVE_INITGROUPS
    697  1.1     elric #define initgroups rk_initgroups
    698  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL initgroups(const char *, gid_t);
    699  1.1     elric #endif
    700  1.1     elric 
    701  1.1     elric #ifndef HAVE_FCHOWN
    702  1.1     elric #define fchown rk_fchown
    703  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL fchown(int, uid_t, gid_t);
    704  1.1     elric #endif
    705  1.1     elric 
    706  1.1     elric #ifdef RENAME_DOES_NOT_UNLINK
    707  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_rename(const char *, const char *);
    708  1.1     elric #else
    709  1.1     elric #define rk_rename(__rk_rn_from,__rk_rn_to) rename(__rk_rn_from,__rk_rn_to)
    710  1.1     elric #endif
    711  1.1     elric 
    712  1.4  christos #ifdef MKDIR_DOES_NOT_HAVE_MODE
    713  1.4  christos #define mkdir rk_mkdir
    714  1.4  christos #else
    715  1.4  christos #define rk_mkdir(__rk_rn_name, __rk_rn_mode) mkdir(__rk_rn_name,__rk_rn_mode)
    716  1.4  christos #endif
    717  1.4  christos 
    718  1.4  christos 
    719  1.1     elric #if !defined(HAVE_DAEMON) || defined(NEED_DAEMON_PROTO)
    720  1.1     elric #ifndef HAVE_DAEMON
    721  1.1     elric #define daemon rk_daemon
    722  1.1     elric #endif
    723  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL daemon(int, int);
    724  1.1     elric #endif
    725  1.1     elric 
    726  1.1     elric #ifndef HAVE_CHOWN
    727  1.1     elric #define chown rk_chown
    728  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL chown(const char *, uid_t, gid_t);
    729  1.1     elric #endif
    730  1.1     elric 
    731  1.1     elric #ifndef HAVE_RCMD
    732  1.1     elric #define rcmd rk_rcmd
    733  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    734  1.1     elric     rcmd(char **, unsigned short, const char *,
    735  1.1     elric 	 const char *, const char *, int *);
    736  1.1     elric #endif
    737  1.1     elric 
    738  1.1     elric #if !defined(HAVE_INNETGR) || defined(NEED_INNETGR_PROTO)
    739  1.1     elric #ifndef HAVE_INNETGR
    740  1.1     elric #define innetgr rk_innetgr
    741  1.1     elric #endif
    742  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL innetgr(const char*, const char*,
    743  1.1     elric     const char*, const char*);
    744  1.1     elric #endif
    745  1.1     elric 
    746  1.1     elric #ifndef HAVE_IRUSEROK
    747  1.1     elric #define iruserok rk_iruserok
    748  1.4  christos ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL iruserok(unsigned, int,
    749  1.1     elric     const char *, const char *);
    750  1.1     elric #endif
    751  1.1     elric 
    752  1.1     elric #if !defined(HAVE_GETHOSTNAME) || defined(NEED_GETHOSTNAME_PROTO)
    753  1.1     elric #ifndef HAVE_GETHOSTNAME
    754  1.1     elric #define gethostname rk_gethostname
    755  1.1     elric #endif
    756  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL gethostname(char *, int);
    757  1.1     elric #endif
    758  1.1     elric 
    759  1.1     elric #ifndef HAVE_WRITEV
    760  1.1     elric #define writev rk_writev
    761  1.1     elric ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
    762  1.1     elric writev(int, const struct iovec *, int);
    763  1.1     elric #endif
    764  1.1     elric 
    765  1.1     elric #ifndef HAVE_READV
    766  1.1     elric #define readv rk_readv
    767  1.1     elric ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
    768  1.1     elric readv(int, const struct iovec *, int);
    769  1.1     elric #endif
    770  1.1     elric 
    771  1.1     elric #ifdef NO_PIDFILES
    772  1.4  christos #define rk_pidfile(x) ((void) 0)
    773  1.1     elric #else
    774  1.4  christos ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL rk_pidfile (const char*);
    775  1.1     elric #endif
    776  1.4  christos 
    777  1.4  christos #ifndef HAVE_BSWAP64
    778  1.4  christos #define bswap64 rk_bswap64
    779  1.4  christos ROKEN_LIB_FUNCTION uint64_t ROKEN_LIB_CALL bswap64(uint64_t);
    780  1.1     elric #endif
    781  1.1     elric 
    782  1.1     elric #ifndef HAVE_BSWAP32
    783  1.1     elric #define bswap32 rk_bswap32
    784  1.1     elric ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL bswap32(unsigned int);
    785  1.1     elric #endif
    786  1.1     elric 
    787  1.1     elric #ifndef HAVE_BSWAP16
    788  1.1     elric #define bswap16 rk_bswap16
    789  1.1     elric ROKEN_LIB_FUNCTION unsigned short ROKEN_LIB_CALL bswap16(unsigned short);
    790  1.1     elric #endif
    791  1.1     elric 
    792  1.1     elric #ifndef HAVE_FLOCK
    793  1.1     elric #ifndef LOCK_SH
    794  1.1     elric #define LOCK_SH   1		/* Shared lock */
    795  1.1     elric #endif
    796  1.1     elric #ifndef	LOCK_EX
    797  1.1     elric #define LOCK_EX   2		/* Exclusive lock */
    798  1.1     elric #endif
    799  1.1     elric #ifndef LOCK_NB
    800  1.1     elric #define LOCK_NB   4		/* Don't block when locking */
    801  1.1     elric #endif
    802  1.1     elric #ifndef LOCK_UN
    803  1.1     elric #define LOCK_UN   8		/* Unlock */
    804  1.1     elric #endif
    805  1.1     elric 
    806  1.1     elric #define flock(_x,_y) rk_flock(_x,_y)
    807  1.1     elric int rk_flock(int fd, int operation);
    808  1.1     elric #endif /* HAVE_FLOCK */
    809  1.1     elric 
    810  1.1     elric #ifndef HAVE_DIRFD
    811  1.1     elric #ifdef HAVE_DIR_DD_FD
    812  1.1     elric #define dirfd(x) ((x)->dd_fd)
    813  1.1     elric #else
    814  1.1     elric #ifndef _WIN32 /* Windows code never calls dirfd */
    815  1.1     elric #error Missing dirfd() and ->dd_fd
    816  1.1     elric #endif
    817  1.1     elric #endif
    818  1.1     elric #endif
    819  1.1     elric 
    820  1.1     elric ROKEN_LIB_FUNCTION time_t ROKEN_LIB_CALL tm2time (struct tm, int);
    821  1.1     elric 
    822  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL unix_verify_user(char *, char *);
    823  1.1     elric 
    824  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL roken_concat (char *, size_t, ...);
    825  1.1     elric 
    826  1.1     elric ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL roken_mconcat (char **, size_t, ...);
    827  1.1     elric 
    828  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL roken_vconcat (char *, size_t, va_list);
    829  1.1     elric 
    830  1.1     elric ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
    831  1.1     elric     roken_vmconcat (char **, size_t, va_list);
    832  1.1     elric 
    833  1.4  christos ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL roken_detach_prep(int, char **, char *);
    834  1.4  christos ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL roken_detach_finish(const char *, int);
    835  1.4  christos 
    836  1.1     elric ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
    837  1.1     elric     net_write (rk_socket_t, const void *, size_t);
    838  1.1     elric 
    839  1.1     elric ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
    840  1.1     elric     net_read (rk_socket_t, void *, size_t);
    841  1.1     elric 
    842  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    843  1.1     elric     issuid(void);
    844  1.1     elric 
    845  1.1     elric #ifndef HAVE_STRUCT_WINSIZE
    846  1.1     elric struct winsize {
    847  1.1     elric 	unsigned short ws_row, ws_col;
    848  1.1     elric 	unsigned short ws_xpixel, ws_ypixel;
    849  1.1     elric };
    850  1.1     elric #endif
    851  1.1     elric 
    852  1.2     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL get_window_size(int fd, int *, int *);
    853  1.1     elric 
    854  1.1     elric #ifndef HAVE_VSYSLOG
    855  1.1     elric #define vsyslog rk_vsyslog
    856  1.1     elric ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL vsyslog(int, const char *, va_list);
    857  1.1     elric #endif
    858  1.1     elric 
    859  1.1     elric #ifndef HAVE_GETOPT
    860  1.1     elric #define getopt rk_getopt
    861  1.1     elric #define optarg rk_optarg
    862  1.1     elric #define optind rk_optind
    863  1.1     elric #define opterr rk_opterr
    864  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    865  1.1     elric getopt(int nargc, char * const *nargv, const char *ostr);
    866  1.1     elric #endif
    867  1.1     elric 
    868  1.1     elric #if !HAVE_DECL_OPTARG
    869  1.1     elric ROKEN_LIB_VARIABLE extern char *optarg;
    870  1.1     elric #endif
    871  1.1     elric #if !HAVE_DECL_OPTIND
    872  1.1     elric ROKEN_LIB_VARIABLE extern int optind;
    873  1.1     elric #endif
    874  1.1     elric #if !HAVE_DECL_OPTERR
    875  1.1     elric ROKEN_LIB_VARIABLE extern int opterr;
    876  1.1     elric #endif
    877  1.1     elric 
    878  1.1     elric #ifndef HAVE_GETIPNODEBYNAME
    879  1.1     elric #define getipnodebyname rk_getipnodebyname
    880  1.1     elric ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
    881  1.1     elric getipnodebyname (const char *, int, int, int *);
    882  1.1     elric #endif
    883  1.1     elric 
    884  1.1     elric #ifndef HAVE_GETIPNODEBYADDR
    885  1.1     elric #define getipnodebyaddr rk_getipnodebyaddr
    886  1.1     elric ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
    887  1.1     elric getipnodebyaddr (const void *, size_t, int, int *);
    888  1.1     elric #endif
    889  1.1     elric 
    890  1.1     elric #ifndef HAVE_FREEHOSTENT
    891  1.1     elric #define freehostent rk_freehostent
    892  1.1     elric ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    893  1.1     elric freehostent (struct hostent *);
    894  1.1     elric #endif
    895  1.1     elric 
    896  1.1     elric #ifndef HAVE_COPYHOSTENT
    897  1.1     elric #define copyhostent rk_copyhostent
    898  1.1     elric ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
    899  1.1     elric copyhostent (const struct hostent *);
    900  1.1     elric #endif
    901  1.1     elric 
    902  1.1     elric #ifndef HAVE_SOCKLEN_T
    903  1.1     elric typedef int socklen_t;
    904  1.1     elric #endif
    905  1.1     elric 
    906  1.1     elric #ifndef HAVE_STRUCT_SOCKADDR_STORAGE
    907  1.1     elric 
    908  1.1     elric #ifndef HAVE_SA_FAMILY_T
    909  1.1     elric typedef unsigned short sa_family_t;
    910  1.1     elric #endif
    911  1.1     elric 
    912  1.1     elric #ifdef HAVE_IPV6
    913  1.1     elric #define _SS_MAXSIZE sizeof(struct sockaddr_in6)
    914  1.1     elric #else
    915  1.1     elric #define _SS_MAXSIZE sizeof(struct sockaddr_in)
    916  1.1     elric #endif
    917  1.1     elric 
    918  1.1     elric #define _SS_ALIGNSIZE	sizeof(unsigned long)
    919  1.1     elric 
    920  1.1     elric #if HAVE_STRUCT_SOCKADDR_SA_LEN
    921  1.1     elric 
    922  1.1     elric typedef unsigned char roken_sa_family_t;
    923  1.1     elric 
    924  1.1     elric #define _SS_PAD1SIZE   ((2 * _SS_ALIGNSIZE - sizeof (roken_sa_family_t) - sizeof(unsigned char)) % _SS_ALIGNSIZE)
    925  1.1     elric #define _SS_PAD2SIZE   (_SS_MAXSIZE - (sizeof (roken_sa_family_t) + sizeof(unsigned char) + _SS_PAD1SIZE + _SS_ALIGNSIZE))
    926  1.1     elric 
    927  1.1     elric struct sockaddr_storage {
    928  1.1     elric     unsigned char	ss_len;
    929  1.1     elric     roken_sa_family_t	ss_family;
    930  1.1     elric     char		__ss_pad1[_SS_PAD1SIZE];
    931  1.1     elric     unsigned long	__ss_align[_SS_PAD2SIZE / sizeof(unsigned long) + 1];
    932  1.1     elric };
    933  1.1     elric 
    934  1.1     elric #else /* !HAVE_STRUCT_SOCKADDR_SA_LEN */
    935  1.1     elric 
    936  1.1     elric typedef unsigned short roken_sa_family_t;
    937  1.1     elric 
    938  1.1     elric #define _SS_PAD1SIZE   ((2 * _SS_ALIGNSIZE - sizeof (roken_sa_family_t)) % _SS_ALIGNSIZE)
    939  1.1     elric #define _SS_PAD2SIZE   (_SS_MAXSIZE - (sizeof (roken_sa_family_t) + _SS_PAD1SIZE + _SS_ALIGNSIZE))
    940  1.1     elric 
    941  1.1     elric struct sockaddr_storage {
    942  1.1     elric     roken_sa_family_t	ss_family;
    943  1.1     elric     char		__ss_pad1[_SS_PAD1SIZE];
    944  1.1     elric     unsigned long	__ss_align[_SS_PAD2SIZE / sizeof(unsigned long) + 1];
    945  1.1     elric };
    946  1.1     elric 
    947  1.1     elric #endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */
    948  1.1     elric 
    949  1.1     elric #endif /* HAVE_STRUCT_SOCKADDR_STORAGE */
    950  1.1     elric 
    951  1.1     elric #ifndef HAVE_STRUCT_ADDRINFO
    952  1.1     elric struct addrinfo {
    953  1.1     elric     int    ai_flags;
    954  1.1     elric     int    ai_family;
    955  1.1     elric     int    ai_socktype;
    956  1.1     elric     int    ai_protocol;
    957  1.1     elric     size_t ai_addrlen;
    958  1.1     elric     char  *ai_canonname;
    959  1.1     elric     struct sockaddr *ai_addr;
    960  1.1     elric     struct addrinfo *ai_next;
    961  1.1     elric };
    962  1.1     elric #endif
    963  1.1     elric 
    964  1.1     elric #ifndef HAVE_GETADDRINFO
    965  1.1     elric #define getaddrinfo rk_getaddrinfo
    966  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    967  1.1     elric getaddrinfo(const char *,
    968  1.1     elric 	    const char *,
    969  1.1     elric 	    const struct addrinfo *,
    970  1.1     elric 	    struct addrinfo **);
    971  1.1     elric #endif
    972  1.1     elric 
    973  1.1     elric #ifndef HAVE_GETNAMEINFO
    974  1.1     elric #define getnameinfo rk_getnameinfo
    975  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
    976  1.1     elric getnameinfo(const struct sockaddr *, socklen_t,
    977  1.1     elric 		char *, size_t,
    978  1.1     elric 		char *, size_t,
    979  1.1     elric 		int);
    980  1.1     elric #endif
    981  1.1     elric 
    982  1.1     elric #ifndef HAVE_FREEADDRINFO
    983  1.1     elric #define freeaddrinfo rk_freeaddrinfo
    984  1.1     elric ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
    985  1.1     elric freeaddrinfo(struct addrinfo *);
    986  1.1     elric #endif
    987  1.1     elric 
    988  1.1     elric #ifndef HAVE_GAI_STRERROR
    989  1.1     elric #define gai_strerror rk_gai_strerror
    990  1.1     elric ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
    991  1.1     elric gai_strerror(int);
    992  1.1     elric #endif
    993  1.1     elric 
    994  1.1     elric #ifdef NO_SLEEP
    995  1.1     elric 
    996  1.1     elric ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL
    997  1.1     elric sleep(unsigned int seconds);
    998  1.1     elric 
    999  1.4  christos ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL
   1000  1.4  christos usleep(unsigned int useconds);
   1001  1.4  christos 
   1002  1.1     elric #endif
   1003  1.1     elric 
   1004  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
   1005  1.1     elric getnameinfo_verified(const struct sockaddr *, socklen_t,
   1006  1.1     elric 		     char *, size_t,
   1007  1.1     elric 		     char *, size_t,
   1008  1.1     elric 		     int);
   1009  1.1     elric 
   1010  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
   1011  1.4  christos roken_getaddrinfo_hostspec(const char *, int, struct addrinfo **);
   1012  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
   1013  1.1     elric roken_getaddrinfo_hostspec2(const char *, int, int, struct addrinfo **);
   1014  1.1     elric 
   1015  1.1     elric #ifndef HAVE_STRFTIME
   1016  1.1     elric #define strftime rk_strftime
   1017  1.1     elric ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
   1018  1.1     elric strftime (char *, size_t, const char *, const struct tm *);
   1019  1.1     elric #endif
   1020  1.1     elric 
   1021  1.1     elric #ifndef HAVE_STRPTIME
   1022  1.1     elric #define strptime rk_strptime
   1023  1.1     elric ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
   1024  1.1     elric strptime (const char *, const char *, struct tm *);
   1025  1.1     elric #endif
   1026  1.1     elric 
   1027  1.1     elric #ifndef HAVE_GETTIMEOFDAY
   1028  1.1     elric #define gettimeofday rk_gettimeofday
   1029  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
   1030  1.1     elric gettimeofday (struct timeval *, void *);
   1031  1.1     elric #endif
   1032  1.1     elric 
   1033  1.1     elric #ifndef HAVE_EMALLOC
   1034  1.1     elric #define emalloc rk_emalloc
   1035  1.1     elric ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL emalloc (size_t);
   1036  1.1     elric #endif
   1037  1.1     elric #ifndef HAVE_ECALLOC
   1038  1.1     elric #define ecalloc rk_ecalloc
   1039  1.1     elric ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL ecalloc(size_t, size_t);
   1040  1.1     elric #endif
   1041  1.1     elric #ifndef HAVE_EREALLOC
   1042  1.1     elric #define erealloc rk_erealloc
   1043  1.1     elric ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL erealloc (void *, size_t);
   1044  1.1     elric #endif
   1045  1.1     elric #ifndef HAVE_ESTRDUP
   1046  1.1     elric #define estrdup rk_estrdup
   1047  1.1     elric ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL estrdup (const char *);
   1048  1.1     elric #endif
   1049  1.1     elric 
   1050  1.1     elric /*
   1051  1.1     elric  * kludges and such
   1052  1.1     elric  */
   1053  1.1     elric 
   1054  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
   1055  1.1     elric roken_gethostby_setup(const char*, const char*);
   1056  1.1     elric ROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL
   1057  1.1     elric roken_gethostbyname(const char*);
   1058  1.4  christos ROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL
   1059  1.1     elric roken_gethostbyaddr(const void*, size_t, int);
   1060  1.1     elric 
   1061  1.1     elric #ifdef GETSERVBYNAME_PROTO_COMPATIBLE
   1062  1.1     elric #define roken_getservbyname(x,y) getservbyname(x,y)
   1063  1.1     elric #else
   1064  1.1     elric #define roken_getservbyname(x,y) getservbyname((char *)x, (char *)y)
   1065  1.1     elric #endif
   1066  1.1     elric 
   1067  1.1     elric #ifdef OPENLOG_PROTO_COMPATIBLE
   1068  1.1     elric #define roken_openlog(a,b,c) openlog(a,b,c)
   1069  1.1     elric #else
   1070  1.1     elric #define roken_openlog(a,b,c) openlog((char *)a,b,c)
   1071  1.1     elric #endif
   1072  1.1     elric 
   1073  1.1     elric #ifdef GETSOCKNAME_PROTO_COMPATIBLE
   1074  1.1     elric #define roken_getsockname(a,b,c) getsockname(a,b,c)
   1075  1.1     elric #else
   1076  1.1     elric #define roken_getsockname(a,b,c) getsockname(a, b, (void*)c)
   1077  1.1     elric #endif
   1078  1.1     elric 
   1079  1.1     elric #ifndef HAVE_SETPROGNAME
   1080  1.1     elric #define setprogname rk_setprogname
   1081  1.1     elric ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL setprogname(const char *);
   1082  1.1     elric #endif
   1083  1.1     elric 
   1084  1.1     elric #ifndef HAVE_GETPROGNAME
   1085  1.1     elric #define getprogname rk_getprogname
   1086  1.1     elric ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL getprogname(void);
   1087  1.1     elric #endif
   1088  1.1     elric 
   1089  1.1     elric #if !defined(HAVE_SETPROGNAME) && !defined(HAVE_GETPROGNAME) && !HAVE_DECL___PROGNAME
   1090  1.1     elric extern const char *__progname;
   1091  1.1     elric #endif
   1092  1.1     elric 
   1093  1.1     elric ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
   1094  1.1     elric mini_inetd_addrinfo (struct addrinfo*, rk_socket_t *);
   1095  1.1     elric 
   1096  1.1     elric ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
   1097  1.1     elric mini_inetd (int, rk_socket_t *);
   1098  1.1     elric 
   1099  1.1     elric #ifndef HAVE_LOCALTIME_R
   1100  1.1     elric #define localtime_r rk_localtime_r
   1101  1.1     elric ROKEN_LIB_FUNCTION struct tm * ROKEN_LIB_CALL
   1102  1.1     elric localtime_r(const time_t *, struct tm *);
   1103  1.1     elric #endif
   1104  1.1     elric 
   1105  1.4  christos #if !defined(HAVE_STRTOLL) || defined(NEED_STRTOLL_PROTO)
   1106  1.4  christos #ifndef HAVE_STRTOLL
   1107  1.4  christos #define strtoll rk_strtoll
   1108  1.4  christos #endif
   1109  1.4  christos ROKEN_LIB_FUNCTION long long ROKEN_LIB_CALL
   1110  1.4  christos strtoll(const char * nptr, char ** endptr, int base);
   1111  1.4  christos #endif
   1112  1.4  christos 
   1113  1.4  christos #if !defined(HAVE_STRTOULL) || defined(NEED_STRTOULL_PROTO)
   1114  1.4  christos #ifndef HAVE_STRTOULL
   1115  1.4  christos #define strtoull rk_strtoull
   1116  1.4  christos #endif
   1117  1.4  christos ROKEN_LIB_FUNCTION unsigned long long ROKEN_LIB_CALL
   1118  1.4  christos strtoull(const char * nptr, char ** endptr, int base);
   1119  1.4  christos #endif
   1120  1.4  christos 
   1121  1.1     elric #if !defined(HAVE_STRSVIS) || defined(NEED_STRSVIS_PROTO)
   1122  1.1     elric #ifndef HAVE_STRSVIS
   1123  1.1     elric #define strsvis rk_strsvis
   1124  1.1     elric #endif
   1125  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
   1126  1.1     elric strsvis(char *, const char *, int, const char *);
   1127  1.1     elric #endif
   1128  1.1     elric 
   1129  1.1     elric #if !defined(HAVE_STRSVISX) || defined(NEED_STRSVISX_PROTO)
   1130  1.1     elric #ifndef HAVE_STRSVISX
   1131  1.1     elric #define strsvisx rk_strsvisx
   1132  1.1     elric #endif
   1133  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
   1134  1.1     elric strsvisx(char *, const char *, size_t, int, const char *);
   1135  1.1     elric #endif
   1136  1.1     elric 
   1137  1.1     elric #if !defined(HAVE_STRUNVIS) || defined(NEED_STRUNVIS_PROTO)
   1138  1.1     elric #ifndef HAVE_STRUNVIS
   1139  1.1     elric #define strunvis rk_strunvis
   1140  1.1     elric #endif
   1141  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
   1142  1.1     elric strunvis(char *, const char *);
   1143  1.1     elric #endif
   1144  1.1     elric 
   1145  1.1     elric #if !defined(HAVE_STRVIS) || defined(NEED_STRVIS_PROTO)
   1146  1.1     elric #ifndef HAVE_STRVIS
   1147  1.1     elric #define strvis rk_strvis
   1148  1.1     elric #endif
   1149  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
   1150  1.1     elric strvis(char *, const char *, int);
   1151  1.1     elric #endif
   1152  1.1     elric 
   1153  1.1     elric #if !defined(HAVE_STRVISX) || defined(NEED_STRVISX_PROTO)
   1154  1.1     elric #ifndef HAVE_STRVISX
   1155  1.1     elric #define strvisx rk_strvisx
   1156  1.1     elric #endif
   1157  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
   1158  1.1     elric strvisx(char *, const char *, size_t, int);
   1159  1.1     elric #endif
   1160  1.1     elric 
   1161  1.1     elric #if !defined(HAVE_SVIS) || defined(NEED_SVIS_PROTO)
   1162  1.1     elric #ifndef HAVE_SVIS
   1163  1.1     elric #define svis rk_svis
   1164  1.1     elric #endif
   1165  1.1     elric ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
   1166  1.1     elric svis(char *, int, int, int, const char *);
   1167  1.1     elric #endif
   1168  1.1     elric 
   1169  1.1     elric #if !defined(HAVE_UNVIS) || defined(NEED_UNVIS_PROTO)
   1170  1.1     elric #ifndef HAVE_UNVIS
   1171  1.1     elric #define unvis rk_unvis
   1172  1.1     elric #endif
   1173  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
   1174  1.1     elric unvis(char *, int, int *, int);
   1175  1.1     elric #endif
   1176  1.1     elric 
   1177  1.1     elric #if !defined(HAVE_VIS) || defined(NEED_VIS_PROTO)
   1178  1.1     elric #ifndef HAVE_VIS
   1179  1.1     elric #define vis rk_vis
   1180  1.1     elric #endif
   1181  1.1     elric ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
   1182  1.1     elric vis(char *, int, int, int);
   1183  1.1     elric #endif
   1184  1.1     elric 
   1185  1.1     elric #if !defined(HAVE_CLOSEFROM)
   1186  1.1     elric #define closefrom rk_closefrom
   1187  1.1     elric ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
   1188  1.1     elric closefrom(int);
   1189  1.1     elric #endif
   1190  1.1     elric 
   1191  1.1     elric #if !defined(HAVE_TIMEGM)
   1192  1.1     elric #define timegm rk_timegm
   1193  1.1     elric ROKEN_LIB_FUNCTION time_t ROKEN_LIB_CALL
   1194  1.1     elric rk_timegm(struct tm *tm);
   1195  1.1     elric #endif
   1196  1.1     elric 
   1197  1.1     elric #ifdef NEED_QSORT
   1198  1.1     elric #define qsort rk_qsort
   1199  1.1     elric void
   1200  1.1     elric rk_qsort(void *, size_t, size_t, int (*)(const void *, const void *));
   1201  1.1     elric #endif
   1202  1.1     elric 
   1203  1.4  christos #ifndef HAVE_MEMSET_S
   1204  1.4  christos #define memset_s rk_memset_s
   1205  1.4  christos ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL memset_s(void *s, size_t smax,
   1206  1.4  christos 					int c, size_t n);
   1207  1.4  christos #endif
   1208  1.4  christos 
   1209  1.1     elric #if defined(HAVE_ARC4RANDOM)
   1210  1.4  christos # define rk_random() arc4random()
   1211  1.1     elric #elif defined(HAVE_RANDOM)
   1212  1.4  christos # define rk_random() random()
   1213  1.1     elric #else
   1214  1.4  christos # ifdef HAVE_WIN32_RAND_S
   1215  1.4  christos ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL
   1216  1.4  christos rk_random(void);
   1217  1.4  christos # else
   1218  1.4  christos #  define rk_random() rand()
   1219  1.4  christos # endif
   1220  1.1     elric #endif
   1221  1.1     elric 
   1222  1.1     elric #ifndef HAVE_TDELETE
   1223  1.1     elric #define tdelete(a,b,c) rk_tdelete(a,b,c)
   1224  1.1     elric #endif
   1225  1.1     elric #ifndef HAVE_TFIND
   1226  1.1     elric #define tfind(a,b,c) rk_tfind(a,b,c)
   1227  1.1     elric #endif
   1228  1.1     elric #ifndef HAVE_TSEARCH
   1229  1.1     elric #define tsearch(a,b,c) rk_tsearch(a,b,c)
   1230  1.1     elric #endif
   1231  1.1     elric #ifndef HAVE_TWALK
   1232  1.1     elric #define twalk(a,b) rk_twalk(a,b)
   1233  1.1     elric #endif
   1234  1.1     elric 
   1235  1.1     elric #if defined(__linux__) && defined(SOCK_CLOEXEC) && !defined(SOCKET_WRAPPER_REPLACE) && !defined(__SOCKET_WRAPPER_H__)
   1236  1.1     elric #undef socket
   1237  1.1     elric #define socket(_fam,_type,_prot) rk_socket(_fam,_type,_prot)
   1238  1.1     elric int ROKEN_LIB_FUNCTION rk_socket(int, int, int);
   1239  1.1     elric #endif
   1240  1.1     elric 
   1241  1.4  christos /* Microsoft VC 2010 POSIX definitions */
   1242  1.4  christos #ifndef EAFNOSUPPORT
   1243  1.4  christos #define EAFNOSUPPORT            102
   1244  1.4  christos #endif
   1245  1.4  christos #ifndef EINPROGRESS
   1246  1.4  christos #define EINPROGRESS             112
   1247  1.4  christos #endif
   1248  1.4  christos #ifndef ELOOP
   1249  1.4  christos #define ELOOP			114
   1250  1.4  christos #endif
   1251  1.4  christos #ifndef ENOTSOCK
   1252  1.4  christos #define ENOTSOCK		128
   1253  1.4  christos #endif
   1254  1.4  christos #ifndef ENOTSUP
   1255  1.4  christos #define ENOTSUP                 129
   1256  1.4  christos #endif
   1257  1.4  christos #ifndef EOVERFLOW
   1258  1.4  christos #define EOVERFLOW               132
   1259  1.4  christos #endif
   1260  1.4  christos #ifndef ETIMEDOUT
   1261  1.4  christos #define ETIMEDOUT               138
   1262  1.4  christos #endif
   1263  1.4  christos #ifndef EWOULDBLOCK
   1264  1.4  christos #define EWOULDBLOCK             140
   1265  1.4  christos #endif
   1266  1.4  christos 
   1267  1.4  christos 
   1268  1.1     elric #ifdef SOCKET_WRAPPER_REPLACE
   1269  1.1     elric #include <socket_wrapper.h>
   1270  1.1     elric #endif
   1271  1.1     elric 
   1272  1.1     elric ROKEN_CPP_END
   1273