source: branches/samba-3.3.x/source/include/includes.h

Last change on this file was 370, checked in by Herwig Bauernfeind, 16 years ago

Update Samba 3.3 to 3.3.10 (source)

File size: 30.7 KB
Line 
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 3 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, see <http://www.gnu.org/licenses/>.
21*/
22
23#include "lib/replace/replace.h"
24
25/* make sure we have included the correct config.h */
26#ifndef NO_CONFIG_H /* for some tests */
27#ifndef CONFIG_H_IS_FROM_SAMBA
28#error "make sure you have removed all config.h files from standalone builds!"
29#error "the included config.h isn't from samba!"
30#endif
31#endif /* NO_CONFIG_H */
32
33/* only do the C++ reserved word check when we compile
34 to include --with-developer since too many systems
35 still have comflicts with their header files (e.g. IRIX 6.4) */
36
37#if !defined(__cplusplus) && defined(DEVELOPER)
38#define class #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
39#define private #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
40#define public #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
41#define protected #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
42#define template #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
43#define this #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
44#define new #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
45#define delete #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
46#define friend #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
47#endif
48
49#include "local.h"
50
51#ifdef AIX
52#define DEFAULT_PRINTING PRINT_AIX
53#define PRINTCAP_NAME "/etc/qconfig"
54#endif
55
56#ifdef HPUX
57#define DEFAULT_PRINTING PRINT_HPUX
58#endif
59
60#ifdef QNX
61#define DEFAULT_PRINTING PRINT_QNX
62#endif
63
64#ifdef SUNOS4
65/* on SUNOS4 termios.h conflicts with sys/ioctl.h */
66#undef HAVE_TERMIOS_H
67#endif
68
69#ifndef _PUBLIC_
70#ifdef HAVE_VISIBILITY_ATTR
71# define _PUBLIC_ __attribute__((visibility("default")))
72#else
73# define _PUBLIC_
74#endif
75#endif
76
77#if defined(__GNUC__) && !defined(__cplusplus)
78/** gcc attribute used on function parameters so that it does not emit
79 * warnings about them being unused. **/
80# define UNUSED(param) param __attribute__ ((unused))
81#else
82# define UNUSED(param) param
83/** Feel free to add definitions for other compilers here. */
84#endif
85
86#ifdef RELIANTUNIX
87/*
88 * <unistd.h> has to be included before any other to get
89 * large file support on Reliant UNIX. Yes, it's broken :-).
90 */
91#ifdef HAVE_UNISTD_H
92#include <unistd.h>
93#endif
94#endif /* RELIANTUNIX */
95
96#include "system/capability.h"
97#include "system/dir.h"
98#include "system/filesys.h"
99#include "system/glob.h"
100#include "system/iconv.h"
101#include "system/locale.h"
102#include "system/network.h"
103#include "system/passwd.h"
104#include "system/readline.h"
105#include "system/select.h"
106#include "system/shmem.h"
107#include "system/syslog.h"
108#include "system/terminal.h"
109#include "system/time.h"
110#include "system/wait.h"
111
112#if defined(HAVE_RPC_RPC_H)
113/*
114 * Check for AUTH_ERROR define conflict with rpc/rpc.h in prot.h.
115 */
116#if defined(HAVE_SYS_SECURITY_H) && defined(HAVE_RPC_AUTH_ERROR_CONFLICT)
117#undef AUTH_ERROR
118#endif
119/*
120 * HP-UX 11.X has TCP_NODELAY and TCP_MAXSEG defined in <netinet/tcp.h> which
121 * was included above. However <rpc/rpc.h> includes <sys/xti.h> which defines
122 * them again without checking if they already exsist. This generates
123 * two "Redefinition of macro" warnings for every single .c file that is
124 * compiled.
125 */
126#if defined(HPUX) && defined(TCP_NODELAY)
127#undef TCP_NODELAY
128#endif
129#if defined(HPUX) && defined(TCP_MAXSEG)
130#undef TCP_MAXSEG
131#endif
132#include <rpc/rpc.h>
133#endif
134
135#if defined(HAVE_YP_GET_DEFAULT_DOMAIN) && defined(HAVE_SETNETGRENT) && defined(HAVE_ENDNETGRENT) && defined(HAVE_GETNETGRENT)
136#define HAVE_NETGROUP 1
137#endif
138
139#if defined (HAVE_NETGROUP)
140#if defined(HAVE_RPCSVC_YP_PROT_H)
141/*
142 * HP-UX 11.X has TCP_NODELAY and TCP_MAXSEG defined in <netinet/tcp.h> which
143 * was included above. However <rpc/rpc.h> includes <sys/xti.h> which defines
144 * them again without checking if they already exsist. This generates
145 * two "Redefinition of macro" warnings for every single .c file that is
146 * compiled.
147 */
148#if defined(HPUX) && defined(TCP_NODELAY)
149#undef TCP_NODELAY
150#endif
151#if defined(HPUX) && defined(TCP_MAXSEG)
152#undef TCP_MAXSEG
153#endif
154#include <rpcsvc/yp_prot.h>
155#endif
156#if defined(HAVE_RPCSVC_YPCLNT_H)
157#include <rpcsvc/ypclnt.h>
158#endif
159#endif /* HAVE_NETGROUP */
160
161#ifndef HAVE_KRB5_H
162#undef HAVE_KRB5
163#endif
164
165#if HAVE_LBER_H
166#include <lber.h>
167#if defined(HPUX) && !defined(_LBER_TYPES_H)
168/* Define ber_tag_t and ber_int_t for using
169 * HP LDAP-UX Integration products' LDAP libraries.
170*/
171#ifndef ber_tag_t
172typedef unsigned long ber_tag_t;
173typedef int ber_int_t;
174#endif
175#endif /* defined(HPUX) && !defined(_LBER_TYPES_H) */
176#ifndef LBER_USE_DER
177#define LBER_USE_DER 0x01
178#endif
179#endif
180
181#if HAVE_LDAP_H
182#include <ldap.h>
183#ifndef LDAP_CONST
184#define LDAP_CONST const
185#endif
186#ifndef LDAP_OPT_SUCCESS
187#define LDAP_OPT_SUCCESS 0
188#endif
189/* Solaris 8 and maybe other LDAP implementations spell this "..._INPROGRESS": */
190#if defined(LDAP_SASL_BIND_INPROGRESS) && !defined(LDAP_SASL_BIND_IN_PROGRESS)
191#define LDAP_SASL_BIND_IN_PROGRESS LDAP_SASL_BIND_INPROGRESS
192#endif
193/* Solaris 8 defines SSL_LDAP_PORT, not LDAPS_PORT and it only does so if
194 LDAP_SSL is defined - but SSL is not working. We just want the
195 port number! Let's just define LDAPS_PORT correct. */
196#if !defined(LDAPS_PORT)
197#define LDAPS_PORT 636
198#endif
199#else
200#undef HAVE_LDAP
201#endif
202
203#if HAVE_GSSAPI_GSSAPI_H
204#include <gssapi/gssapi.h>
205#elif HAVE_GSSAPI_GSSAPI_GENERIC_H
206#include <gssapi/gssapi_generic.h>
207#elif HAVE_GSSAPI_H
208#include <gssapi.h>
209#endif
210
211#if HAVE_COM_ERR_H
212#include <com_err.h>
213#endif
214
215#if HAVE_SYS_ATTRIBUTES_H
216#include <sys/attributes.h>
217#endif
218
219#ifndef ENOATTR
220#define ENOATTR ENODATA
221#endif
222
223/* mutually exclusive (SuSE 8.2) */
224#if HAVE_ATTR_XATTR_H
225#include <attr/xattr.h>
226#elif HAVE_SYS_XATTR_H
227#include <sys/xattr.h>
228#endif
229
230#ifdef HAVE_SYS_EA_H
231#include <sys/ea.h>
232#endif
233
234#ifdef HAVE_SYS_EXTATTR_H
235#include <sys/extattr.h>
236#endif
237
238#ifdef HAVE_SYS_UIO_H
239#include <sys/uio.h>
240#endif
241
242#if HAVE_LANGINFO_H
243#include <langinfo.h>
244#endif
245
246#if HAVE_NETGROUP_H
247#include <netgroup.h>
248#endif
249
250#if defined(HAVE_AIO_H) && defined(WITH_AIO)
251#include <aio.h>
252#endif
253
254/* skip valgrind headers on 64bit AMD boxes */
255#ifndef HAVE_64BIT_LINUX
256/* Special macros that are no-ops except when run under Valgrind on
257 * x86. They've moved a little bit from valgrind 1.0.4 to 1.9.4 */
258#if HAVE_VALGRIND_MEMCHECK_H
259 /* memcheck.h includes valgrind.h */
260#include <valgrind/memcheck.h>
261#elif HAVE_VALGRIND_H
262#include <valgrind.h>
263#endif
264#endif
265
266/* If we have --enable-developer and the valgrind header is present,
267 * then we're OK to use it. Set a macro so this logic can be done only
268 * once. */
269#if defined(DEVELOPER) && !defined(HAVE_64BIT_LINUX)
270#if (HAVE_VALGRIND_H || HAVE_VALGRIND_VALGRIND_H)
271#define VALGRIND
272#endif
273#endif
274
275
276/* we support ADS if we want it and have krb5 and ldap libs */
277#if defined(WITH_ADS) && defined(HAVE_KRB5) && defined(HAVE_LDAP)
278#define HAVE_ADS
279#endif
280
281/*
282 * Define VOLATILE if needed.
283 */
284
285#if defined(HAVE_VOLATILE)
286#define VOLATILE volatile
287#else
288#define VOLATILE
289#endif
290
291/*
292 * Define additional missing types
293 */
294#if defined(HAVE_SIG_ATOMIC_T_TYPE) && defined(AIX)
295typedef sig_atomic_t SIG_ATOMIC_T;
296#elif defined(HAVE_SIG_ATOMIC_T_TYPE) && !defined(AIX)
297typedef sig_atomic_t VOLATILE SIG_ATOMIC_T;
298#else
299typedef int VOLATILE SIG_ATOMIC_T;
300#endif
301
302#ifndef uchar
303#define uchar unsigned char
304#endif
305
306#ifdef HAVE_UNSIGNED_CHAR
307#define schar signed char
308#else
309#define schar char
310#endif
311
312/*
313 Samba needs type definitions for int16, int32, uint16 and uint32.
314
315 Normally these are signed and unsigned 16 and 32 bit integers, but
316 they actually only need to be at least 16 and 32 bits
317 respectively. Thus if your word size is 8 bytes just defining them
318 as signed and unsigned int will work.
319*/
320
321#ifndef uint8
322#define uint8 unsigned char
323#endif
324
325#if !defined(int16) && !defined(HAVE_INT16_FROM_RPC_RPC_H)
326# if (SIZEOF_SHORT == 4)
327# define int16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
328# else /* SIZEOF_SHORT != 4 */
329# define int16 short
330# endif /* SIZEOF_SHORT != 4 */
331 /* needed to work around compile issue on HP-UX 11.x */
332# define _INT16 1
333#endif
334
335/*
336 * Note we duplicate the size tests in the unsigned
337 * case as int16 may be a typedef from rpc/rpc.h
338 */
339
340#if !defined(uint16) && !defined(HAVE_UINT16_FROM_RPC_RPC_H)
341#if (SIZEOF_SHORT == 4)
342#define uint16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
343#else /* SIZEOF_SHORT != 4 */
344#define uint16 unsigned short
345#endif /* SIZEOF_SHORT != 4 */
346#endif
347
348#if !defined(int32) && !defined(HAVE_INT32_FROM_RPC_RPC_H)
349# if (SIZEOF_INT == 4)
350# define int32 int
351# elif (SIZEOF_LONG == 4)
352# define int32 long
353# elif (SIZEOF_SHORT == 4)
354# define int32 short
355# else
356 /* uggh - no 32 bit type?? probably a CRAY. just hope this works ... */
357# define int32 int
358# endif
359 /* needed to work around compile issue on HP-UX 11.x */
360# define _INT32 1
361#endif
362
363/*
364 * Note we duplicate the size tests in the unsigned
365 * case as int32 may be a typedef from rpc/rpc.h
366 */
367
368#if !defined(uint32) && !defined(HAVE_UINT32_FROM_RPC_RPC_H)
369#if (SIZEOF_INT == 4)
370#define uint32 unsigned int
371#elif (SIZEOF_LONG == 4)
372#define uint32 unsigned long
373#elif (SIZEOF_SHORT == 4)
374#define uint32 unsigned short
375#else
376/* uggh - no 32 bit type?? probably a CRAY. just hope this works ... */
377#define uint32 unsigned
378#endif
379#endif
380
381/*
382 * check for 8 byte long long
383 */
384
385#if !defined(uint64)
386#if (SIZEOF_LONG == 8)
387#define uint64 unsigned long
388#elif (SIZEOF_LONG_LONG == 8)
389#define uint64 unsigned long long
390#endif /* don't lie. If we don't have it, then don't use it */
391#endif
392
393#if !defined(int64)
394#if (SIZEOF_LONG == 8)
395#define int64 long
396#elif (SIZEOF_LONG_LONG == 8)
397#define int64 long long
398#endif /* don't lie. If we don't have it, then don't use it */
399#endif
400
401
402/*
403 * Types for devices, inodes and offsets.
404 */
405
406#ifndef SMB_DEV_T
407# if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_DEV64_T)
408# define SMB_DEV_T dev64_t
409# else
410# define SMB_DEV_T dev_t
411# endif
412#endif
413
414#ifndef LARGE_SMB_DEV_T
415# if (defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_DEV64_T)) || (defined(SIZEOF_DEV_T) && (SIZEOF_DEV_T == 8))
416# define LARGE_SMB_DEV_T 1
417# endif
418#endif
419
420#ifdef LARGE_SMB_DEV_T
421#define SDEV_T_VAL(p, ofs, v) (SIVAL((p),(ofs),(v)&0xFFFFFFFF), SIVAL((p),(ofs)+4,(v)>>32))
422#define DEV_T_VAL(p, ofs) ((SMB_DEV_T)(((SMB_BIG_UINT)(IVAL((p),(ofs))))| (((SMB_BIG_UINT)(IVAL((p),(ofs)+4))) << 32)))
423#else
424#define SDEV_T_VAL(p, ofs, v) (SIVAL((p),(ofs),v),SIVAL((p),(ofs)+4,0))
425#define DEV_T_VAL(p, ofs) ((SMB_DEV_T)(IVAL((p),(ofs))))
426#endif
427
428/*
429 * Setup the correctly sized inode type.
430 */
431
432#ifndef SMB_INO_T
433# if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_INO64_T)
434# define SMB_INO_T ino64_t
435# else
436# define SMB_INO_T ino_t
437# endif
438#endif
439
440#ifndef LARGE_SMB_INO_T
441# if (defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_INO64_T)) || (defined(SIZEOF_INO_T) && (SIZEOF_INO_T == 8))
442# define LARGE_SMB_INO_T 1
443# endif
444#endif
445
446#ifdef LARGE_SMB_INO_T
447#define SINO_T_VAL(p, ofs, v) (SIVAL((p),(ofs),(v)&0xFFFFFFFF), SIVAL((p),(ofs)+4,(v)>>32))
448#define INO_T_VAL(p, ofs) ((SMB_INO_T)(((SMB_BIG_UINT)(IVAL(p,ofs)))| (((SMB_BIG_UINT)(IVAL(p,(ofs)+4))) << 32)))
449#else
450#define SINO_T_VAL(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
451#define INO_T_VAL(p, ofs) ((SMB_INO_T)(IVAL((p),(ofs))))
452#endif
453
454#ifndef SMB_OFF_T
455# if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T)
456# define SMB_OFF_T off64_t
457# else
458# define SMB_OFF_T off_t
459# endif
460#endif
461
462#if defined(HAVE_LONGLONG)
463#define SMB_BIG_UINT unsigned long long
464#define SMB_BIG_INT long long
465#define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
466#define BIG_UINT(p, ofs) ((((SMB_BIG_UINT) IVAL(p,(ofs)+4))<<32)|IVAL(p,ofs))
467#else
468#define SMB_BIG_UINT unsigned long
469#define SMB_BIG_INT long
470#define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
471#define BIG_UINT(p, ofs) (IVAL(p,ofs))
472#endif
473
474#define SMB_BIG_UINT_BITS (sizeof(SMB_BIG_UINT)*8)
475
476/* this should really be a 64 bit type if possible */
477#define br_off SMB_BIG_UINT
478
479#define SMB_OFF_T_BITS (sizeof(SMB_OFF_T)*8)
480
481/*
482 * Set the define that tells us if we can do 64 bit
483 * NT SMB calls.
484 */
485
486#ifndef LARGE_SMB_OFF_T
487# if (defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T)) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8))
488# define LARGE_SMB_OFF_T 1
489# endif
490#endif
491
492#ifdef LARGE_SMB_OFF_T
493#define SOFF_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
494#define SOFF_T_R(p, ofs, v) (SIVAL(p,(ofs)+4,(v)&0xFFFFFFFF), SIVAL(p,ofs,(v)>>32))
495#define IVAL_TO_SMB_OFF_T(buf,off) ((SMB_OFF_T)(( ((SMB_BIG_UINT)(IVAL((buf),(off)))) & ((SMB_BIG_UINT)0xFFFFFFFF) )))
496#define IVAL2_TO_SMB_BIG_UINT(buf,off) ( (((SMB_BIG_UINT)(IVAL((buf),(off)))) & ((SMB_BIG_UINT)0xFFFFFFFF)) | \
497 (( ((SMB_BIG_UINT)(IVAL((buf),(off+4)))) & ((SMB_BIG_UINT)0xFFFFFFFF) ) << 32 ) )
498#else
499#define SOFF_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
500#define SOFF_T_R(p, ofs, v) (SIVAL(p,(ofs)+4,v),SIVAL(p,ofs,0))
501#define IVAL_TO_SMB_OFF_T(buf,off) ((SMB_OFF_T)(( ((uint32)(IVAL((buf),(off)))) & 0xFFFFFFFF )))
502#define IVAL2_TO_SMB_BIG_UINT(buf,off) ( (((SMB_BIG_UINT)(IVAL((buf),(off)))) & ((SMB_BIG_UINT)0xFFFFFFFF)) | \
503 (( ((SMB_BIG_UINT)(IVAL((buf),(off+4)))) & ((SMB_BIG_UINT)0xFFFFFFFF) ) << 32 ) )
504#endif
505
506/*
507 * Type for stat structure.
508 */
509
510#ifndef SMB_STRUCT_STAT
511# if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STAT64) && defined(HAVE_OFF64_T)
512# define SMB_STRUCT_STAT struct stat64
513# else
514# define SMB_STRUCT_STAT struct stat
515# endif
516#endif
517
518/*
519 * Type for dirent structure.
520 */
521
522#ifndef SMB_STRUCT_DIRENT
523# if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_DIRENT64)
524# define SMB_STRUCT_DIRENT struct dirent64
525# else
526# define SMB_STRUCT_DIRENT struct dirent
527# endif
528#endif
529
530/*
531 * Type for DIR structure.
532 */
533
534#ifndef SMB_STRUCT_DIR
535# if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_DIR64)
536# define SMB_STRUCT_DIR DIR64
537# else
538# define SMB_STRUCT_DIR DIR
539# endif
540#endif
541
542/*
543 * Defines for 64 bit fcntl locks.
544 */
545
546#ifndef SMB_STRUCT_FLOCK
547# if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
548# define SMB_STRUCT_FLOCK struct flock64
549# else
550# define SMB_STRUCT_FLOCK struct flock
551# endif
552#endif
553
554#ifndef SMB_F_SETLKW
555# if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
556# define SMB_F_SETLKW F_SETLKW64
557# else
558# define SMB_F_SETLKW F_SETLKW
559# endif
560#endif
561
562#ifndef SMB_F_SETLK
563# if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
564# define SMB_F_SETLK F_SETLK64
565# else
566# define SMB_F_SETLK F_SETLK
567# endif
568#endif
569
570#ifndef SMB_F_GETLK
571# if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
572# define SMB_F_GETLK F_GETLK64
573# else
574# define SMB_F_GETLK F_GETLK
575# endif
576#endif
577
578/*
579 * Type for aiocb structure.
580 */
581
582#ifndef SMB_STRUCT_AIOCB
583# if defined(WITH_AIO)
584# if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_AIOCB64)
585# define SMB_STRUCT_AIOCB struct aiocb64
586# else
587# define SMB_STRUCT_AIOCB struct aiocb
588# endif
589# else
590# define SMB_STRUCT_AIOCB int /* AIO not being used but we still need the define.... */
591# endif
592#endif
593
594#ifndef HAVE_STRUCT_TIMESPEC
595struct timespec {
596 time_t tv_sec; /* Seconds. */
597 long tv_nsec; /* Nanoseconds. */
598};
599#endif
600
601#ifndef MIN
602#define MIN(a,b) ((a)<(b)?(a):(b))
603#endif
604
605#ifndef MAX
606#define MAX(a,b) ((a)>(b)?(a):(b))
607#endif
608
609#ifdef HAVE_BROKEN_GETGROUPS
610#define GID_T int
611#else
612#define GID_T gid_t
613#endif
614
615#ifndef NGROUPS_MAX
616#define NGROUPS_MAX 32 /* Guess... */
617#endif
618
619/* Our own fstrings */
620
621/*
622 --------------
623 / \
624 / REST \
625 / IN \
626 / PEACE \
627 / \
628 | The infamous pstring |
629 | |
630 | |
631 | 7 December |
632 | |
633 | 2007 |
634 *| * * * | *
635 _________)/\\_//(\/(/\)/\//\/\///|_)_______
636*/
637
638#ifndef FSTRING_LEN
639#define FSTRING_LEN 256
640typedef char fstring[FSTRING_LEN];
641#endif
642
643/* Lists, trees, caching, database... */
644#include "xfile.h"
645#include "intl.h"
646#include "dlinklist.h"
647#include "tdb.h"
648#include "util_tdb.h"
649
650#include "lib/talloc/talloc.h"
651/* And a little extension. Abort on type mismatch */
652#define talloc_get_type_abort(ptr, type) \
653 (type *)talloc_check_name_abort(ptr, #type)
654
655#include "event.h"
656#include "nt_status.h"
657#include "ads.h"
658#include "ads_dns.h"
659#include "interfaces.h"
660#include "trans2.h"
661#include "nterr.h"
662#include "ntioctl.h"
663#include "charset.h"
664#include "dynconfig.h"
665#include "util_getent.h"
666#include "debugparse.h"
667#include "version.h"
668#include "privileges.h"
669#include "messages.h"
670#include "locking.h"
671#include "smb.h"
672#include "nameserv.h"
673#include "secrets.h"
674#include "byteorder.h"
675#include "privileges.h"
676#include "rpc_misc.h"
677#include "rpc_dce.h"
678#include "mapping.h"
679#include "passdb.h"
680#include "rpc_secdes.h"
681#include "gpo.h"
682#include "msdfs.h"
683#include "rap.h"
684#include "md5.h"
685#include "hmacmd5.h"
686#include "ntlmssp.h"
687#include "auth.h"
688#include "ntdomain.h"
689#include "rpc_svcctl.h"
690#include "rpc_ntsvcs.h"
691#include "rpc_lsa.h"
692#include "reg_objects.h"
693#include "reg_db.h"
694#include "rpc_spoolss.h"
695#include "rpc_eventlog.h"
696#include "rpc_perfcount.h"
697#include "rpc_perfcount_defs.h"
698#include "librpc/gen_ndr/notify.h"
699#include "librpc/gen_ndr/xattr.h"
700#include "librpc/gen_ndr/ndr_nbt.h"
701#include "librpc/gen_ndr/messaging.h"
702#include "librpc/rpc/dcerpc.h"
703#include "nt_printing.h"
704#include "idmap.h"
705#include "client.h"
706
707#include "session.h"
708#include "asn_1.h"
709#include "popt.h"
710#include "mangle.h"
711#include "module.h"
712#include "nsswitch/winbind_client.h"
713#include "spnego.h"
714#include "rpc_client.h"
715#include "dbwrap.h"
716#include "packet.h"
717#include "ctdbd_conn.h"
718#include "talloc_stack.h"
719#include "memcache.h"
720#include "async_req.h"
721#include "async_smb.h"
722#include "async_sock.h"
723
724#include "lib/smbconf/smbconf.h"
725#include "lib/smbconf/smbconf_init.h"
726#include "lib/smbconf/smbconf_reg.h"
727#include "lib/smbconf/smbconf_txt.h"
728
729/* Defines for wisXXX functions. */
730#define UNI_UPPER 0x1
731#define UNI_LOWER 0x2
732#define UNI_DIGIT 0x4
733#define UNI_XDIGIT 0x8
734#define UNI_SPACE 0x10
735
736#include "nsswitch/winbind_nss.h"
737
738/* forward declaration from printing.h to get around
739 header file dependencies */
740
741struct printjob;
742
743/* forward declarations from smbldap.c */
744
745#include "smbldap.h"
746
747#include "smb_ldap.h"
748
749struct dns_reg_state;
750
751void dns_register_smbd(struct dns_reg_state ** dns_state_ptr,
752 unsigned port,
753 int *maxfd,
754 fd_set *listen_set,
755 struct timeval *timeout);
756
757void dns_register_close(struct dns_reg_state ** dns_state_ptr);
758
759
760bool dns_register_smbd_reply(struct dns_reg_state *dns_state,
761 fd_set *lfds, struct timeval *timeout);
762
763/*
764 * Reasons for cache flush.
765 */
766
767enum flush_reason_enum {
768 SEEK_FLUSH,
769 READ_FLUSH,
770 WRITE_FLUSH,
771 READRAW_FLUSH,
772 OPLOCK_RELEASE_FLUSH,
773 CLOSE_FLUSH,
774 SYNC_FLUSH,
775 SIZECHANGE_FLUSH,
776 /* NUM_FLUSH_REASONS must remain the last value in the enumeration. */
777 NUM_FLUSH_REASONS};
778
779#include "nss_info.h"
780#include "modules/nfs4_acls.h"
781#include "nsswitch/libwbclient/wbclient.h"
782
783/* generated rpc server implementation functions */
784#include "librpc/gen_ndr/srv_echo.h"
785#include "librpc/gen_ndr/srv_svcctl.h"
786#include "librpc/gen_ndr/srv_lsa.h"
787#include "librpc/gen_ndr/srv_eventlog.h"
788#include "librpc/gen_ndr/srv_winreg.h"
789#include "librpc/gen_ndr/srv_initshutdown.h"
790#include "librpc/gen_ndr/srv_netlogon.h"
791#include "librpc/gen_ndr/srv_samr.h"
792#include "librpc/gen_ndr/srv_wkssvc.h"
793#include "librpc/gen_ndr/srv_srvsvc.h"
794#include "librpc/gen_ndr/srv_ntsvcs.h"
795#include "librpc/gen_ndr/srv_dssetup.h"
796#include "librpc/gen_ndr/srv_dfs.h"
797
798/***** automatically generated prototypes *****/
799#ifndef NO_PROTO_H
800#include "proto.h"
801#endif
802
803#if defined(HAVE_POSIX_ACLS)
804#include "modules/vfs_posixacl.h"
805#endif
806
807#if defined(HAVE_TRU64_ACLS)
808#include "modules/vfs_tru64acl.h"
809#endif
810
811#if defined(HAVE_SOLARIS_ACLS) || defined(HAVE_UNIXWARE_ACLS)
812#include "modules/vfs_solarisacl.h"
813#endif
814
815#if defined(HAVE_HPUX_ACLS)
816#include "modules/vfs_hpuxacl.h"
817#endif
818
819#if defined(HAVE_IRIX_ACLS)
820#include "modules/vfs_irixacl.h"
821#endif
822
823#ifdef HAVE_LDAP
824#include "ads_protos.h"
825#endif
826
827/* We need this after proto.h to reference GetTimeOfDay(). */
828#include "smbprofile.h"
829
830/* String routines */
831
832#include "srvstr.h"
833#include "safe_string.h"
834
835/* prototypes from lib/util_transfer_file.c */
836#include "transfer_file.h"
837
838#ifdef __COMPAR_FN_T
839#define QSORT_CAST (__compar_fn_t)
840#endif
841
842#ifndef QSORT_CAST
843#define QSORT_CAST (int (*)(const void *, const void *))
844#endif
845
846#ifndef DEFAULT_PRINTING
847#ifdef HAVE_CUPS
848#define DEFAULT_PRINTING PRINT_CUPS
849#define PRINTCAP_NAME "cups"
850#elif defined(SYSV)
851#define DEFAULT_PRINTING PRINT_SYSV
852#define PRINTCAP_NAME "lpstat"
853#else
854#define DEFAULT_PRINTING PRINT_BSD
855#define PRINTCAP_NAME "/etc/printcap"
856#endif
857#endif
858
859#ifndef PRINTCAP_NAME
860#define PRINTCAP_NAME "/etc/printcap"
861#endif
862
863#ifndef SIGCLD
864#define SIGCLD SIGCHLD
865#endif
866
867#ifndef SIGRTMIN
868#define SIGRTMIN 32
869#endif
870
871#ifndef MAP_FILE
872#define MAP_FILE 0
873#endif
874
875#if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
876#define OSF1_ENH_SEC 1
877#endif
878
879#ifndef ALLOW_CHANGE_PASSWORD
880#if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
881#define ALLOW_CHANGE_PASSWORD 1
882#endif
883#endif
884
885/* what is the longest significant password available on your system?
886 Knowing this speeds up password searches a lot */
887#ifndef PASSWORD_LENGTH
888#define PASSWORD_LENGTH 8
889#endif
890
891#ifndef HAVE_PIPE
892#define SYNC_DNS 1
893#endif
894
895#ifndef SEEK_SET
896#define SEEK_SET 0
897#endif
898
899#ifndef INADDR_LOOPBACK
900#define INADDR_LOOPBACK 0x7f000001
901#endif
902
903#ifndef INADDR_NONE
904#define INADDR_NONE 0xffffffff
905#endif
906
907#ifndef HAVE_CRYPT
908#define crypt ufc_crypt
909#endif
910
911#ifndef O_ACCMODE
912#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
913#endif
914
915#if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
916#define ULTRIX_AUTH 1
917#endif
918
919#if (defined(USE_SETRESUID) && !defined(HAVE_SETRESUID_DECL))
920/* stupid glibc */
921int setresuid(uid_t ruid, uid_t euid, uid_t suid);
922#endif
923#if (defined(USE_SETRESUID) && !defined(HAVE_SETRESGID_DECL))
924int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
925#endif
926
927/*
928 * Some older systems seem not to have MAXHOSTNAMELEN
929 * defined.
930 */
931#ifndef MAXHOSTNAMELEN
932#define MAXHOSTNAMELEN 255
933#endif
934
935/* yuck, I'd like a better way of doing this */
936#define DIRP_SIZE (256 + 32)
937
938/*
939 * glibc on linux doesn't seem to have MSG_WAITALL
940 * defined. I think the kernel has it though..
941 */
942
943#ifndef MSG_WAITALL
944#define MSG_WAITALL 0
945#endif
946
947/* default socket options. Dave Miller thinks we should default to TCP_NODELAY
948 given the socket IO pattern that Samba uses */
949#ifdef TCP_NODELAY
950#define DEFAULT_SOCKET_OPTIONS "TCP_NODELAY"
951#else
952#define DEFAULT_SOCKET_OPTIONS ""
953#endif
954
955/* dmalloc -- free heap debugger (dmalloc.org). This should be near
956 * the *bottom* of include files so as not to conflict. */
957#ifdef ENABLE_DMALLOC
958# include <dmalloc.h>
959#endif
960
961
962/* Some POSIX definitions for those without */
963
964#ifndef S_IFDIR
965#define S_IFDIR 0x4000
966#endif
967#ifndef S_ISDIR
968#define S_ISDIR(mode) ((mode & 0xF000) == S_IFDIR)
969#endif
970#ifndef S_IRWXU
971#define S_IRWXU 00700 /* read, write, execute: owner */
972#endif
973#ifndef S_IRUSR
974#define S_IRUSR 00400 /* read permission: owner */
975#endif
976#ifndef S_IWUSR
977#define S_IWUSR 00200 /* write permission: owner */
978#endif
979#ifndef S_IXUSR
980#define S_IXUSR 00100 /* execute permission: owner */
981#endif
982#ifndef S_IRWXG
983#define S_IRWXG 00070 /* read, write, execute: group */
984#endif
985#ifndef S_IRGRP
986#define S_IRGRP 00040 /* read permission: group */
987#endif
988#ifndef S_IWGRP
989#define S_IWGRP 00020 /* write permission: group */
990#endif
991#ifndef S_IXGRP
992#define S_IXGRP 00010 /* execute permission: group */
993#endif
994#ifndef S_IRWXO
995#define S_IRWXO 00007 /* read, write, execute: other */
996#endif
997#ifndef S_IROTH
998#define S_IROTH 00004 /* read permission: other */
999#endif
1000#ifndef S_IWOTH
1001#define S_IWOTH 00002 /* write permission: other */
1002#endif
1003#ifndef S_IXOTH
1004#define S_IXOTH 00001 /* execute permission: other */
1005#endif
1006
1007/* For sys_adminlog(). */
1008#ifndef LOG_EMERG
1009#define LOG_EMERG 0 /* system is unusable */
1010#endif
1011
1012#ifndef LOG_ALERT
1013#define LOG_ALERT 1 /* action must be taken immediately */
1014#endif
1015
1016#ifndef LOG_CRIT
1017#define LOG_CRIT 2 /* critical conditions */
1018#endif
1019
1020#ifndef LOG_ERR
1021#define LOG_ERR 3 /* error conditions */
1022#endif
1023
1024#ifndef LOG_WARNING
1025#define LOG_WARNING 4 /* warning conditions */
1026#endif
1027
1028#ifndef LOG_NOTICE
1029#define LOG_NOTICE 5 /* normal but significant condition */
1030#endif
1031
1032#ifndef LOG_INFO
1033#define LOG_INFO 6 /* informational */
1034#endif
1035
1036#ifndef LOG_DEBUG
1037#define LOG_DEBUG 7 /* debug-level messages */
1038#endif
1039
1040#if HAVE_KERNEL_SHARE_MODES
1041#ifndef LOCK_MAND
1042#define LOCK_MAND 32 /* This is a mandatory flock */
1043#define LOCK_READ 64 /* ... Which allows concurrent read operations */
1044#define LOCK_WRITE 128 /* ... Which allows concurrent write operations */
1045#define LOCK_RW 192 /* ... Which allows concurrent read & write ops */
1046#endif
1047#endif
1048
1049extern int DEBUGLEVEL;
1050
1051#define MAX_SEC_CTX_DEPTH 8 /* Maximum number of security contexts */
1052
1053
1054#ifdef GLIBC_HACK_FCNTL64
1055/* this is a gross hack. 64 bit locking is completely screwed up on
1056 i386 Linux in glibc 2.1.95 (which ships with RedHat 7.0). This hack
1057 "fixes" the problem with the current 2.4.0test kernels
1058*/
1059#define fcntl fcntl64
1060#undef F_SETLKW
1061#undef F_SETLK
1062#define F_SETLK 13
1063#define F_SETLKW 14
1064#endif
1065
1066
1067/* Needed for sys_dlopen/sys_dlsym/sys_dlclose */
1068#ifndef RTLD_GLOBAL
1069#define RTLD_GLOBAL 0
1070#endif
1071
1072#ifndef RTLD_LAZY
1073#define RTLD_LAZY 0
1074#endif
1075
1076#ifndef RTLD_NOW
1077#define RTLD_NOW 0
1078#endif
1079
1080/* needed for some systems without iconv. Doesn't really matter
1081 what error code we use */
1082#ifndef EILSEQ
1083#define EILSEQ EIO
1084#endif
1085
1086/* add varargs prototypes with printf checking */
1087/*PRINTFLIKE2 */
1088int fdprintf(int , const char *, ...) PRINTF_ATTRIBUTE(2,3);
1089/*PRINTFLIKE1 */
1090int d_printf(const char *, ...) PRINTF_ATTRIBUTE(1,2);
1091/*PRINTFLIKE2 */
1092int d_fprintf(FILE *f, const char *, ...) PRINTF_ATTRIBUTE(2,3);
1093
1094/* PRINTFLIKE2 */
1095void sys_adminlog(int priority, const char *format_str, ...) PRINTF_ATTRIBUTE(2,3);
1096
1097/* PRINTFLIKE2 */
1098int fstr_sprintf(fstring s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
1099
1100int d_vfprintf(FILE *f, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0);
1101
1102int smb_xvasprintf(char **ptr, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0);
1103
1104int asprintf_strupper_m(char **strp, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
1105char *talloc_asprintf_strupper_m(TALLOC_CTX *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
1106
1107/* we used to use these fns, but now we have good replacements
1108 for snprintf and vsnprintf */
1109#define slprintf snprintf
1110#define vslprintf vsnprintf
1111
1112/* we need to use __va_copy() on some platforms */
1113#ifdef HAVE_VA_COPY
1114#define VA_COPY(dest, src) va_copy(dest, src)
1115#else
1116#ifdef HAVE___VA_COPY
1117#define VA_COPY(dest, src) __va_copy(dest, src)
1118#else
1119#define VA_COPY(dest, src) (dest) = (src)
1120#endif
1121#endif
1122
1123/*
1124 * Veritas File System. Often in addition to native.
1125 * Quotas different.
1126 */
1127#if defined(HAVE_SYS_FS_VX_QUOTA_H)
1128#define VXFS_QUOTA
1129#endif
1130
1131#ifndef XATTR_CREATE
1132#define XATTR_CREATE 0x1 /* set value, fail if attr already exists */
1133#endif
1134
1135#ifndef XATTR_REPLACE
1136#define XATTR_REPLACE 0x2 /* set value, fail if attr does not exist */
1137#endif
1138
1139#ifdef HAVE_LDAP
1140
1141/* function declarations not included in proto.h */
1142LDAP *ldap_open_with_timeout(const char *server, int port, unsigned int to);
1143
1144#endif /* HAVE_LDAP */
1145
1146#if defined(HAVE_LINUX_READAHEAD) && ! defined(HAVE_READAHEAD_DECL)
1147ssize_t readahead(int fd, off64_t offset, size_t count);
1148#endif
1149
1150/* TRUE and FALSE are part of the C99 standard and gcc, but
1151 unfortunately many vendor compilers don't support them. Use True
1152 and False instead. */
1153
1154#ifdef TRUE
1155#undef TRUE
1156#endif
1157#define TRUE __ERROR__XX__DONT_USE_TRUE
1158
1159#ifdef FALSE
1160#undef FALSE
1161#endif
1162#define FALSE __ERROR__XX__DONT_USE_FALSE
1163
1164/* If we have blacklisted mmap() try to avoid using it accidentally by
1165 undefining the HAVE_MMAP symbol. */
1166
1167#ifdef MMAP_BLACKLIST
1168#undef HAVE_MMAP
1169#endif
1170
1171#define CONST_DISCARD(type, ptr) ((type) ((void *) (ptr)))
1172#define CONST_ADD(type, ptr) ((type) ((const void *) (ptr)))
1173
1174#ifndef NORETURN_ATTRIBUTE
1175#if (__GNUC__ >= 3)
1176#define NORETURN_ATTRIBUTE __attribute__ ((noreturn))
1177#else
1178#define NORETURN_ATTRIBUTE
1179#endif
1180#endif
1181
1182void smb_panic( const char *why ) NORETURN_ATTRIBUTE ;
1183void dump_core(void) NORETURN_ATTRIBUTE ;
1184void exit_server(const char *const reason) NORETURN_ATTRIBUTE ;
1185void exit_server_cleanly(const char *const reason) NORETURN_ATTRIBUTE ;
1186void exit_server_fault(void) NORETURN_ATTRIBUTE ;
1187
1188#ifdef HAVE_LIBNSCD
1189#include "libnscd.h"
1190#endif
1191
1192#if defined(HAVE_IPV6)
1193void in6_addr_to_sockaddr_storage(struct sockaddr_storage *ss,
1194 struct in6_addr ip);
1195#endif
1196
1197#endif /* _INCLUDES_H */
Note: See TracBrowser for help on using the repository browser.