portab.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. * ngIRCd -- The Next Generation IRC Daemon
  3. * Copyright (c)2001-2012 Alexander Barton (alex@barton.de) and Contributors.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. * Please read the file COPYING, README and AUTHORS for more information.
  10. */
  11. #ifndef __PORTAB__
  12. #define __PORTAB__
  13. /**
  14. * @file
  15. * Portability functions and declarations (header)
  16. */
  17. #include "config.h"
  18. #ifndef DEBUG
  19. # define NDEBUG
  20. #endif
  21. #ifdef HAVE_SYS_TYPES_H
  22. # include <sys/types.h>
  23. #endif
  24. #ifdef HAVE_INTTYPES_H
  25. # include <inttypes.h>
  26. # define NGIRC_GOT_INTTYPES
  27. #else
  28. # ifdef HAVE_STDINT_H
  29. # include <stdint.h>
  30. # define NGIRC_GOT_INTTYPES
  31. # endif
  32. #endif
  33. #ifdef HAVE_STDDEF_H
  34. # include <stddef.h>
  35. #endif
  36. #ifdef HAVE_STDBOOL_H
  37. # include <stdbool.h>
  38. #endif
  39. /* compiler features */
  40. #if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 7))
  41. # define PUNUSED(x) __attribute__ ((unused)) x
  42. # define UNUSED __attribute__ ((unused))
  43. #else
  44. # define PUNUSED(x) x
  45. # define UNUSED
  46. #endif
  47. #ifndef PARAMS
  48. # if PROTOTYPES
  49. # define PARAMS(args) args
  50. # else
  51. # define PARAMS(args) ()
  52. # endif
  53. #endif
  54. /* datatypes */
  55. #ifndef PROTOTYPES
  56. # ifndef signed
  57. # define signed
  58. # endif
  59. #endif
  60. typedef void POINTER;
  61. #ifdef NGIRC_GOT_INTTYPES
  62. typedef uint8_t UINT8;
  63. typedef uint16_t UINT16;
  64. typedef uint32_t UINT32;
  65. #else
  66. typedef unsigned char UINT8;
  67. typedef unsigned short UINT16;
  68. typedef unsigned int UINT32;
  69. #endif
  70. #ifndef HAVE_STDBOOL_H
  71. typedef unsigned char bool;
  72. #define true (bool)1
  73. #define false (bool)0
  74. #endif
  75. #ifndef NULL
  76. #ifdef PROTOTYPES
  77. # define NULL (void *)0
  78. #else
  79. # define NULL 0L
  80. #endif
  81. #endif
  82. #ifdef NeXT
  83. #define S_IRUSR 0000400 /* read permission, owner */
  84. #define S_IWUSR 0000200 /* write permission, owner */
  85. #define S_IRGRP 0000040 /* read permission, group */
  86. #define S_IROTH 0000004 /* read permission, other */
  87. #define ssize_t int
  88. #endif
  89. #undef GLOBAL
  90. #define GLOBAL
  91. /* SPLint */
  92. #ifdef S_SPLINT_S
  93. #include "splint.h"
  94. #endif
  95. /* target constants */
  96. #ifndef HOST_OS
  97. #define HOST_OS "unknown"
  98. #endif
  99. #ifndef HOST_CPU
  100. #define HOST_CPU "unknown"
  101. #endif
  102. #ifndef HOST_VENDOR
  103. #define HOST_VENDOR "unknown"
  104. #endif
  105. #ifdef __HAIKU__
  106. #define SINGLE_USER_OS
  107. #endif
  108. /* configure options */
  109. #ifndef HAVE_socklen_t
  110. typedef int socklen_t; /* for Mac OS X, amongst others */
  111. #endif
  112. #ifndef HAVE_SNPRINTF
  113. extern int snprintf PARAMS(( char *str, size_t count, const char *fmt, ... ));
  114. #endif
  115. #ifndef HAVE_STRLCAT
  116. extern size_t strlcat PARAMS(( char *dst, const char *src, size_t size ));
  117. #endif
  118. #ifndef HAVE_STRLCPY
  119. extern size_t strlcpy PARAMS(( char *dst, const char *src, size_t size ));
  120. #endif
  121. #ifndef HAVE_STRDUP
  122. extern char * strdup PARAMS(( const char *s ));
  123. #endif
  124. #ifndef HAVE_STRTOK_R
  125. extern char * strtok_r PARAMS((char *str, const char *delim, char **saveptr));
  126. #endif
  127. #ifndef HAVE_VSNPRINTF
  128. #include <stdarg.h>
  129. extern int vsnprintf PARAMS(( char *str, size_t count, const char *fmt, va_list args ));
  130. #endif
  131. #ifndef HAVE_GAI_STRERROR
  132. #define gai_strerror(r) "unknown error"
  133. #endif
  134. #ifndef PACKAGE_NAME
  135. #define PACKAGE_NAME PACKAGE
  136. #endif
  137. #ifndef PACKAGE_VERSION
  138. #define PACKAGE_VERSION VERSION
  139. #endif
  140. #endif
  141. /* -eof- */