posix.h
1 /* ========================================================================== */
2 /* Operating system API */
3 /*
4  * Include this as the first header in a C source file that should access the
5  * operating system. A C++ source file must never include this header.
6  */
7 
8 #ifdef __cplusplus
9 # error The POSIX.1-1990 API has no C++ binding!
10 #endif /* __cplusplus */
11 
12 
13 /* ========================================================================== */
14 /* Configuration (must be 1st) */
15 
16 #include "config.h"
17 
18 
19 /* ========================================================================== */
20 /* Tell system headers that they should be POSIX conformant (must be 2nd) */
21 
22 #ifdef POSIX_H
23  /* This must always be the first header that is included */
24 # error Never include this header more than once!
25 #endif /* POSIX_H */
26 #define POSIX_H 1
27 
28 /*
29  * CHeck twice before requesting another API, this can have many side effects.
30  * It is obvious that older APIs lack support for some features, but newer APIs
31  * also have features removed (because they where deprecated). In both cases we
32  * must provide replacements for (different) missing features.
33  *
34  * See also: ../INSTALL.HP-UX
35  */
36 #if CFG_USE_POSIX_API >= 200809
37 # define _POSIX_C_SOURCE 200809L
38 #elif CFG_USE_POSIX_API == 200112
39  /*
40  * Attention:
41  * At least POSIX.1g-2000 is required for IP6 option
42  */
43 # define _POSIX_C_SOURCE 200112L
44 #else /* CFG_USE_POSIX_API */
45  /*
46  * Attention:
47  * POSIX.1-1990 is not sufficient because we need the POSIX.1b-1993 Realtime
48  * and POSIX.1c-1996 thread extensions
49  */
50 # define _POSIX_C_SOURCE 199506L
51 #endif /* CFG_USE_POSIX_API */
52 
53 #if CFG_USE_XSI
54 # if CFG_USE_POSIX_API >= 200809
55  /*
56  * Attention:
57  * The POSIX version must be not greater than 200809 if this value is 700:
58  * https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_02_01_02
59  */
60 # define _XOPEN_SOURCE 700
61 # elif CFG_USE_POSIX_API == 200112
62  /*
63  * Attention:
64  * The POSIX version must be not greater than 200112 if this value is 600:
65  * http://pubs.opengroup.org/onlinepubs/007904975/functions/xsh_chap02_02.html#tag_02_02_01_02
66  */
67 # define _XOPEN_SOURCE 600
68 # else /* CFG_USE_POSIX_API */
69  /*
70  * Attention:
71  * The POSIX version must be not greater than 199506 if this value is 500:
72  * http://pubs.opengroup.org/onlinepubs/7908799/xns/compilation.html
73  */
74 # define _XOPEN_SOURCE 500
75 # endif /* CFG_USE_POSIX_API */
76 #endif /* CFG_USE_XSI */
77 
78 /*
79  * This definition allows linking objects compiled for XNS and BSD sockets:
80  * http://docstore.mik.ua/manuals/hp-ux/en/B2355-60130/xopen_networking.7.html
81  */
82 #if defined(__hpux) && CFG_USE_XSI
83 # define _HPUX_ALT_XOPEN_SOCKET_API 1
84 #endif /* defined(__hpux) && CFG_USE_XSI */
85 
86 #include <sys/types.h>
87 #include <pthread.h>
88 #include <stdlib.h>
89 #include <stddef.h>
90 #include <limits.h>
91 #include <errno.h>
92 #include <unistd.h>
93 
94 
95 /* ========================================================================== */
96 /* POSIX.1b realtime support */
97 
98 #include <time.h>
99 
100 #define struct_posix_timespec struct timespec
101 
102 #define posix_nanosleep nanosleep
103 
104 #if CFG_USE_FSC
105 # define posix_fsync fsync
106 #else /* CFG_USE_FSC */
107 int posix_fsync(int);
108 #endif /* CFG_USE_FSC */
109 
110 
111 /* ========================================================================== */
112 /* POSIX.1c thread support */
113 
114 #define POSIX_PTHREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
115 #define POSIX_PTHREAD_COND_INITIALIZER PTHREAD_COND_INITIALIZER
116 #define POSIX_PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE
117 
118 #define posix_pthread_t pthread_t
119 #define posix_pthread_mutex_t pthread_mutex_t
120 #define posix_pthread_cond_t pthread_cond_t
121 
122 #define posix_pthread_create pthread_create
123 #define posix_pthread_cancel pthread_cancel
124 #define posix_pthread_setcancelstate pthread_setcancelstate
125 #define posix_pthread_join pthread_join
126 #define posix_pthread_self pthread_self
127 #define posix_pthread_equal pthread_equal
128 #define posix_pthread_sigmask pthread_sigmask
129 #define posix_pthread_cleanup_push pthread_cleanup_push
130 #define posix_pthread_cleanup_pop pthread_cleanup_pop
131 #define posix_pthread_mutex_lock pthread_mutex_lock
132 #define posix_pthread_mutex_trylock pthread_mutex_trylock
133 #define posix_pthread_mutex_unlock pthread_mutex_unlock
134 #define posix_pthread_cond_wait pthread_cond_wait
135 #define posix_pthread_cond_signal pthread_cond_signal
136 
137 
138 /* ========================================================================== */
139 /* POSIX.2 support */
140 
141 #include <stdio.h>
142 
143 #define posix_popen popen
144 #define posix_pclose pclose
145 
146 
147 /* ========================================================================== */
148 /* System limits */
149 
150 #if CFG_HDR_INTTYPES_H
151 # include <inttypes.h>
152 #endif /* CFG_HDR_INTTYPES_H */
153 
154 #define POSIX_INT_MAX INT_MAX
155 #define POSIX_UINT_MAX UINT_MAX
156 #define POSIX_LONG_MAX LONG_MAX
157 #define POSIX_ULONG_MAX ULONG_MAX
158 #define POSIX_SSIZE_MAX SSIZE_MAX
159 #ifdef SIZE_MAX
160 # define POSIX_SIZE_MAX SIZE_MAX
161 #else /* SIZE_MAX */
162  /* Adding 1 may fail on machines that don't use 2's complement arithmetic */
163 # define POSIX_SIZE_MAX ((size_t) POSIX_SSIZE_MAX * (size_t) 2)
164 #endif /* SIZE_MAX */
165 
166 
167 /* ========================================================================== */
168 /* Environment and return values */
169 
170 /* Pointer to array with environment variables */
171 extern char** environ;
172 #define posix_environ environ
173 
174 /* Standard return values for processes */
175 #define POSIX_EXIT_SUCCESS EXIT_SUCCESS
176 #define POSIX_EXIT_FAILURE EXIT_FAILURE
177 
178 
179 /* ========================================================================== */
180 /* System information */
181 
182 #include <sys/utsname.h>
183 
184 #define struct_posix_utsname struct utsname
185 
186 #define posix_uname uname
187 
188 
189 /* ========================================================================== */
190 /* System errors */
191 
192 #define POSIX_EACCES EACCES
193 #define POSIX_EAGAIN EAGAIN
194 #define POSIX_EBADF EBADF
195 #define POSIX_ECONNREFUSED ECONNREFUSED
196 #define POSIX_EEXIST EEXIST
197 #define POSIX_EINTR EINTR
198 #define POSIX_EINPROGRESS EINPROGRESS
199 #define POSIX_EINVAL EINVAL
200 #define POSIX_EIO EIO
201 #define POSIX_ENOENT ENOENT
202 #define POSIX_ENOMEM ENOMEM
203 #define POSIX_ENOPROTOOPT ENOPROTOOPT
204 #define POSIX_ENOSYS ENOSYS
205 #define POSIX_ENOTSOCK ENOTSOCK
206 #define POSIX_EOVERFLOW EOVERFLOW
207 
208 #define posix_errno errno
209 
210 
211 /* ========================================================================== */
212 /* Signal handling */
213 
214 #include <signal.h>
215 
216 #define posix_sig_atomic_t sig_atomic_t
217 
218 #define struct_posix_sigaction struct sigaction
219 
220 #define POSIX_SIGHUP SIGHUP
221 #define POSIX_SIGINT SIGINT
222 #define POSIX_SIGPIPE SIGPIPE
223 #define POSIX_SIGQUIT SIGQUIT
224 #define POSIX_SIGTERM SIGTERM
225 
226 #define POSIX_SIG_DFL SIG_DFL
227 #define POSIX_SIG_IGN SIG_IGN
228 
229 #define POSIX_SIG_BLOCK SIG_BLOCK
230 #define POSIX_SIG_SETMASK SIG_SETMASK
231 
232 #define posix_sigset_t sigset_t
233 
234 #define posix_kill kill
235 #define posix_sigemptyset sigemptyset
236 #define posix_sigaddset sigaddset
237 #define posix_sigaction sigaction
238 
239 
240 /* ========================================================================== */
241 /* Process handling */
242 
243 #include <sys/wait.h>
244 
245 #define posix_pid_t pid_t
246 
247 #define POSIX_WIFEXITED WIFEXITED
248 #define POSIX_WEXITSTATUS WEXITSTATUS
249 
250 #define POSIX_WNOHANG WNOHANG
251 
252 #define posix_fork fork
253 #define posix_execl execl
254 #define posix_execlp execlp
255 #define posix_waitpid waitpid
256 #define posix_getpid getpid
257 
258 
259 /* ========================================================================== */
260 /* Time */
261 
262 #define posix_time_t time_t
263 #define struct_posix_tm struct tm
264 
265 #define posix_time time
266 
267 #define posix_gmtime_r gmtime_r
268 #define posix_localtime_r localtime_r
269 
270 /* The %z conversion was included into POSIX.1 since Issue 6 */
271 #if CFG_USE_POSIX_API >= 200112 || CFG_USE_XSI
272 # define posix_strftime strftime
273 #endif /* CFG_USE_POSIX_API >= 200112 || CFG_USE_XSI */
274 
275 #if CFG_USE_XSI
276 # include <sys/time.h>
277 
278 # define posix_time_t time_t
279 # define posix_suseconds_t suseconds_t
280 # define struct_posix_timeval struct timeval
281 #else /* CFG_USE_XSI */
282 # define posix_suseconds_t long int
283 
284 struct posix_timeval
285 {
286  posix_time_t tv_sec;
287  posix_suseconds_t tv_usec;
288 };
289 
290 # define struct_posix_timeval struct posix_timeval
291 #endif /* CFG_USE_XSI */
292 
293 
294 /* ========================================================================== */
295 /* Memory management */
296 
297 #if CFG_USE_MEMDEBUG
298 void* posix_malloc(size_t);
299 void* posix_realloc(void*, size_t);
300 void posix_free(void*);
301 #else /* CFG_USE_MEMDEBUG */
302 # define posix_malloc malloc
303 # define posix_realloc realloc
304 # define posix_free free
305 #endif /* CFG_USE_MEMDEBUG */
306 
307 
308 /* ========================================================================== */
309 /* Random numbers */
310 
311 #if CFG_USE_XSI
312 # define posix_srandom srandom
313 # define posix_random random
314 #else /* CFG_USE_XSI */
315 void posix_srandom(unsigned int);
316 long int posix_random(void);
317 #endif /* CFG_USE_XSI */
318 
319 
320 /* ========================================================================== */
321 /* File & directory handling */
322 
323 #include <sys/stat.h>
324 #include <fcntl.h>
325 #include <dirent.h>
326 #include <string.h>
327 
328 #define posix_off_t off_t
329 
330 #define POSIX_SEEK_SET SEEK_SET
331 
332 #define POSIX_FD_CLOEXEC FD_CLOEXEC
333 
334 #define POSIX_O_NONBLOCK O_NONBLOCK
335 #define POSIX_O_CREAT O_CREAT
336 #define POSIX_O_TRUNC O_TRUNC
337 #define POSIX_O_RDONLY O_RDONLY
338 #define POSIX_O_WRONLY O_WRONLY
339 #define POSIX_O_RDWR O_RDWR
340 #define POSIX_O_EXCL O_EXCL
341 
342 #define POSIX_S_IRWXU S_IRWXU
343 #define POSIX_S_IRWXG S_IRWXG
344 #define POSIX_S_IRWXO S_IRWXO
345 #define POSIX_S_IRUSR S_IRUSR
346 #define POSIX_S_IWUSR S_IWUSR
347 #define POSIX_S_IXUSR S_IXUSR
348 #define POSIX_S_IRGRP S_IRGRP
349 #define POSIX_S_IWGRP S_IWGRP
350 #define POSIX_S_IROTH S_IROTH
351 #define POSIX_S_IWOTH S_IWOTH
352 
353 #define POSIX_F_GETFL F_GETFL
354 #define POSIX_F_SETFL F_SETFL
355 #define POSIX_F_WRLCK F_WRLCK
356 #define POSIX_F_SETLK F_SETLK
357 #define POSIX_F_SETFD F_SETFD
358 
359 #define POSIX_STDIN_FILENO STDIN_FILENO
360 #define POSIX_STDOUT_FILENO STDOUT_FILENO
361 
362 #define POSIX_DIR DIR
363 
364 #define POSIX_S_ISREG S_ISREG
365 #define POSIX_S_ISDIR S_ISDIR
366 
367 #define posix_mode_t mode_t
368 #define struct_posix_flock struct flock
369 #define struct_posix_stat struct stat
370 #define struct_posix_dirent struct dirent
371 
372 #define posix_dup2 dup2
373 #define posix_pipe pipe
374 #define posix_unlink unlink
375 #define posix_rename rename
376 #define posix_open open
377 #define posix_fdopen fdopen
378 #define posix_close close
379 #define posix_lseek lseek
380 #define posix_read read
381 #define posix_write write
382 #define posix_fcntl fcntl
383 #define posix_fgetc fgetc
384 #define posix_mkdir mkdir
385 #define posix_rmdir rmdir
386 #define posix_opendir opendir
387 #define posix_readdir readdir
388 #define posix_closedir closedir
389 #define posix_stat stat
390 
391 #if CFG_USE_POSIX_API >= 200112 || CFG_USE_XSI
392 # define posix_ftruncate ftruncate
393 # define posix_lstat lstat
394 # define posix_symlink symlink
395 #endif /* CFG_USE_POSIX_API >= 200112 || CFG_USE_XSI */
396 
397 /* Included into POSIX.1 since Issue 7 */
398 #if CFG_USE_POSIX_API >= 200809 || CFG_USE_XSI
399 # define posix_mkstemp mkstemp
400 #else /* CFG_USE_POSIX_API >= 200809 || CFG_USE_XSI */
401 int posix_mkstemp(char*);
402 #endif /* CFG_USE_POSIX_API >= 200809 || CFG_USE_XSI */
403 
404 #if CFG_USE_POSIX_API >= 200809
405 # define posix_scandir scandir
406 #else /* CFG_USE_POSIX_API >= 200809 */
407 int posix_scandir(const char*, struct_posix_dirent***,
408  int (*sel)(struct_posix_dirent*),
409  int (*compar)(const struct_posix_dirent**,
410  const struct_posix_dirent**));
411 #endif /* CFG_USE_POSIX_API >= 200809 */
412 
413 
414 /* ========================================================================== */
415 /* System limits */
416 
417 # define POSIX_PC_NAME_MAX _PC_NAME_MAX
418 # define POSIX_PC_PATH_MAX _PC_PATH_MAX
419 
420 # define posix_pathconf pathconf
421 
422 
423 /* ========================================================================== */
424 /* NLS */
425 
426 #if CFG_USE_POSIX_API >= 200112 || CFG_USE_XSI
427 # include <locale.h>
428 
429 # define POSIX_LC_ALL LC_ALL
430 # define POSIX_LC_CTYPE LC_CTYPE
431 # define POSIX_LC_MESSAGES LC_MESSAGES
432 
433 # define posix_setlocale setlocale
434 #endif /* CFG_USE_POSIX_API >= 200112 || CFG_USE_XSI */
435 
436 #if CFG_USE_POSIX_API >= 200809 || CFG_USE_XSI
437 # include <nl_types.h>
438 # include <langinfo.h>
439 
440 # define POSIX_NL_MSGMAX NL_MSGMAX
441 # define POSIX_NL_CAT_LOCALE NL_CAT_LOCALE
442 
443 # define posix_nl_catd nl_catd
444 
445 # define posix_nl_langinfo nl_langinfo
446 # define posix_catopen catopen
447 # define posix_catgets catgets
448 # define posix_catclose catclose
449 #endif /* CFG_USE_POSIX_API >= 200809 || CFG_USE_XSI */
450 
451 /* These functions are part of POSIX.1 since Issue 7 */
452 #if CFG_USE_POSIX_API >= 200809
453 # include <strings.h>
454 
455 # define POSIX_LC_CTYPE_MASK LC_CTYPE_MASK
456 
457 # define posix_locale_t locale_t
458 
459 # define posix_newlocale newlocale
460 # define posix_freelocale freelocale
461 # define posix_strcasecmp_l strcasecmp_l
462 # define posix_strncasecmp_l strncasecmp_l
463 #else /* CFG_USE_POSIX_API >= 200809 */
464 # define POSIX_LC_CTYPE_MASK 0
465 
466 typedef int posix_locale_t;
467 
468 posix_locale_t posix_newlocale(int, const char*, posix_locale_t);
469 void posix_freelocale(posix_locale_t);
470 int posix_strcasecmp_l(const char*, const char*, posix_locale_t);
471 int posix_strncasecmp_l(const char*, const char*, size_t, posix_locale_t);
472 #endif /* CFG_USE_POSIX_API >= 200809 */
473 
474 
475 /* ========================================================================== */
476 /* BSD socket interface (XNS) */
477 
478 /*
479  * If the system report the IP6 option as available, we expect that it provides
480  * XNS too (logical OR)
481  */
482 #if CFG_USE_POSIX_API >= 200112 || CFG_USE_XSI || CFG_USE_IP6
483 # include <netinet/in.h>
484 # include <arpa/inet.h>
485 
486 # define POSIX_AF_UNSPEC AF_UNSPEC
487 # define POSIX_AF_INET AF_INET
488 # if CFG_USE_IP6
489 # define POSIX_AF_INET6 AF_INET6
490 # endif /* CFG_USE_IP6 */
491 
492 # define POSIX_MSG_PEEK MSG_PEEK
493 
494 # define posix_ssize_t ssize_t
495 
496 /* Some systems that claim to be SUSv2 conformant don't define 'in_addr_t' */
497 # if CFG_HDR_INTTYPES_H
498 # include <inttypes.h>
499 typedef uint16_t posix_in_port_t;
500 typedef uint32_t posix_in_addr_t;
501 # else /* CFG_HDR_INTTYPES_H */
502 typedef CFG_UINT16_TYPE posix_in_port_t;
503 typedef CFG_UINT32_TYPE posix_in_addr_t;
504 # endif /* CFG_HDR_INTTYPES_H */
505 
506 # define struct_posix_in_addr struct in_addr
507 # define struct_posix_sockaddr_in struct sockaddr_in
508 
509 # if CFG_USE_IP6
510 # define struct_posix_in6_addr struct in6_addr
511 # define struct_posix_sockaddr_in6 struct sockaddr_in6
512 # endif /* CFG_USE_IP6 */
513 
514 /* Bug in NetBSD: Declarations not exposed for POSIX.1-2001 without XSI */
515 # define posix_htons htons
516 # define posix_htonl htonl
517 # define posix_ntohs ntohs
518 # define posix_ntohl ntohl
519 
520 # define posix_inet_addr inet_addr
521 # if CFG_USE_POSIX_API >= 200112
522 # define posix_inet_pton inet_pton
523 # else /* CFG_USE_POSIX_API >= 200112 */
524 int posix_inet_pton(int, const char*, void*);
525 # endif /* CFG_USE_POSIX_API >= 200112 */
526 
527 # include <sys/socket.h>
528 
529 # define posix_sa_family_t sa_family_t
530 # define posix_socklen_t socklen_t
531 
532 /*
533  * 'struct sockaddr_storage' is broken on AIX (see documentation)
534  * Currently there is no workaround provided by this module
535  */
536 # define struct_posix_sockaddr_storage struct sockaddr_storage
537 # define struct_posix_sockaddr struct sockaddr
538 
539 # define struct_posix_servent struct servent
540 # define struct_posix_hostent struct hostent
541 
542 # define posix_getservbyname getservbyname
543 
544 # if CFG_USE_POSIX_API >= 200809
545  /*
546  * gethostbyname() is marked obsolete in POSIX.1 Issue 6
547  * and was removed with Issue 7.
548  * No replacement is implemented, use getaddrinfo() instead.
549  */
550 # else /* CFG_USE_POSIX_API >= 200809 */
551 # define posix_gethostbyname gethostbyname
552 # endif /* CFG_USE_POSIX_API >= 200809 */
553 
554 # define posix_socket socket
555 
556 # define POSIX_SOCK_STREAM SOCK_STREAM
557 
558 # define posix_connect connect
559 
560 # define POSIX_SOL_SOCKET SOL_SOCKET
561 
562 # define POSIX_SO_ERROR SO_ERROR
563 # define POSIX_SO_RCVTIMEO SO_RCVTIMEO
564 # define POSIX_SO_SNDTIMEO SO_SNDTIMEO
565 
566 # define posix_getsockopt getsockopt
567 # define posix_setsockopt setsockopt
568 
569 # define posix_send send
570 # define posix_recv recv
571 
572 # include <poll.h>
573 
574 # define POSIX_POLLIN POLLIN
575 # define POSIX_POLLOUT POLLOUT
576 # define POSIX_POLLERR POLLERR
577 
578 # define struct_posix_pollfd struct pollfd
579 
580 # define posix_poll poll
581 #else /* CFG_USE_POSIX_API >= 200112 || CFG_USE_XSI || CFG_USE_IP6 */
582 # /* Use wrappers for original BSD socket API */
583 # define BSD_FOR_POSIX
584 # include "bsd.h"
585 #endif /* CFG_USE_POSIX_API >= 200112 || CFG_USE_XSI || CFG_USE_IP6 */
586 
587 
588 /* ========================================================================== */
589 /* Address information */
590 
591 #include <netdb.h>
592 
593 /*
594  * If the system report the IP6 option as available, we expect that it provides
595  * the POSIX.1g API too (logical OR)
596  *
597  * Attention: This subsystem is emulated using 'gethostbyname()':
598  * This function was marked obsolete by POSIX.1-2001 and was eventually removed
599  * in POSIX.1-2008 => The emulation can no longer be used since POSIX.1-2008
600  * (even for IPv4).
601  */
602 #if CFG_USE_POSIX_API >= 200112 || CFG_USE_IP6
603 # define POSIX_AI_ADDRCONFIG AI_ADDRCONFIG
604 
605 # define POSIX_EAI_AGAIN EAI_AGAIN
606 # define POSIX_EAI_BADFLAGS EAI_BADFLAGS
607 # define POSIX_EAI_FAIL EAI_FAIL
608 # define POSIX_EAI_FAMILY EAI_FAMILY
609 # define POSIX_EAI_MEMORY EAI_MEMORY
610 # define POSIX_EAI_NONAME EAI_NONAME
611 # define POSIX_EAI_OVERFLOW EAI_OVERFLOW
612 # define POSIX_EAI_SERVICE EAI_SERVICE
613 # define POSIX_EAI_SOCKTYPE EAI_SOCKTYPE
614 # define POSIX_EAI_SYSTEM EAI_SYSTEM
615 
616 # define struct_posix_addrinfo struct addrinfo
617 
618 # define posix_freeaddrinfo freeaddrinfo
619 # define posix_getaddrinfo getaddrinfo
620 # define posix_gai_strerror gai_strerror
621 #else /* CFG_USE_POSIX_API >= 200112 || CFG_USE_IP6 */
622 # define POSIX_AI_ADDRCONFIG 0x0001
623 
624 # define POSIX_EAI_AGAIN -1
625 # define POSIX_EAI_BADFLAGS -2
626 # define POSIX_EAI_FAIL -3
627 # define POSIX_EAI_FAMILY -4
628 # define POSIX_EAI_MEMORY -5
629 # define POSIX_EAI_NONAME -6
630 # define POSIX_EAI_OVERFLOW -7
631 # define POSIX_EAI_SERVICE -8
632 # define POSIX_EAI_SOCKTYPE -9
633 # define POSIX_EAI_SYSTEM -10
634 
635 struct posix_addrinfo
636 {
637  int ai_flags;
638  int ai_family;
639  int ai_socktype;
640  int ai_protocol;
641  posix_socklen_t ai_addrlen;
642  struct_posix_sockaddr* ai_addr;
643  char* ai_canonname;
644  struct posix_addrinfo* ai_next;
645 };
646 
647 # define struct_posix_addrinfo struct posix_addrinfo
648 
649 void posix_freeaddrinfo(struct_posix_addrinfo*);
650 int posix_getaddrinfo(const char*, const char*, const struct_posix_addrinfo*,
651  struct_posix_addrinfo**);
652 const char* posix_gai_strerror(int);
653 #endif /* CFG_USE_POSIX_API >= 200112 || CFG_USE_IP6 */
654 
655 
656 /* ========================================================================== */
657 /* Standard I/O */
658 
659 #include <stdarg.h>
660 #include <string.h>
661 #include <stdio.h>
662 
663 /*
664  * Available since POSIX.1-2001.
665  * Attention: The version in SUSv2 is not sufficient (different semantics)!
666  */
667 #if CFG_USE_POSIX_API >= 200112
668 # define posix_snprintf snprintf
669 #else /* CFG_USE_POSIX_API >= 200112 */
670 int posix_snprintf(char*, size_t, const char*, ...);
671 #endif /* CFG_USE_POSIX_API >= 200112 */
672 
673 /* Part of POSIX.1 since Issue 7 */
674 #if CFG_USE_POSIX_API >= 200809
675 # define posix_getline getline
676 #else /* CFG_USE_POSIX_API >= 200809 */
677 posix_ssize_t posix_getline(char**, size_t*, FILE*);
678 #endif /* CFG_USE_POSIX_API >= 200809 */
679 
680 
681 /* ========================================================================== */
682 /* Regular expression matching */
683 
684 #if CFG_USE_POSIX_API >= 200112 || CFG_USE_XSI || CFG_USE_CLB
685 # include <regex.h>
686 
687 # define POSIX_REG_EXTENDED REG_EXTENDED
688 # define POSIX_REG_ICASE REG_ICASE
689 # define POSIX_REG_NOSUB REG_NOSUB
690 # define POSIX_REG_NEWLINE REG_NEWLINE
691 
692 # define posix_regex_t regex_t
693 
694 # define posix_regcomp regcomp
695 # define posix_regerror regerror
696 # define posix_regexec regexec
697 # define posix_regfree regfree
698 #endif /* CFG_USE_POSIX_API >= 200112 || CFG_USE_XSI || CFG_USE_CLB */
699 
700 
701 /* EOF */

Generated at 2024-04-27 using  doxygen