r3463: separated out some more headers (asn_1.h, messages.h, dlinklist.h and ioctl.h)
[samba.git] / source4 / include / includes.h
1 #ifndef _INCLUDES_H
2 #define _INCLUDES_H
3 /* 
4    Unix SMB/CIFS implementation.
5    Machine customisation and include handling
6    Copyright (C) Andrew Tridgell 1994-1998
7    Copyright (C) 2002 by Martin Pool <mbp@samba.org>
8    
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2 of the License, or
12    (at your option) any later version.
13    
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18    
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24 #ifndef NO_CONFIG_H /* for some tests */
25 #include "config.h"
26 #include "smb_build.h"
27 #endif
28
29 #include "local.h"
30
31 #ifdef AIX
32 #define DEFAULT_PRINTING PRINT_AIX
33 #define PRINTCAP_NAME "/etc/qconfig"
34 #endif
35
36 #ifdef HPUX
37 #define DEFAULT_PRINTING PRINT_HPUX
38 #endif
39
40 #ifdef QNX
41 #define DEFAULT_PRINTING PRINT_QNX
42 #endif
43
44 #ifdef SUNOS4
45 /* on SUNOS4 termios.h conflicts with sys/ioctl.h */
46 #undef HAVE_TERMIOS_H
47 #endif
48
49 #ifndef DEFAULT_PRINTING
50 #define DEFAULT_PRINTING PRINT_BSD
51 #endif
52 #ifndef PRINTCAP_NAME
53 #define PRINTCAP_NAME "/etc/printcap"
54 #endif
55
56 #if (__GNUC__ >= 3)
57 /** Use gcc attribute to check printf fns.  a1 is the 1-based index of
58  * the parameter containing the format, and a2 the index of the first
59  * argument. Note that some gcc 2.x versions don't handle this
60  * properly **/
61 #define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
62 #else
63 #define PRINTF_ATTRIBUTE(a1, a2)
64 #endif
65
66 #ifdef __GNUC__
67 /** gcc attribute used on function parameters so that it does not emit
68  * warnings about them being unused. **/
69 #  define UNUSED(param) param __attribute__ ((unused))
70 #else
71 #  define UNUSED(param) param
72 /** Feel free to add definitions for other compilers here. */
73 #endif
74
75 #include <sys/types.h>
76 #include <stdio.h>
77 #include <stdlib.h>
78 #include <stddef.h>
79
80 #ifdef HAVE_STDINT_H
81 #include <stdint.h>
82 #endif
83
84 #ifdef HAVE_STRING_H
85 #include <string.h>
86 #endif
87
88 #include <signal.h>
89 #include <errno.h>
90
91 #ifdef HAVE_STDARG_H
92 #include <stdarg.h>
93 #else
94 #include <varargs.h>
95 #endif
96
97 /* we support ADS if we want it and have krb5 and ldap libs */
98 #if defined(WITH_ADS) && defined(HAVE_KRB5) && defined(HAVE_LDAP)
99 #define HAVE_ADS
100 #endif
101
102 /*
103  * Define VOLATILE if needed.
104  */
105
106 #if defined(HAVE_VOLATILE)
107 #define VOLATILE volatile
108 #else
109 #define VOLATILE
110 #endif
111
112 /*
113    Samba needs type definitions for 
114    int8_t,  int16_t,  int32_t, int64_t 
115    uint8_t, uint16_t, uint32_t and uint64_t.
116
117    Normally these are signed and unsigned 8, 16, 32 and 64 bit integers, but
118    they actually only need to be at least 8, 16, 32 and 64 bits
119    respectively. Thus if your word size is 8 bytes just defining them
120    as signed and unsigned int will work.
121 */
122
123 #if !defined(int8)
124 #define int8 int8_t
125 #endif
126
127 #if !defined(uint8)
128 #define uint8 uint8_t
129 #endif
130
131 #if !defined(int16)
132 #define int16 int16_t
133 #endif
134
135 #if !defined(uint16)
136 #define uint16 uint16_t
137 #endif
138
139 #if !defined(int32)
140 #define int32 int32_t
141 #endif
142
143 #if !defined(uint32)
144 #define uint32 uint32_t
145 #endif
146
147 #if !defined(int64)
148 #define int64 int64_t
149 #endif
150
151 #if !defined(uint64)
152 #define uint64 uint64_t
153 #endif
154
155 /*
156   we use struct ipv4_addr to avoid having to include all the
157   system networking headers everywhere
158 */
159 struct ipv4_addr {
160         uint32_t addr;
161 };
162
163 #ifndef MIN
164 #define MIN(a,b) ((a)<(b)?(a):(b))
165 #endif
166
167 #ifndef MAX
168 #define MAX(a,b) ((a)>(b)?(a):(b))
169 #endif
170
171 #ifndef HAVE_STRERROR
172 extern char *sys_errlist[];
173 #define strerror(i) sys_errlist[i]
174 #endif
175
176 #ifndef HAVE_ERRNO_DECL
177 extern int errno;
178 #endif
179
180 /* Our own pstrings and fstrings */
181 #include "pstring.h"
182
183 /* Lists, trees, caching, database... */
184 #include "xfile.h"
185 #include "talloc.h"
186 #include "lib/ldb/include/ldb.h"
187 #include "lib/tdb/include/tdb.h"
188 #include "lib/tdb/include/spinlock.h"
189 #include "lib/tdb/include/tdbutil.h"
190 #include "db_wrap.h"
191 #include "nt_status.h"
192 #include "trans2.h"
193 #include "nterr.h"
194 #include "charset.h"
195 #include "dynconfig.h"
196
197 #include "version.h"
198 #include "rewrite.h"
199 #include "smb.h"
200 #include "ads.h"
201 #include "lib/socket/socket.h"
202 #include "libcli/ldap/ldap.h"
203 #include "nameserv.h"
204
205 #include "byteorder.h"
206
207 #include "module.h"
208
209 #include "mutex.h"
210
211 #include "structs.h"
212 #include "librpc/ndr/libndr.h"
213 #include "librpc/ndr/ndr_sec.h"
214 #include "librpc/gen_ndr/ndr_misc.h"
215 #include "librpc/gen_ndr/ndr_dcerpc.h"
216 #include "librpc/rpc/dcerpc.h"
217 #include "librpc/gen_ndr/tables.h"
218
219 #include "smb_interfaces.h"
220 #include "smbd/server.h"
221 #include "smbd/service.h"
222 #include "rpc_server/dcerpc_server.h"
223 #include "request.h"
224 #include "signing.h"
225 #include "smb_server/smb_server.h"
226 #include "ntvfs/ntvfs.h"
227 #include "cli_context.h"
228 #include "registry.h"
229 #include "rap.h"
230 #include "ldap_server/ldap_server.h"
231
232 #include "libnet/libnet.h"
233 #include "utils/net/net.h"
234
235 #include "nsswitch/winbind_client.h"
236
237 /* hmm, this really is getting ugly isn't it .... we probably need to
238    have some way to have subsystem includes without including it
239    globally */
240 #include "ntvfs/posix/vfs_posix.h"
241
242 #define malloc_p(type) (type *)malloc(sizeof(type))
243 #define malloc_array_p(type, count) (type *)realloc_array(NULL, sizeof(type), count)
244 #define realloc_p(p, type, count) (type *)realloc_array(p, sizeof(type), count)
245
246 #ifndef HAVE_COMPARISON_FN_T
247 typedef int (*comparison_fn_t)(const void *, const void *);
248 #endif
249
250 /***** automatically generated prototypes *****/
251 #define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2)
252 #include "proto.h"
253 #undef _PRINTF_ATTRIBUTE
254 #define _PRINTF_ATTRIBUTE(a1, a2)
255
256 /* String routines */
257
258 #include "safe_string.h"
259
260 #ifdef __COMPAR_FN_T
261 #define QSORT_CAST (__compar_fn_t)
262 #endif
263
264 #ifndef QSORT_CAST
265 #define QSORT_CAST (int (*)(const void *, const void *))
266 #endif
267
268 #ifndef SIGCLD
269 #define SIGCLD SIGCHLD
270 #endif
271
272 #ifndef MAP_FILE
273 #define MAP_FILE 0
274 #endif
275
276 #if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
277 #define OSF1_ENH_SEC 1
278 #endif
279
280 #ifndef ALLOW_CHANGE_PASSWORD
281 #if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
282 #define ALLOW_CHANGE_PASSWORD 1
283 #endif
284 #endif
285
286 /* what is the longest significant password available on your system? 
287  Knowing this speeds up password searches a lot */
288 #ifndef PASSWORD_LENGTH
289 #define PASSWORD_LENGTH 8
290 #endif
291
292 #ifndef HAVE_PIPE
293 #define SYNC_DNS 1
294 #endif
295
296 #ifndef MAXPATHLEN
297 #define MAXPATHLEN 256
298 #endif
299
300 #ifndef SEEK_SET
301 #define SEEK_SET 0
302 #endif
303
304 #ifndef INADDR_LOOPBACK
305 #define INADDR_LOOPBACK 0x7f000001
306 #endif
307
308 #ifndef INADDR_NONE
309 #define INADDR_NONE 0xffffffff
310 #endif
311
312 #if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
313 #define ULTRIX_AUTH 1
314 #endif
315
316 #ifndef HAVE_STRDUP
317 char *strdup(const char *s);
318 #endif
319
320 #ifndef HAVE_MEMMOVE
321 void *memmove(void *dest,const void *src,int size);
322 #endif
323
324 #ifndef HAVE_MKTIME
325 time_t mktime(struct tm *t);
326 #endif
327
328 #ifndef HAVE_STRLCPY
329 size_t strlcpy(char *d, const char *s, size_t bufsize);
330 #endif
331
332 #ifndef HAVE_STRLCAT
333 size_t strlcat(char *d, const char *s, size_t bufsize);
334 #endif
335
336 #ifndef HAVE_FTRUNCATE
337 int ftruncate(int f,long l);
338 #endif
339
340 #ifndef HAVE_STRNDUP
341 char *strndup(const char *s, size_t n);
342 #endif
343
344 #ifndef HAVE_STRNLEN
345 size_t strnlen(const char *s, size_t n);
346 #endif
347
348 #ifndef HAVE_STRTOUL
349 unsigned long strtoul(const char *nptr, char **endptr, int base);
350 #endif
351
352 #ifndef HAVE_SETENV
353 int setenv(const char *name, const char *value, int overwrite); 
354 #endif
355
356 #ifndef HAVE_VASPRINTF_DECL
357 int vasprintf(char **ptr, const char *format, va_list ap);
358 #endif
359
360 #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
361 #define bzero(a,b) memset((a),'\0',(b))
362 #endif
363
364 extern int DEBUGLEVEL;
365
366 /* add varargs prototypes with printf checking */
367 #ifndef HAVE_SNPRINTF_DECL
368 int snprintf(char *,size_t ,const char *, ...) PRINTF_ATTRIBUTE(3,4);
369 #endif
370 #ifndef HAVE_ASPRINTF_DECL
371 int asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3);
372 #endif
373
374
375 /* we used to use these fns, but now we have good replacements
376    for snprintf and vsnprintf */
377 #define slprintf snprintf
378
379
380 /* we need to use __va_copy() on some platforms */
381 #ifdef HAVE_VA_COPY
382 #define VA_COPY(dest, src) __va_copy(dest, src)
383 #else
384 #define VA_COPY(dest, src) (dest) = (src)
385 #endif
386
387 #ifndef HAVE_TIMEGM
388 time_t timegm(struct tm *tm);
389 #endif
390
391 #if defined(VALGRIND)
392 #define strlen(x) valgrind_strlen(x)
393 #endif
394
395 #define TALLOC_ABORT(reason) smb_panic(reason)
396
397
398 /*
399   this is a warning hack. The idea is to use this everywhere that we
400   get the "discarding const" warning from gcc. That doesn't actually
401   fix the problem of course, but it means that when we do get to
402   cleaning them up we can do it by searching the code for
403   discard_const.
404
405   It also means that other error types aren't as swamped by the noise
406   of hundreds of const warnings, so we are more likely to notice when
407   we get new errors.
408
409   Please only add more uses of this macro when you find it
410   _really_ hard to fix const warnings. Our aim is to eventually use
411   this function in only a very few places.
412
413   Also, please call this via the discard_const_p() macro interface, as that
414   makes the return type safe.
415 */
416 #ifdef HAVE_INTPTR_T
417 #define discard_const(ptr) ((void *)((intptr_t)(ptr)))
418 #else
419 #define discard_const(ptr) ((void *)(ptr))
420 #endif
421 #define discard_const_p(type, ptr) ((type *)discard_const(ptr))
422
423 #endif /* _INCLUDES_H */
424