Windows: add usleep() to roken
[heimdal.git] / lib / roken / roken.h.in
blob6e76b3f63332532563ae3686e903644f4e667da4
1 /* -*- C -*- */
2 /*
3 * Copyright (c) 1995-2005 Kungliga Tekniska Högskolan
4 * (Royal Institute of Technology, Stockholm, Sweden).
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
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
32 * SUCH DAMAGE.
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <stdarg.h>
38 #ifdef HAVE_STDINT_H
39 #include <stdint.h>
40 #endif
41 #include <string.h>
42 #include <limits.h>
43 #include <signal.h>
45 #ifndef ROKEN_LIB_FUNCTION
46 #ifdef _WIN32
47 # define ROKEN_LIB_CALL __cdecl
48 # ifdef ROKEN_LIB_DYNAMIC
49 # define ROKEN_LIB_FUNCTION __declspec(dllimport)
50 # define ROKEN_LIB_VARIABLE __declspec(dllimport)
51 # else
52 # define ROKEN_LIB_FUNCTION
53 # define ROKEN_LIB_VARIABLE
54 # endif
55 #else
56 #define ROKEN_LIB_FUNCTION
57 #define ROKEN_LIB_CALL
58 #define ROKEN_LIB_VARIABLE
59 #endif
60 #endif
62 #ifdef HAVE_WINSOCK
63 /* Declarations for Microsoft Windows */
65 #include <winsock2.h>
66 #include <ws2tcpip.h>
69 * error codes for inet_ntop/inet_pton
71 typedef SOCKET rk_socket_t;
73 #define rk_closesocket(x) closesocket(x)
74 #define rk_INVALID_SOCKET INVALID_SOCKET
75 #define rk_IS_BAD_SOCKET(s) ((s) == INVALID_SOCKET)
76 #define rk_IS_SOCKET_ERROR(rv) ((rv) == SOCKET_ERROR)
77 #define rk_SOCK_ERRNO WSAGetLastError()
79 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_SOCK_IOCTL(SOCKET s, long cmd, int * argp);
81 #define rk_SOCK_INIT() rk_WSAStartup()
82 #define rk_SOCK_EXIT() rk_WSACleanup()
84 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_WSAStartup(void);
85 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_WSACleanup(void);
87 #else /* not WinSock */
89 typedef int rk_socket_t;
91 #define rk_closesocket(x) close(x)
92 #define rk_SOCK_IOCTL(s,c,a) ioctl((s),(c),(a))
93 #define rk_IS_BAD_SOCKET(s) ((s) < 0)
94 #define rk_IS_SOCKET_ERROR(rv) ((rv) < 0)
95 #define rk_SOCK_ERRNO errno
96 #define rk_INVALID_SOCKET (-1)
98 #define rk_SOCK_INIT() 0
99 #define rk_SOCK_EXIT() do { } while(0)
101 #endif /* WinSock */
103 #ifndef IN_LOOPBACKNET
104 #define IN_LOOPBACKNET 127
105 #endif
107 #ifdef _MSC_VER
108 #ifndef HAVE_STDINT_H
109 #include <intsafe.h>
110 #endif
112 /* Declarations for Microsoft Visual C runtime on Windows */
114 #include<process.h>
116 #include<io.h>
118 #ifndef __BIT_TYPES_DEFINED__
119 #define __BIT_TYPES_DEFINED__
121 typedef __int8 int8_t;
122 typedef __int16 int16_t;
123 typedef __int32 int32_t;
124 typedef __int64 int64_t;
125 typedef unsigned __int8 uint8_t;
126 typedef unsigned __int16 uint16_t;
127 typedef unsigned __int32 uint32_t;
128 typedef unsigned __int64 uint64_t;
129 typedef uint8_t u_int8_t;
130 typedef uint16_t u_int16_t;
131 typedef uint32_t u_int32_t;
132 typedef uint64_t u_int64_t;
134 #endif /* __BIT_TYPES_DEFINED__ */
136 #define UNREACHABLE(x) x
137 #define UNUSED_ARGUMENT(x) ((void) x)
139 #define RETSIGTYPE void
141 #define VOID_RETSIGTYPE 1
143 #ifdef VOID_RETSIGTYPE
144 #define SIGRETURN(x) return
145 #else
146 #define SIGRETURN(x) return (RETSIGTYPE)(x)
147 #endif
149 #ifndef CPP_ONLY
151 typedef int pid_t;
153 typedef unsigned int gid_t;
155 typedef unsigned int uid_t;
157 typedef unsigned short mode_t;
159 #endif
161 #ifndef __cplusplus
162 #define inline __inline
163 #endif
165 #else
167 #define UNREACHABLE(x)
168 #define UNUSED_ARGUMENT(x)
170 #endif
172 #ifdef _AIX
173 struct ether_addr;
174 struct sockaddr_dl;
175 #endif
176 #ifdef HAVE_SYS_PARAM_H
177 #include <sys/param.h>
178 #endif
179 #ifdef HAVE_INTTYPES_H
180 #include <inttypes.h>
181 #endif
182 #ifdef HAVE_SYS_TYPES_H
183 #include <sys/types.h>
184 #endif
185 #ifdef HAVE_SYS_BITYPES_H
186 #include <sys/bitypes.h>
187 #endif
188 #ifdef HAVE_BIND_BITYPES_H
189 #include <bind/bitypes.h>
190 #endif
191 #ifdef HAVE_NETINET_IN6_MACHTYPES_H
192 #include <netinet/in6_machtypes.h>
193 #endif
194 #ifdef HAVE_UNISTD_H
195 #include <unistd.h>
196 #endif
197 #ifdef HAVE_SYS_SOCKET_H
198 #include <sys/socket.h>
199 #endif
200 #ifdef HAVE_SYS_UIO_H
201 #include <sys/uio.h>
202 #endif
203 #ifdef HAVE_GRP_H
204 #include <grp.h>
205 #endif
206 #ifdef HAVE_SYS_STAT_H
207 #include <sys/stat.h>
208 #endif
209 #ifdef HAVE_NETINET_IN_H
210 #include <netinet/in.h>
211 #endif
212 #ifdef HAVE_NETINET_IN6_H
213 #include <netinet/in6.h>
214 #endif
215 #ifdef HAVE_NETINET6_IN6_H
216 #include <netinet6/in6.h>
217 #endif
218 #ifdef HAVE_ARPA_INET_H
219 #include <arpa/inet.h>
220 #endif
221 #ifdef HAVE_NETDB_H
222 #include <netdb.h>
223 #endif
224 #ifdef HAVE_ARPA_NAMESER_H
225 #include <arpa/nameser.h>
226 #endif
227 #ifdef HAVE_RESOLV_H
228 #include <resolv.h>
229 #endif
230 #ifdef HAVE_SYSLOG_H
231 #include <syslog.h>
232 #endif
233 #ifdef HAVE_FCNTL_H
234 #include <fcntl.h>
235 #endif
236 #ifdef HAVE_ERRNO_H
237 #include <errno.h>
238 #endif
239 #include <err.h>
240 #ifdef HAVE_TERMIOS_H
241 #include <termios.h>
242 #endif
243 #ifdef HAVE_SYS_IOCTL_H
244 #include <sys/ioctl.h>
245 #endif
246 #ifdef TIME_WITH_SYS_TIME
247 #include <sys/time.h>
248 #include <time.h>
249 #elif defined(HAVE_SYS_TIME_H)
250 #include <sys/time.h>
251 #else
252 #include <time.h>
253 #endif
255 #ifdef HAVE_PATHS_H
256 #include <paths.h>
257 #endif
259 #ifdef HAVE_DIRENT_H
260 #include <dirent.h>
261 #endif
263 #ifdef HAVE_DIRECT_H
264 #include <direct.h>
265 #endif
267 #ifdef BACKSLASH_PATH_DELIM
268 #define rk_PATH_DELIM '\\'
269 #endif
271 #ifndef HAVE_SSIZE_T
272 #ifndef SSIZE_T_DEFINED
273 #ifdef ssize_t
274 #undef ssize_t
275 #endif
276 #ifdef _WIN64
277 typedef __int64 ssize_t;
278 #else
279 typedef int ssize_t;
280 #endif
281 #define SSIZE_T_DEFINED
282 #endif /* SSIZE_T_DEFINED */
283 #endif /* HAVE_SSIZE_T */
285 #include <roken-common.h>
287 ROKEN_CPP_START
289 #ifdef HAVE_UINTPTR_T
290 #define rk_UNCONST(x) ((void *)(uintptr_t)(const void *)(x))
291 #else
292 #define rk_UNCONST(x) ((void *)(unsigned long)(const void *)(x))
293 #endif
295 #if !defined(HAVE_SETSID) && defined(HAVE__SETSID)
296 #define setsid _setsid
297 #endif
299 #ifdef _MSC_VER
300 /* Additional macros for Visual C/C++ runtime */
302 #define close _close
304 #define getpid _getpid
306 #define open _open
308 #define chdir _chdir
310 #define fsync _commit
312 /* The MSVC implementation of snprintf is not C99 compliant. */
313 #define snprintf rk_snprintf
314 #define vsnprintf rk_vsnprintf
315 #define vasnprintf rk_vasnprintf
316 #define vasprintf rk_vasprintf
317 #define asnprintf rk_asnprintf
318 #define asprintf rk_asprintf
320 #define _PIPE_BUFFER_SZ 8192
321 #define pipe(fds) _pipe((fds), _PIPE_BUFFER_SZ, O_BINARY);
323 #define ftruncate(fd, sz) _chsize((fd), (sz))
325 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
326 rk_snprintf (char *str, size_t sz, const char *format, ...);
328 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
329 rk_asprintf (char **ret, const char *format, ...);
331 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
332 rk_asnprintf (char **ret, size_t max_sz, const char *format, ...);
334 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
335 rk_vasprintf (char **ret, const char *format, va_list args);
337 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
338 rk_vasnprintf (char **ret, size_t max_sz, const char *format, va_list args);
340 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
341 rk_vsnprintf (char *str, size_t sz, const char *format, va_list args);
343 /* missing stat.h predicates */
345 #define S_ISREG(m) (((m) & _S_IFREG) == _S_IFREG)
347 #define S_ISDIR(m) (((m) & _S_IFDIR) == _S_IFDIR)
349 #define S_ISCHR(m) (((m) & _S_IFCHR) == _S_IFCHR)
351 #define S_ISFIFO(m) (((m) & _S_IFIFO) == _S_IFIFO)
353 /* The following are not implemented:
355 S_ISLNK(m)
356 S_ISSOCK(m)
357 S_ISBLK(m)
360 /* The following symbolic constants are provided for rk_mkdir mode */
362 #define S_IRWXU 00700 /* user (file owner) has read, write and execute permission */
363 #define S_IRUSR 00400 /* user has read permission */
364 #define S_IWUSR 00200 /* user has write permission */
365 #define S_IXUSR 00100 /* user has execute permission */
366 #define S_IRWXG 00070 /* group has read, write and execute permission */
367 #define S_IRGRP 00040 /* group has read permission */
368 #define S_IWGRP 00020 /* group has write permission */
369 #define S_IXGRP 00010 /* group has execute permission */
370 #define S_IRWXO 00007 /* others have read, write and execute permission */
371 #define S_IROTH 00004 /* others have read permission */
372 #define S_IWOTH 00002 /* others have write permission */
373 #define S_IXOTH 00001 /* others have execute permission */
375 #if !defined(ROKEN_NO_DEFINE_ALLOCATORS)
376 /* Ensure that a common memory allocator is used by all */
377 #define calloc rk_calloc
378 #define free rk_free
379 #define malloc rk_malloc
380 #define realloc rk_realloc
381 #define strdup rk_strdup
382 #define wcsdup rk_wcsdup
383 #endif
385 ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
386 rk_calloc(size_t, size_t);
388 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
389 rk_free(void *);
391 ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
392 rk_malloc(size_t);
394 ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
395 rk_realloc(void *, size_t);
397 ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
398 rk_strdup(const char *);
400 ROKEN_LIB_FUNCTION unsigned short * ROKEN_LIB_CALL
401 rk_wcsdup(const unsigned short *);
403 #endif /* _MSC_VER */
405 #ifdef HAVE_WINSOCK
407 /* While we are at it, define WinSock specific scatter gather socket
408 I/O. */
410 #define iovec _WSABUF
411 #define iov_base buf
412 #define iov_len len
414 struct msghdr {
415 void *msg_name;
416 socklen_t msg_namelen;
417 struct iovec *msg_iov;
418 size_t msg_iovlen;
419 void *msg_control;
420 socklen_t msg_controllen;
421 int msg_flags;
424 #define sendmsg sendmsg_w32
426 ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
427 sendmsg_w32(rk_socket_t s, const struct msghdr * msg, int flags);
429 #endif /* HAVE_WINSOCK */
431 #ifndef HAVE_PUTENV
432 #define putenv rk_putenv
433 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL putenv(const char *);
434 #endif
436 #if !defined(HAVE_SETENV) || defined(NEED_SETENV_PROTO)
437 #ifndef HAVE_SETENV
438 #define setenv rk_setenv
439 #endif
440 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL setenv(const char *, const char *, int);
441 #endif
443 #if !defined(HAVE_UNSETENV) || defined(NEED_UNSETENV_PROTO)
444 #ifndef HAVE_UNSETENV
445 #define unsetenv rk_unsetenv
446 #endif
447 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL unsetenv(const char *);
448 #endif
450 #if !defined(HAVE_GETUSERSHELL) || defined(NEED_GETUSERSHELL_PROTO)
451 #ifndef HAVE_GETUSERSHELL
452 #define getusershell rk_getusershell
453 #define endusershell rk_endusershell
454 #endif
455 ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL getusershell(void);
456 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL endusershell(void);
457 #endif
459 #if !defined(HAVE_SNPRINTF) || defined(NEED_SNPRINTF_PROTO)
460 #ifndef HAVE_SNPRINTF
461 #define snprintf rk_snprintf
462 #endif
463 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
464 rk_snprintf (char *, size_t, const char *, ...)
465 __attribute__ ((format (printf, 3, 4)));
466 #endif
468 #if !defined(HAVE_VSNPRINTF) || defined(NEED_VSNPRINTF_PROTO)
469 #ifndef HAVE_VSNPRINTF
470 #define vsnprintf rk_vsnprintf
471 #endif
472 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
473 rk_vsnprintf (char *, size_t, const char *, va_list)
474 __attribute__((format (printf, 3, 0)));
475 #endif
477 #if !defined(HAVE_ASPRINTF) || defined(NEED_ASPRINTF_PROTO)
478 #ifndef HAVE_ASPRINTF
479 #define asprintf rk_asprintf
480 #endif
481 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
482 rk_asprintf (char **, const char *, ...)
483 __attribute__ ((format (printf, 2, 3)));
484 #endif
486 #if !defined(HAVE_VASPRINTF) || defined(NEED_VASPRINTF_PROTO)
487 #ifndef HAVE_VASPRINTF
488 #define vasprintf rk_vasprintf
489 #endif
490 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
491 rk_vasprintf (char **, const char *, va_list)
492 __attribute__((format (printf, 2, 0)));
493 #endif
495 #if !defined(HAVE_ASNPRINTF) || defined(NEED_ASNPRINTF_PROTO)
496 #ifndef HAVE_ASNPRINTF
497 #define asnprintf rk_asnprintf
498 #endif
499 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
500 rk_asnprintf (char **, size_t, const char *, ...)
501 __attribute__ ((format (printf, 3, 4)));
502 #endif
504 #if !defined(HAVE_VASNPRINTF) || defined(NEED_VASNPRINTF_PROTO)
505 #ifndef HAVE_VASNPRINTF
506 #define vasnprintf rk_vasnprintf
507 #endif
508 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
509 vasnprintf (char **, size_t, const char *, va_list)
510 __attribute__((format (printf, 3, 0)));
511 #endif
513 #ifndef HAVE_STRDUP
514 #define strdup rk_strdup
515 ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strdup(const char *);
516 #endif
518 #if !defined(HAVE_STRNDUP) || defined(NEED_STRNDUP_PROTO)
519 #ifndef HAVE_STRNDUP
520 #define strndup rk_strndup
521 #endif
522 ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strndup(const char *, size_t);
523 #endif
525 #ifndef HAVE_STRLWR
526 #define strlwr rk_strlwr
527 ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strlwr(char *);
528 #endif
530 #ifndef HAVE_STRNLEN
531 #define strnlen rk_strnlen
532 ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL strnlen(const char*, size_t);
533 #endif
535 #if !defined(HAVE_STRSEP) || defined(NEED_STRSEP_PROTO)
536 #ifndef HAVE_STRSEP
537 #define strsep rk_strsep
538 #endif
539 ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strsep(char**, const char*);
540 #endif
542 #if !defined(HAVE_STRSEP_COPY) || defined(NEED_STRSEP_COPY_PROTO)
543 #ifndef HAVE_STRSEP_COPY
544 #define strsep_copy rk_strsep_copy
545 #endif
546 ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL strsep_copy(const char**, const char*, char*, size_t);
547 #endif
549 #ifndef HAVE_STRCASECMP
550 #define strcasecmp rk_strcasecmp
551 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL strcasecmp(const char *, const char *);
552 #endif
554 #ifdef NEED_FCLOSE_PROTO
555 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL fclose(FILE *);
556 #endif
558 #ifdef NEED_STRTOK_R_PROTO
559 ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strtok_r(char *, const char *, char **);
560 #endif
562 #ifndef HAVE_STRUPR
563 #define strupr rk_strupr
564 ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strupr(char *);
565 #endif
567 #ifndef HAVE_STRLCPY
568 #define strlcpy rk_strlcpy
569 ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL strlcpy (char *, const char *, size_t);
570 #endif
572 #ifndef HAVE_STRLCAT
573 #define strlcat rk_strlcat
574 ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL strlcat (char *, const char *, size_t);
575 #endif
577 #ifndef HAVE_GETDTABLESIZE
578 #define getdtablesize rk_getdtablesize
579 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL getdtablesize(void);
580 #endif
582 #if !defined(HAVE_STRERROR) && !defined(strerror)
583 #define strerror rk_strerror
584 ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL strerror(int);
585 #endif
587 #if (!defined(HAVE_STRERROR_R) && !defined(strerror_r)) || (!defined(STRERROR_R_PROTO_COMPATIBLE) && defined(HAVE_STRERROR_R))
588 int ROKEN_LIB_FUNCTION rk_strerror_r(int, char *, size_t);
589 #else
590 #define rk_strerror_r strerror_r
591 #endif
593 #if !defined(HAVE_HSTRERROR) || defined(NEED_HSTRERROR_PROTO)
594 #ifndef HAVE_HSTRERROR
595 #define hstrerror rk_hstrerror
596 #endif
597 /* This causes a fatal error under Psoriasis */
598 #ifndef SunOS
599 ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL hstrerror(int);
600 #endif
601 #endif
603 #if !HAVE_DECL_H_ERRNO
604 extern int h_errno;
605 #endif
607 #if !defined(HAVE_INET_ATON) || defined(NEED_INET_ATON_PROTO)
608 #ifndef HAVE_INET_ATON
609 #define inet_aton rk_inet_aton
610 #endif
611 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL inet_aton(const char *, struct in_addr *);
612 #endif
614 #ifndef HAVE_INET_NTOP
615 #define inet_ntop rk_inet_ntop
616 ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
617 inet_ntop(int af, const void *src, char *dst, size_t size);
618 #endif
620 #ifndef HAVE_INET_PTON
621 #define inet_pton rk_inet_pton
622 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
623 inet_pton(int, const char *, void *);
624 #endif
626 #ifndef HAVE_GETCWD
627 #define getcwd rk_getcwd
628 ROKEN_LIB_FUNCTION char* ROKEN_LIB_CALL getcwd(char *, size_t);
629 #endif
631 #ifdef HAVE_PWD_H
632 #include <pwd.h>
633 ROKEN_LIB_FUNCTION struct passwd * ROKEN_LIB_CALL k_getpwnam (const char *);
634 ROKEN_LIB_FUNCTION struct passwd * ROKEN_LIB_CALL k_getpwuid (uid_t);
635 #endif
637 #ifdef POSIX_GETPWNAM_R
638 #define rk_getpwnam_r(_n, _pw, _b, _sz, _pwd) getpwnam_r(_n, _pw, _b, _sz, _pwd)
639 #else
640 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
641 rk_getpwnam_r(const char *, struct passwd *, char *, size_t, struct passwd **);
642 #endif
644 ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL get_default_username (void);
646 #ifndef HAVE_SETEUID
647 #define seteuid rk_seteuid
648 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL seteuid(uid_t);
649 #endif
651 #ifndef HAVE_SETEGID
652 #define setegid rk_setegid
653 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL setegid(gid_t);
654 #endif
656 #ifndef HAVE_LSTAT
657 #define lstat rk_lstat
658 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL lstat(const char *, struct stat *);
659 #endif
661 #if !defined(HAVE_MKSTEMP) || defined(NEED_MKSTEMP_PROTO)
662 #ifndef HAVE_MKSTEMP
663 #define mkstemp rk_mkstemp
664 #endif
665 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL mkstemp(char *);
666 #endif
668 #ifndef HAVE_CGETENT
669 #define cgetent rk_cgetent
670 #define cgetstr rk_cgetstr
671 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetent(char **, char **, const char *);
672 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetstr(char *, const char *, char **);
673 #endif
675 #ifndef HAVE_INITGROUPS
676 #define initgroups rk_initgroups
677 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL initgroups(const char *, gid_t);
678 #endif
680 #ifndef HAVE_FCHOWN
681 #define fchown rk_fchown
682 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL fchown(int, uid_t, gid_t);
683 #endif
685 #ifdef RENAME_DOES_NOT_UNLINK
686 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_rename(const char *, const char *);
687 #else
688 #define rk_rename(__rk_rn_from,__rk_rn_to) rename(__rk_rn_from,__rk_rn_to)
689 #endif
691 #ifdef MKDIR_DOES_NOT_HAVE_MODE
692 #define mkdir rk_mkdir
693 #else
694 #define rk_mkdir(__rk_rn_name, __rk_rn_mode) mkdir(__rk_rn_name,__rk_rn_mode)
695 #endif
697 #if !defined(HAVE_DAEMON) || defined(NEED_DAEMON_PROTO)
698 #ifndef HAVE_DAEMON
699 #define daemon rk_daemon
700 #endif
701 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL daemon(int, int);
702 #endif
704 #ifndef HAVE_CHOWN
705 #define chown rk_chown
706 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL chown(const char *, uid_t, gid_t);
707 #endif
709 #ifndef HAVE_RCMD
710 #define rcmd rk_rcmd
711 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
712 rcmd(char **, unsigned short, const char *,
713 const char *, const char *, int *);
714 #endif
716 #if !defined(HAVE_INNETGR) || defined(NEED_INNETGR_PROTO)
717 #ifndef HAVE_INNETGR
718 #define innetgr rk_innetgr
719 #endif
720 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL innetgr(const char*, const char*,
721 const char*, const char*);
722 #endif
724 #ifndef HAVE_IRUSEROK
725 #define iruserok rk_iruserok
726 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL iruserok(unsigned, int,
727 const char *, const char *);
728 #endif
730 #if !defined(HAVE_GETHOSTNAME) || defined(NEED_GETHOSTNAME_PROTO)
731 #ifndef HAVE_GETHOSTNAME
732 #define gethostname rk_gethostname
733 #endif
734 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL gethostname(char *, int);
735 #endif
737 #ifndef HAVE_WRITEV
738 #define writev rk_writev
739 ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
740 writev(int, const struct iovec *, int);
741 #endif
743 #ifndef HAVE_READV
744 #define readv rk_readv
745 ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
746 readv(int, const struct iovec *, int);
747 #endif
749 #ifndef HAVE_PIDFILE
750 #ifdef NO_PIDFILES
751 #define pidfile(x) ((void) 0)
752 #else
753 #define pidfile rk_pidfile
754 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL pidfile (const char*);
755 #endif
756 #endif
758 #ifndef HAVE_BSWAP32
759 #define bswap32 rk_bswap32
760 ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL bswap32(unsigned int);
761 #endif
763 #ifndef HAVE_BSWAP16
764 #define bswap16 rk_bswap16
765 ROKEN_LIB_FUNCTION unsigned short ROKEN_LIB_CALL bswap16(unsigned short);
766 #endif
768 #ifndef HAVE_FLOCK
769 #ifndef LOCK_SH
770 #define LOCK_SH 1 /* Shared lock */
771 #endif
772 #ifndef LOCK_EX
773 #define LOCK_EX 2 /* Exclusive lock */
774 #endif
775 #ifndef LOCK_NB
776 #define LOCK_NB 4 /* Don't block when locking */
777 #endif
778 #ifndef LOCK_UN
779 #define LOCK_UN 8 /* Unlock */
780 #endif
782 #define flock(_x,_y) rk_flock(_x,_y)
783 int rk_flock(int fd, int operation);
784 #endif /* HAVE_FLOCK */
786 #ifndef HAVE_DIRFD
787 #ifdef HAVE_DIR_DD_FD
788 #define dirfd(x) ((x)->dd_fd)
789 #else
790 #ifndef _WIN32 /* Windows code never calls dirfd */
791 #error Missing dirfd() and ->dd_fd
792 #endif
793 #endif
794 #endif
796 ROKEN_LIB_FUNCTION time_t ROKEN_LIB_CALL tm2time (struct tm, int);
798 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL unix_verify_user(char *, char *);
800 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL roken_concat (char *, size_t, ...);
802 ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL roken_mconcat (char **, size_t, ...);
804 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL roken_vconcat (char *, size_t, va_list);
806 ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
807 roken_vmconcat (char **, size_t, va_list);
809 ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
810 net_write (rk_socket_t, const void *, size_t);
812 ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
813 net_read (rk_socket_t, void *, size_t);
815 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
816 issuid(void);
818 #ifndef HAVE_STRUCT_WINSIZE
819 struct winsize {
820 unsigned short ws_row, ws_col;
821 unsigned short ws_xpixel, ws_ypixel;
823 #endif
825 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL get_window_size(int fd, int *, int *);
827 #ifndef HAVE_VSYSLOG
828 #define vsyslog rk_vsyslog
829 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL vsyslog(int, const char *, va_list);
830 #endif
832 #ifndef HAVE_GETOPT
833 #define getopt rk_getopt
834 #define optarg rk_optarg
835 #define optind rk_optind
836 #define opterr rk_opterr
837 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
838 getopt(int nargc, char * const *nargv, const char *ostr);
839 #endif
841 #if !HAVE_DECL_OPTARG
842 ROKEN_LIB_VARIABLE extern char *optarg;
843 #endif
844 #if !HAVE_DECL_OPTIND
845 ROKEN_LIB_VARIABLE extern int optind;
846 #endif
847 #if !HAVE_DECL_OPTERR
848 ROKEN_LIB_VARIABLE extern int opterr;
849 #endif
851 #ifndef HAVE_GETIPNODEBYNAME
852 #define getipnodebyname rk_getipnodebyname
853 ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
854 getipnodebyname (const char *, int, int, int *);
855 #endif
857 #ifndef HAVE_GETIPNODEBYADDR
858 #define getipnodebyaddr rk_getipnodebyaddr
859 ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
860 getipnodebyaddr (const void *, size_t, int, int *);
861 #endif
863 #ifndef HAVE_FREEHOSTENT
864 #define freehostent rk_freehostent
865 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
866 freehostent (struct hostent *);
867 #endif
869 #ifndef HAVE_COPYHOSTENT
870 #define copyhostent rk_copyhostent
871 ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL
872 copyhostent (const struct hostent *);
873 #endif
875 #ifndef HAVE_SOCKLEN_T
876 typedef int socklen_t;
877 #endif
879 #ifndef HAVE_STRUCT_SOCKADDR_STORAGE
881 #ifndef HAVE_SA_FAMILY_T
882 typedef unsigned short sa_family_t;
883 #endif
885 #ifdef HAVE_IPV6
886 #define _SS_MAXSIZE sizeof(struct sockaddr_in6)
887 #else
888 #define _SS_MAXSIZE sizeof(struct sockaddr_in)
889 #endif
891 #define _SS_ALIGNSIZE sizeof(unsigned long)
893 #if HAVE_STRUCT_SOCKADDR_SA_LEN
895 typedef unsigned char roken_sa_family_t;
897 #define _SS_PAD1SIZE ((2 * _SS_ALIGNSIZE - sizeof (roken_sa_family_t) - sizeof(unsigned char)) % _SS_ALIGNSIZE)
898 #define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (roken_sa_family_t) + sizeof(unsigned char) + _SS_PAD1SIZE + _SS_ALIGNSIZE))
900 struct sockaddr_storage {
901 unsigned char ss_len;
902 roken_sa_family_t ss_family;
903 char __ss_pad1[_SS_PAD1SIZE];
904 unsigned long __ss_align[_SS_PAD2SIZE / sizeof(unsigned long) + 1];
907 #else /* !HAVE_STRUCT_SOCKADDR_SA_LEN */
909 typedef unsigned short roken_sa_family_t;
911 #define _SS_PAD1SIZE ((2 * _SS_ALIGNSIZE - sizeof (roken_sa_family_t)) % _SS_ALIGNSIZE)
912 #define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (roken_sa_family_t) + _SS_PAD1SIZE + _SS_ALIGNSIZE))
914 struct sockaddr_storage {
915 roken_sa_family_t ss_family;
916 char __ss_pad1[_SS_PAD1SIZE];
917 unsigned long __ss_align[_SS_PAD2SIZE / sizeof(unsigned long) + 1];
920 #endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */
922 #endif /* HAVE_STRUCT_SOCKADDR_STORAGE */
924 #ifndef HAVE_STRUCT_ADDRINFO
925 struct addrinfo {
926 int ai_flags;
927 int ai_family;
928 int ai_socktype;
929 int ai_protocol;
930 size_t ai_addrlen;
931 char *ai_canonname;
932 struct sockaddr *ai_addr;
933 struct addrinfo *ai_next;
935 #endif
937 #ifndef HAVE_GETADDRINFO
938 #define getaddrinfo rk_getaddrinfo
939 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
940 getaddrinfo(const char *,
941 const char *,
942 const struct addrinfo *,
943 struct addrinfo **);
944 #endif
946 #ifndef HAVE_GETNAMEINFO
947 #define getnameinfo rk_getnameinfo
948 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
949 getnameinfo(const struct sockaddr *, socklen_t,
950 char *, size_t,
951 char *, size_t,
952 int);
953 #endif
955 #ifndef HAVE_FREEADDRINFO
956 #define freeaddrinfo rk_freeaddrinfo
957 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
958 freeaddrinfo(struct addrinfo *);
959 #endif
961 #ifndef HAVE_GAI_STRERROR
962 #define gai_strerror rk_gai_strerror
963 ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL
964 gai_strerror(int);
965 #endif
967 #ifdef NO_SLEEP
969 ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL
970 sleep(unsigned int seconds);
972 ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL
973 usleep(unsigned int useconds);
975 #endif
977 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
978 getnameinfo_verified(const struct sockaddr *, socklen_t,
979 char *, size_t,
980 char *, size_t,
981 int);
983 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
984 roken_getaddrinfo_hostspec(const char *, int, struct addrinfo **);
985 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
986 roken_getaddrinfo_hostspec2(const char *, int, int, struct addrinfo **);
988 #ifndef HAVE_STRFTIME
989 #define strftime rk_strftime
990 ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
991 strftime (char *, size_t, const char *, const struct tm *);
992 #endif
994 #ifndef HAVE_STRPTIME
995 #define strptime rk_strptime
996 ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
997 strptime (const char *, const char *, struct tm *);
998 #endif
1000 #ifndef HAVE_GETTIMEOFDAY
1001 #define gettimeofday rk_gettimeofday
1002 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
1003 gettimeofday (struct timeval *, void *);
1004 #endif
1006 #ifndef HAVE_EMALLOC
1007 #define emalloc rk_emalloc
1008 ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL emalloc (size_t);
1009 #endif
1010 #ifndef HAVE_ECALLOC
1011 #define ecalloc rk_ecalloc
1012 ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL ecalloc(size_t, size_t);
1013 #endif
1014 #ifndef HAVE_EREALLOC
1015 #define erealloc rk_erealloc
1016 ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL erealloc (void *, size_t);
1017 #endif
1018 #ifndef HAVE_ESTRDUP
1019 #define estrdup rk_estrdup
1020 ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL estrdup (const char *);
1021 #endif
1024 * kludges and such
1027 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
1028 roken_gethostby_setup(const char*, const char*);
1029 ROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL
1030 roken_gethostbyname(const char*);
1031 ROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL
1032 roken_gethostbyaddr(const void*, size_t, int);
1034 #ifdef GETSERVBYNAME_PROTO_COMPATIBLE
1035 #define roken_getservbyname(x,y) getservbyname(x,y)
1036 #else
1037 #define roken_getservbyname(x,y) getservbyname((char *)x, (char *)y)
1038 #endif
1040 #ifdef OPENLOG_PROTO_COMPATIBLE
1041 #define roken_openlog(a,b,c) openlog(a,b,c)
1042 #else
1043 #define roken_openlog(a,b,c) openlog((char *)a,b,c)
1044 #endif
1046 #ifdef GETSOCKNAME_PROTO_COMPATIBLE
1047 #define roken_getsockname(a,b,c) getsockname(a,b,c)
1048 #else
1049 #define roken_getsockname(a,b,c) getsockname(a, b, (void*)c)
1050 #endif
1052 #ifndef HAVE_SETPROGNAME
1053 #define setprogname rk_setprogname
1054 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL setprogname(const char *);
1055 #endif
1057 #ifndef HAVE_GETPROGNAME
1058 #define getprogname rk_getprogname
1059 ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL getprogname(void);
1060 #endif
1062 #if !defined(HAVE_SETPROGNAME) && !defined(HAVE_GETPROGNAME) && !HAVE_DECL___PROGNAME
1063 extern const char *__progname;
1064 #endif
1066 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
1067 mini_inetd_addrinfo (struct addrinfo*, rk_socket_t *);
1069 ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
1070 mini_inetd (int, rk_socket_t *);
1072 #ifndef HAVE_LOCALTIME_R
1073 #define localtime_r rk_localtime_r
1074 ROKEN_LIB_FUNCTION struct tm * ROKEN_LIB_CALL
1075 localtime_r(const time_t *, struct tm *);
1076 #endif
1078 #if !defined(HAVE_STRTOLL) || defined(NEED_STRTOLL_PROTO)
1079 #ifndef HAVE_STRTOLL
1080 #define strtoll rk_strtoll
1081 #endif
1082 ROKEN_LIB_FUNCTION long long ROKEN_LIB_CALL
1083 strtoll(const char * nptr, char ** endptr, int base);
1084 #endif
1086 #if !defined(HAVE_STRTOULL) || defined(NEED_STRTOULL_PROTO)
1087 #ifndef HAVE_STRTOULL
1088 #define strtoull rk_strtoull
1089 #endif
1090 ROKEN_LIB_FUNCTION unsigned long long ROKEN_LIB_CALL
1091 strtoull(const char * nptr, char ** endptr, int base);
1092 #endif
1094 #if !defined(HAVE_STRSVIS) || defined(NEED_STRSVIS_PROTO)
1095 #ifndef HAVE_STRSVIS
1096 #define strsvis rk_strsvis
1097 #endif
1098 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
1099 strsvis(char *, const char *, int, const char *);
1100 #endif
1102 #if !defined(HAVE_STRSVISX) || defined(NEED_STRSVISX_PROTO)
1103 #ifndef HAVE_STRSVISX
1104 #define strsvisx rk_strsvisx
1105 #endif
1106 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
1107 strsvisx(char *, const char *, size_t, int, const char *);
1108 #endif
1110 #if !defined(HAVE_STRUNVIS) || defined(NEED_STRUNVIS_PROTO)
1111 #ifndef HAVE_STRUNVIS
1112 #define strunvis rk_strunvis
1113 #endif
1114 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
1115 strunvis(char *, const char *);
1116 #endif
1118 #if !defined(HAVE_STRVIS) || defined(NEED_STRVIS_PROTO)
1119 #ifndef HAVE_STRVIS
1120 #define strvis rk_strvis
1121 #endif
1122 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
1123 strvis(char *, const char *, int);
1124 #endif
1126 #if !defined(HAVE_STRVISX) || defined(NEED_STRVISX_PROTO)
1127 #ifndef HAVE_STRVISX
1128 #define strvisx rk_strvisx
1129 #endif
1130 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
1131 strvisx(char *, const char *, size_t, int);
1132 #endif
1134 #if !defined(HAVE_SVIS) || defined(NEED_SVIS_PROTO)
1135 #ifndef HAVE_SVIS
1136 #define svis rk_svis
1137 #endif
1138 ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
1139 svis(char *, int, int, int, const char *);
1140 #endif
1142 #if !defined(HAVE_UNVIS) || defined(NEED_UNVIS_PROTO)
1143 #ifndef HAVE_UNVIS
1144 #define unvis rk_unvis
1145 #endif
1146 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
1147 unvis(char *, int, int *, int);
1148 #endif
1150 #if !defined(HAVE_VIS) || defined(NEED_VIS_PROTO)
1151 #ifndef HAVE_VIS
1152 #define vis rk_vis
1153 #endif
1154 ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
1155 vis(char *, int, int, int);
1156 #endif
1158 #if !defined(HAVE_CLOSEFROM)
1159 #define closefrom rk_closefrom
1160 ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
1161 closefrom(int);
1162 #endif
1164 #if !defined(HAVE_TIMEGM)
1165 #define timegm rk_timegm
1166 ROKEN_LIB_FUNCTION time_t ROKEN_LIB_CALL
1167 rk_timegm(struct tm *tm);
1168 #endif
1170 #ifdef NEED_QSORT
1171 #define qsort rk_qsort
1172 void
1173 rk_qsort(void *, size_t, size_t, int (*)(const void *, const void *));
1174 #endif
1176 #if defined(HAVE_ARC4RANDOM)
1177 #define rk_random() arc4random()
1178 #elif defined(HAVE_RANDOM)
1179 #define rk_random() random()
1180 #else
1181 #define rk_random() rand()
1182 #endif
1184 #ifndef HAVE_TDELETE
1185 #define tdelete(a,b,c) rk_tdelete(a,b,c)
1186 #endif
1187 #ifndef HAVE_TFIND
1188 #define tfind(a,b,c) rk_tfind(a,b,c)
1189 #endif
1190 #ifndef HAVE_TSEARCH
1191 #define tsearch(a,b,c) rk_tsearch(a,b,c)
1192 #endif
1193 #ifndef HAVE_TWALK
1194 #define twalk(a,b) rk_twalk(a,b)
1195 #endif
1197 #if defined(__linux__) && defined(SOCK_CLOEXEC) && !defined(SOCKET_WRAPPER_REPLACE) && !defined(__SOCKET_WRAPPER_H__)
1198 #undef socket
1199 #define socket(_fam,_type,_prot) rk_socket(_fam,_type,_prot)
1200 int ROKEN_LIB_FUNCTION rk_socket(int, int, int);
1201 #endif
1203 /* Microsoft VC 2010 POSIX definitions */
1204 #ifndef EAFNOSUPPORT
1205 #define EAFNOSUPPORT 102
1206 #endif
1207 #ifndef EINPROGRESS
1208 #define EINPROGRESS 112
1209 #endif
1210 #ifndef ENOTSOCK
1211 #define ENOTSOCK 128
1212 #endif
1213 #ifndef ENOTSUP
1214 #define ENOTSUP 129
1215 #endif
1216 #ifndef EOVERFLOW
1217 #define EOVERFLOW 132
1218 #endif
1219 #ifndef ETIMEDOUT
1220 #define ETIMEDOUT 138
1221 #endif
1222 #ifndef EWOULDBLOCK
1223 #define EWOULDBLOCK 140
1224 #endif
1227 #ifdef SOCKET_WRAPPER_REPLACE
1228 #include <socket_wrapper.h>
1229 #endif
1231 ROKEN_CPP_END