LCOV - code coverage report
Current view: top level - third_party/heimdal/lib/roken - roken.h.in (source / functions) Hit Total Coverage
Test: coverage report for v4-17-test 1498b464 Lines: 2 2 100.0 %
Date: 2024-06-13 04:01:37 Functions: 1 1 100.0 %

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

Generated by: LCOV version 1.13