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