]> arthur.barton.de Git - ngircd-alex.git/blob - src/portab/portab.h
78b6f7e126e66b870b7d9016e6b2a9d0575dd824
[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 #ifndef DEBUG
23 # define NDEBUG
24 #endif
25
26 /* compiler features */
27
28 #if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 7))
29 # define PUNUSED(x) __attribute__ ((unused)) x
30 # define UNUSED     __attribute__ ((unused))
31 #else
32 # define PUNUSED(x) x
33 # define UNUSED
34 #endif
35
36 #ifndef PARAMS
37 # if PROTOTYPES
38 #  define PARAMS(args) args
39 # else
40 #  define PARAMS(args) ()
41 # endif
42 #endif
43
44 /* datatypes */
45
46 #include <sys/types.h>
47
48 #ifdef HAVE_STDDEF_H
49 # include <stddef.h>
50 #endif
51
52 #ifdef HAVE_INTTYPES_H
53 # include <inttypes.h>
54 # define NGIRC_GOT_INTTYPES
55 #else
56 # ifdef HAVE_STDINT_H
57 #  include <stdint.h>
58 #  define NGIRC_GOT_INTTYPES
59 # endif
60 #endif
61
62 #ifndef PROTOTYPES
63 # ifndef signed
64 #  define signed
65 # endif
66 #endif
67
68 typedef void POINTER;
69
70 #ifdef NGIRC_GOT_INTTYPES
71 typedef uint8_t UINT8;
72 typedef uint16_t UINT16;
73 typedef uint32_t UINT32;
74 #else
75 typedef unsigned char UINT8;
76 typedef unsigned short UINT16;
77 typedef unsigned int UINT32;
78 #endif
79
80 #ifdef HAVE_STDBOOL_H
81 # include <stdbool.h>
82 #else
83 typedef unsigned char bool;
84 # define true (bool)1
85 # define false (bool)0
86 #endif
87
88 #ifndef NULL
89 # ifdef PROTOTYPES
90 #  define NULL (void *)0
91 # else
92 #  define NULL 0L
93 # endif
94 #endif
95
96 #ifdef NeXT
97 # define S_IRUSR 0000400                /* read permission, owner */
98 # define S_IWUSR 0000200                /* write permission, owner */
99 # define S_IRGRP 0000040                /* read permission, group */
100 # define S_IROTH 0000004                /* read permission, other */
101 # define ssize_t int
102 #endif
103
104 #undef GLOBAL
105 #define GLOBAL
106
107 /* SPLint */
108
109 #ifdef S_SPLINT_S
110 # include "splint.h"
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 #endif
179
180 /* -eof- */