roken.h.in revision 233294
155682Smarkm/* -*- C -*- */ 255682Smarkm/* 3233294Sstas * Copyright (c) 1995-2005 Kungliga Tekniska H��gskolan 455682Smarkm * (Royal Institute of Technology, Stockholm, Sweden). 555682Smarkm * All rights reserved. 655682Smarkm * 755682Smarkm * Redistribution and use in source and binary forms, with or without 855682Smarkm * modification, are permitted provided that the following conditions 955682Smarkm * are met: 1055682Smarkm * 1155682Smarkm * 1. Redistributions of source code must retain the above copyright 1255682Smarkm * notice, this list of conditions and the following disclaimer. 1355682Smarkm * 1455682Smarkm * 2. Redistributions in binary form must reproduce the above copyright 1555682Smarkm * notice, this list of conditions and the following disclaimer in the 1655682Smarkm * documentation and/or other materials provided with the distribution. 1755682Smarkm * 1855682Smarkm * 3. Neither the name of the Institute nor the names of its contributors 1955682Smarkm * may be used to endorse or promote products derived from this software 2055682Smarkm * without specific prior written permission. 2155682Smarkm * 2255682Smarkm * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 2355682Smarkm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2455682Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2555682Smarkm * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 2655682Smarkm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2755682Smarkm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2855682Smarkm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2955682Smarkm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3055682Smarkm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3155682Smarkm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3255682Smarkm * SUCH DAMAGE. 3355682Smarkm */ 3455682Smarkm 3555682Smarkm#include <stdio.h> 3655682Smarkm#include <stdlib.h> 3755682Smarkm#include <stdarg.h> 38178825Sdfr#ifdef HAVE_STDINT_H 39178825Sdfr#include <stdint.h> 40178825Sdfr#endif 4155682Smarkm#include <string.h> 4255682Smarkm#include <signal.h> 4372445Sassar 44233294Sstas#ifndef ROKEN_LIB_FUNCTION 45233294Sstas#ifdef _WIN32 46233294Sstas# define ROKEN_LIB_CALL __cdecl 47233294Sstas# ifdef ROKEN_LIB_DYNAMIC 48233294Sstas# define ROKEN_LIB_FUNCTION __declspec(dllimport) 49233294Sstas# define ROKEN_LIB_VARIABLE __declspec(dllimport) 50233294Sstas# else 51233294Sstas# define ROKEN_LIB_FUNCTION 52233294Sstas# define ROKEN_LIB_VARIABLE 53233294Sstas# endif 54233294Sstas#else 55233294Sstas#define ROKEN_LIB_FUNCTION 56233294Sstas#define ROKEN_LIB_CALL 57233294Sstas#define ROKEN_LIB_VARIABLE 58233294Sstas#endif 59233294Sstas#endif 60233294Sstas 61233294Sstas#ifdef HAVE_WINSOCK 62233294Sstas/* Declarations for Microsoft Windows */ 63233294Sstas 64233294Sstas#include <winsock2.h> 65233294Sstas#include <ws2tcpip.h> 66233294Sstas 67233294Sstas/* 68233294Sstas * error codes for inet_ntop/inet_pton 69233294Sstas */ 70233294Sstas#define EAFNOSUPPORT WSAEAFNOSUPPORT 71233294Sstas 72233294Sstastypedef SOCKET rk_socket_t; 73233294Sstas 74233294Sstas#define rk_closesocket(x) closesocket(x) 75233294Sstas#define rk_INVALID_SOCKET INVALID_SOCKET 76233294Sstas#define rk_IS_BAD_SOCKET(s) ((s) == INVALID_SOCKET) 77233294Sstas#define rk_IS_SOCKET_ERROR(rv) ((rv) == SOCKET_ERROR) 78233294Sstas#define rk_SOCK_ERRNO WSAGetLastError() 79233294Sstas 80233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_SOCK_IOCTL(SOCKET s, long cmd, int * argp); 81233294Sstas 82233294Sstas/* Microsoft VC 2010 POSIX definitions */ 83233294Sstas#ifndef ENOTSOCK 84233294Sstas#define ENOTSOCK 128 85233294Sstas#endif 86233294Sstas#ifndef ENOTSUP 87233294Sstas#define ENOTSUP 129 88233294Sstas#endif 89233294Sstas#ifndef EOVERFLOW 90233294Sstas#define EOVERFLOW 132 91233294Sstas#endif 92233294Sstas#ifndef ETIMEDOUT 93233294Sstas#define ETIMEDOUT 138 94233294Sstas#endif 95233294Sstas#ifndef EWOULDBLOCK 96233294Sstas#define EWOULDBLOCK 140 97233294Sstas#endif 98233294Sstas 99233294Sstas#define rk_SOCK_INIT() rk_WSAStartup() 100233294Sstas#define rk_SOCK_EXIT() rk_WSACleanup() 101233294Sstas 102233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_WSAStartup(void); 103233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_WSACleanup(void); 104233294Sstas 105233294Sstas#else /* not WinSock */ 106233294Sstas 107233294Sstastypedef int rk_socket_t; 108233294Sstas 109233294Sstas#define rk_closesocket(x) close(x) 110233294Sstas#define rk_SOCK_IOCTL(s,c,a) ioctl((s),(c),(a)) 111233294Sstas#define rk_IS_BAD_SOCKET(s) ((s) < 0) 112233294Sstas#define rk_IS_SOCKET_ERROR(rv) ((rv) < 0) 113233294Sstas#define rk_SOCK_ERRNO errno 114233294Sstas#define rk_INVALID_SOCKET (-1) 115233294Sstas 116233294Sstas#define rk_SOCK_INIT() 0 117233294Sstas#define rk_SOCK_EXIT() do { } while(0) 118233294Sstas 119233294Sstas#endif 120233294Sstas 121233294Sstas#ifndef IN_LOOPBACKNET 122233294Sstas#define IN_LOOPBACKNET 127 123233294Sstas#endif 124233294Sstas 125233294Sstas#ifdef _MSC_VER 126233294Sstas/* Declarations for Microsoft Visual C runtime on Windows */ 127233294Sstas 128233294Sstas#include<process.h> 129233294Sstas 130233294Sstas#include<io.h> 131233294Sstas 132233294Sstas#ifndef __BIT_TYPES_DEFINED__ 133233294Sstas#define __BIT_TYPES_DEFINED__ 134233294Sstas 135233294Sstastypedef __int8 int8_t; 136233294Sstastypedef __int16 int16_t; 137233294Sstastypedef __int32 int32_t; 138233294Sstastypedef __int64 int64_t; 139233294Sstastypedef unsigned __int8 uint8_t; 140233294Sstastypedef unsigned __int16 uint16_t; 141233294Sstastypedef unsigned __int32 uint32_t; 142233294Sstastypedef unsigned __int64 uint64_t; 143233294Sstastypedef uint8_t u_int8_t; 144233294Sstastypedef uint16_t u_int16_t; 145233294Sstastypedef uint32_t u_int32_t; 146233294Sstastypedef uint64_t u_int64_t; 147233294Sstas 148233294Sstas#endif /* __BIT_TYPES_DEFINED__ */ 149233294Sstas 150233294Sstas#define UNREACHABLE(x) x 151233294Sstas#define UNUSED_ARGUMENT(x) ((void) x) 152233294Sstas 153233294Sstas#define RETSIGTYPE void 154233294Sstas 155233294Sstas#define VOID_RETSIGTYPE 1 156233294Sstas 157233294Sstas#ifdef VOID_RETSIGTYPE 158233294Sstas#define SIGRETURN(x) return 159233294Sstas#else 160233294Sstas#define SIGRETURN(x) return (RETSIGTYPE)(x) 161233294Sstas#endif 162233294Sstas 163233294Sstas#ifndef CPP_ONLY 164233294Sstas 165233294Sstastypedef int pid_t; 166233294Sstas 167233294Sstastypedef unsigned int gid_t; 168233294Sstas 169233294Sstastypedef unsigned int uid_t; 170233294Sstas 171233294Sstastypedef unsigned short mode_t; 172233294Sstas 173233294Sstas#endif 174233294Sstas 175233294Sstas#ifndef __cplusplus 176233294Sstas#define inline __inline 177233294Sstas#endif 178233294Sstas 179233294Sstas#else 180233294Sstas 181233294Sstas#define UNREACHABLE(x) 182233294Sstas#define UNUSED_ARGUMENT(x) 183233294Sstas 184233294Sstas#endif 185233294Sstas 18672445Sassar#ifdef _AIX 18772445Sassarstruct ether_addr; 18872445Sassarstruct sockaddr_dl; 18972445Sassar#endif 19055682Smarkm#ifdef HAVE_SYS_PARAM_H 19155682Smarkm#include <sys/param.h> 19255682Smarkm#endif 19378527Sassar#ifdef HAVE_INTTYPES_H 19478527Sassar#include <inttypes.h> 19578527Sassar#endif 19655682Smarkm#ifdef HAVE_SYS_TYPES_H 19755682Smarkm#include <sys/types.h> 19855682Smarkm#endif 19978527Sassar#ifdef HAVE_SYS_BITYPES_H 20078527Sassar#include <sys/bitypes.h> 20178527Sassar#endif 20278527Sassar#ifdef HAVE_BIND_BITYPES_H 20378527Sassar#include <bind/bitypes.h> 20478527Sassar#endif 20578527Sassar#ifdef HAVE_NETINET_IN6_MACHTYPES_H 20678527Sassar#include <netinet/in6_machtypes.h> 20778527Sassar#endif 20855682Smarkm#ifdef HAVE_UNISTD_H 20955682Smarkm#include <unistd.h> 21055682Smarkm#endif 21155682Smarkm#ifdef HAVE_SYS_SOCKET_H 21255682Smarkm#include <sys/socket.h> 21355682Smarkm#endif 21455682Smarkm#ifdef HAVE_SYS_UIO_H 21555682Smarkm#include <sys/uio.h> 21655682Smarkm#endif 21755682Smarkm#ifdef HAVE_GRP_H 21855682Smarkm#include <grp.h> 21955682Smarkm#endif 22055682Smarkm#ifdef HAVE_SYS_STAT_H 22155682Smarkm#include <sys/stat.h> 22255682Smarkm#endif 22355682Smarkm#ifdef HAVE_NETINET_IN_H 22455682Smarkm#include <netinet/in.h> 22555682Smarkm#endif 22655682Smarkm#ifdef HAVE_NETINET_IN6_H 22755682Smarkm#include <netinet/in6.h> 22855682Smarkm#endif 22955682Smarkm#ifdef HAVE_NETINET6_IN6_H 23055682Smarkm#include <netinet6/in6.h> 23155682Smarkm#endif 23255682Smarkm#ifdef HAVE_ARPA_INET_H 23355682Smarkm#include <arpa/inet.h> 23455682Smarkm#endif 23555682Smarkm#ifdef HAVE_NETDB_H 23655682Smarkm#include <netdb.h> 23755682Smarkm#endif 23890926Snectar#ifdef HAVE_ARPA_NAMESER_H 23990926Snectar#include <arpa/nameser.h> 24090926Snectar#endif 24190926Snectar#ifdef HAVE_RESOLV_H 24290926Snectar#include <resolv.h> 24390926Snectar#endif 24455682Smarkm#ifdef HAVE_SYSLOG_H 24555682Smarkm#include <syslog.h> 24655682Smarkm#endif 24755682Smarkm#ifdef HAVE_FCNTL_H 24855682Smarkm#include <fcntl.h> 24955682Smarkm#endif 25055682Smarkm#ifdef HAVE_ERRNO_H 25155682Smarkm#include <errno.h> 25255682Smarkm#endif 25355682Smarkm#include <err.h> 25455682Smarkm#ifdef HAVE_TERMIOS_H 25555682Smarkm#include <termios.h> 25655682Smarkm#endif 257233294Sstas#ifdef HAVE_SYS_IOCTL_H 25855682Smarkm#include <sys/ioctl.h> 25955682Smarkm#endif 26055682Smarkm#ifdef TIME_WITH_SYS_TIME 26155682Smarkm#include <sys/time.h> 26255682Smarkm#include <time.h> 26355682Smarkm#elif defined(HAVE_SYS_TIME_H) 26455682Smarkm#include <sys/time.h> 26555682Smarkm#else 26655682Smarkm#include <time.h> 26755682Smarkm#endif 26855682Smarkm 26955682Smarkm#ifdef HAVE_PATHS_H 27055682Smarkm#include <paths.h> 27155682Smarkm#endif 27255682Smarkm 273233294Sstas#ifdef HAVE_DIRENT_H 274233294Sstas#include <dirent.h> 275233294Sstas#endif 276233294Sstas 277233294Sstas#ifdef BACKSLASH_PATH_DELIM 278233294Sstas#define rk_PATH_DELIM '\\' 279233294Sstas#endif 280233294Sstas 281102644Snectar#ifndef HAVE_SSIZE_T 282233294Sstas#ifndef SSIZE_T_DEFINED 283233294Sstas#ifdef ssize_t 284233294Sstas#undef ssize_t 285233294Sstas#endif 286233294Sstas#ifdef _WIN64 287233294Sstastypedef __int64 ssize_t; 288233294Sstas#else 289102644Snectartypedef int ssize_t; 290102644Snectar#endif 291233294Sstas#define SSIZE_T_DEFINED 292233294Sstas#endif /* SSIZE_T_DEFINED */ 293233294Sstas#endif /* HAVE_SSIZE_T */ 294102644Snectar 29555682Smarkm#include <roken-common.h> 29655682Smarkm 29772445SassarROKEN_CPP_START 29872445Sassar 299178825Sdfr#ifdef HAVE_UINTPTR_T 300178825Sdfr#define rk_UNCONST(x) ((void *)(uintptr_t)(const void *)(x)) 301178825Sdfr#else 302178825Sdfr#define rk_UNCONST(x) ((void *)(unsigned long)(const void *)(x)) 303178825Sdfr#endif 304178825Sdfr 30555682Smarkm#if !defined(HAVE_SETSID) && defined(HAVE__SETSID) 30655682Smarkm#define setsid _setsid 30755682Smarkm#endif 30855682Smarkm 309233294Sstas#ifdef _MSC_VER 310233294Sstas/* Additional macros for Visual C/C++ runtime */ 311233294Sstas 312233294Sstas#define close _close 313233294Sstas 314233294Sstas#define getpid _getpid 315233294Sstas 316233294Sstas#define open _open 317233294Sstas 318233294Sstas#define chdir _chdir 319233294Sstas 320233294Sstas#define fsync _commit 321233294Sstas 322233294Sstas/* The MSVC implementation of snprintf is not C99 compliant. */ 323233294Sstas#define snprintf rk_snprintf 324233294Sstas#define vsnprintf rk_vsnprintf 325233294Sstas#define vasnprintf rk_vasnprintf 326233294Sstas#define vasprintf rk_vasprintf 327233294Sstas#define asnprintf rk_asnprintf 328233294Sstas#define asprintf rk_asprintf 329233294Sstas 330233294Sstas#define _PIPE_BUFFER_SZ 8192 331233294Sstas#define pipe(fds) _pipe((fds), _PIPE_BUFFER_SZ, O_BINARY); 332233294Sstas 333233294Sstas#define ftruncate(fd, sz) _chsize((fd), (sz)) 334233294Sstas 335233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 336233294Sstasrk_snprintf (char *str, size_t sz, const char *format, ...); 337233294Sstas 338233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 339233294Sstasrk_asprintf (char **ret, const char *format, ...); 340233294Sstas 341233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 342233294Sstasrk_asnprintf (char **ret, size_t max_sz, const char *format, ...); 343233294Sstas 344233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 345233294Sstasrk_vasprintf (char **ret, const char *format, va_list args); 346233294Sstas 347233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 348233294Sstasrk_vasnprintf (char **ret, size_t max_sz, const char *format, va_list args); 349233294Sstas 350233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 351233294Sstasrk_vsnprintf (char *str, size_t sz, const char *format, va_list args); 352233294Sstas 353233294Sstas/* missing stat.h predicates */ 354233294Sstas 355233294Sstas#define S_ISREG(m) (((m) & _S_IFREG) == _S_IFREG) 356233294Sstas 357233294Sstas#define S_ISDIR(m) (((m) & _S_IFDIR) == _S_IFDIR) 358233294Sstas 359233294Sstas#define S_ISCHR(m) (((m) & _S_IFCHR) == _S_IFCHR) 360233294Sstas 361233294Sstas#define S_ISFIFO(m) (((m) & _S_IFIFO) == _S_IFIFO) 362233294Sstas 363233294Sstas/* The following are not implemented: 364233294Sstas 365233294Sstas S_ISLNK(m) 366233294Sstas S_ISSOCK(m) 367233294Sstas S_ISBLK(m) 368233294Sstas*/ 369233294Sstas 370233294Sstas#endif /* _MSC_VER */ 371233294Sstas 372233294Sstas#ifdef HAVE_WINSOCK 373233294Sstas 374233294Sstas/* While we are at it, define WinSock specific scatter gather socket 375233294Sstas I/O. */ 376233294Sstas 377233294Sstas#define iovec _WSABUF 378233294Sstas#define iov_base buf 379233294Sstas#define iov_len len 380233294Sstas 381233294Sstasstruct msghdr { 382233294Sstas void *msg_name; 383233294Sstas socklen_t msg_namelen; 384233294Sstas struct iovec *msg_iov; 385233294Sstas size_t msg_iovlen; 386233294Sstas void *msg_control; 387233294Sstas socklen_t msg_controllen; 388233294Sstas int msg_flags; 389233294Sstas}; 390233294Sstas 391233294Sstas#define sendmsg sendmsg_w32 392233294Sstas 393233294SstasROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL 394233294Sstassendmsg_w32(rk_socket_t s, const struct msghdr * msg, int flags); 395233294Sstas 396233294Sstas#endif /* HAVE_WINSOCK */ 397233294Sstas 39855682Smarkm#ifndef HAVE_PUTENV 399233294Sstas#define putenv rk_putenv 400233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL putenv(const char *); 40155682Smarkm#endif 40255682Smarkm 40355682Smarkm#if !defined(HAVE_SETENV) || defined(NEED_SETENV_PROTO) 404233294Sstas#ifndef HAVE_SETENV 405233294Sstas#define setenv rk_setenv 40655682Smarkm#endif 407233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL setenv(const char *, const char *, int); 408233294Sstas#endif 40955682Smarkm 41055682Smarkm#if !defined(HAVE_UNSETENV) || defined(NEED_UNSETENV_PROTO) 411233294Sstas#ifndef HAVE_UNSETENV 412233294Sstas#define unsetenv rk_unsetenv 41355682Smarkm#endif 414233294SstasROKEN_LIB_FUNCTION void ROKEN_LIB_CALL unsetenv(const char *); 415233294Sstas#endif 41655682Smarkm 41755682Smarkm#if !defined(HAVE_GETUSERSHELL) || defined(NEED_GETUSERSHELL_PROTO) 418233294Sstas#ifndef HAVE_GETUSERSHELL 419233294Sstas#define getusershell rk_getusershell 420233294Sstas#define endusershell rk_endusershell 42155682Smarkm#endif 422233294SstasROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL getusershell(void); 423233294SstasROKEN_LIB_FUNCTION void ROKEN_LIB_CALL endusershell(void); 424233294Sstas#endif 42555682Smarkm 42655682Smarkm#if !defined(HAVE_SNPRINTF) || defined(NEED_SNPRINTF_PROTO) 427233294Sstas#ifndef HAVE_SNPRINTF 428233294Sstas#define snprintf rk_snprintf 429233294Sstas#endif 430233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 431233294Sstas rk_snprintf (char *, size_t, const char *, ...) 43255682Smarkm __attribute__ ((format (printf, 3, 4))); 43355682Smarkm#endif 43455682Smarkm 43555682Smarkm#if !defined(HAVE_VSNPRINTF) || defined(NEED_VSNPRINTF_PROTO) 436233294Sstas#ifndef HAVE_VSNPRINTF 437233294Sstas#define vsnprintf rk_vsnprintf 438233294Sstas#endif 439233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 440233294Sstas rk_vsnprintf (char *, size_t, const char *, va_list) 44155682Smarkm __attribute__((format (printf, 3, 0))); 44255682Smarkm#endif 44355682Smarkm 44455682Smarkm#if !defined(HAVE_ASPRINTF) || defined(NEED_ASPRINTF_PROTO) 445233294Sstas#ifndef HAVE_ASPRINTF 446233294Sstas#define asprintf rk_asprintf 447233294Sstas#endif 448233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 449233294Sstas rk_asprintf (char **, const char *, ...) 45055682Smarkm __attribute__ ((format (printf, 2, 3))); 45155682Smarkm#endif 45255682Smarkm 45355682Smarkm#if !defined(HAVE_VASPRINTF) || defined(NEED_VASPRINTF_PROTO) 454233294Sstas#ifndef HAVE_VASPRINTF 455233294Sstas#define vasprintf rk_vasprintf 456233294Sstas#endif 457233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 458233294Sstas rk_vasprintf (char **, const char *, va_list) 45955682Smarkm __attribute__((format (printf, 2, 0))); 46055682Smarkm#endif 46155682Smarkm 46255682Smarkm#if !defined(HAVE_ASNPRINTF) || defined(NEED_ASNPRINTF_PROTO) 463233294Sstas#ifndef HAVE_ASNPRINTF 464233294Sstas#define asnprintf rk_asnprintf 465233294Sstas#endif 466233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 467233294Sstas rk_asnprintf (char **, size_t, const char *, ...) 46855682Smarkm __attribute__ ((format (printf, 3, 4))); 46955682Smarkm#endif 47055682Smarkm 47155682Smarkm#if !defined(HAVE_VASNPRINTF) || defined(NEED_VASNPRINTF_PROTO) 472233294Sstas#ifndef HAVE_VASNPRINTF 473233294Sstas#define vasnprintf rk_vasnprintf 474233294Sstas#endif 475233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 476178825Sdfr vasnprintf (char **, size_t, const char *, va_list) 47755682Smarkm __attribute__((format (printf, 3, 0))); 47855682Smarkm#endif 47955682Smarkm 48055682Smarkm#ifndef HAVE_STRDUP 481233294Sstas#define strdup rk_strdup 482233294SstasROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strdup(const char *); 48355682Smarkm#endif 48455682Smarkm 485102644Snectar#if !defined(HAVE_STRNDUP) || defined(NEED_STRNDUP_PROTO) 486233294Sstas#ifndef HAVE_STRNDUP 487233294Sstas#define strndup rk_strndup 48855682Smarkm#endif 489233294SstasROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strndup(const char *, size_t); 490233294Sstas#endif 49155682Smarkm 49255682Smarkm#ifndef HAVE_STRLWR 493233294Sstas#define strlwr rk_strlwr 494233294SstasROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strlwr(char *); 49555682Smarkm#endif 49655682Smarkm 49755682Smarkm#ifndef HAVE_STRNLEN 498233294Sstas#define strnlen rk_strnlen 499233294SstasROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL strnlen(const char*, size_t); 50055682Smarkm#endif 50155682Smarkm 50255682Smarkm#if !defined(HAVE_STRSEP) || defined(NEED_STRSEP_PROTO) 503233294Sstas#ifndef HAVE_STRSEP 504233294Sstas#define strsep rk_strsep 50555682Smarkm#endif 506233294SstasROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strsep(char**, const char*); 507233294Sstas#endif 50855682Smarkm 50972445Sassar#if !defined(HAVE_STRSEP_COPY) || defined(NEED_STRSEP_COPY_PROTO) 510233294Sstas#ifndef HAVE_STRSEP_COPY 511233294Sstas#define strsep_copy rk_strsep_copy 51272445Sassar#endif 513233294SstasROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL strsep_copy(const char**, const char*, char*, size_t); 514233294Sstas#endif 51572445Sassar 51655682Smarkm#ifndef HAVE_STRCASECMP 517233294Sstas#define strcasecmp rk_strcasecmp 518233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL strcasecmp(const char *, const char *); 51955682Smarkm#endif 52055682Smarkm 52155682Smarkm#ifdef NEED_FCLOSE_PROTO 522233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL fclose(FILE *); 52355682Smarkm#endif 52455682Smarkm 52555682Smarkm#ifdef NEED_STRTOK_R_PROTO 526233294SstasROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strtok_r(char *, const char *, char **); 52755682Smarkm#endif 52855682Smarkm 52955682Smarkm#ifndef HAVE_STRUPR 530233294Sstas#define strupr rk_strupr 531233294SstasROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strupr(char *); 53255682Smarkm#endif 53355682Smarkm 53455682Smarkm#ifndef HAVE_STRLCPY 535233294Sstas#define strlcpy rk_strlcpy 536233294SstasROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL strlcpy (char *, const char *, size_t); 53755682Smarkm#endif 53855682Smarkm 53955682Smarkm#ifndef HAVE_STRLCAT 540233294Sstas#define strlcat rk_strlcat 541233294SstasROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL strlcat (char *, const char *, size_t); 54255682Smarkm#endif 54355682Smarkm 54455682Smarkm#ifndef HAVE_GETDTABLESIZE 545233294Sstas#define getdtablesize rk_getdtablesize 546233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL getdtablesize(void); 54755682Smarkm#endif 54855682Smarkm 54955682Smarkm#if !defined(HAVE_STRERROR) && !defined(strerror) 550233294Sstas#define strerror rk_strerror 551233294SstasROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strerror(int); 55255682Smarkm#endif 55355682Smarkm 554233294Sstas#if (!defined(HAVE_STRERROR_R) && !defined(strerror_r)) || (!defined(STRERROR_R_PROTO_COMPATIBLE) && defined(HAVE_STRERROR_R)) 555233294Sstasint ROKEN_LIB_FUNCTION rk_strerror_r(int, char *, size_t); 556233294Sstas#else 557233294Sstas#define rk_strerror_r strerror_r 558233294Sstas#endif 559233294Sstas 56055682Smarkm#if !defined(HAVE_HSTRERROR) || defined(NEED_HSTRERROR_PROTO) 561233294Sstas#ifndef HAVE_HSTRERROR 562233294Sstas#define hstrerror rk_hstrerror 563233294Sstas#endif 56455682Smarkm/* This causes a fatal error under Psoriasis */ 565233294Sstas#ifndef SunOS 566233294SstasROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL hstrerror(int); 56755682Smarkm#endif 56855682Smarkm#endif 56955682Smarkm 570178825Sdfr#if !HAVE_DECL_H_ERRNO 57155682Smarkmextern int h_errno; 57255682Smarkm#endif 57355682Smarkm 57455682Smarkm#if !defined(HAVE_INET_ATON) || defined(NEED_INET_ATON_PROTO) 575233294Sstas#ifndef HAVE_INET_ATON 576233294Sstas#define inet_aton rk_inet_aton 57755682Smarkm#endif 578233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL inet_aton(const char *, struct in_addr *); 579233294Sstas#endif 58055682Smarkm 58155682Smarkm#ifndef HAVE_INET_NTOP 582233294Sstas#define inet_ntop rk_inet_ntop 583233294SstasROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL 58455682Smarkminet_ntop(int af, const void *src, char *dst, size_t size); 58555682Smarkm#endif 58655682Smarkm 58755682Smarkm#ifndef HAVE_INET_PTON 588233294Sstas#define inet_pton rk_inet_pton 589233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 590178825Sdfrinet_pton(int, const char *, void *); 59155682Smarkm#endif 59255682Smarkm 593233294Sstas#ifndef HAVE_GETCWD 594233294Sstas#define getcwd rk_getcwd 595233294SstasROKEN_LIB_FUNCTION char* ROKEN_LIB_CALL getcwd(char *, size_t); 59655682Smarkm#endif 59755682Smarkm 59855682Smarkm#ifdef HAVE_PWD_H 59955682Smarkm#include <pwd.h> 600233294SstasROKEN_LIB_FUNCTION struct passwd * ROKEN_LIB_CALL k_getpwnam (const char *); 601233294SstasROKEN_LIB_FUNCTION struct passwd * ROKEN_LIB_CALL k_getpwuid (uid_t); 60255682Smarkm#endif 60355682Smarkm 604233294SstasROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL get_default_username (void); 60555682Smarkm 60655682Smarkm#ifndef HAVE_SETEUID 607233294Sstas#define seteuid rk_seteuid 608233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL seteuid(uid_t); 60955682Smarkm#endif 61055682Smarkm 61155682Smarkm#ifndef HAVE_SETEGID 612233294Sstas#define setegid rk_setegid 613233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL setegid(gid_t); 61455682Smarkm#endif 61555682Smarkm 61655682Smarkm#ifndef HAVE_LSTAT 617233294Sstas#define lstat rk_lstat 618233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL lstat(const char *, struct stat *); 61955682Smarkm#endif 62055682Smarkm 62155682Smarkm#if !defined(HAVE_MKSTEMP) || defined(NEED_MKSTEMP_PROTO) 622233294Sstas#ifndef HAVE_MKSTEMP 623233294Sstas#define mkstemp rk_mkstemp 62455682Smarkm#endif 625233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL mkstemp(char *); 626233294Sstas#endif 62755682Smarkm 62855682Smarkm#ifndef HAVE_CGETENT 629233294Sstas#define cgetent rk_cgetent 630233294Sstas#define cgetstr rk_cgetstr 631233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetent(char **, char **, const char *); 632233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetstr(char *, const char *, char **); 63355682Smarkm#endif 63455682Smarkm 63555682Smarkm#ifndef HAVE_INITGROUPS 636233294Sstas#define initgroups rk_initgroups 637233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL initgroups(const char *, gid_t); 63855682Smarkm#endif 63955682Smarkm 64055682Smarkm#ifndef HAVE_FCHOWN 641233294Sstas#define fchown rk_fchown 642233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL fchown(int, uid_t, gid_t); 64355682Smarkm#endif 64455682Smarkm 645233294Sstas#ifdef RENAME_DOES_NOT_UNLINK 646233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_rename(const char *, const char *); 647233294Sstas#else 648233294Sstas#define rk_rename(__rk_rn_from,__rk_rn_to) rename(__rk_rn_from,__rk_rn_to) 64955682Smarkm#endif 65055682Smarkm 651233294Sstas#if !defined(HAVE_DAEMON) || defined(NEED_DAEMON_PROTO) 652233294Sstas#ifndef HAVE_DAEMON 653233294Sstas#define daemon rk_daemon 65455682Smarkm#endif 655233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL daemon(int, int); 656233294Sstas#endif 65755682Smarkm 65855682Smarkm#ifndef HAVE_CHOWN 659233294Sstas#define chown rk_chown 660233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL chown(const char *, uid_t, gid_t); 66155682Smarkm#endif 66255682Smarkm 66355682Smarkm#ifndef HAVE_RCMD 664233294Sstas#define rcmd rk_rcmd 665233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 666178825Sdfr rcmd(char **, unsigned short, const char *, 667178825Sdfr const char *, const char *, int *); 66855682Smarkm#endif 66955682Smarkm 67055682Smarkm#if !defined(HAVE_INNETGR) || defined(NEED_INNETGR_PROTO) 671233294Sstas#ifndef HAVE_INNETGR 672233294Sstas#define innetgr rk_innetgr 673233294Sstas#endif 674233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL innetgr(const char*, const char*, 675178825Sdfr const char*, const char*); 67655682Smarkm#endif 67755682Smarkm 67855682Smarkm#ifndef HAVE_IRUSEROK 679233294Sstas#define iruserok rk_iruserok 680233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL iruserok(unsigned, int, 681178825Sdfr const char *, const char *); 68255682Smarkm#endif 68355682Smarkm 68455682Smarkm#if !defined(HAVE_GETHOSTNAME) || defined(NEED_GETHOSTNAME_PROTO) 685233294Sstas#ifndef HAVE_GETHOSTNAME 686233294Sstas#define gethostname rk_gethostname 68755682Smarkm#endif 688233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL gethostname(char *, int); 689233294Sstas#endif 69055682Smarkm 69155682Smarkm#ifndef HAVE_WRITEV 692233294Sstas#define writev rk_writev 693233294SstasROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL 694178825Sdfrwritev(int, const struct iovec *, int); 69555682Smarkm#endif 69655682Smarkm 69755682Smarkm#ifndef HAVE_READV 698233294Sstas#define readv rk_readv 699233294SstasROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL 700178825Sdfrreadv(int, const struct iovec *, int); 70155682Smarkm#endif 70255682Smarkm 70372445Sassar#ifndef HAVE_PIDFILE 704233294Sstas#ifdef NO_PIDFILES 705233294Sstas#define pidfile(x) ((void) 0) 706233294Sstas#else 707233294Sstas#define pidfile rk_pidfile 708233294SstasROKEN_LIB_FUNCTION void ROKEN_LIB_CALL pidfile (const char*); 70972445Sassar#endif 710233294Sstas#endif 71172445Sassar 71278527Sassar#ifndef HAVE_BSWAP32 713233294Sstas#define bswap32 rk_bswap32 714233294SstasROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL bswap32(unsigned int); 71578527Sassar#endif 71678527Sassar 71778527Sassar#ifndef HAVE_BSWAP16 718233294Sstas#define bswap16 rk_bswap16 719233294SstasROKEN_LIB_FUNCTION unsigned short ROKEN_LIB_CALL bswap16(unsigned short); 72078527Sassar#endif 72178527Sassar 72255682Smarkm#ifndef HAVE_FLOCK 72355682Smarkm#ifndef LOCK_SH 72455682Smarkm#define LOCK_SH 1 /* Shared lock */ 72555682Smarkm#endif 72655682Smarkm#ifndef LOCK_EX 72755682Smarkm#define LOCK_EX 2 /* Exclusive lock */ 72855682Smarkm#endif 72955682Smarkm#ifndef LOCK_NB 73055682Smarkm#define LOCK_NB 4 /* Don't block when locking */ 73155682Smarkm#endif 73255682Smarkm#ifndef LOCK_UN 73355682Smarkm#define LOCK_UN 8 /* Unlock */ 73455682Smarkm#endif 73555682Smarkm 736233294Sstas#define flock(_x,_y) rk_flock(_x,_y) 737233294Sstasint rk_flock(int fd, int operation); 73855682Smarkm#endif /* HAVE_FLOCK */ 73955682Smarkm 740233294Sstas#ifndef HAVE_DIRFD 741233294Sstas#ifdef HAVE_DIR_DD_FD 742233294Sstas#define dirfd(x) ((x)->dd_fd) 743233294Sstas#else 744233294Sstas#ifndef _WIN32 /* Windows code never calls dirfd */ 745233294Sstas#error Missing dirfd() and ->dd_fd 746233294Sstas#endif 747233294Sstas#endif 748233294Sstas#endif 74955682Smarkm 750233294SstasROKEN_LIB_FUNCTION time_t ROKEN_LIB_CALL tm2time (struct tm, int); 75155682Smarkm 752233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL unix_verify_user(char *, char *); 75355682Smarkm 754233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL roken_concat (char *, size_t, ...); 75555682Smarkm 756233294SstasROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL roken_mconcat (char **, size_t, ...); 75755682Smarkm 758233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL roken_vconcat (char *, size_t, va_list); 759233294Sstas 760233294SstasROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL 761178825Sdfr roken_vmconcat (char **, size_t, va_list); 76255682Smarkm 763233294SstasROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL 764233294Sstas net_write (rk_socket_t, const void *, size_t); 76555682Smarkm 766233294SstasROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL 767233294Sstas net_read (rk_socket_t, void *, size_t); 76855682Smarkm 769233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 770233294Sstas issuid(void); 77155682Smarkm 77255682Smarkm#ifndef HAVE_STRUCT_WINSIZE 77355682Smarkmstruct winsize { 77455682Smarkm unsigned short ws_row, ws_col; 77555682Smarkm unsigned short ws_xpixel, ws_ypixel; 77655682Smarkm}; 77755682Smarkm#endif 77855682Smarkm 779233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL get_window_size(int fd, int *, int *); 78055682Smarkm 78155682Smarkm#ifndef HAVE_VSYSLOG 782233294Sstas#define vsyslog rk_vsyslog 783233294SstasROKEN_LIB_FUNCTION void ROKEN_LIB_CALL vsyslog(int, const char *, va_list); 78455682Smarkm#endif 78555682Smarkm 786233294Sstas#ifndef HAVE_GETOPT 787233294Sstas#define getopt rk_getopt 788233294Sstas#define optarg rk_optarg 789233294Sstas#define optind rk_optind 790233294Sstas#define opterr rk_opterr 791233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 792233294Sstasgetopt(int nargc, char * const *nargv, const char *ostr); 793233294Sstas#endif 794233294Sstas 795178825Sdfr#if !HAVE_DECL_OPTARG 796233294SstasROKEN_LIB_VARIABLE extern char *optarg; 79755682Smarkm#endif 798178825Sdfr#if !HAVE_DECL_OPTIND 799233294SstasROKEN_LIB_VARIABLE extern int optind; 80055682Smarkm#endif 801178825Sdfr#if !HAVE_DECL_OPTERR 802233294SstasROKEN_LIB_VARIABLE extern int opterr; 80355682Smarkm#endif 80455682Smarkm 80555682Smarkm#ifndef HAVE_GETIPNODEBYNAME 806233294Sstas#define getipnodebyname rk_getipnodebyname 807233294SstasROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL 808178825Sdfrgetipnodebyname (const char *, int, int, int *); 80955682Smarkm#endif 81055682Smarkm 81155682Smarkm#ifndef HAVE_GETIPNODEBYADDR 812233294Sstas#define getipnodebyaddr rk_getipnodebyaddr 813233294SstasROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL 814178825Sdfrgetipnodebyaddr (const void *, size_t, int, int *); 81555682Smarkm#endif 81655682Smarkm 81755682Smarkm#ifndef HAVE_FREEHOSTENT 818233294Sstas#define freehostent rk_freehostent 819233294SstasROKEN_LIB_FUNCTION void ROKEN_LIB_CALL 820178825Sdfrfreehostent (struct hostent *); 82155682Smarkm#endif 82255682Smarkm 82355682Smarkm#ifndef HAVE_COPYHOSTENT 824233294Sstas#define copyhostent rk_copyhostent 825233294SstasROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL 826178825Sdfrcopyhostent (const struct hostent *); 82755682Smarkm#endif 82855682Smarkm 82955682Smarkm#ifndef HAVE_SOCKLEN_T 83055682Smarkmtypedef int socklen_t; 83155682Smarkm#endif 83255682Smarkm 83355682Smarkm#ifndef HAVE_STRUCT_SOCKADDR_STORAGE 83455682Smarkm 83555682Smarkm#ifndef HAVE_SA_FAMILY_T 83655682Smarkmtypedef unsigned short sa_family_t; 83755682Smarkm#endif 83855682Smarkm 83955682Smarkm#ifdef HAVE_IPV6 84055682Smarkm#define _SS_MAXSIZE sizeof(struct sockaddr_in6) 84155682Smarkm#else 84255682Smarkm#define _SS_MAXSIZE sizeof(struct sockaddr_in) 84355682Smarkm#endif 84455682Smarkm 84555682Smarkm#define _SS_ALIGNSIZE sizeof(unsigned long) 84655682Smarkm 84755682Smarkm#if HAVE_STRUCT_SOCKADDR_SA_LEN 84855682Smarkm 84955682Smarkmtypedef unsigned char roken_sa_family_t; 85055682Smarkm 85172445Sassar#define _SS_PAD1SIZE ((2 * _SS_ALIGNSIZE - sizeof (roken_sa_family_t) - sizeof(unsigned char)) % _SS_ALIGNSIZE) 85255682Smarkm#define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (roken_sa_family_t) + sizeof(unsigned char) + _SS_PAD1SIZE + _SS_ALIGNSIZE)) 85355682Smarkm 85455682Smarkmstruct sockaddr_storage { 85555682Smarkm unsigned char ss_len; 85655682Smarkm roken_sa_family_t ss_family; 85755682Smarkm char __ss_pad1[_SS_PAD1SIZE]; 85855682Smarkm unsigned long __ss_align[_SS_PAD2SIZE / sizeof(unsigned long) + 1]; 85955682Smarkm}; 86055682Smarkm 86155682Smarkm#else /* !HAVE_STRUCT_SOCKADDR_SA_LEN */ 86255682Smarkm 86355682Smarkmtypedef unsigned short roken_sa_family_t; 86455682Smarkm 86572445Sassar#define _SS_PAD1SIZE ((2 * _SS_ALIGNSIZE - sizeof (roken_sa_family_t)) % _SS_ALIGNSIZE) 86655682Smarkm#define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (roken_sa_family_t) + _SS_PAD1SIZE + _SS_ALIGNSIZE)) 86755682Smarkm 86855682Smarkmstruct sockaddr_storage { 86955682Smarkm roken_sa_family_t ss_family; 87055682Smarkm char __ss_pad1[_SS_PAD1SIZE]; 87155682Smarkm unsigned long __ss_align[_SS_PAD2SIZE / sizeof(unsigned long) + 1]; 87255682Smarkm}; 87355682Smarkm 87455682Smarkm#endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */ 87555682Smarkm 87655682Smarkm#endif /* HAVE_STRUCT_SOCKADDR_STORAGE */ 87755682Smarkm 87855682Smarkm#ifndef HAVE_STRUCT_ADDRINFO 87955682Smarkmstruct addrinfo { 88055682Smarkm int ai_flags; 88155682Smarkm int ai_family; 88255682Smarkm int ai_socktype; 88355682Smarkm int ai_protocol; 88455682Smarkm size_t ai_addrlen; 88555682Smarkm char *ai_canonname; 88655682Smarkm struct sockaddr *ai_addr; 88755682Smarkm struct addrinfo *ai_next; 88855682Smarkm}; 88955682Smarkm#endif 89055682Smarkm 89155682Smarkm#ifndef HAVE_GETADDRINFO 892233294Sstas#define getaddrinfo rk_getaddrinfo 893233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 894178825Sdfrgetaddrinfo(const char *, 895178825Sdfr const char *, 896178825Sdfr const struct addrinfo *, 897178825Sdfr struct addrinfo **); 89855682Smarkm#endif 89955682Smarkm 90055682Smarkm#ifndef HAVE_GETNAMEINFO 901233294Sstas#define getnameinfo rk_getnameinfo 902233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 903178825Sdfrgetnameinfo(const struct sockaddr *, socklen_t, 904178825Sdfr char *, size_t, 905178825Sdfr char *, size_t, 906178825Sdfr int); 90755682Smarkm#endif 90855682Smarkm 90955682Smarkm#ifndef HAVE_FREEADDRINFO 910233294Sstas#define freeaddrinfo rk_freeaddrinfo 911233294SstasROKEN_LIB_FUNCTION void ROKEN_LIB_CALL 912178825Sdfrfreeaddrinfo(struct addrinfo *); 91355682Smarkm#endif 91455682Smarkm 91555682Smarkm#ifndef HAVE_GAI_STRERROR 916233294Sstas#define gai_strerror rk_gai_strerror 917233294SstasROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL 918178825Sdfrgai_strerror(int); 91955682Smarkm#endif 92055682Smarkm 921233294Sstas#ifdef NO_SLEEP 922233294Sstas 923233294SstasROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL 924233294Sstassleep(unsigned int seconds); 925233294Sstas 926233294Sstas#endif 927233294Sstas 928233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 929178825Sdfrgetnameinfo_verified(const struct sockaddr *, socklen_t, 930178825Sdfr char *, size_t, 931178825Sdfr char *, size_t, 932178825Sdfr int); 93355682Smarkm 934233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 935178825Sdfrroken_getaddrinfo_hostspec(const char *, int, struct addrinfo **); 936233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 937178825Sdfrroken_getaddrinfo_hostspec2(const char *, int, int, struct addrinfo **); 93857419Smarkm 93955682Smarkm#ifndef HAVE_STRFTIME 940233294Sstas#define strftime rk_strftime 941233294SstasROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL 942178825Sdfrstrftime (char *, size_t, const char *, const struct tm *); 94355682Smarkm#endif 94455682Smarkm 94555682Smarkm#ifndef HAVE_STRPTIME 946233294Sstas#define strptime rk_strptime 947233294SstasROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL 948178825Sdfrstrptime (const char *, const char *, struct tm *); 94955682Smarkm#endif 95055682Smarkm 951233294Sstas#ifndef HAVE_GETTIMEOFDAY 952233294Sstas#define gettimeofday rk_gettimeofday 953233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 954233294Sstasgettimeofday (struct timeval *, void *); 955233294Sstas#endif 956233294Sstas 95790926Snectar#ifndef HAVE_EMALLOC 958233294Sstas#define emalloc rk_emalloc 959233294SstasROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL emalloc (size_t); 96090926Snectar#endif 96190926Snectar#ifndef HAVE_ECALLOC 962233294Sstas#define ecalloc rk_ecalloc 963233294SstasROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL ecalloc(size_t, size_t); 96490926Snectar#endif 96590926Snectar#ifndef HAVE_EREALLOC 966233294Sstas#define erealloc rk_erealloc 967233294SstasROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL erealloc (void *, size_t); 96890926Snectar#endif 96990926Snectar#ifndef HAVE_ESTRDUP 970233294Sstas#define estrdup rk_estrdup 971233294SstasROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL estrdup (const char *); 97290926Snectar#endif 97390926Snectar 97455682Smarkm/* 97555682Smarkm * kludges and such 97655682Smarkm */ 97755682Smarkm 978233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 979178825Sdfrroken_gethostby_setup(const char*, const char*); 980233294SstasROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL 981178825Sdfrroken_gethostbyname(const char*); 982233294SstasROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL 983178825Sdfrroken_gethostbyaddr(const void*, size_t, int); 98455682Smarkm 98555682Smarkm#ifdef GETSERVBYNAME_PROTO_COMPATIBLE 98655682Smarkm#define roken_getservbyname(x,y) getservbyname(x,y) 98755682Smarkm#else 98855682Smarkm#define roken_getservbyname(x,y) getservbyname((char *)x, (char *)y) 98955682Smarkm#endif 99055682Smarkm 99155682Smarkm#ifdef OPENLOG_PROTO_COMPATIBLE 99255682Smarkm#define roken_openlog(a,b,c) openlog(a,b,c) 99355682Smarkm#else 99455682Smarkm#define roken_openlog(a,b,c) openlog((char *)a,b,c) 99555682Smarkm#endif 99655682Smarkm 99772445Sassar#ifdef GETSOCKNAME_PROTO_COMPATIBLE 99872445Sassar#define roken_getsockname(a,b,c) getsockname(a,b,c) 99972445Sassar#else 100072445Sassar#define roken_getsockname(a,b,c) getsockname(a, b, (void*)c) 100172445Sassar#endif 100272445Sassar 100378527Sassar#ifndef HAVE_SETPROGNAME 1004233294Sstas#define setprogname rk_setprogname 1005233294SstasROKEN_LIB_FUNCTION void ROKEN_LIB_CALL setprogname(const char *); 100678527Sassar#endif 100778527Sassar 100878527Sassar#ifndef HAVE_GETPROGNAME 1009233294Sstas#define getprogname rk_getprogname 1010233294SstasROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL getprogname(void); 101178527Sassar#endif 101278527Sassar 1013178825Sdfr#if !defined(HAVE_SETPROGNAME) && !defined(HAVE_GETPROGNAME) && !HAVE_DECL___PROGNAME 1014178825Sdfrextern const char *__progname; 1015178825Sdfr#endif 1016102644Snectar 1017233294SstasROKEN_LIB_FUNCTION void ROKEN_LIB_CALL 1018233294Sstasmini_inetd_addrinfo (struct addrinfo*, rk_socket_t *); 101955682Smarkm 1020233294SstasROKEN_LIB_FUNCTION void ROKEN_LIB_CALL 1021233294Sstasmini_inetd (int, rk_socket_t *); 1022233294Sstas 102390926Snectar#ifndef HAVE_LOCALTIME_R 1024233294Sstas#define localtime_r rk_localtime_r 1025233294SstasROKEN_LIB_FUNCTION struct tm * ROKEN_LIB_CALL 1026178825Sdfrlocaltime_r(const time_t *, struct tm *); 102790926Snectar#endif 102890926Snectar 1029102644Snectar#if !defined(HAVE_STRSVIS) || defined(NEED_STRSVIS_PROTO) 1030233294Sstas#ifndef HAVE_STRSVIS 1031233294Sstas#define strsvis rk_strsvis 1032233294Sstas#endif 1033233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 1034178825Sdfrstrsvis(char *, const char *, int, const char *); 1035102644Snectar#endif 1036102644Snectar 1037233294Sstas#if !defined(HAVE_STRSVISX) || defined(NEED_STRSVISX_PROTO) 1038233294Sstas#ifndef HAVE_STRSVISX 1039233294Sstas#define strsvisx rk_strsvisx 1040233294Sstas#endif 1041233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 1042233294Sstasstrsvisx(char *, const char *, size_t, int, const char *); 1043233294Sstas#endif 1044233294Sstas 1045102644Snectar#if !defined(HAVE_STRUNVIS) || defined(NEED_STRUNVIS_PROTO) 1046233294Sstas#ifndef HAVE_STRUNVIS 1047233294Sstas#define strunvis rk_strunvis 1048233294Sstas#endif 1049233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 1050178825Sdfrstrunvis(char *, const char *); 1051102644Snectar#endif 1052102644Snectar 1053102644Snectar#if !defined(HAVE_STRVIS) || defined(NEED_STRVIS_PROTO) 1054233294Sstas#ifndef HAVE_STRVIS 1055233294Sstas#define strvis rk_strvis 1056233294Sstas#endif 1057233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 1058178825Sdfrstrvis(char *, const char *, int); 1059102644Snectar#endif 1060102644Snectar 1061102644Snectar#if !defined(HAVE_STRVISX) || defined(NEED_STRVISX_PROTO) 1062233294Sstas#ifndef HAVE_STRVISX 1063233294Sstas#define strvisx rk_strvisx 1064233294Sstas#endif 1065233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 1066178825Sdfrstrvisx(char *, const char *, size_t, int); 1067102644Snectar#endif 1068102644Snectar 1069102644Snectar#if !defined(HAVE_SVIS) || defined(NEED_SVIS_PROTO) 1070233294Sstas#ifndef HAVE_SVIS 1071233294Sstas#define svis rk_svis 1072233294Sstas#endif 1073233294SstasROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL 1074178825Sdfrsvis(char *, int, int, int, const char *); 1075102644Snectar#endif 1076102644Snectar 1077102644Snectar#if !defined(HAVE_UNVIS) || defined(NEED_UNVIS_PROTO) 1078233294Sstas#ifndef HAVE_UNVIS 1079233294Sstas#define unvis rk_unvis 1080233294Sstas#endif 1081233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 1082178825Sdfrunvis(char *, int, int *, int); 1083102644Snectar#endif 1084102644Snectar 1085102644Snectar#if !defined(HAVE_VIS) || defined(NEED_VIS_PROTO) 1086233294Sstas#ifndef HAVE_VIS 1087233294Sstas#define vis rk_vis 1088233294Sstas#endif 1089233294SstasROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL 1090178825Sdfrvis(char *, int, int, int); 1091102644Snectar#endif 1092102644Snectar 1093178825Sdfr#if !defined(HAVE_CLOSEFROM) 1094233294Sstas#define closefrom rk_closefrom 1095233294SstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL 1096178825Sdfrclosefrom(int); 1097178825Sdfr#endif 1098178825Sdfr 1099178825Sdfr#if !defined(HAVE_TIMEGM) 1100178825Sdfr#define timegm rk_timegm 1101233294SstasROKEN_LIB_FUNCTION time_t ROKEN_LIB_CALL 1102178825Sdfrrk_timegm(struct tm *tm); 1103178825Sdfr#endif 1104178825Sdfr 1105233294Sstas#ifdef NEED_QSORT 1106233294Sstas#define qsort rk_qsort 1107233294Sstasvoid 1108233294Sstasrk_qsort(void *, size_t, size_t, int (*)(const void *, const void *)); 1109233294Sstas#endif 1110233294Sstas 1111233294Sstas#if defined(HAVE_ARC4RANDOM) 1112233294Sstas#define rk_random() arc4random() 1113233294Sstas#elif defined(HAVE_RANDOM) 1114233294Sstas#define rk_random() random() 1115233294Sstas#else 1116233294Sstas#define rk_random() rand() 1117233294Sstas#endif 1118233294Sstas 1119233294Sstas#ifndef HAVE_TDELETE 1120233294Sstas#define tdelete(a,b,c) rk_tdelete(a,b,c) 1121233294Sstas#endif 1122233294Sstas#ifndef HAVE_TFIND 1123233294Sstas#define tfind(a,b,c) rk_tfind(a,b,c) 1124233294Sstas#endif 1125233294Sstas#ifndef HAVE_TSEARCH 1126233294Sstas#define tsearch(a,b,c) rk_tsearch(a,b,c) 1127233294Sstas#endif 1128233294Sstas#ifndef HAVE_TWALK 1129233294Sstas#define twalk(a,b) rk_twalk(a,b) 1130233294Sstas#endif 1131233294Sstas 1132233294Sstas#if defined(__linux__) && defined(SOCK_CLOEXEC) && !defined(SOCKET_WRAPPER_REPLACE) && !defined(__SOCKET_WRAPPER_H__) 1133233294Sstas#undef socket 1134233294Sstas#define socket(_fam,_type,_prot) rk_socket(_fam,_type,_prot) 1135233294Sstasint ROKEN_LIB_FUNCTION rk_socket(int, int, int); 1136233294Sstas#endif 1137233294Sstas 1138178825Sdfr#ifdef SOCKET_WRAPPER_REPLACE 1139178825Sdfr#include <socket_wrapper.h> 1140178825Sdfr#endif 1141178825Sdfr 114272445SassarROKEN_CPP_END 1143