portab.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * ngIRCd -- The Next Generation IRC Daemon
  3. * Copyright (c)2001-2005 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. * $Id: portab.h,v 1.22 2005/07/31 20:13:11 alex Exp $
  12. *
  13. * Portability functions and declarations (header for libngbportab).
  14. */
  15. #ifndef __PORTAB__
  16. #define __PORTAB__
  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. #undef GLOBAL
  83. #define GLOBAL
  84. /* SPLint */
  85. #ifdef S_SPLINT_S
  86. #include "splint.h"
  87. #endif
  88. /* target constants */
  89. #ifndef TARGET_OS
  90. #define TARGET_OS "unknown"
  91. #endif
  92. #ifndef TARGET_CPU
  93. #define TARGET_CPU "unknown"
  94. #endif
  95. #ifndef TARGET_VENDOR
  96. #define TARGET_VENDOR "unknown"
  97. #endif
  98. /* configure options */
  99. #ifndef HAVE_socklen_t
  100. typedef int socklen_t; /* for Mac OS X, amongst others */
  101. #endif
  102. #ifndef HAVE_SNPRINTF
  103. extern int snprintf PARAMS(( char *str, size_t count, const char *fmt, ... ));
  104. #endif
  105. #ifndef HAVE_STRLCAT
  106. extern size_t strlcat PARAMS(( char *dst, const char *src, size_t size ));
  107. #endif
  108. #ifndef HAVE_STRLCPY
  109. extern size_t strlcpy PARAMS(( char *dst, const char *src, size_t size ));
  110. #endif
  111. #ifndef HAVE_STRDUP
  112. extern char * strdup PARAMS(( const char *s ));
  113. #endif
  114. #ifndef HAVE_VSNPRINTF
  115. #include <stdarg.h>
  116. extern int vsnprintf PARAMS(( char *str, size_t count, const char *fmt, va_list args ));
  117. #endif
  118. #ifndef PACKAGE_NAME
  119. #define PACKAGE_NAME PACKAGE
  120. #endif
  121. #ifndef PACKAGE_VERSION
  122. #define PACKAGE_VERSION VERSION
  123. #endif
  124. #endif
  125. /* -eof- */