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 #ifdef RENAME_DOES_NOT_UNLINK
620 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
rk_rename(const char *, const char *);
622 #define rk_rename rename
625 #if !defined(HAVE_DAEMON) || defined(NEED_DAEMON_PROTO)
627 #define daemon rk_daemon
629 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
daemon(int, int);
633 #define chown rk_chown
634 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
chown(const char *, uid_t
, gid_t
);
639 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
640 rcmd(char **, unsigned short, const char *,
641 const char *, const char *, int *);
644 #if !defined(HAVE_INNETGR) || defined(NEED_INNETGR_PROTO)
646 #define innetgr rk_innetgr
648 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
innetgr(const char*, const char*,
649 const char*, const char*);
652 #ifndef HAVE_IRUSEROK
653 #define iruserok rk_iruserok
654 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
iruserok(unsigned, int,
655 const char *, const char *);
658 #if !defined(HAVE_GETHOSTNAME) || defined(NEED_GETHOSTNAME_PROTO)
659 #ifndef HAVE_GETHOSTNAME
660 #define gethostname rk_gethostname
662 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
gethostname(char *, int);
666 #define writev rk_writev
667 ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
668 writev(int, const struct iovec
*, int);
672 #define readv rk_readv
673 ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
674 readv(int, const struct iovec
*, int);
679 #define pidfile(x) ((void) 0)
681 #define pidfile rk_pidfile
682 ROKEN_LIB_FUNCTION
void ROKEN_LIB_CALL
pidfile (const char*);
687 #define bswap32 rk_bswap32
688 ROKEN_LIB_FUNCTION
unsigned int ROKEN_LIB_CALL
bswap32(unsigned int);
692 #define bswap16 rk_bswap16
693 ROKEN_LIB_FUNCTION
unsigned short ROKEN_LIB_CALL
bswap16(unsigned short);
698 #define LOCK_SH 1 /* Shared lock */
701 #define LOCK_EX 2 /* Exclusive lock */
704 #define LOCK_NB 4 /* Don't block when locking */
707 #define LOCK_UN 8 /* Unlock */
710 #define flock(_x,_y) rk_flock(_x,_y)
711 int rk_flock(int fd
, int operation
);
712 #endif /* HAVE_FLOCK */
715 #ifdef HAVE_DIR_DD_FD
716 #define dirfd(x) ((x)->dd_fd)
718 #ifndef _WIN32 /* Windows code never calls dirfd */
719 #error Missing dirfd() and ->dd_fd
724 ROKEN_LIB_FUNCTION
time_t ROKEN_LIB_CALL
tm2time (struct tm
, int);
726 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
unix_verify_user(char *, char *);
728 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
roken_concat (char *, size_t, ...);
730 ROKEN_LIB_FUNCTION
size_t ROKEN_LIB_CALL
roken_mconcat (char **, size_t, ...);
732 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
roken_vconcat (char *, size_t, va_list);
734 ROKEN_LIB_FUNCTION
size_t ROKEN_LIB_CALL
735 roken_vmconcat (char **, size_t, va_list);
737 ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
738 net_write (rk_socket_t
, const void *, size_t);
740 ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
741 net_read (rk_socket_t
, void *, size_t);
743 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
746 #ifndef HAVE_STRUCT_WINSIZE
748 unsigned short ws_row
, ws_col
;
749 unsigned short ws_xpixel
, ws_ypixel
;
753 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
get_window_size(int fd
, struct winsize
*);
756 #define vsyslog rk_vsyslog
757 ROKEN_LIB_FUNCTION
void ROKEN_LIB_CALL
vsyslog(int, const char *, va_list);
760 #if !HAVE_DECL_OPTARG
763 #if !HAVE_DECL_OPTIND
766 #if !HAVE_DECL_OPTERR
770 #ifndef HAVE_GETIPNODEBYNAME
771 #define getipnodebyname rk_getipnodebyname
772 ROKEN_LIB_FUNCTION
struct hostent
* ROKEN_LIB_CALL
773 getipnodebyname (const char *, int, int, int *);
776 #ifndef HAVE_GETIPNODEBYADDR
777 #define getipnodebyaddr rk_getipnodebyaddr
778 ROKEN_LIB_FUNCTION
struct hostent
* ROKEN_LIB_CALL
779 getipnodebyaddr (const void *, size_t, int, int *);
782 #ifndef HAVE_FREEHOSTENT
783 #define freehostent rk_freehostent
784 ROKEN_LIB_FUNCTION
void ROKEN_LIB_CALL
785 freehostent (struct hostent
*);
788 #ifndef HAVE_COPYHOSTENT
789 #define copyhostent rk_copyhostent
790 ROKEN_LIB_FUNCTION
struct hostent
* ROKEN_LIB_CALL
791 copyhostent (const struct hostent
*);
794 #ifndef HAVE_SOCKLEN_T
795 typedef int socklen_t
;
798 #ifndef HAVE_STRUCT_SOCKADDR_STORAGE
800 #ifndef HAVE_SA_FAMILY_T
801 typedef unsigned short sa_family_t
;
805 #define _SS_MAXSIZE sizeof(struct sockaddr_in6)
807 #define _SS_MAXSIZE sizeof(struct sockaddr_in)
810 #define _SS_ALIGNSIZE sizeof(unsigned long)
812 #if HAVE_STRUCT_SOCKADDR_SA_LEN
814 typedef unsigned char roken_sa_family_t
;
816 #define _SS_PAD1SIZE ((2 * _SS_ALIGNSIZE - sizeof (roken_sa_family_t) - sizeof(unsigned char)) % _SS_ALIGNSIZE)
817 #define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (roken_sa_family_t) + sizeof(unsigned char) + _SS_PAD1SIZE + _SS_ALIGNSIZE))
819 struct sockaddr_storage
{
820 unsigned char ss_len
;
821 roken_sa_family_t ss_family
;
822 char __ss_pad1
[_SS_PAD1SIZE
];
823 unsigned long __ss_align
[_SS_PAD2SIZE
/ sizeof(unsigned long) + 1];
826 #else /* !HAVE_STRUCT_SOCKADDR_SA_LEN */
828 typedef unsigned short roken_sa_family_t
;
830 #define _SS_PAD1SIZE ((2 * _SS_ALIGNSIZE - sizeof (roken_sa_family_t)) % _SS_ALIGNSIZE)
831 #define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (roken_sa_family_t) + _SS_PAD1SIZE + _SS_ALIGNSIZE))
833 struct sockaddr_storage
{
834 roken_sa_family_t ss_family
;
835 char __ss_pad1
[_SS_PAD1SIZE
];
836 unsigned long __ss_align
[_SS_PAD2SIZE
/ sizeof(unsigned long) + 1];
839 #endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */
841 #endif /* HAVE_STRUCT_SOCKADDR_STORAGE */
843 #ifndef HAVE_STRUCT_ADDRINFO
851 struct sockaddr
*ai_addr
;
852 struct addrinfo
*ai_next
;
856 #ifndef HAVE_GETADDRINFO
857 #define getaddrinfo rk_getaddrinfo
858 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
859 getaddrinfo(const char *,
861 const struct addrinfo
*,
865 #ifndef HAVE_GETNAMEINFO
866 #define getnameinfo rk_getnameinfo
867 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
868 getnameinfo(const struct sockaddr
*, socklen_t
,
874 #ifndef HAVE_FREEADDRINFO
875 #define freeaddrinfo rk_freeaddrinfo
876 ROKEN_LIB_FUNCTION
void ROKEN_LIB_CALL
877 freeaddrinfo(struct addrinfo
*);
880 #ifndef HAVE_GAI_STRERROR
881 #define gai_strerror rk_gai_strerror
882 ROKEN_LIB_FUNCTION
const char * ROKEN_LIB_CALL
888 ROKEN_LIB_FUNCTION
unsigned int ROKEN_LIB_CALL
889 sleep(unsigned int seconds
);
893 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
894 getnameinfo_verified(const struct sockaddr
*, socklen_t
,
899 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
900 roken_getaddrinfo_hostspec(const char *, int, struct addrinfo
**);
901 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
902 roken_getaddrinfo_hostspec2(const char *, int, int, struct addrinfo
**);
904 #ifndef HAVE_STRFTIME
905 #define strftime rk_strftime
906 ROKEN_LIB_FUNCTION
size_t ROKEN_LIB_CALL
907 strftime (char *, size_t, const char *, const struct tm
*);
910 #ifndef HAVE_STRPTIME
911 #define strptime rk_strptime
912 ROKEN_LIB_FUNCTION
char * ROKEN_LIB_CALL
913 strptime (const char *, const char *, struct tm
*);
916 #ifndef HAVE_GETTIMEOFDAY
917 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
918 gettimeofday (struct timeval
*, void *);
922 #define emalloc rk_emalloc
923 ROKEN_LIB_FUNCTION
void * ROKEN_LIB_CALL
emalloc (size_t);
926 #define ecalloc rk_ecalloc
927 ROKEN_LIB_FUNCTION
void * ROKEN_LIB_CALL
ecalloc(size_t, size_t);
929 #ifndef HAVE_EREALLOC
930 #define erealloc rk_erealloc
931 ROKEN_LIB_FUNCTION
void * ROKEN_LIB_CALL
erealloc (void *, size_t);
934 #define estrdup rk_estrdup
935 ROKEN_LIB_FUNCTION
char * ROKEN_LIB_CALL
estrdup (const char *);
942 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
943 roken_gethostby_setup(const char*, const char*);
944 ROKEN_LIB_FUNCTION
struct hostent
* ROKEN_LIB_CALL
945 roken_gethostbyname(const char*);
946 ROKEN_LIB_FUNCTION
struct hostent
* ROKEN_LIB_CALL
947 roken_gethostbyaddr(const void*, size_t, int);
949 #ifdef GETSERVBYNAME_PROTO_COMPATIBLE
950 #define roken_getservbyname(x,y) getservbyname(x,y)
952 #define roken_getservbyname(x,y) getservbyname((char *)x, (char *)y)
955 #ifdef OPENLOG_PROTO_COMPATIBLE
956 #define roken_openlog(a,b,c) openlog(a,b,c)
958 #define roken_openlog(a,b,c) openlog((char *)a,b,c)
961 #ifdef GETSOCKNAME_PROTO_COMPATIBLE
962 #define roken_getsockname(a,b,c) getsockname(a,b,c)
964 #define roken_getsockname(a,b,c) getsockname(a, b, (void*)c)
967 #ifndef HAVE_SETPROGNAME
968 #define setprogname rk_setprogname
969 ROKEN_LIB_FUNCTION
void ROKEN_LIB_CALL
setprogname(const char *);
972 #ifndef HAVE_GETPROGNAME
973 #define getprogname rk_getprogname
974 ROKEN_LIB_FUNCTION
const char * ROKEN_LIB_CALL
getprogname(void);
977 #if !defined(HAVE_SETPROGNAME) && !defined(HAVE_GETPROGNAME) && !HAVE_DECL___PROGNAME
978 extern const char *__progname
;
981 ROKEN_LIB_FUNCTION
void ROKEN_LIB_CALL
982 mini_inetd_addrinfo (struct addrinfo
*, rk_socket_t
*);
984 ROKEN_LIB_FUNCTION
void ROKEN_LIB_CALL
985 mini_inetd (int, rk_socket_t
*);
987 #ifndef HAVE_LOCALTIME_R
988 #define localtime_r rk_localtime_r
989 ROKEN_LIB_FUNCTION
struct tm
* ROKEN_LIB_CALL
990 localtime_r(const time_t *, struct tm
*);
993 #if !defined(HAVE_STRSVIS) || defined(NEED_STRSVIS_PROTO)
995 #define strsvis rk_strsvis
997 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
998 strsvis(char *, const char *, int, const char *);
1001 #if !defined(HAVE_STRSVISX) || defined(NEED_STRSVISX_PROTO)
1002 #ifndef HAVE_STRSVISX
1003 #define strsvisx rk_strsvisx
1005 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
1006 strsvisx(char *, const char *, size_t, int, const char *);
1009 #if !defined(HAVE_STRUNVIS) || defined(NEED_STRUNVIS_PROTO)
1010 #ifndef HAVE_STRUNVIS
1011 #define strunvis rk_strunvis
1013 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
1014 strunvis(char *, const char *);
1017 #if !defined(HAVE_STRVIS) || defined(NEED_STRVIS_PROTO)
1019 #define strvis rk_strvis
1021 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
1022 strvis(char *, const char *, int);
1025 #if !defined(HAVE_STRVISX) || defined(NEED_STRVISX_PROTO)
1026 #ifndef HAVE_STRVISX
1027 #define strvisx rk_strvisx
1029 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
1030 strvisx(char *, const char *, size_t, int);
1033 #if !defined(HAVE_SVIS) || defined(NEED_SVIS_PROTO)
1035 #define svis rk_svis
1037 ROKEN_LIB_FUNCTION
char * ROKEN_LIB_CALL
1038 svis(char *, int, int, int, const char *);
1041 #if !defined(HAVE_UNVIS) || defined(NEED_UNVIS_PROTO)
1043 #define unvis rk_unvis
1045 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
1046 unvis(char *, int, int *, int);
1049 #if !defined(HAVE_VIS) || defined(NEED_VIS_PROTO)
1053 ROKEN_LIB_FUNCTION
char * ROKEN_LIB_CALL
1054 vis(char *, int, int, int);
1057 #if !defined(HAVE_CLOSEFROM)
1058 #define closefrom rk_closefrom
1059 ROKEN_LIB_FUNCTION
int ROKEN_LIB_CALL
1063 #if !defined(HAVE_TIMEGM)
1064 #define timegm rk_timegm
1065 ROKEN_LIB_FUNCTION
time_t ROKEN_LIB_CALL
1066 rk_timegm(struct tm
*tm
);
1070 #define qsort rk_qsort
1072 rk_qsort(void *, size_t, size_t, int (*)(const void *, const void *));
1075 #if defined(__linux__) && defined(SOCK_CLOEXEC) && !defined(SOCKET_WRAPPER_REPLACE)
1077 #define socket(_fam,_type,_prot) rk_socket(_fam,_type,_prot)
1078 int ROKEN_LIB_FUNCTION
rk_socket(int, int, int);
1081 #ifdef SOCKET_WRAPPER_REPLACE
1082 #include <socket_wrapper.h>