1 /* 2 * ---------------------------------------------------------------- 3 * System Headers Includes 4 * ---------------------------------------------------------------- 5 * Copyright (C) 1997-2009 Jonas Kvinge 6 * 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU Lesser General Public License as 9 * published by the Free Software Foundation, either version 3 of the 10 * License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public License 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * 20 * $Id: headers.h 54 2009-03-18 18:23:29Z jonasio $ 21 * 22 */ 23 24 #ifdef HEADERS_H 25 #warning "headers.h already included." 26 #else 27 #define HEADERS_H 28 29 #if OS_HPUNIX 30 #define _XOPEN_SOURCE_EXTENDED 31 #endif 32 33 #ifndef NEED_SYS_TYPES_H 34 #define NEED_SYS_TYPES_H 1 35 #endif 36 #ifndef NEED_SYS_PARAM_H 37 #define NEED_SYS_PARAM_H 1 38 #endif 39 #ifndef NEED_LIMITS_H 40 #define NEED_LIMITS_H 0 41 #endif 42 #ifndef NEED_STDARG_H 43 #define NEED_STDARG_H 1 44 #endif 45 #ifndef NEED_ERRNO_H 46 #define NEED_ERRNO_H 1 47 #endif 48 #ifndef NEED_CTYPE_H 49 #define NEED_CTYPE_H 1 50 #endif 51 #ifndef NEED_NETINET_IN_H 52 #define NEED_NETINET_IN_H 0 53 #endif 54 #ifndef NEED_STDIO_H 55 #define NEED_STDIO_H 1 56 #endif 57 #ifndef NEED_STDLIB_H 58 #define NEED_STDLIB_H 1 59 #endif 60 #ifndef NEED_TIME_H 61 #define NEED_TIME_H 1 62 #endif 63 #ifndef NEED_SYS_STAT_H 64 #define NEED_SYS_STAT_H 0 65 #endif 66 #ifndef NEED_SYS_UIO_H 67 #define NEED_SYS_UIO_H 0 68 #endif 69 #ifndef NEED_FCNTL_H 70 #define NEED_FCNTL_H 0 71 #endif 72 #ifndef NEED_SYS_IOCTL_H 73 #define NEED_SYS_IOCTL_H 0 74 #endif 75 #ifndef NEED_SYS_FILIO_H 76 #define NEED_SYS_FILIO_H 0 77 #endif 78 #ifndef NEED_UNISTD_H 79 #define NEED_UNISTD_H 1 80 #endif 81 #ifndef NEED_STRING_H 82 #define NEED_STRING_H 1 83 #endif 84 #ifndef NEED_SIGNAL_H 85 #define NEED_SIGNAL_H 0 86 #endif 87 #ifndef NEED_ARPA_INET_H 88 #define NEED_ARPA_INET_H 0 89 #endif 90 #ifndef NEED_SYS_SOCKET_H 91 #define NEED_SYS_SOCKET_H 0 92 #endif 93 #ifndef NEED_NETDB_H 94 #define NEED_NETDB_H 0 95 #endif 96 #ifndef NEED_SYSCTL_H 97 #define NEED_SYSCTL_H 0 98 #endif 99 #ifndef NEED_ARPA_NAMESER_H 100 #define NEED_ARPA_NAMESER_H 0 101 #endif 102 #ifndef NEED_GETUSERPW_HEADERS 103 #define NEED_GETUSERPW_HEADERS 0 104 #endif 105 106 /* 107 * <sys/types.h> 108 * 109 * size_t, time_t, pid_t, uid_t, gid_t, socklen_t, off_t quad_t 110 * FD_SETSIZE, FD_SET(), FD_CLR(), FD_ISSET(), FD_COPY(), FD_ZERO() 111 * 112 */ 113 #if NEED_SYS_TYPES_H 114 #if HAVE_SYS_TYPES_H 115 #include <sys/types.h> 116 #else 117 #warning "This system does not have sys/types.h" 118 #endif 119 #endif 120 121 122 /* 123 * <sys/param.h> 124 * 125 * Some systems need this file. 126 * 127 */ 128 #if NEED_SYS_PARAM_H 129 #if HAVE_SYS_PARAM_H 130 #include <sys/param.h> 131 #else 132 #warning "This system does not have sys/param.h" 133 #endif 134 #endif 135 136 137 /* 138 * <limits.h> 139 * 140 */ 141 #if NEED_LIMITS_H 142 #if HAVE_LIMITS_H 143 #include <limits.h> 144 #else 145 #warning "This system does not have limits.h!" 146 #endif 147 #endif 148 149 150 /* 151 * <stdarg.h> 152 * 153 * va_list, va_start, va_arg, va_end 154 * 155 */ 156 #if NEED_STDARG_H 157 #if HAVE_STDARG_H 158 #include <stdarg.h> 159 #else 160 #warning "This system does not have stdarg.h!" 161 #endif 162 #endif 163 164 165 /* 166 * <errno.h> 167 * 168 * errno 169 * 170 */ 171 #if NEED_ERRNO_H 172 #if HAVE_ERRNO_H 173 #include <errno.h> 174 #else 175 #warning "This system does not have errno.h!" 176 #endif 177 #endif 178 179 180 /* 181 * <ctype.h> 182 * 183 * isalnum(), isalpha(), iscntrl(), isdigit(), isgraph(), islower(), isprint(), ispunct(), isspace(), isupper(), isxdigit(), tolower(), toupper() 184 * digittoint(), isascii(), isblank(), ishexnumber(), isideogram(), isnumber(), isphonogram(), isrune(), isspecial(), toascii() 185 * 186 */ 187 #if NEED_CTYPE_H 188 #if HAVE_CTYPE_H 189 #include <ctype.h> 190 #else 191 #warning "This system does not have ctype.h!" 192 #endif 193 #endif 194 195 196 /* 197 * <netinet/in.h> Definitions for third level IPv4/IPv6 identifiers and fourth level IPv4/v6 identifiers 198 * 199 * struct in_addr, struct sockaddr_in 200 * 201 */ 202 #if NEED_NETINET_IN_H 203 #if HAVE_NETINET_IN_H 204 #include <netinet/in.h> 205 #else 206 #warning "This system does not have netinet/in.h!" 207 #endif 208 #endif 209 210 211 /* 212 * <stdio.h> 213 * 214 * FILE, BUFSIZ, EOF, stdin, stdout, stderr 215 * 216 * fopen(), fdopen(), freopen(), fclose(), fflush(), fpurge(), fread(), fwrite(), fgets(), gets() 217 * printf(), fprintf(), sprintf(), snprintf(), asprintf(), vprintf(), vfprintf(), vsprintf(), vsnprintf(), vasprintf() 218 * scanf(), fscanf(), sscanf(), vscanf(), vsscanf(), vfscanf() 219 * clearerr(), feof(), ferror(), fileno() 220 * fgetc(), getc(), getchar(), getw() 221 * fputc(), putc(), putchar(), putw() 222 * ungetc() 223 * fseek(), ftell(), rewind(), fgetpos(), fsetpos(), fseeko(), ftello() 224 * setbuf(), setbuffer(), setlinebuf(), setvbuf() 225 * perror() 226 * remove(), rename() 227 * tmpfile(), tmpnam(), tempnam() 228 * ctermid(), ctermid_r() 229 * fgetln() 230 * fmtcheck() 231 * popen(), pclose() 232 * funopen(), fropen(), fwopen() 233 * 234 */ 235 #if NEED_STDIO_H 236 #if HAVE_STDIO_H 237 #include <stdio.h> 238 #else 239 #warning "This system does not have stdio.h!" 240 #endif 241 #endif 242 243 244 /* 245 * <stdlib.h> 246 * 247 * NULL, EXIT_FAILURE, EXIT_SUCCESS 248 * 249 * exit(), abort(), atexit() 250 * atof(), atoi(), atol() 251 * strtod(), strtol(), strtoll(), strtoul(), strtoull() strtoq() strtouq() 252 * malloc(), calloc(), realloc(), reallocf(), free() 253 * labs(), abs(), div(), ldiv(), math() 254 * bsearch(), lsearch(), qsort(), heapsort(), mergesort() 255 * rand(), srand(), rand_r() 256 * random(), srandom(), srandomdev(), initstate(), setstate() 257 * system(), daemon(), devname(), getloadavg(), getprogname(), setprogname() 258 * getenv(), setenv(), putenv(), unsetenv() 259 * mblen(), mbstowcs(), mbtowc(), wcstombs(), wctomb() 260 * getbsize() 261 * cgetent(), cgetset(), cgetmatch(), cgetcap(), cgetnum(), cgetstr(), cgetustr(), cgetfirst(), cgetnext(), cgetclose() 262 * radixsort(), sradixsort() 263 * realpath() 264 * user_from_uid(), group_from_gid() 265 * 266 */ 267 #if NEED_STDLIB_H 268 #if HAVE_STDLIB_H 269 #include <stdlib.h> 270 #else 271 #warning "This system does not have stdlib.h!" 272 #endif 273 #endif 274 275 276 /* 277 * <time.h> / <sys/time.h> 278 * 279 * struct tm, struct timeval, struct timespec, struct timecounter, struct itimerval, struct clockinfo 280 * 281 * microtime(), getmicrotime(), nanotime(), getnanotime() 282 * microuptime(), getmicrouptime(), nanouptime(), getnanouptime() 283 * time(), tvtohz(), clock() 284 * adjtime() 285 * utimes(), lutimes(), futimes() 286 * getitimer(), setitimer() 287 * gettimeofday(), settimeofday() 288 * ctime(), difftime(), asctime(), localtime(), gmtime(), mktime(), timegm(), ctime_r(), localtime_r(), gmtime_r(), asctime_r() 289 * strftime(), strptime() 290 * timezone() 291 * tzset(), tzsetwall() 292 * clock_getres(), clock_gettime(), clock_settime() 293 * nanosleep() 294 * 295 */ 296 #if NEED_TIME_H 297 #if TIME_WITH_SYS_TIME 298 #include <sys/time.h> 299 #include <time.h> 300 #else 301 #if HAVE_SYS_TIME_H 302 #include <sys/time.h> 303 #else 304 #include <time.h> 305 #endif 306 #endif 307 #endif 308 309 310 /* 311 * <sys/stat.h> 312 * 313 * chmod(), fchmod(), lchmod() 314 * stat(), lstat(), fstat() 315 * mkdir(), mkfifo(), umask() 316 * chflags(), fchflags() 317 * 318 */ 319 #if NEED_SYS_STAT_H 320 #if HAVE_SYS_STAT_H 321 #include <sys/stat.h> 322 #else 323 #warning "This system does not have sys/stat.h!" 324 #endif 325 #endif 326 327 328 /* 329 * <sys/uio.h> 330 * 331 * struct iovec, struct uio 332 * 333 * uiomove() 334 * 335 */ 336 #if NEED_SYS_UIO_H 337 #if HAVE_SYS_UIO_H 338 #include <sys/uio.h> 339 #else 340 #warning "This system does not have sys/uio.h!" 341 #endif 342 #endif 343 344 345 /* 346 * <fcntl.h> 347 * 348 * open(), creat(), fcntl() 349 * 350 * 351 */ 352 #if NEED_FCNTL_H 353 #if HAVE_FCNTL_H 354 #include <fcntl.h> 355 #else 356 #warning "This system does not have fcntl.h!" 357 #endif 358 #endif 359 360 361 /* 362 * <sys/ioctl.h> 363 * 364 * ioctl() 365 * 366 * 367 */ 368 #if NEED_SYS_IOCTL_H 369 #if HAVE_SYS_IOCTL_H 370 #include <sys/ioctl.h> 371 #else 372 #warning "This system does not have sys/ioctl.h!" 373 #endif 374 #endif 375 376 377 /* 378 * <sys/filio.h> 379 * 380 * Solaris need this for ioctl() 381 * 382 * 383 */ 384 #if NEED_SYS_FILIO_H 385 #if HAVE_SYS_FILIO_H 386 #include <sys/filio.h> 387 #endif 388 #endif 389 390 391 /* 392 * <unistd.h> 393 * 394 * STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO 395 * 396 * getopt(), getsubopt() 397 * pause(), sleep(), usleep() 398 * alarm(), ualarm() 399 * _exit() 400 * access() 401 * chdir(), fchdir(), rmdir() 402 * chown(), fchown(), lchown() 403 * execl(), execlp(), execle(), exect(), execv(), execvp() 404 * pipe() 405 * read(), readv(), pread() 406 * write(), writev(), pwrite() 407 * dup(), dup2(), close(), select() 408 * revoke(), lockf(), lseek() 409 * valloc() 410 * fork(), rfork(), rfork_thread(), vfork() 411 * getpid(), getppid() 412 * getdomainname(), setdomainname(), gethostid(), sethostid(), gethostname(), sethostname(), getlogin_r(), setlogin(), getusershell(), setusershell(), endusershell() 413 * getcwd(), getwd(), chroot() 414 * sysconf(), pathconf(), fpathconf() 415 * getuid(), geteuid(), getgid(), getegid() 416 * setuid(), seteuid(), setgid(), setegid() 417 * setruid(), setrgid(), setreuid(), setregid(), setresgid(), setresuid() 418 * issetugid() 419 * initgroups(), getgrouplist(), getgroups(), getlogin(), getlogin_r(), setlogin() 420 * getpgrp(), getpgid(), getpid(), getppid() 421 * setpgid(), setpgrp() 422 * setproctitle() 423 * getsid(), setsid() 424 * ttyname(), isatty(), ttyslot() 425 * link(), unlink(), readlink(), symlink() 426 * tcgetpgrp(), tcsetpgrp() 427 * acct(), brk() 428 * confstr() 429 * getpass(), crypt(), crypt_get_format(), crypt_set_format() 430 * setkey(), encrypt(), des_setkey(), des_cipher() 431 * getusershell(), setusershell(), endusershell() 432 * fflagstostr(), strtofflags() 433 * fsync(), truncate(), ftruncate() 434 * getdtablesize() getpagesize() 435 * getmode(), setmode() 436 * getpeereid() 437 * rcmd(), rresvport(), iruserok(), ruserok(), rcmd_af(), rresvport_af(), iruserok_sa() 438 * rcmdsh 439 * mktemp(), mkstemp(), mkstemps(), mkdtemp() 440 * mknod() 441 * nfssvc() 442 * nice() 443 * profil() 444 * re_comp(), re_exec() 445 * swapon(), sync(), reboot() 446 * brk(), sbrk() 447 * syscall() 448 * undelete() 449 * 450 */ 451 #if NEED_UNISTD_H 452 #if HAVE_UNISTD_H 453 #include <unistd.h> 454 #else 455 #warning "This system does not have unistd.h!" 456 #endif 457 #endif 458 459 460 /* 461 * <string.h> 462 * 463 * memchr(), memcmp(), memcpy(), memmove(), memset() 464 * strchr(), strstr(), strpbrk(), strrchr(), strtok(), strtok_r(), strxfrm() 465 * strcat(), strncat() 466 * strcmp, strncmp(), strcpy, strncpy 467 * strcoll() 468 * strspn(), strcspn() 469 * strerror() 470 * strlen() 471 * 472 */ 473 #if NEED_STRING_H 474 #if HAVE_STRING_H 475 #include <string.h> 476 #else 477 #warning "This system does not have string.h!" 478 #endif 479 #endif 480 481 482 /* 483 * <signal.h> 484 * 485 * struct sigaction, sig_t 486 * 487 * raise(), kill(), killpg() 488 * signal(), sigaction(), sigpending(), sigprocmask(), sigsuspend(), sigwait() 489 * sigaltstack(), sigblock(), siginterrupt(), sigpause(), sigreturn(), sigsetmask(), sigstack(), sigvec(), psignal() 490 * sigemptyset(), sigfillset(), sigaddset(), sigdelset(), sigismember() 491 * 492 */ 493 #if NEED_SIGNAL_H 494 #if HAVE_SIGNAL_H 495 #include <signal.h> 496 #else 497 #warning "This system does not have errno.h!" 498 #endif 499 #endif 500 501 502 /* 503 * <arpa/inet.h> 504 * 505 * inet_addr(), inet_aton(), inet_lnaof(), inet_makeaddr(), inet_neta(), inet_netof(), inet_network() 506 * inet_net_ntop(), inet_net_pton(), inet_ntoa(), inet_pton(), inet_ntop(), inet_nsap_addr(), inet_nsap_ntoa() 507 * 508 */ 509 #if NEED_ARPA_INET_H 510 #if HAVE_ARPA_INET_H 511 #include <arpa/inet.h> 512 #else 513 #warning "This system does not have arpa/inet.h!" 514 #endif 515 #endif 516 517 518 /* 519 * <sys/socket.h> Definitions for second level network identifiers 520 * 521 * struct sockaddr 522 * 523 * socket(), bind(), connect(), listen(), accept() 524 * getpeername(), getsockname(), getsockopt() 525 * recv(), recvfrom(), recvmsg(), send(), sendto(), sendmsg() 526 * sendfile(), shutdown(), socketpair() 527 * 528 */ 529 #if NEED_SYS_SOCKET_H 530 #if HAVE_SYS_SOCKET_H 531 #include <sys/socket.h> 532 #else 533 #warning "This system does not have sys/socket.h!" 534 #endif 535 #endif 536 537 538 /* 539 * <netdb.h> 540 * 541 * h_errno 542 * struct hostent, struct netent, struct servent, struct protoent, struct addrinfo 543 * 544 * gethostbyname(), gethostbyname2(), gethostbyaddr(), gethostent(), sethostent(), endhostent(), herror(), hstrerror() 545 * getnetent(), getnetbyname(), getnetbyaddr(), setnetent(), endnetent() 546 * getnetgrent(), innetgr(), setnetgrent(), endnetgrent() 547 * getprotoent(), getprotobyname(), getprotobynumber(), setprotoent(), endprotoent() 548 * getservent(), getservbyname(), getservbyport(), setservent(), endservent() 549 * getipnodebyname(), getipnodebyaddr(), freehostent() 550 * getaddrinfo(), freeaddrinfo(), gai_strerror() 551 * getnameinfo() 552 * 553 */ 554 #if NEED_NETDB_H 555 #if HAVE_NETDB_H 556 #include <netdb.h> 557 #else 558 #warning "This system does not have netdb.h!" 559 #endif 560 #endif 561 562 563 /* 564 * 565 * <sys/sysctl.h> Definitions for top level identifiers, second level kernel and hardware identifiers, and user level identifiers 566 * 567 * sysctl_add_oid(), sysctl_remove_oid() 568 * sysctl_ctx_init(), sysctl_ctx_free(), sysctl_ctx_entry_add(), sysctl_ctx_entry_find(), sysctl_ctx_entry_del() 569 * sysctl(), sysctlbyname(), sysctlnametomib() 570 * 571 */ 572 #if NEED_SYSCTL_H 573 #if HAVE_SYS_SYSCTL_H 574 #include <sys/sysctl.h> 575 #else 576 #warning "This system does not have sys/sysctl.h!" 577 #endif 578 #endif 579 580 581 /* 582 * <arpa/nameser.h> 583 * 584 * Nameserver stuff needed for Ares. 585 * 586 */ 587 #if NEED_ARPA_NAMESER_H 588 #if HAVE_ARPA_NAMESER_H 589 #include <arpa/nameser.h> 590 #else 591 #warning "This system does not have arpa/nameser.h!" 592 #endif 593 #endif 594 595 596 /* 597 * <crypt.h> 598 * 599 * 600 * 601 */ 602 #if NEED_CRYPT && HAVE_CRYPT_H 603 #include <crypt.h> 604 #endif 605 606 607 /* 608 * <assert.h> 609 * 610 */ 611 #if USE_ASSERT && HAVE_ASSERT_H 612 #include <assert.h> 613 #else 614 #warning "!!! NOT USING ASSERTIONS !!!" 615 #define assert(X) 616 #endif 617 618 /* 619 * Stuff we need to retrive system passwords. 620 * This might not work on all systems. 621 * 622 */ 623 #if NEED_GETUSERPW_HEADERS 624 625 #if HAVE_PWD_H 626 #include <pwd.h> 627 #endif 628 629 #if HAVE_PROT_H 630 #include <prot.h> 631 #endif 632 633 #if HAVE_SHADOW_H 634 #include <shadow.h> 635 #endif 636 637 #if HAVE_USERPW_H 638 #include <userpw.h> 639 #endif 640 641 #if HAVE_HPSECURITY_H 642 #include <hpsecurity.h> 643 #endif 644 645 #endif 646 647 /* 648 * Stuff needed for ares functions 649 */ 650 651 #if ARES && NEED_ARES && HAVE_ARES_H 652 #include <ares.h> 653 #if HAVE_ARES_VERSION_H 654 #include <ares_version.h> 655 #endif 656 #endif 657 658 659 /* 660 * MySQL 661 * 662 * 663 */ 664 665 #if NEED_SSL && HAVE_MYSQL_MYSQL_H 666 #include <mysql/mysql.h> 667 #endif 668 669 670 /* 671 * Stuff needed for SSL support 672 * 673 * 674 */ 675 676 #if SSL_SUPPORT && NEED_SSL 677 678 #if defined(HAVE_GNUTLS) 679 680 #include <gnutls/openssl.h> 681 682 #elif defined(HAVE_OPENSSL) 683 684 #if HAVE_OPENSSL_X509_H 685 #include <openssl/x509.h> 686 #endif 687 #if HAVE_OPENSSL_SSL_H 688 #include <openssl/ssl.h> 689 #endif 690 #if HAVE_OPENSSL_ERR_H 691 #include <openssl/err.h> 692 #endif 693 694 #endif 695 696 #endif 697 698 /* 699 * Memory debugging 700 * 701 */ 702 703 #if MEMDEBUG 704 #if HAVE_MEMCALLS_H 705 #include <memcalls.h> 706 #else 707 #include "memcalls.h" 708 #endif 709 #if 0 710 #include "memlist.h" 711 #endif 712 #endif 713 714 /* 715 * FD debugging 716 * 717 */ 718 719 #if FDDEBUG 720 #if HAVE_FDCALLS_H 721 #include <fdcalls.h> 722 #else 723 #include "fdcalls.h" 724 #endif 725 #endif 726 727 #endif 728