3 * Copyright (c) 1995-2005 Kungliga Tekniska Högskolan
4 * (Royal Institute of Technology, Stockholm, Sweden).
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
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.
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.
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
44 #ifndef ROKEN_LIB_FUNCTION
46 #define ROKEN_LIB_FUNCTION
47 #define ROKEN_LIB_CALL __cdecl
49 #define ROKEN_LIB_FUNCTION
50 #define ROKEN_LIB_CALL
55 /* Declarations for Microsoft Windows */
60 * error codes for inet_ntop/inet_pton
62 #define EAFNOSUPPORT WSAEAFNOSUPPORT
64 typedef SOCKET rk_socket_t
;
66 #define rk_closesocket(x) closesocket(x)
67 #define rk_INVALID_SOCKET INVALID_SOCKET
68 #define rk_IS_BAD_SOCKET(s) ((s) == INVALID_SOCKET)
69 #define rk_IS_SOCKET_ERROR(rv) ((rv) == SOCKET_ERROR)
70 #define rk_SOCK_ERRNO WSAGetLastError()
72 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
rk_SOCK_IOCTL(SOCKET s
, long cmd
, int * argp
);
74 #define ETIMEDOUT WSAETIMEDOUT
75 #define EWOULDBLOCK WSAEWOULDBLOCK
76 #define ENOTSOCK WSAENOTSOCK
78 #define rk_SOCK_INIT() rk_WSAStartup()
79 #define rk_SOCK_EXIT() rk_WSACleanup()
81 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
rk_WSAStartup(void);
82 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
rk_WSACleanup(void);
84 #else /* not WinSock */
86 typedef int rk_socket_t
;
88 #define rk_closesocket(x) close(x)
89 #define rk_SOCK_IOCTL(s,c,a) ioctl((s),(c),(a))
90 #define rk_IS_BAD_SOCKET(s) ((s) < 0)
91 #define rk_IS_SOCKET_ERROR(rv) ((rv) < 0)
92 #define rk_SOCK_ERRNO errno
93 #define rk_INVALID_SOCKET (-1)
95 #define rk_SOCK_INIT() 0
96 #define rk_SOCK_EXIT() do { } while(0)
101 /* Declarations for Microsoft Visual C runtime on Windows */
107 #ifndef __BIT_TYPES_DEFINED__
108 #define __BIT_TYPES_DEFINED__
110 typedef __int8
int8_t;
111 typedef __int16
int16_t;
112 typedef __int32
int32_t;
113 typedef __int64
int64_t;
114 typedef unsigned __int8
uint8_t;
115 typedef unsigned __int16
uint16_t;
116 typedef unsigned __int32
uint32_t;
117 typedef unsigned __int64
uint64_t;
118 typedef uint8_t u_int8_t
;
119 typedef uint16_t u_int16_t
;
120 typedef uint32_t u_int32_t
;
121 typedef uint64_t u_int64_t
;
123 #endif /* __BIT_TYPES_DEFINED__ */
125 #define UNREACHABLE(x) x
126 #define UNUSED_ARGUMENT(x) ((void) x)
128 #define RETSIGTYPE void
130 #define VOID_RETSIGTYPE 1
132 #ifdef VOID_RETSIGTYPE
133 #define SIGRETURN(x) return
135 #define SIGRETURN(x) return (RETSIGTYPE)(x)
142 typedef unsigned int gid_t
;
144 typedef unsigned int uid_t
;
146 typedef unsigned short mode_t
;
151 #define inline __inline
156 #define UNREACHABLE(x)
157 #define UNUSED_ARGUMENT(x)
165 #ifdef HAVE_SYS_PARAM_H
166 #include <sys/param.h>
168 #ifdef HAVE_INTTYPES_H
169 #include <inttypes.h>
171 #ifdef HAVE_SYS_TYPES_H
172 #include <sys/types.h>
174 #ifdef HAVE_SYS_BITYPES_H
175 #include <sys/bitypes.h>
177 #ifdef HAVE_BIND_BITYPES_H
178 #include <bind/bitypes.h>
180 #ifdef HAVE_NETINET_IN6_MACHTYPES_H
181 #include <netinet/in6_machtypes.h>
186 #ifdef HAVE_SYS_SOCKET_H
187 #include <sys/socket.h>
189 #ifdef HAVE_SYS_UIO_H
195 #ifdef HAVE_SYS_STAT_H
196 #include <sys/stat.h>
198 #ifdef HAVE_NETINET_IN_H
199 #include <netinet/in.h>
201 #ifdef HAVE_NETINET_IN6_H
202 #include <netinet/in6.h>
204 #ifdef HAVE_NETINET6_IN6_H
205 #include <netinet6/in6.h>
207 #ifdef HAVE_ARPA_INET_H
208 #include <arpa/inet.h>
213 #ifdef HAVE_ARPA_NAMESER_H
214 #include <arpa/nameser.h>
229 #ifdef HAVE_TERMIOS_H
232 #ifdef HAVE_SYS_IOCTL_H
233 #include <sys/ioctl.h>
235 #ifdef TIME_WITH_SYS_TIME
236 #include <sys/time.h>
238 #elif defined(HAVE_SYS_TIME_H)
239 #include <sys/time.h>
244 #ifdef HAVE_WS2TCPIP_H
245 #include <ws2tcpip.h>
256 #ifdef BACKSLASH_PATH_DELIM
257 #define rk_PATH_DELIM '\\'
262 typedef __int64 ssize_t
;
268 #include <roken-common.h>
272 #ifdef HAVE_UINTPTR_T
273 #define rk_UNCONST(x) ((void *)(uintptr_t)(const void *)(x))
275 #define rk_UNCONST(x) ((void *)(unsigned long)(const void *)(x))
278 #if !defined(HAVE_SETSID) && defined(HAVE__SETSID)
279 #define setsid _setsid
283 /* Additional macros for Visual C/C++ runtime */
287 #define getpid _getpid
293 #define fsync _commit
295 /* The MSVC implementation of snprintf is not C99 compliant. */
296 #define snprintf rk_snprintf
297 #define vsnprintf rk_vsnprintf
298 #define vasnprintf rk_vasnprintf
299 #define vasprintf rk_vasprintf
300 #define asnprintf rk_asnprintf
301 #define asprintf rk_asprintf
303 #define _PIPE_BUFFER_SZ 8192
304 #define pipe(fds) _pipe((fds), _PIPE_BUFFER_SZ, O_BINARY);
306 #define ftruncate(fd, sz) _chsize((fd), (sz))
308 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
309 rk_snprintf (char *str
, size_t sz
, const char *format
, ...);
311 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
312 rk_asprintf (char **ret
, const char *format
, ...);
314 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
315 rk_asnprintf (char **ret
, size_t max_sz
, const char *format
, ...);
317 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
318 rk_vasprintf (char **ret
, const char *format
, va_list args
);
320 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
321 rk_vasnprintf (char **ret
, size_t max_sz
, const char *format
, va_list args
);
323 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
324 rk_vsnprintf (char *str
, size_t sz
, const char *format
, va_list args
);
326 /* missing stat.h predicates */
328 #define S_ISREG(m) (((m) & _S_IFREG) == _S_IFREG)
330 #define S_ISDIR(m) (((m) & _S_IFDIR) == _S_IFDIR)
332 #define S_ISCHR(m) (((m) & _S_IFCHR) == _S_IFCHR)
334 #define S_ISFIFO(m) (((m) & _S_IFIFO) == _S_IFIFO)
336 /* The following are not implemented:
343 #endif /* _MSC_VER */
347 /* While we are at it, define WinSock specific scatter gather socket
350 #define iovec _WSABUF
356 socklen_t msg_namelen
;
357 struct iovec
*msg_iov
;
360 socklen_t msg_controllen
;
364 #define sendmsg sendmsg_w32
366 ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
367 sendmsg_w32(rk_socket_t s
, const struct msghdr
* msg
, int flags
);
369 #endif /* HAVE_WINSOCK */
372 #define putenv rk_putenv
373 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
putenv(const char *);
376 #if !defined(HAVE_SETENV) || defined(NEED_SETENV_PROTO)
378 #define setenv rk_setenv
380 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
setenv(const char *, const char *, int);
383 #if !defined(HAVE_UNSETENV) || defined(NEED_UNSETENV_PROTO)
384 #ifndef HAVE_UNSETENV
385 #define unsetenv rk_unsetenv
387 ROKEN_LIB_FUNCTION
void ROKEN_LIB_CALL
unsetenv(const char *);
390 #if !defined(HAVE_GETUSERSHELL) || defined(NEED_GETUSERSHELL_PROTO)
391 #ifndef HAVE_GETUSERSHELL
392 #define getusershell rk_getusershell
393 #define endusershell rk_endusershell
395 ROKEN_LIB_FUNCTION
char * ROKEN_LIB_CALL
getusershell(void);
396 ROKEN_LIB_FUNCTION
void ROKEN_LIB_CALL
endusershell(void);
399 #if !defined(HAVE_SNPRINTF) || defined(NEED_SNPRINTF_PROTO)
400 #ifndef HAVE_SNPRINTF
401 #define snprintf rk_snprintf
403 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
404 rk_snprintf (char *, size_t, const char *, ...)
405 __attribute__ ((format (printf
, 3, 4)));
408 #if !defined(HAVE_VSNPRINTF) || defined(NEED_VSNPRINTF_PROTO)
409 #ifndef HAVE_VSNPRINTF
410 #define vsnprintf rk_vsnprintf
412 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
413 rk_vsnprintf (char *, size_t, const char *, va_list)
414 __attribute__((format (printf
, 3, 0)));
417 #if !defined(HAVE_ASPRINTF) || defined(NEED_ASPRINTF_PROTO)
418 #ifndef HAVE_ASPRINTF
419 #define asprintf rk_asprintf
421 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
422 rk_asprintf (char **, const char *, ...)
423 __attribute__ ((format (printf
, 2, 3)));
426 #if !defined(HAVE_VASPRINTF) || defined(NEED_VASPRINTF_PROTO)
427 #ifndef HAVE_VASPRINTF
428 #define vasprintf rk_vasprintf
430 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
431 rk_vasprintf (char **, const char *, va_list)
432 __attribute__((format (printf
, 2, 0)));
435 #if !defined(HAVE_ASNPRINTF) || defined(NEED_ASNPRINTF_PROTO)
436 #ifndef HAVE_ASNPRINTF
437 #define asnprintf rk_asnprintf
439 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
440 rk_asnprintf (char **, size_t, const char *, ...)
441 __attribute__ ((format (printf
, 3, 4)));
444 #if !defined(HAVE_VASNPRINTF) || defined(NEED_VASNPRINTF_PROTO)
445 #ifndef HAVE_VASNPRINTF
446 #define vasnprintf rk_vasnprintf
448 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
449 vasnprintf (char **, size_t, const char *, va_list)
450 __attribute__((format (printf
, 3, 0)));
454 #define strdup rk_strdup
455 ROKEN_LIB_FUNCTION
char * ROKEN_LIB_CALL
strdup(const char *);
458 #if !defined(HAVE_STRNDUP) || defined(NEED_STRNDUP_PROTO)
460 #define strndup rk_strndup
462 ROKEN_LIB_FUNCTION
char * ROKEN_LIB_CALL
strndup(const char *, size_t);
466 #define strlwr rk_strlwr
467 ROKEN_LIB_FUNCTION
char * ROKEN_LIB_CALL
strlwr(char *);
471 #define strnlen rk_strnlen
472 ROKEN_LIB_FUNCTION
size_t ROKEN_LIB_CALL
strnlen(const char*, size_t);
475 #if !defined(HAVE_STRSEP) || defined(NEED_STRSEP_PROTO)
477 #define strsep rk_strsep
479 ROKEN_LIB_FUNCTION
char * ROKEN_LIB_CALL
strsep(char**, const char*);
482 #if !defined(HAVE_STRSEP_COPY) || defined(NEED_STRSEP_COPY_PROTO)
483 #ifndef HAVE_STRSEP_COPY
484 #define strsep_copy rk_strsep_copy
486 ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
strsep_copy(const char**, const char*, char*, size_t);
489 #ifndef HAVE_STRCASECMP
490 #define strcasecmp rk_strcasecmp
491 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
strcasecmp(const char *, const char *);
494 #ifdef NEED_FCLOSE_PROTO
495 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
fclose(FILE *);
498 #ifdef NEED_STRTOK_R_PROTO
499 ROKEN_LIB_FUNCTION
char * ROKEN_LIB_CALL
strtok_r(char *, const char *, char **);
503 #define strupr rk_strupr
504 ROKEN_LIB_FUNCTION
char * ROKEN_LIB_CALL
strupr(char *);
508 #define strlcpy rk_strlcpy
509 ROKEN_LIB_FUNCTION
size_t ROKEN_LIB_CALL
strlcpy (char *, const char *, size_t);
513 #define strlcat rk_strlcat
514 ROKEN_LIB_FUNCTION
size_t ROKEN_LIB_CALL
strlcat (char *, const char *, size_t);
517 #ifndef HAVE_GETDTABLESIZE
518 #define getdtablesize rk_getdtablesize
519 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
getdtablesize(void);
522 #if !defined(HAVE_STRERROR) && !defined(strerror)
523 #define strerror rk_strerror
524 ROKEN_LIB_FUNCTION
char * ROKEN_LIB_CALL
strerror(int);
527 #if (!defined(HAVE_STRERROR_R) && !defined(strerror_r)) || (!defined(STRERROR_R_PROTO_COMPATIBLE) && defined(HAVE_STRERROR_R))
528 int ROKEN_LIB_FUNCTION
rk_strerror_r(int, char *, size_t);
530 #define rk_strerror_r strerror_r
533 #if !defined(HAVE_HSTRERROR) || defined(NEED_HSTRERROR_PROTO)
534 #ifndef HAVE_HSTRERROR
535 #define hstrerror rk_hstrerror
537 /* This causes a fatal error under Psoriasis */
539 const char * ROKEN_LIB_FUNCTION
hstrerror(int);
540 ROKEN_LIB_FUNCTION
const char * ROKEN_LIB_CALL
hstrerror(int);
544 #if !HAVE_DECL_H_ERRNO
548 #if !defined(HAVE_INET_ATON) || defined(NEED_INET_ATON_PROTO)
549 #ifndef HAVE_INET_ATON
550 #define inet_aton rk_inet_aton
552 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
inet_aton(const char *, struct in_addr
*);
555 #ifndef HAVE_INET_NTOP
556 #define inet_ntop rk_inet_ntop
557 ROKEN_LIB_FUNCTION
const char * ROKEN_LIB_CALL
558 inet_ntop(int af
, const void *src
, char *dst
, size_t size
);
561 #ifndef HAVE_INET_PTON
562 #define inet_pton rk_inet_pton
563 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
564 inet_pton(int, const char *, void *);
568 #define getcwd rk_getcwd
569 ROKEN_LIB_FUNCTION
char* ROKEN_LIB_CALL
getcwd(char *, size_t);
574 ROKEN_LIB_FUNCTION
struct passwd
* ROKEN_LIB_CALL
k_getpwnam (const char *);
575 ROKEN_LIB_FUNCTION
struct passwd
* ROKEN_LIB_CALL
k_getpwuid (uid_t
);
578 ROKEN_LIB_FUNCTION
const char * ROKEN_LIB_CALL
get_default_username (void);
581 #define seteuid rk_seteuid
582 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
seteuid(uid_t
);
586 #define setegid rk_setegid
587 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
setegid(gid_t
);
591 #define lstat rk_lstat
592 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
lstat(const char *, struct stat
*);
595 #if !defined(HAVE_MKSTEMP) || defined(NEED_MKSTEMP_PROTO)
597 #define mkstemp rk_mkstemp
599 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
mkstemp(char *);
603 #define cgetent rk_cgetent
604 #define cgetstr rk_cgetstr
605 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
cgetent(char **, char **, const char *);
606 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
cgetstr(char *, const char *, char **);
609 #ifndef HAVE_INITGROUPS
610 #define initgroups rk_initgroups
611 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
initgroups(const char *, gid_t
);
615 #define fchown rk_fchown
616 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
fchown(int, uid_t
, gid_t
);
619 #if !defined(HAVE_DAEMON) || defined(NEED_DAEMON_PROTO)
621 #define daemon rk_daemon
623 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
daemon(int, int);
627 #define chown rk_chown
628 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
chown(const char *, uid_t
, gid_t
);
633 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
634 rcmd(char **, unsigned short, const char *,
635 const char *, const char *, int *);
638 #if !defined(HAVE_INNETGR) || defined(NEED_INNETGR_PROTO)
640 #define innetgr rk_innetgr
642 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
innetgr(const char*, const char*,
643 const char*, const char*);
646 #ifndef HAVE_IRUSEROK
647 #define iruserok rk_iruserok
648 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
iruserok(unsigned, int,
649 const char *, const char *);
652 #if !defined(HAVE_GETHOSTNAME) || defined(NEED_GETHOSTNAME_PROTO)
653 #ifndef HAVE_GETHOSTNAME
654 #define gethostname rk_gethostname
656 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
gethostname(char *, int);
660 #define writev rk_writev
661 ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
662 writev(int, const struct iovec
*, int);
666 #define readv rk_readv
667 ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
668 readv(int, const struct iovec
*, int);
673 #define pidfile(x) ((void) 0)
675 #define pidfile rk_pidfile
676 ROKEN_LIB_FUNCTION
void ROKEN_LIB_CALL
pidfile (const char*);
681 #define bswap32 rk_bswap32
682 ROKEN_LIB_FUNCTION
unsigned int ROKEN_LIB_CALL
bswap32(unsigned int);
686 #define bswap16 rk_bswap16
687 ROKEN_LIB_FUNCTION
unsigned short ROKEN_LIB_CALL
bswap16(unsigned short);
692 #define LOCK_SH 1 /* Shared lock */
695 #define LOCK_EX 2 /* Exclusive lock */
698 #define LOCK_NB 4 /* Don't block when locking */
701 #define LOCK_UN 8 /* Unlock */
704 #define flock(_x,_y) rk_flock(_x,_y)
705 int rk_flock(int fd
, int operation
);
706 #endif /* HAVE_FLOCK */
709 #ifdef HAVE_DIR_DD_FD
710 #define dirfd(x) ((x)->dd_fd)
712 #ifndef _WIN32 /* Windows code never calls dirfd */
713 #error Missing dirfd() and ->dd_fd
718 ROKEN_LIB_FUNCTION
time_t ROKEN_LIB_CALL
tm2time (struct tm
, int);
720 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
unix_verify_user(char *, char *);
722 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
roken_concat (char *, size_t, ...);
724 ROKEN_LIB_FUNCTION
size_t ROKEN_LIB_CALL
roken_mconcat (char **, size_t, ...);
726 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
roken_vconcat (char *, size_t, va_list);
728 ROKEN_LIB_FUNCTION
size_t ROKEN_LIB_CALL
729 roken_vmconcat (char **, size_t, va_list);
731 ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
732 net_write (rk_socket_t
, const void *, size_t);
734 ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
735 net_read (rk_socket_t
, void *, size_t);
737 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
740 #ifndef HAVE_STRUCT_WINSIZE
742 unsigned short ws_row
, ws_col
;
743 unsigned short ws_xpixel
, ws_ypixel
;
747 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
get_window_size(int fd
, struct winsize
*);
750 #define vsyslog rk_vsyslog
751 ROKEN_LIB_FUNCTION
void ROKEN_LIB_CALL
vsyslog(int, const char *, va_list);
754 #if !HAVE_DECL_OPTARG
757 #if !HAVE_DECL_OPTIND
760 #if !HAVE_DECL_OPTERR
764 #ifndef HAVE_GETIPNODEBYNAME
765 #define getipnodebyname rk_getipnodebyname
766 ROKEN_LIB_FUNCTION
struct hostent
* ROKEN_LIB_CALL
767 getipnodebyname (const char *, int, int, int *);
770 #ifndef HAVE_GETIPNODEBYADDR
771 #define getipnodebyaddr rk_getipnodebyaddr
772 ROKEN_LIB_FUNCTION
struct hostent
* ROKEN_LIB_CALL
773 getipnodebyaddr (const void *, size_t, int, int *);
776 #ifndef HAVE_FREEHOSTENT
777 #define freehostent rk_freehostent
778 ROKEN_LIB_FUNCTION
void ROKEN_LIB_CALL
779 freehostent (struct hostent
*);
782 #ifndef HAVE_COPYHOSTENT
783 #define copyhostent rk_copyhostent
784 ROKEN_LIB_FUNCTION
struct hostent
* ROKEN_LIB_CALL
785 copyhostent (const struct hostent
*);
788 #ifndef HAVE_SOCKLEN_T
789 typedef int socklen_t
;
792 #ifndef HAVE_STRUCT_SOCKADDR_STORAGE
794 #ifndef HAVE_SA_FAMILY_T
795 typedef unsigned short sa_family_t
;
799 #define _SS_MAXSIZE sizeof(struct sockaddr_in6)
801 #define _SS_MAXSIZE sizeof(struct sockaddr_in)
804 #define _SS_ALIGNSIZE sizeof(unsigned long)
806 #if HAVE_STRUCT_SOCKADDR_SA_LEN
808 typedef unsigned char roken_sa_family_t
;
810 #define _SS_PAD1SIZE ((2 * _SS_ALIGNSIZE - sizeof (roken_sa_family_t) - sizeof(unsigned char)) % _SS_ALIGNSIZE)
811 #define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (roken_sa_family_t) + sizeof(unsigned char) + _SS_PAD1SIZE + _SS_ALIGNSIZE))
813 struct sockaddr_storage
{
814 unsigned char ss_len
;
815 roken_sa_family_t ss_family
;
816 char __ss_pad1
[_SS_PAD1SIZE
];
817 unsigned long __ss_align
[_SS_PAD2SIZE
/ sizeof(unsigned long) + 1];
820 #else /* !HAVE_STRUCT_SOCKADDR_SA_LEN */
822 typedef unsigned short roken_sa_family_t
;
824 #define _SS_PAD1SIZE ((2 * _SS_ALIGNSIZE - sizeof (roken_sa_family_t)) % _SS_ALIGNSIZE)
825 #define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (roken_sa_family_t) + _SS_PAD1SIZE + _SS_ALIGNSIZE))
827 struct sockaddr_storage
{
828 roken_sa_family_t ss_family
;
829 char __ss_pad1
[_SS_PAD1SIZE
];
830 unsigned long __ss_align
[_SS_PAD2SIZE
/ sizeof(unsigned long) + 1];
833 #endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */
835 #endif /* HAVE_STRUCT_SOCKADDR_STORAGE */
837 #ifndef HAVE_STRUCT_ADDRINFO
845 struct sockaddr
*ai_addr
;
846 struct addrinfo
*ai_next
;
850 #ifndef HAVE_GETADDRINFO
851 #define getaddrinfo rk_getaddrinfo
852 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
853 getaddrinfo(const char *,
855 const struct addrinfo
*,
859 #ifndef HAVE_GETNAMEINFO
860 #define getnameinfo rk_getnameinfo
861 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
862 getnameinfo(const struct sockaddr
*, socklen_t
,
868 #ifndef HAVE_FREEADDRINFO
869 #define freeaddrinfo rk_freeaddrinfo
870 ROKEN_LIB_FUNCTION
void ROKEN_LIB_CALL
871 freeaddrinfo(struct addrinfo
*);
874 #ifndef HAVE_GAI_STRERROR
875 #define gai_strerror rk_gai_strerror
876 ROKEN_LIB_FUNCTION
const char * ROKEN_LIB_CALL
882 ROKEN_LIB_FUNCTION
unsigned int ROKEN_LIB_CALL
883 sleep(unsigned int seconds
);
887 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
888 getnameinfo_verified(const struct sockaddr
*, socklen_t
,
893 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
894 roken_getaddrinfo_hostspec(const char *, int, struct addrinfo
**);
895 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
896 roken_getaddrinfo_hostspec2(const char *, int, int, struct addrinfo
**);
898 #ifndef HAVE_STRFTIME
899 #define strftime rk_strftime
900 ROKEN_LIB_FUNCTION
size_t ROKEN_LIB_CALL
901 strftime (char *, size_t, const char *, const struct tm
*);
904 #ifndef HAVE_STRPTIME
905 #define strptime rk_strptime
906 ROKEN_LIB_FUNCTION
char * ROKEN_LIB_CALL
907 strptime (const char *, const char *, struct tm
*);
910 #ifndef HAVE_GETTIMEOFDAY
911 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
912 gettimeofday (struct timeval
*, void *);
916 #define emalloc rk_emalloc
917 ROKEN_LIB_FUNCTION
void * ROKEN_LIB_CALL
emalloc (size_t);
920 #define ecalloc rk_ecalloc
921 ROKEN_LIB_FUNCTION
void * ROKEN_LIB_CALL
ecalloc(size_t, size_t);
923 #ifndef HAVE_EREALLOC
924 #define erealloc rk_erealloc
925 ROKEN_LIB_FUNCTION
void * ROKEN_LIB_CALL
erealloc (void *, size_t);
928 #define estrdup rk_estrdup
929 ROKEN_LIB_FUNCTION
char * ROKEN_LIB_CALL
estrdup (const char *);
936 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
937 roken_gethostby_setup(const char*, const char*);
938 ROKEN_LIB_FUNCTION
struct hostent
* ROKEN_LIB_CALL
939 roken_gethostbyname(const char*);
940 ROKEN_LIB_FUNCTION
struct hostent
* ROKEN_LIB_CALL
941 roken_gethostbyaddr(const void*, size_t, int);
943 #ifdef GETSERVBYNAME_PROTO_COMPATIBLE
944 #define roken_getservbyname(x,y) getservbyname(x,y)
946 #define roken_getservbyname(x,y) getservbyname((char *)x, (char *)y)
949 #ifdef OPENLOG_PROTO_COMPATIBLE
950 #define roken_openlog(a,b,c) openlog(a,b,c)
952 #define roken_openlog(a,b,c) openlog((char *)a,b,c)
955 #ifdef GETSOCKNAME_PROTO_COMPATIBLE
956 #define roken_getsockname(a,b,c) getsockname(a,b,c)
958 #define roken_getsockname(a,b,c) getsockname(a, b, (void*)c)
961 #ifndef HAVE_SETPROGNAME
962 #define setprogname rk_setprogname
963 ROKEN_LIB_FUNCTION
void ROKEN_LIB_CALL
setprogname(const char *);
966 #ifndef HAVE_GETPROGNAME
967 #define getprogname rk_getprogname
968 ROKEN_LIB_FUNCTION
const char * ROKEN_LIB_CALL
getprogname(void);
971 #if !defined(HAVE_SETPROGNAME) && !defined(HAVE_GETPROGNAME) && !HAVE_DECL___PROGNAME
972 extern const char *__progname
;
975 ROKEN_LIB_FUNCTION
void ROKEN_LIB_CALL
976 mini_inetd_addrinfo (struct addrinfo
*, rk_socket_t
*);
978 ROKEN_LIB_FUNCTION
void ROKEN_LIB_CALL
979 mini_inetd (int, rk_socket_t
*);
981 #ifndef HAVE_LOCALTIME_R
982 #define localtime_r rk_localtime_r
983 ROKEN_LIB_FUNCTION
struct tm
* ROKEN_LIB_CALL
984 localtime_r(const time_t *, struct tm
*);
987 #if !defined(HAVE_STRSVIS) || defined(NEED_STRSVIS_PROTO)
989 #define strsvis rk_strsvis
991 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
992 strsvis(char *, const char *, int, const char *);
995 #if !defined(HAVE_STRSVISX) || defined(NEED_STRSVISX_PROTO)
996 #ifndef HAVE_STRSVISX
997 #define strsvisx rk_strsvisx
999 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
1000 strsvisx(char *, const char *, size_t, int, const char *);
1003 #if !defined(HAVE_STRUNVIS) || defined(NEED_STRUNVIS_PROTO)
1004 #ifndef HAVE_STRUNVIS
1005 #define strunvis rk_strunvis
1007 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
1008 strunvis(char *, const char *);
1011 #if !defined(HAVE_STRVIS) || defined(NEED_STRVIS_PROTO)
1013 #define strvis rk_strvis
1015 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
1016 strvis(char *, const char *, int);
1019 #if !defined(HAVE_STRVISX) || defined(NEED_STRVISX_PROTO)
1020 #ifndef HAVE_STRVISX
1021 #define strvisx rk_strvisx
1023 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
1024 strvisx(char *, const char *, size_t, int);
1027 #if !defined(HAVE_SVIS) || defined(NEED_SVIS_PROTO)
1029 #define svis rk_svis
1031 ROKEN_LIB_FUNCTION
char * ROKEN_LIB_CALL
1032 svis(char *, int, int, int, const char *);
1035 #if !defined(HAVE_UNVIS) || defined(NEED_UNVIS_PROTO)
1037 #define unvis rk_unvis
1039 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
1040 unvis(char *, int, int *, int);
1043 #if !defined(HAVE_VIS) || defined(NEED_VIS_PROTO)
1047 ROKEN_LIB_FUNCTION
char * ROKEN_LIB_CALL
1048 vis(char *, int, int, int);
1051 #if !defined(HAVE_CLOSEFROM)
1052 #define closefrom rk_closefrom
1053 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
1057 #if !defined(HAVE_TIMEGM)
1058 #define timegm rk_timegm
1059 ROKEN_LIB_FUNCTION
time_t ROKEN_LIB_CALL
1060 rk_timegm(struct tm
*tm
);
1064 #define qsort rk_qsort
1066 rk_qsort(void *, size_t, size_t, int (*)(const void *, const void *));
1069 #if defined(__linux__) && defined(SOCK_CLOEXEC) && !defined(SOCKET_WRAPPER_REPLACE)
1071 #define socket(_fam,_type,_prot) rk_socket(_fam,_type,_prot)
1072 int ROKEN_LIB_FUNCTION
rk_socket(int, int, int);
1075 #ifdef SOCKET_WRAPPER_REPLACE
1076 #include <socket_wrapper.h>