]> arthur.barton.de Git - ngircd-alex.git/blob - src/portab/portab.h
Merge branch 'bug92-xop'
[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
67 /* datatypes */
68
69 #ifndef PROTOTYPES
70 # ifndef signed
71 #  define signed
72 # endif
73 #endif
74
75 typedef void POINTER;
76
77 #ifdef NGIRC_GOT_INTTYPES
78 typedef uint8_t UINT8;
79 typedef uint16_t UINT16;
80 typedef uint32_t UINT32;
81 #else
82 typedef unsigned char UINT8;
83 typedef unsigned short UINT16;
84 typedef unsigned int UINT32;
85 #endif
86
87 #ifndef HAVE_STDBOOL_H
88 typedef unsigned char bool;
89 #define true (bool)1
90 #define false (bool)0
91 #endif
92
93 #ifndef NULL
94 #ifdef PROTOTYPES
95 # define NULL (void *)0
96 #else
97 # define NULL 0L
98 #endif
99 #endif
100
101 #ifdef NeXT
102 #define S_IRUSR 0000400         /* read permission, owner */
103 #define S_IWUSR 0000200         /* write permission, owner */
104 #define S_IRGRP 0000040         /* read permission, group */
105 #define S_IROTH 0000004         /* read permission, other */
106 #define ssize_t int
107 #endif
108
109 #undef GLOBAL
110 #define GLOBAL
111
112
113 /* SPLint */
114
115
116 #ifdef S_SPLINT_S
117 #include "splint.h"
118 #endif
119
120
121 /* target constants  */
122
123 #ifndef HOST_OS
124 #define HOST_OS "unknown"
125 #endif
126
127 #ifndef HOST_CPU
128 #define HOST_CPU "unknown"
129 #endif
130
131 #ifndef HOST_VENDOR
132 #define HOST_VENDOR "unknown"
133 #endif
134
135
136 /* configure options */
137
138 #ifndef HAVE_socklen_t
139 typedef int socklen_t;                  /* for Mac OS X, amongst others */
140 #endif
141
142 #ifndef HAVE_SNPRINTF
143 extern int snprintf PARAMS(( char *str, size_t count, const char *fmt, ... ));
144 #endif
145
146 #ifndef HAVE_STRLCAT
147 extern size_t strlcat PARAMS(( char *dst, const char *src, size_t size ));
148 #endif
149
150 #ifndef HAVE_STRLCPY
151 extern size_t strlcpy PARAMS(( char *dst, const char *src, size_t size ));
152 #endif
153
154 #ifndef HAVE_STRDUP
155 extern char * strdup PARAMS(( const char *s ));
156 #endif
157
158 #ifndef HAVE_STRTOK_R
159 extern char * strtok_r PARAMS((char *str, const char *delim, char **saveptr));
160 #endif
161
162 #ifndef HAVE_VSNPRINTF
163 #include <stdarg.h>
164 extern int vsnprintf PARAMS(( char *str, size_t count, const char *fmt, va_list args ));
165 #endif
166
167 #ifndef HAVE_GAI_STRERROR
168 #define gai_strerror(r) "unknown error"
169 #endif
170
171 #ifndef PACKAGE_NAME
172 #define PACKAGE_NAME PACKAGE
173 #endif
174
175 #ifndef PACKAGE_VERSION
176 #define PACKAGE_VERSION VERSION
177 #endif
178
179
180 #endif
181
182
183 /* -eof- */