]> arthur.barton.de Git - ngircd-alex.git/blob - src/portab/portab.h
e30262d8e5d8914087c169150f58c2f0c07910c7
[ngircd-alex.git] / src / portab / portab.h
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
12 #ifndef __PORTAB__
13 #define __PORTAB__
14
15 /**
16  * @file
17  * Portability functions and declarations (header)
18  */
19
20 #include "config.h"
21
22 #ifndef DEBUG
23 # define NDEBUG
24 #endif
25
26 #ifdef HAVE_SYS_TYPES_H
27 # include <sys/types.h>
28 #endif
29
30 #ifdef HAVE_INTTYPES_H
31 # include <inttypes.h>
32 # define NGIRC_GOT_INTTYPES
33 #else
34 # ifdef HAVE_STDINT_H
35 #  include <stdint.h>
36 #  define NGIRC_GOT_INTTYPES
37 # endif
38 #endif
39
40 #ifdef HAVE_STDDEF_H
41 # include <stddef.h>
42 #endif
43
44 #ifdef HAVE_STDBOOL_H
45 # include <stdbool.h>
46 #endif
47
48 /* compiler features */
49
50 #if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 7))
51 # define PUNUSED(x) __attribute__ ((unused)) x
52 # define UNUSED     __attribute__ ((unused))
53 #else
54 # define PUNUSED(x) x
55 # define UNUSED
56 #endif
57
58 #ifndef PARAMS
59 # if PROTOTYPES
60 #  define PARAMS(args) args
61 # else
62 #  define PARAMS(args) ()
63 # endif
64 #endif
65
66 /* datatypes */
67
68 #ifndef PROTOTYPES
69 # ifndef signed
70 #  define signed
71 # endif
72 #endif
73
74 typedef void POINTER;
75
76 #ifdef NGIRC_GOT_INTTYPES
77 typedef uint8_t UINT8;
78 typedef uint16_t UINT16;
79 typedef uint32_t UINT32;
80 #else
81 typedef unsigned char UINT8;
82 typedef unsigned short UINT16;
83 typedef unsigned int UINT32;
84 #endif
85
86 #ifndef HAVE_STDBOOL_H
87 typedef unsigned char bool;
88 #define true (bool)1
89 #define false (bool)0
90 #endif
91
92 #ifndef NULL
93 #ifdef PROTOTYPES
94 # define NULL (void *)0
95 #else
96 # define NULL 0L
97 #endif
98 #endif
99
100 #ifdef NeXT
101 #define S_IRUSR 0000400         /* read permission, owner */
102 #define S_IWUSR 0000200         /* write permission, owner */
103 #define S_IRGRP 0000040         /* read permission, group */
104 #define S_IROTH 0000004         /* read permission, other */
105 #define ssize_t int
106 #endif
107
108 #undef GLOBAL
109 #define GLOBAL
110
111 /* SPLint */
112
113 #ifdef S_SPLINT_S
114 #include "splint.h"
115 #endif
116
117 /* target constants  */
118
119 #ifndef HOST_OS
120 #define HOST_OS "unknown"
121 #endif
122
123 #ifndef HOST_CPU
124 #define HOST_CPU "unknown"
125 #endif
126
127 #ifndef HOST_VENDOR
128 #define HOST_VENDOR "unknown"
129 #endif
130
131 #ifdef __HAIKU__
132 #define SINGLE_USER_OS
133 #endif
134
135 /* configure options */
136
137 #ifndef HAVE_socklen_t
138 typedef int socklen_t;                  /* for Mac OS X, amongst others */
139 #endif
140
141 #ifndef HAVE_SNPRINTF
142 extern int snprintf PARAMS(( char *str, size_t count, const char *fmt, ... ));
143 #endif
144
145 #ifndef HAVE_STRLCAT
146 extern size_t strlcat PARAMS(( char *dst, const char *src, size_t size ));
147 #endif
148
149 #ifndef HAVE_STRLCPY
150 extern size_t strlcpy PARAMS(( char *dst, const char *src, size_t size ));
151 #endif
152
153 #ifndef HAVE_STRDUP
154 extern char * strdup PARAMS(( const char *s ));
155 #endif
156
157 #ifndef HAVE_STRNDUP
158 extern char * strndup PARAMS((const char *s, size_t maxlen));
159 #endif
160
161 #ifndef HAVE_STRTOK_R
162 extern char * strtok_r PARAMS((char *str, const char *delim, char **saveptr));
163 #endif
164
165 #ifndef HAVE_VSNPRINTF
166 #include <stdarg.h>
167 extern int vsnprintf PARAMS(( char *str, size_t count, const char *fmt, va_list args ));
168 #endif
169
170 #ifndef HAVE_GAI_STRERROR
171 #define gai_strerror(r) "unknown error"
172 #endif
173
174 #ifndef PACKAGE_NAME
175 #define PACKAGE_NAME PACKAGE
176 #endif
177
178 #ifndef PACKAGE_VERSION
179 #define PACKAGE_VERSION VERSION
180 #endif
181
182 #endif
183
184 /* -eof- */