r3453: - split out the auth and popt includes
[abartlet/samba.git/.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  * Define additional missing types
114  */
115 #ifndef HAVE_SIG_ATOMIC_T_TYPE
116 typedef int sig_atomic_t;
117 #endif
118
119 #ifndef HAVE_SOCKLEN_T_TYPE
120 typedef int socklen_t;
121 #endif
122
123
124 /*
125    Samba needs type definitions for 
126    int8_t,  int16_t,  int32_t, int64_t 
127    uint8_t, uint16_t, uint32_t and uint64_t.
128
129    Normally these are signed and unsigned 8, 16, 32 and 64 bit integers, but
130    they actually only need to be at least 8, 16, 32 and 64 bits
131    respectively. Thus if your word size is 8 bytes just defining them
132    as signed and unsigned int will work.
133 */
134
135 #if !defined(int8)
136 #define int8 int8_t
137 #endif
138
139 #if !defined(uint8)
140 #define uint8 uint8_t
141 #endif
142
143 #if !defined(int16)
144 #define int16 int16_t
145 #endif
146
147 #if !defined(uint16)
148 #define uint16 uint16_t
149 #endif
150
151 #if !defined(int32)
152 #define int32 int32_t
153 #endif
154
155 #if !defined(uint32)
156 #define uint32 uint32_t
157 #endif
158
159 #if !defined(int64)
160 #define int64 int64_t
161 #endif
162
163 #if !defined(uint64)
164 #define uint64 uint64_t
165 #endif
166
167 /*
168   we use struct ipv4_addr to avoid having to include all the
169   system networking headers everywhere
170 */
171 struct ipv4_addr {
172         uint32_t s_addr;
173 };
174
175 #ifndef UINT8_MAX
176 #define UINT8_MAX 255
177 #endif
178
179 #ifndef UINT16_MAX
180 #define UINT16_MAX 65535
181 #endif
182
183 #ifndef MIN
184 #define MIN(a,b) ((a)<(b)?(a):(b))
185 #endif
186
187 #ifndef MAX
188 #define MAX(a,b) ((a)>(b)?(a):(b))
189 #endif
190
191 #ifndef HAVE_STRERROR
192 extern char *sys_errlist[];
193 #define strerror(i) sys_errlist[i]
194 #endif
195
196 #ifndef HAVE_ERRNO_DECL
197 extern int errno;
198 #endif
199
200 #ifdef HAVE_BROKEN_GETGROUPS
201 #define GID_T int
202 #else
203 #define GID_T gid_t
204 #endif
205
206 #ifndef NGROUPS_MAX
207 #define NGROUPS_MAX 32 /* Guess... */
208 #endif
209
210 /* Our own pstrings and fstrings */
211 #include "pstring.h"
212
213 /* Lists, trees, caching, database... */
214 #include "xfile.h"
215 #include "dlinklist.h"
216 #include "talloc.h"
217 #include "lib/ldb/include/ldb.h"
218 #include "lib/tdb/include/tdb.h"
219 #include "lib/tdb/include/spinlock.h"
220 #include "lib/tdb/include/tdbutil.h"
221 #include "db_wrap.h"
222 #include "nt_status.h"
223 #include "trans2.h"
224 #include "ioctl.h"
225 #include "nterr.h"
226 #include "messages.h"
227 #include "charset.h"
228 #include "dynconfig.h"
229
230 #include "version.h"
231 #include "rewrite.h"
232 #include "smb.h"
233 #include "ads.h"
234 #include "lib/socket/socket.h"
235 #include "libcli/ldap/ldap.h"
236 #include "nameserv.h"
237 #include "secrets.h"
238
239 #include "byteorder.h"
240
241 #include "md5.h"
242 #include "hmacmd5.h"
243
244
245 #include "module.h"
246
247 #include "asn_1.h"
248
249 #include "mutex.h"
250
251 #include "structs.h"
252 #include "librpc/ndr/libndr.h"
253 #include "librpc/ndr/ndr_sec.h"
254 #include "librpc/gen_ndr/ndr_misc.h"
255 #include "librpc/gen_ndr/ndr_dcerpc.h"
256 #include "librpc/rpc/dcerpc.h"
257 #include "librpc/gen_ndr/tables.h"
258
259 #include "smb_interfaces.h"
260 #include "smbd/server.h"
261 #include "smbd/service.h"
262 #include "rpc_server/dcerpc_server.h"
263 #include "request.h"
264 #include "signing.h"
265 #include "smb_server/smb_server.h"
266 #include "ntvfs/ntvfs.h"
267 #include "cli_context.h"
268 #include "registry.h"
269 #include "rap.h"
270 #include "ldap_server/ldap_server.h"
271
272 #include "libnet/libnet.h"
273 #include "utils/net/net.h"
274
275 #include "nsswitch/winbind_client.h"
276
277 /* hmm, this really is getting ugly isn't it .... we probably need to
278    have some way to have subsystem includes without including it
279    globally */
280 #include "ntvfs/posix/vfs_posix.h"
281
282 #define malloc_p(type) (type *)malloc(sizeof(type))
283 #define malloc_array_p(type, count) (type *)realloc_array(NULL, sizeof(type), count)
284 #define realloc_p(p, type, count) (type *)realloc_array(p, sizeof(type), count)
285
286 #ifndef HAVE_COMPARISON_FN_T
287 typedef int (*comparison_fn_t)(const void *, const void *);
288 #endif
289
290 /***** automatically generated prototypes *****/
291 #define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2)
292 #include "proto.h"
293 #undef _PRINTF_ATTRIBUTE
294 #define _PRINTF_ATTRIBUTE(a1, a2)
295
296 /* String routines */
297
298 #include "safe_string.h"
299
300 #ifdef __COMPAR_FN_T
301 #define QSORT_CAST (__compar_fn_t)
302 #endif
303
304 #ifndef QSORT_CAST
305 #define QSORT_CAST (int (*)(const void *, const void *))
306 #endif
307
308 #ifndef SIGCLD
309 #define SIGCLD SIGCHLD
310 #endif
311
312 #ifndef MAP_FILE
313 #define MAP_FILE 0
314 #endif
315
316 #if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
317 #define OSF1_ENH_SEC 1
318 #endif
319
320 #ifndef ALLOW_CHANGE_PASSWORD
321 #if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
322 #define ALLOW_CHANGE_PASSWORD 1
323 #endif
324 #endif
325
326 /* what is the longest significant password available on your system? 
327  Knowing this speeds up password searches a lot */
328 #ifndef PASSWORD_LENGTH
329 #define PASSWORD_LENGTH 8
330 #endif
331
332 #ifndef HAVE_PIPE
333 #define SYNC_DNS 1
334 #endif
335
336 #ifndef MAXPATHLEN
337 #define MAXPATHLEN 256
338 #endif
339
340 #ifndef SEEK_SET
341 #define SEEK_SET 0
342 #endif
343
344 #ifndef INADDR_LOOPBACK
345 #define INADDR_LOOPBACK 0x7f000001
346 #endif
347
348 #ifndef INADDR_NONE
349 #define INADDR_NONE 0xffffffff
350 #endif
351
352 #ifndef HAVE_CRYPT
353 #define crypt ufc_crypt
354 #endif
355
356 #ifndef O_ACCMODE
357 #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
358 #endif
359
360 #if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
361 #define ULTRIX_AUTH 1
362 #endif
363
364 #ifndef HAVE_STRDUP
365 char *strdup(const char *s);
366 #endif
367
368 #ifndef HAVE_MEMMOVE
369 void *memmove(void *dest,const void *src,int size);
370 #endif
371
372 #ifndef HAVE_INITGROUPS
373 int initgroups(char *name,gid_t id);
374 #endif
375
376 #ifndef HAVE_RENAME
377 int rename(const char *zfrom, const char *zto);
378 #endif
379
380 #ifndef HAVE_MKTIME
381 time_t mktime(struct tm *t);
382 #endif
383
384 #ifndef HAVE_STRLCPY
385 size_t strlcpy(char *d, const char *s, size_t bufsize);
386 #endif
387
388 #ifndef HAVE_STRLCAT
389 size_t strlcat(char *d, const char *s, size_t bufsize);
390 #endif
391
392 #ifndef HAVE_FTRUNCATE
393 int ftruncate(int f,long l);
394 #endif
395
396 #ifndef HAVE_STRNDUP
397 char *strndup(const char *s, size_t n);
398 #endif
399
400 #ifndef HAVE_STRNLEN
401 size_t strnlen(const char *s, size_t n);
402 #endif
403
404 #ifndef HAVE_STRTOUL
405 unsigned long strtoul(const char *nptr, char **endptr, int base);
406 #endif
407
408 #ifndef HAVE_SETENV
409 int setenv(const char *name, const char *value, int overwrite); 
410 #endif
411
412 #ifndef HAVE_VASPRINTF_DECL
413 int vasprintf(char **ptr, const char *format, va_list ap);
414 #endif
415
416 #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
417 #define bzero(a,b) memset((a),'\0',(b))
418 #endif
419
420 #ifdef REPLACE_GETPASS
421 #define getpass(prompt) getsmbpass((prompt))
422 #endif
423
424 /*
425  * Some older systems seem not to have MAXHOSTNAMELEN
426  * defined.
427  */
428 #ifndef MAXHOSTNAMELEN
429 #define MAXHOSTNAMELEN 254
430 #endif
431
432 /* yuck, I'd like a better way of doing this */
433 #define DIRP_SIZE (256 + 32)
434
435 /*
436  * glibc on linux doesn't seem to have MSG_WAITALL
437  * defined. I think the kernel has it though..
438  */
439
440 #ifndef MSG_WAITALL
441 #define MSG_WAITALL 0
442 #endif
443
444 /* Load header file for dynamic linking stuff */
445 #ifdef HAVE_DLFCN_H
446 #include <dlfcn.h>
447 #endif
448
449 extern int DEBUGLEVEL;
450
451 #ifndef RTLD_LAZY
452 #define RTLD_LAZY 0
453 #endif
454
455 /* needed for some systems without iconv. Doesn't really matter
456    what error code we use */
457 #ifndef EILSEQ
458 #define EILSEQ EIO
459 #endif
460
461 /* add varargs prototypes with printf checking */
462 #ifndef HAVE_SNPRINTF_DECL
463 int snprintf(char *,size_t ,const char *, ...) PRINTF_ATTRIBUTE(3,4);
464 #endif
465 #ifndef HAVE_ASPRINTF_DECL
466 int asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3);
467 #endif
468
469
470 /* we used to use these fns, but now we have good replacements
471    for snprintf and vsnprintf */
472 #define slprintf snprintf
473
474
475 /* we need to use __va_copy() on some platforms */
476 #ifdef HAVE_VA_COPY
477 #define VA_COPY(dest, src) __va_copy(dest, src)
478 #else
479 #define VA_COPY(dest, src) (dest) = (src)
480 #endif
481
482 #ifndef HAVE_TIMEGM
483 time_t timegm(struct tm *tm);
484 #endif
485
486 #if defined(VALGRIND)
487 #define strlen(x) valgrind_strlen(x)
488 #endif
489
490 #define TALLOC_ABORT(reason) smb_panic(reason)
491
492
493 /*
494   this is a warning hack. The idea is to use this everywhere that we
495   get the "discarding const" warning from gcc. That doesn't actually
496   fix the problem of course, but it means that when we do get to
497   cleaning them up we can do it by searching the code for
498   discard_const.
499
500   It also means that other error types aren't as swamped by the noise
501   of hundreds of const warnings, so we are more likely to notice when
502   we get new errors.
503
504   Please only add more uses of this macro when you find it
505   _really_ hard to fix const warnings. Our aim is to eventually use
506   this function in only a very few places.
507
508   Also, please call this via the discard_const_p() macro interface, as that
509   makes the return type safe.
510 */
511 #ifdef HAVE_INTPTR_T
512 #define discard_const(ptr) ((void *)((intptr_t)(ptr)))
513 #else
514 #define discard_const(ptr) ((void *)(ptr))
515 #endif
516 #define discard_const_p(type, ptr) ((type *)discard_const(ptr))
517
518 #endif /* _INCLUDES_H */
519