portab.h 3.2 KB

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