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 * Define additional missing types
115 #ifndef HAVE_SIG_ATOMIC_T_TYPE
116 typedef int sig_atomic_t;
119 #ifndef HAVE_SOCKLEN_T_TYPE
120 typedef int socklen_t;
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.
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.
140 #define uint8 uint8_t
144 #define int16 int16_t
148 #define uint16 uint16_t
152 #define int32 int32_t
156 #define uint32 uint32_t
160 #define int64 int64_t
164 #define uint64 uint64_t
168 we use struct ipv4_addr to avoid having to include all the
169 system networking headers everywhere
176 #define MIN(a,b) ((a)<(b)?(a):(b))
180 #define MAX(a,b) ((a)>(b)?(a):(b))
183 #ifndef HAVE_STRERROR
184 extern char *sys_errlist[];
185 #define strerror(i) sys_errlist[i]
188 #ifndef HAVE_ERRNO_DECL
192 /* Our own pstrings and fstrings */
195 /* Lists, trees, caching, database... */
197 #include "dlinklist.h"
199 #include "lib/ldb/include/ldb.h"
200 #include "lib/tdb/include/tdb.h"
201 #include "lib/tdb/include/spinlock.h"
202 #include "lib/tdb/include/tdbutil.h"
204 #include "nt_status.h"
208 #include "messages.h"
210 #include "dynconfig.h"
216 #include "lib/socket/socket.h"
217 #include "libcli/ldap/ldap.h"
218 #include "nameserv.h"
220 #include "byteorder.h"
229 #include "librpc/ndr/libndr.h"
230 #include "librpc/ndr/ndr_sec.h"
231 #include "librpc/gen_ndr/ndr_misc.h"
232 #include "librpc/gen_ndr/ndr_dcerpc.h"
233 #include "librpc/rpc/dcerpc.h"
234 #include "librpc/gen_ndr/tables.h"
236 #include "smb_interfaces.h"
237 #include "smbd/server.h"
238 #include "smbd/service.h"
239 #include "rpc_server/dcerpc_server.h"
242 #include "smb_server/smb_server.h"
243 #include "ntvfs/ntvfs.h"
244 #include "cli_context.h"
245 #include "registry.h"
247 #include "ldap_server/ldap_server.h"
249 #include "libnet/libnet.h"
250 #include "utils/net/net.h"
252 #include "nsswitch/winbind_client.h"
254 /* hmm, this really is getting ugly isn't it .... we probably need to
255 have some way to have subsystem includes without including it
257 #include "ntvfs/posix/vfs_posix.h"
259 #define malloc_p(type) (type *)malloc(sizeof(type))
260 #define malloc_array_p(type, count) (type *)realloc_array(NULL, sizeof(type), count)
261 #define realloc_p(p, type, count) (type *)realloc_array(p, sizeof(type), count)
263 #ifndef HAVE_COMPARISON_FN_T
264 typedef int (*comparison_fn_t)(const void *, const void *);
267 /***** automatically generated prototypes *****/
268 #define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2)
270 #undef _PRINTF_ATTRIBUTE
271 #define _PRINTF_ATTRIBUTE(a1, a2)
273 /* String routines */
275 #include "safe_string.h"
278 #define QSORT_CAST (__compar_fn_t)
282 #define QSORT_CAST (int (*)(const void *, const void *))
286 #define SIGCLD SIGCHLD
293 #if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
294 #define OSF1_ENH_SEC 1
297 #ifndef ALLOW_CHANGE_PASSWORD
298 #if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
299 #define ALLOW_CHANGE_PASSWORD 1
303 /* what is the longest significant password available on your system?
304 Knowing this speeds up password searches a lot */
305 #ifndef PASSWORD_LENGTH
306 #define PASSWORD_LENGTH 8
314 #define MAXPATHLEN 256
321 #ifndef INADDR_LOOPBACK
322 #define INADDR_LOOPBACK 0x7f000001
326 #define INADDR_NONE 0xffffffff
329 #if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
330 #define ULTRIX_AUTH 1
334 char *strdup(const char *s);
338 void *memmove(void *dest,const void *src,int size);
342 time_t mktime(struct tm *t);
346 size_t strlcpy(char *d, const char *s, size_t bufsize);
350 size_t strlcat(char *d, const char *s, size_t bufsize);
353 #ifndef HAVE_FTRUNCATE
354 int ftruncate(int f,long l);
358 char *strndup(const char *s, size_t n);
362 size_t strnlen(const char *s, size_t n);
366 unsigned long strtoul(const char *nptr, char **endptr, int base);
370 int setenv(const char *name, const char *value, int overwrite);
373 #ifndef HAVE_VASPRINTF_DECL
374 int vasprintf(char **ptr, const char *format, va_list ap);
377 #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
378 #define bzero(a,b) memset((a),'\0',(b))
381 extern int DEBUGLEVEL;
383 /* add varargs prototypes with printf checking */
384 #ifndef HAVE_SNPRINTF_DECL
385 int snprintf(char *,size_t ,const char *, ...) PRINTF_ATTRIBUTE(3,4);
387 #ifndef HAVE_ASPRINTF_DECL
388 int asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3);
392 /* we used to use these fns, but now we have good replacements
393 for snprintf and vsnprintf */
394 #define slprintf snprintf
397 /* we need to use __va_copy() on some platforms */
399 #define VA_COPY(dest, src) __va_copy(dest, src)
401 #define VA_COPY(dest, src) (dest) = (src)
405 time_t timegm(struct tm *tm);
408 #if defined(VALGRIND)
409 #define strlen(x) valgrind_strlen(x)
412 #define TALLOC_ABORT(reason) smb_panic(reason)
416 this is a warning hack. The idea is to use this everywhere that we
417 get the "discarding const" warning from gcc. That doesn't actually
418 fix the problem of course, but it means that when we do get to
419 cleaning them up we can do it by searching the code for
422 It also means that other error types aren't as swamped by the noise
423 of hundreds of const warnings, so we are more likely to notice when
426 Please only add more uses of this macro when you find it
427 _really_ hard to fix const warnings. Our aim is to eventually use
428 this function in only a very few places.
430 Also, please call this via the discard_const_p() macro interface, as that
431 makes the return type safe.
434 #define discard_const(ptr) ((void *)((intptr_t)(ptr)))
436 #define discard_const(ptr) ((void *)(ptr))
438 #define discard_const_p(type, ptr) ((type *)discard_const(ptr))
440 #endif /* _INCLUDES_H */