portab.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /*
  2. * ngIRCd -- The Next Generation IRC Daemon
  3. * Copyright (c)2001-2014 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. /* compiler features */
  22. #if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 7))
  23. # define PUNUSED(x) __attribute__ ((unused)) x
  24. # define UNUSED __attribute__ ((unused))
  25. #else
  26. # define PUNUSED(x) x
  27. # define UNUSED
  28. #endif
  29. #ifndef PARAMS
  30. # if PROTOTYPES
  31. # define PARAMS(args) args
  32. # else
  33. # define PARAMS(args) ()
  34. # endif
  35. #endif
  36. /* datatypes */
  37. #include <sys/types.h>
  38. #ifdef HAVE_STDDEF_H
  39. # include <stddef.h>
  40. #endif
  41. #ifdef HAVE_INTTYPES_H
  42. # include <inttypes.h>
  43. # define NGIRC_GOT_INTTYPES
  44. #else
  45. # ifdef HAVE_STDINT_H
  46. # include <stdint.h>
  47. # define NGIRC_GOT_INTTYPES
  48. # endif
  49. #endif
  50. #ifndef PROTOTYPES
  51. # ifndef signed
  52. # define signed
  53. # endif
  54. #endif
  55. typedef void POINTER;
  56. #ifdef NGIRC_GOT_INTTYPES
  57. typedef uint8_t UINT8;
  58. typedef uint16_t UINT16;
  59. typedef uint32_t UINT32;
  60. #else
  61. typedef unsigned char UINT8;
  62. typedef unsigned short UINT16;
  63. typedef unsigned int UINT32;
  64. #endif
  65. #ifdef HAVE_STDBOOL_H
  66. # include <stdbool.h>
  67. #else
  68. typedef unsigned char bool;
  69. # define true (bool)1
  70. # define false (bool)0
  71. #endif
  72. #ifndef NULL
  73. # ifdef PROTOTYPES
  74. # define NULL (void *)0
  75. # else
  76. # define NULL 0L
  77. # endif
  78. #endif
  79. #ifdef NeXT
  80. # define S_IRUSR 0000400 /* read permission, owner */
  81. # define S_IWUSR 0000200 /* write permission, owner */
  82. # define S_IRGRP 0000040 /* read permission, group */
  83. # define S_IROTH 0000004 /* read permission, other */
  84. # define ssize_t int
  85. #endif
  86. #undef GLOBAL
  87. #ifdef GLOBAL_INIT
  88. #define GLOBAL
  89. #else
  90. #define GLOBAL extern
  91. #endif
  92. /* SPLint */
  93. #ifdef S_SPLINT_S
  94. # include "splint.h"
  95. #endif
  96. /* target constants */
  97. #ifndef HOST_OS
  98. # define HOST_OS "unknown"
  99. #endif
  100. #ifndef HOST_CPU
  101. # define HOST_CPU "unknown"
  102. #endif
  103. #ifndef HOST_VENDOR
  104. # define HOST_VENDOR "unknown"
  105. #endif
  106. #ifdef __HAIKU__
  107. # define SINGLE_USER_OS
  108. #endif
  109. /* configure options */
  110. #ifndef HAVE_socklen_t
  111. typedef int socklen_t; /* for Mac OS X, amongst others */
  112. #endif
  113. #ifndef HAVE_SNPRINTF
  114. extern int snprintf PARAMS(( char *str, size_t count, const char *fmt, ... ));
  115. #endif
  116. #ifndef HAVE_STRLCAT
  117. extern size_t strlcat PARAMS(( char *dst, const char *src, size_t size ));
  118. #endif
  119. #ifndef HAVE_STRLCPY
  120. extern size_t strlcpy PARAMS(( char *dst, const char *src, size_t size ));
  121. #endif
  122. #ifndef HAVE_STRDUP
  123. extern char * strdup PARAMS(( const char *s ));
  124. #endif
  125. #ifndef HAVE_STRNDUP
  126. extern char * strndup PARAMS((const char *s, size_t maxlen));
  127. #endif
  128. #ifndef HAVE_STRTOK_R
  129. extern char * strtok_r PARAMS((char *str, const char *delim, char **saveptr));
  130. #endif
  131. #ifndef HAVE_VSNPRINTF
  132. #include <stdarg.h>
  133. extern int vsnprintf PARAMS(( char *str, size_t count, const char *fmt, va_list args ));
  134. #endif
  135. #ifndef HAVE_GAI_STRERROR
  136. # define gai_strerror(r) "unknown error"
  137. #endif
  138. #ifndef PACKAGE_NAME
  139. # define PACKAGE_NAME PACKAGE
  140. #endif
  141. #ifndef PACKAGE_VERSION
  142. # define PACKAGE_VERSION VERSION
  143. #endif
  144. #ifndef SYSCONFDIR
  145. # define SYSCONFDIR "/etc"
  146. #endif
  147. #endif
  148. /* -eof- */