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>
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.
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.
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.
24 #ifndef NO_CONFIG_H /* for some tests */
26 #include "smb_build.h"
32 #define DEFAULT_PRINTING PRINT_AIX
33 #define PRINTCAP_NAME "/etc/qconfig"
37 #define DEFAULT_PRINTING PRINT_HPUX
41 #define DEFAULT_PRINTING PRINT_QNX
45 /* on SUNOS4 termios.h conflicts with sys/ioctl.h */
49 #ifndef DEFAULT_PRINTING
50 #define DEFAULT_PRINTING PRINT_BSD
53 #define PRINTCAP_NAME "/etc/printcap"
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
61 #define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
63 #define PRINTF_ATTRIBUTE(a1, a2)
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))
71 # define UNUSED(param) param
72 /** Feel free to add definitions for other compilers here. */
75 #include <sys/types.h>
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)
103 * Define VOLATILE if needed.
106 #if defined(HAVE_VOLATILE)
107 #define VOLATILE volatile
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.
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.
128 #define uint8 uint8_t
132 #define int16 int16_t
136 #define uint16 uint16_t
140 #define int32 int32_t
144 #define uint32 uint32_t
148 #define int64 int64_t
152 #define uint64 uint64_t
156 we use struct ipv4_addr to avoid having to include all the
157 system networking headers everywhere
164 #define MIN(a,b) ((a)<(b)?(a):(b))
168 #define MAX(a,b) ((a)>(b)?(a):(b))
171 #ifndef HAVE_STRERROR
172 extern char *sys_errlist[];
173 #define strerror(i) sys_errlist[i]
176 #ifndef HAVE_ERRNO_DECL
180 /* Our own pstrings and fstrings */
183 /* Lists, trees, caching, database... */
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"
191 #include "nt_status.h"
195 #include "dynconfig.h"
201 #include "lib/socket/socket.h"
202 #include "libcli/ldap/ldap.h"
203 #include "nameserv.h"
205 #include "byteorder.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"
219 #include "smb_interfaces.h"
220 #include "smbd/server.h"
221 #include "smbd/service.h"
222 #include "rpc_server/dcerpc_server.h"
225 #include "smb_server/smb_server.h"
226 #include "ntvfs/ntvfs.h"
227 #include "cli_context.h"
228 #include "registry.h"
230 #include "ldap_server/ldap_server.h"
232 #include "libnet/libnet.h"
233 #include "utils/net/net.h"
235 #include "nsswitch/winbind_client.h"
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
240 #include "ntvfs/posix/vfs_posix.h"
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)
246 #ifndef HAVE_COMPARISON_FN_T
247 typedef int (*comparison_fn_t)(const void *, const void *);
250 /***** automatically generated prototypes *****/
251 #define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2)
253 #undef _PRINTF_ATTRIBUTE
254 #define _PRINTF_ATTRIBUTE(a1, a2)
256 /* String routines */
258 #include "safe_string.h"
261 #define QSORT_CAST (__compar_fn_t)
265 #define QSORT_CAST (int (*)(const void *, const void *))
269 #define SIGCLD SIGCHLD
276 #if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
277 #define OSF1_ENH_SEC 1
280 #ifndef ALLOW_CHANGE_PASSWORD
281 #if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
282 #define ALLOW_CHANGE_PASSWORD 1
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
297 #define MAXPATHLEN 256
304 #ifndef INADDR_LOOPBACK
305 #define INADDR_LOOPBACK 0x7f000001
309 #define INADDR_NONE 0xffffffff
312 #if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
313 #define ULTRIX_AUTH 1
317 char *strdup(const char *s);
321 void *memmove(void *dest,const void *src,int size);
325 time_t mktime(struct tm *t);
329 size_t strlcpy(char *d, const char *s, size_t bufsize);
333 size_t strlcat(char *d, const char *s, size_t bufsize);
336 #ifndef HAVE_FTRUNCATE
337 int ftruncate(int f,long l);
341 char *strndup(const char *s, size_t n);
345 size_t strnlen(const char *s, size_t n);
349 unsigned long strtoul(const char *nptr, char **endptr, int base);
353 int setenv(const char *name, const char *value, int overwrite);
356 #ifndef HAVE_VASPRINTF_DECL
357 int vasprintf(char **ptr, const char *format, va_list ap);
360 #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
361 #define bzero(a,b) memset((a),'\0',(b))
364 extern int DEBUGLEVEL;
366 /* add varargs prototypes with printf checking */
367 #ifndef HAVE_SNPRINTF_DECL
368 int snprintf(char *,size_t ,const char *, ...) PRINTF_ATTRIBUTE(3,4);
370 #ifndef HAVE_ASPRINTF_DECL
371 int asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3);
375 /* we used to use these fns, but now we have good replacements
376 for snprintf and vsnprintf */
377 #define slprintf snprintf
380 /* we need to use __va_copy() on some platforms */
382 #define VA_COPY(dest, src) __va_copy(dest, src)
384 #define VA_COPY(dest, src) (dest) = (src)
388 time_t timegm(struct tm *tm);
391 #if defined(VALGRIND)
392 #define strlen(x) valgrind_strlen(x)
395 #define TALLOC_ABORT(reason) smb_panic(reason)
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
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
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.
413 Also, please call this via the discard_const_p() macro interface, as that
414 makes the return type safe.
417 #define discard_const(ptr) ((void *)((intptr_t)(ptr)))
419 #define discard_const(ptr) ((void *)(ptr))
421 #define discard_const_p(type, ptr) ((type *)discard_const(ptr))
423 #endif /* _INCLUDES_H */