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