update copyright notice since it we are now almost 4 months into 2003
[Samba.git] / source / include / includes.h
blob88dd6cd867a68d96ee5e2afad8a91a14e9c90a26
1 #ifndef _INCLUDES_H
2 #define _INCLUDES_H
3 /*
4 Unix SMB/Netbios implementation.
5 Version 1.9.
6 Machine customisation and include handling
7 Copyright (C) Andrew Tridgell 1994-1998
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 */
25 #include "config.h"
26 #endif
28 #include "local.h"
30 #ifdef AIX
31 #define DEFAULT_PRINTING PRINT_AIX
32 #define PRINTCAP_NAME "/etc/qconfig"
33 #endif
35 #ifdef HPUX
36 #define DEFAULT_PRINTING PRINT_HPUX
37 #endif
39 #ifdef QNX
40 #define DEFAULT_PRINTING PRINT_QNX
41 #endif
43 #ifdef SUNOS4
44 /* on SUNOS4 termios.h conflicts with sys/ioctl.h */
45 #undef HAVE_TERMIOS_H
46 #endif
48 #ifdef LINUX
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 #endif
57 /* use gcc attribute to check printf fns */
58 #ifdef __GNUC__
59 #define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
60 #else
61 #define PRINTF_ATTRIBUTE(a1, a2)
62 #endif
64 #ifdef RELIANTUNIX
66 * <unistd.h> has to be included before any other to get
67 * large file support on Reliant UNIX. Yes, it's broken :-).
69 #ifdef HAVE_UNISTD_H
70 #include <unistd.h>
71 #endif
72 #endif /* RELIANTUNIX */
74 #include <sys/types.h>
76 #ifdef TIME_WITH_SYS_TIME
77 #include <sys/time.h>
78 #include <time.h>
79 #else
80 #ifdef HAVE_SYS_TIME_H
81 #include <sys/time.h>
82 #else
83 #include <time.h>
84 #endif
85 #endif
87 #ifdef HAVE_SYS_RESOURCE_H
88 #include <sys/resource.h>
89 #endif
91 #ifdef HAVE_UNISTD_H
92 #include <unistd.h>
93 #endif
95 #include <stdio.h>
96 #include <stddef.h>
98 #ifdef HAVE_SYS_PARAM_H
99 #include <sys/param.h>
100 #endif
102 #ifdef HAVE_STDLIB_H
103 #include <stdlib.h>
104 #endif
106 #ifdef HAVE_SYS_SOCKET_H
107 #include <sys/socket.h>
108 #endif
110 #ifdef HAVE_UNIXSOCKET
111 #include <sys/un.h>
112 #endif
114 #ifdef HAVE_SYS_SYSCALL_H
115 #include <sys/syscall.h>
116 #elif HAVE_SYSCALL_H
117 #include <syscall.h>
118 #endif
120 #ifdef HAVE_STRING_H
121 #include <string.h>
122 #endif
124 #ifdef HAVE_STRINGS_H
125 #include <strings.h>
126 #endif
128 #ifdef HAVE_MEMORY_H
129 #include <memory.h>
130 #endif
132 #ifdef HAVE_MALLOC_H
133 #include <malloc.h>
134 #endif
136 #ifdef HAVE_FCNTL_H
137 #include <fcntl.h>
138 #else
139 #ifdef HAVE_SYS_FCNTL_H
140 #include <sys/fcntl.h>
141 #endif
142 #endif
144 #include <sys/stat.h>
146 #ifdef HAVE_LIMITS_H
147 #include <limits.h>
148 #endif
150 #ifdef HAVE_SYS_IOCTL_H
151 #include <sys/ioctl.h>
152 #endif
154 #ifdef HAVE_SYS_FILIO_H
155 #include <sys/filio.h>
156 #endif
158 #include <signal.h>
160 #ifdef HAVE_SYS_WAIT_H
161 #include <sys/wait.h>
162 #endif
163 #ifdef HAVE_CTYPE_H
164 #include <ctype.h>
165 #endif
166 #ifdef HAVE_GRP_H
167 #include <grp.h>
168 #endif
169 #ifdef HAVE_SYS_PRIV_H
170 #include <sys/priv.h>
171 #endif
172 #ifdef HAVE_SYS_ID_H
173 #include <sys/id.h>
174 #endif
176 #include <errno.h>
178 #ifdef HAVE_UTIME_H
179 #include <utime.h>
180 #endif
182 #ifdef HAVE_SYS_SELECT_H
183 #include <sys/select.h>
184 #endif
186 #ifdef HAVE_SYS_MODE_H
187 /* apparently AIX needs this for S_ISLNK */
188 #ifndef S_ISLNK
189 #include <sys/mode.h>
190 #endif
191 #endif
193 #ifdef HAVE_GLOB_H
194 #include <glob.h>
195 #endif
197 #include <pwd.h>
199 #ifdef HAVE_STDARG_H
200 #include <stdarg.h>
201 #else
202 #include <varargs.h>
203 #endif
205 #include <netinet/in.h>
206 #include <arpa/inet.h>
207 #include <netdb.h>
208 #ifdef HAVE_SYSLOG_H
209 #include <syslog.h>
210 #endif
211 #ifdef HAVE_SYS_FILE_H
212 #include <sys/file.h>
213 #endif
215 #ifdef HAVE_NETINET_TCP_H
216 #include <netinet/tcp.h>
217 #endif
220 * The next three defines are needed to access the IPTOS_* options
221 * on some systems.
224 #ifdef HAVE_NETINET_IN_SYSTM_H
225 #include <netinet/in_systm.h>
226 #endif
228 #ifdef HAVE_NETINET_IN_IP_H
229 #include <netinet/in_ip.h>
230 #endif
232 #ifdef HAVE_NETINET_IP_H
233 #include <netinet/ip.h>
234 #endif
236 #if defined(HAVE_TERMIOS_H)
237 /* POSIX terminal handling. */
238 #include <termios.h>
239 #elif defined(HAVE_TERMIO_H)
240 /* Older SYSV terminal handling - don't use if we can avoid it. */
241 #include <termio.h>
242 #elif defined(HAVE_SYS_TERMIO_H)
243 /* Older SYSV terminal handling - don't use if we can avoid it. */
244 #include <sys/termio.h>
245 #endif
247 #if HAVE_DIRENT_H
248 # include <dirent.h>
249 # define NAMLEN(dirent) strlen((dirent)->d_name)
250 #else
251 # define dirent direct
252 # define NAMLEN(dirent) (dirent)->d_namlen
253 # if HAVE_SYS_NDIR_H
254 # include <sys/ndir.h>
255 # endif
256 # if HAVE_SYS_DIR_H
257 # include <sys/dir.h>
258 # endif
259 # if HAVE_NDIR_H
260 # include <ndir.h>
261 # endif
262 #endif
264 #ifdef HAVE_SYS_MMAN_H
265 #include <sys/mman.h>
266 #endif
268 #ifdef HAVE_NET_IF_H
269 #include <net/if.h>
270 #endif
273 #ifdef HAVE_SYS_MOUNT_H
274 #include <sys/mount.h>
275 #endif
277 #ifdef HAVE_SYS_VFS_H
278 #include <sys/vfs.h>
279 #endif
281 #ifdef HAVE_SYS_ACL_H
282 #include <sys/acl.h>
283 #endif
285 #ifdef HAVE_SYS_FS_S5PARAM_H
286 #include <sys/fs/s5param.h>
287 #endif
289 #if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
290 #include <sys/filsys.h>
291 #endif
293 #ifdef HAVE_SYS_STATFS_H
294 # include <sys/statfs.h>
295 #endif
297 #ifdef HAVE_DUSTAT_H
298 #include <sys/dustat.h>
299 #endif
301 #ifdef HAVE_SYS_STATVFS_H
302 #include <sys/statvfs.h>
303 #endif
305 #ifdef HAVE_SHADOW_H
306 #include <shadow.h>
307 #endif
309 #ifdef HAVE_GETPWANAM
310 #include <sys/label.h>
311 #include <sys/audit.h>
312 #include <pwdadj.h>
313 #endif
315 #ifdef HAVE_SYS_SECURITY_H
316 #include <sys/security.h>
317 #include <prot.h>
318 #define PASSWORD_LENGTH 16
319 #endif /* HAVE_SYS_SECURITY_H */
321 #ifdef HAVE_COMPAT_H
322 #include <compat.h>
323 #endif
325 #ifdef HAVE_STROPTS_H
326 #include <stropts.h>
327 #endif
329 #ifdef HAVE_POLL_H
330 #include <poll.h>
331 #endif
333 #ifdef HAVE_SYS_CAPABILITY_H
335 #if defined(BROKEN_REDHAT_7_SYSTEM_HEADERS) && !defined(_I386_STATFS_H)
336 #define _I386_STATFS_H
337 #define BROKEN_REDHAT_7_STATFS_WORKAROUND
338 #endif
340 #include <sys/capability.h>
342 #ifdef BROKEN_REDHAT_7_STATFS_WORKAROUND
343 #undef _I386_STATFS_H
344 #undef BROKEN_REDHAT_7_STATFS_WORKAROUND
345 #endif
347 #endif
349 #if defined(HAVE_RPC_RPC_H)
351 * Check for AUTH_ERROR define conflict with rpc/rpc.h in prot.h.
353 #if defined(HAVE_SYS_SECURITY_H) && defined(HAVE_RPC_AUTH_ERROR_CONFLICT)
354 #undef AUTH_ERROR
355 #endif
356 #include <rpc/rpc.h>
357 #endif
359 #if defined(HAVE_YP_GET_DEFAULT_DOMAIN) && defined(HAVE_SETNETGRENT) && defined(HAVE_ENDNETGRENT) && defined(HAVE_GETNETGRENT)
360 #define HAVE_NETGROUP 1
361 #endif
363 #if defined (HAVE_NETGROUP)
364 #if defined(HAVE_RPCSVC_YP_PROT_H)
365 #include <rpcsvc/yp_prot.h>
366 #endif
367 #if defined(HAVE_RPCSVC_YPCLNT_H)
368 #include <rpcsvc/ypclnt.h>
369 #endif
370 #endif /* HAVE_NETGROUP */
372 #if defined(HAVE_SYS_IPC_H)
373 #include <sys/ipc.h>
374 #endif /* HAVE_SYS_IPC_H */
376 #if defined(HAVE_SYS_SHM_H)
377 #include <sys/shm.h>
378 #endif /* HAVE_SYS_SHM_H */
381 * Define VOLATILE if needed.
384 #if defined(HAVE_VOLATILE)
385 #define VOLATILE volatile
386 #else
387 #define VOLATILE
388 #endif
391 * Define additional missing types
393 #if defined(HAVE_SIG_ATOMIC_T_TYPE) && defined(AIX)
394 typedef sig_atomic_t SIG_ATOMIC_T;
395 #elif defined(HAVE_SIG_ATOMIC_T_TYPE) && !defined(AIX)
396 typedef sig_atomic_t VOLATILE SIG_ATOMIC_T;
397 #else
398 typedef int VOLATILE SIG_ATOMIC_T;
399 #endif
401 #ifndef HAVE_SOCKLEN_T_TYPE
402 typedef int socklen_t;
403 #endif
406 #ifndef uchar
407 #define uchar unsigned char
408 #endif
410 #ifdef HAVE_UNSIGNED_CHAR
411 #define schar signed char
412 #else
413 #define schar char
414 #endif
417 Samba needs type definitions for int16, int32, uint16 and uint32.
419 Normally these are signed and unsigned 16 and 32 bit integers, but
420 they actually only need to be at least 16 and 32 bits
421 respectively. Thus if your word size is 8 bytes just defining them
422 as signed and unsigned int will work.
425 #ifndef uint8
426 #define uint8 unsigned char
427 #endif
429 #if !defined(int16) && !defined(HAVE_INT16_FROM_RPC_RPC_H)
430 #if (SIZEOF_SHORT == 4)
431 #define int16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
432 #else /* SIZEOF_SHORT != 4 */
433 #define int16 short
434 #endif /* SIZEOF_SHORT != 4 */
435 #endif
438 * Note we duplicate the size tests in the unsigned
439 * case as int16 may be a typedef from rpc/rpc.h
442 #if !defined(uint16) && !defined(HAVE_UINT16_FROM_RPC_RPC_H)
443 #if (SIZEOF_SHORT == 4)
444 #define uint16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
445 #else /* SIZEOF_SHORT != 4 */
446 #define uint16 unsigned short
447 #endif /* SIZEOF_SHORT != 4 */
448 #endif
450 #if !defined(int32) && !defined(HAVE_INT32_FROM_RPC_RPC_H)
451 #if (SIZEOF_INT == 4)
452 #define int32 int
453 #elif (SIZEOF_LONG == 4)
454 #define int32 long
455 #elif (SIZEOF_SHORT == 4)
456 #define int32 short
457 #else
458 /* uggh - no 32 bit type?? probably a CRAY. just hope this works ... */
459 #define int32 int
460 #endif
461 #endif
464 * Note we duplicate the size tests in the unsigned
465 * case as int32 may be a typedef from rpc/rpc.h
468 #if !defined(uint32) && !defined(HAVE_UINT32_FROM_RPC_RPC_H)
469 #if (SIZEOF_INT == 4)
470 #define uint32 unsigned int
471 #elif (SIZEOF_LONG == 4)
472 #define uint32 unsigned long
473 #elif (SIZEOF_SHORT == 4)
474 #define uint32 unsigned short
475 #else
476 /* uggh - no 32 bit type?? probably a CRAY. just hope this works ... */
477 #define uint32 unsigned
478 #endif
479 #endif
482 * Types for devices, inodes and offsets.
485 #ifndef SMB_DEV_T
486 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_DEV64_T)
487 # define SMB_DEV_T dev64_t
488 # else
489 # define SMB_DEV_T dev_t
490 # endif
491 #endif
494 * Setup the correctly sized inode type.
497 #ifndef SMB_INO_T
498 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_INO64_T)
499 # define SMB_INO_T ino64_t
500 # else
501 # define SMB_INO_T ino_t
502 # endif
503 #endif
505 #ifndef LARGE_SMB_INO_T
506 # if (defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_INO64_T)) || (defined(SIZEOF_INO_T) && (SIZEOF_INO_T == 8))
507 # define LARGE_SMB_INO_T 1
508 # endif
509 #endif
511 #ifdef LARGE_SMB_INO_T
512 #define SINO_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
513 #else
514 #define SINO_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
515 #endif
517 #ifndef SMB_OFF_T
518 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T)
519 # define SMB_OFF_T off64_t
520 # else
521 # define SMB_OFF_T off_t
522 # endif
523 #endif
525 /* this should really be a 64 bit type if possible */
526 #define br_off SMB_BIG_UINT
528 #define SMB_OFF_T_BITS (sizeof(SMB_OFF_T)*8)
531 * Set the define that tells us if we can do 64 bit
532 * NT SMB calls.
535 #ifndef LARGE_SMB_OFF_T
536 # if (defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T)) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8))
537 # define LARGE_SMB_OFF_T 1
538 # endif
539 #endif
541 #ifdef LARGE_SMB_OFF_T
542 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
543 #define SOFF_T_R(p, ofs, v) (SIVAL(p,(ofs)+4,(v)&0xFFFFFFFF), SIVAL(p,ofs,(v)>>32))
544 #define IVAL_TO_SMB_OFF_T(buf,off) ((SMB_OFF_T)(( ((SMB_BIG_UINT)(IVAL((buf),(off)))) & ((SMB_BIG_UINT)0xFFFFFFFF) )))
545 #define IVAL2_TO_SMB_BIG_UINT(buf,off) ( (((SMB_BIG_UINT)(IVAL((buf),(off)))) & ((SMB_BIG_UINT)0xFFFFFFFF)) | \
546 (( ((SMB_BIG_UINT)(IVAL((buf),(off+4)))) & ((SMB_BIG_UINT)0xFFFFFFFF) ) << 32 ) )
547 #else
548 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
549 #define SOFF_T_R(p, ofs, v) (SIVAL(p,(ofs)+4,v),SIVAL(p,ofs,0))
550 #define IVAL_TO_SMB_OFF_T(buf,off) ((SMB_OFF_T)(( ((uint32)(IVAL((buf),(off)))) & 0xFFFFFFFF )))
551 #define IVAL2_TO_SMB_BIG_UINT(buf,off) ( (((SMB_BIG_UINT)(IVAL((buf),(off)))) & ((SMB_BIG_UINT)0xFFFFFFFF)) | \
552 (( ((SMB_BIG_UINT)(IVAL((buf),(off+4)))) & ((SMB_BIG_UINT)0xFFFFFFFF) ) << 32 ) )
553 #endif
556 * Type for stat structure.
559 #ifndef SMB_STRUCT_STAT
560 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STAT64) && defined(HAVE_OFF64_T)
561 # define SMB_STRUCT_STAT struct stat64
562 # else
563 # define SMB_STRUCT_STAT struct stat
564 # endif
565 #endif
568 * Type for dirent structure.
571 #ifndef SMB_STRUCT_DIRENT
572 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_DIRENT64)
573 # define SMB_STRUCT_DIRENT struct dirent64
574 # else
575 # define SMB_STRUCT_DIRENT struct dirent
576 # endif
577 #endif
580 * Defines for 64 bit fcntl locks.
583 #ifndef SMB_STRUCT_FLOCK
584 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
585 # define SMB_STRUCT_FLOCK struct flock64
586 # else
587 # define SMB_STRUCT_FLOCK struct flock
588 # endif
589 #endif
591 #ifndef SMB_F_SETLKW
592 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
593 # define SMB_F_SETLKW F_SETLKW64
594 # else
595 # define SMB_F_SETLKW F_SETLKW
596 # endif
597 #endif
599 #ifndef SMB_F_SETLK
600 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
601 # define SMB_F_SETLK F_SETLK64
602 # else
603 # define SMB_F_SETLK F_SETLK
604 # endif
605 #endif
607 #ifndef SMB_F_GETLK
608 # if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
609 # define SMB_F_GETLK F_GETLK64
610 # else
611 # define SMB_F_GETLK F_GETLK
612 # endif
613 #endif
615 #if defined(HAVE_LONGLONG)
616 #define SMB_BIG_UINT unsigned long long
617 #define SMB_BIG_INT long long
618 #define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
619 #else
620 #define SMB_BIG_UINT unsigned long
621 #define SMB_BIG_INT long
622 #define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
623 #endif
625 #define SMB_BIG_UINT_BITS (sizeof(SMB_BIG_UINT)*8)
627 #ifndef MIN
628 #define MIN(a,b) ((a)<(b)?(a):(b))
629 #endif
631 #ifndef MAX
632 #define MAX(a,b) ((a)>(b)?(a):(b))
633 #endif
635 #ifndef HAVE_STRERROR
636 extern char *sys_errlist[];
637 #define strerror(i) sys_errlist[i]
638 #endif
640 #ifndef HAVE_STRCHR
641 # define strchr index
642 # define strrchr rindex
643 #endif
645 #ifndef HAVE_ERRNO_DECL
646 extern int errno;
647 #endif
649 #ifdef HAVE_BROKEN_GETGROUPS
650 #define GID_T int
651 #else
652 #define GID_T gid_t
653 #endif
655 #ifndef NGROUPS_MAX
656 #define NGROUPS_MAX 32 /* Guess... */
657 #endif
659 /* Lists, trees, caching, database... */
660 #include "ubi_sLinkList.h"
661 #include "ubi_dLinkList.h"
662 #include "dlinklist.h"
663 #include "../tdb/tdb.h"
664 #include "../tdb/spinlock.h"
665 #include "talloc.h"
666 #include "interfaces.h"
667 #include "hash.h"
668 #include "trans2.h"
669 #include "nterr.h"
670 #include "ntioctl.h"
671 #include "secrets.h"
672 #include "messages.h"
674 #include "util_getent.h"
676 #ifndef UBI_BINTREE_H
677 #include "ubi_Cache.h"
678 #endif /* UBI_BINTREE_H */
680 #include "debugparse.h"
682 #include "version.h"
683 #include "smb.h"
684 #include "smbw.h"
685 #include "nameserv.h"
687 #include "byteorder.h"
689 #include "kanji.h"
690 #include "charset.h"
692 #include "ntdomain.h"
694 #include "msdfs.h"
696 #include "profile.h"
698 #include "mapping.h"
700 #include "rap.h"
702 #include "popt.h"
704 #include "mangle.h"
706 #ifndef MAXCODEPAGELINES
707 #define MAXCODEPAGELINES 256
708 #endif
711 * Type for wide character dirent structure.
712 * Only d_name is defined by POSIX.
715 typedef struct smb_wdirent {
716 wpstring d_name;
717 } SMB_STRUCT_WDIRENT;
720 * Type for wide character passwd structure.
723 typedef struct smb_wpasswd {
724 wfstring pw_name;
725 char *pw_passwd;
726 uid_t pw_uid;
727 gid_t pw_gid;
728 wpstring pw_gecos;
729 wpstring pw_dir;
730 wpstring pw_shell;
731 } SMB_STRUCT_WPASSWD;
733 /* Defines for wisXXX functions. */
734 #define UNI_UPPER 0x1
735 #define UNI_LOWER 0x2
736 #define UNI_DIGIT 0x4
737 #define UNI_XDIGIT 0x8
738 #define UNI_SPACE 0x10
740 #include "nsswitch/sys_nss.h"
742 /***** automatically generated prototypes *****/
743 #include "proto.h"
745 /* String routines */
747 #include "safe_string.h"
749 #ifdef __COMPAR_FN_T
750 #define QSORT_CAST (__compar_fn_t)
751 #endif
753 #ifndef QSORT_CAST
754 #define QSORT_CAST (int (*)(const void *, const void *))
755 #endif
757 /* this guess needs to be improved (tridge) */
758 #if (defined(STAT_STATVFS) || defined(STAT_STATVFS64)) && !defined(SYSV)
759 #define SYSV 1
760 #endif
763 * Veritas File System. Often in addition to native.
764 * Quotas different.
766 #if defined(HAVE_SYS_FS_VX_QUOTA_H)
767 #define VXFS_QUOTA
768 #endif
770 #ifndef DEFAULT_PRINTING
771 #ifdef HAVE_CUPS
772 #define DEFAULT_PRINTING PRINT_CUPS
773 #define PRINTCAP_NAME "cups"
774 #elif defined(SYSV)
775 #define DEFAULT_PRINTING PRINT_SYSV
776 #define PRINTCAP_NAME "lpstat"
777 #else
778 #define DEFAULT_PRINTING PRINT_BSD
779 #define PRINTCAP_NAME "/etc/printcap"
780 #endif
781 #endif
783 #ifndef PRINTCAP_NAME
784 #define PRINTCAP_NAME "/etc/printcap"
785 #endif
787 #ifndef SIGCLD
788 #define SIGCLD SIGCHLD
789 #endif
791 #ifndef MAP_FILE
792 #define MAP_FILE 0
793 #endif
795 #if (!defined(WITH_NISPLUS) && !defined(WITH_LDAP) && !defined(WITH_TDB_SAM))
796 #define USE_SMBPASS_DB 1
797 #endif
799 #if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
800 #define OSF1_ENH_SEC 1
801 #endif
803 #ifndef ALLOW_CHANGE_PASSWORD
804 #if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
805 #define ALLOW_CHANGE_PASSWORD 1
806 #endif
807 #endif
809 /* what is the longest significant password available on your system?
810 Knowing this speeds up password searches a lot */
811 #ifndef PASSWORD_LENGTH
812 #define PASSWORD_LENGTH 8
813 #endif
815 #ifdef REPLACE_INET_NTOA
816 #define inet_ntoa rep_inet_ntoa
817 #endif
819 #ifndef HAVE_PIPE
820 #define SYNC_DNS 1
821 #endif
823 #ifndef MAXPATHLEN
824 #define MAXPATHLEN 256
825 #endif
827 #ifndef SEEK_SET
828 #define SEEK_SET 0
829 #endif
831 #ifndef INADDR_LOOPBACK
832 #define INADDR_LOOPBACK 0x7f000001
833 #endif
835 #ifndef INADDR_NONE
836 #define INADDR_NONE 0xffffffff
837 #endif
839 #ifndef HAVE_CRYPT
840 #define crypt ufc_crypt
841 #endif
843 #ifndef O_ACCMODE
844 #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
845 #endif
847 #if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
848 #define ULTRIX_AUTH 1
849 #endif
851 #ifdef HAVE_LIBREADLINE
852 # ifdef HAVE_READLINE_READLINE_H
853 # include <readline/readline.h>
854 # ifdef HAVE_READLINE_HISTORY_H
855 # include <readline/history.h>
856 # endif
857 # else
858 # ifdef HAVE_READLINE_H
859 # include <readline.h>
860 # ifdef HAVE_HISTORY_H
861 # include <history.h>
862 # endif
863 # else
864 # undef HAVE_LIBREADLINE
865 # endif
866 # endif
867 #endif
869 #ifndef HAVE_STRDUP
870 char *strdup(const char *s);
871 #endif
873 #ifndef HAVE_MEMMOVE
874 void *memmove(void *dest,const void *src,int size);
875 #endif
877 #ifndef HAVE_INITGROUPS
878 int initgroups(char *name,gid_t id);
879 #endif
881 #ifndef HAVE_RENAME
882 int rename(const char *zfrom, const char *zto);
883 #endif
885 #ifndef HAVE_MKTIME
886 time_t mktime(struct tm *t);
887 #endif
889 #ifndef HAVE_STRLCPY
890 size_t strlcpy(char *d, const char *s, size_t bufsize);
891 #endif
893 #ifndef HAVE_STRLCAT
894 size_t strlcat(char *d, const char *s, size_t bufsize);
895 #endif
897 #ifndef HAVE_FTRUNCATE
898 int ftruncate(int f,long l);
899 #endif
901 #ifndef HAVE_STRNDUP
902 char *strndup(const char *s, size_t n);
903 #endif
905 #ifndef HAVE_STRNLEN
906 size_t strnlen(const char *s, size_t n);
907 #endif
909 #ifndef HAVE_STRTOUL
910 unsigned long strtoul(const char *nptr, char **endptr, int base);
911 #endif
913 #if (defined(USE_SETRESUID) && !defined(HAVE_SETRESUID_DECL))
914 /* stupid glibc */
915 int setresuid(uid_t ruid, uid_t euid, uid_t suid);
916 #endif
917 #if (defined(USE_SETRESUID) && !defined(HAVE_SETRESGID_DECL))
918 int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
919 #endif
920 #ifndef HAVE_VASPRINTF_DECL
921 int vasprintf(char **ptr, const char *format, va_list ap);
922 #endif
924 #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
925 #define bzero(a,b) memset((a),'\0',(b))
926 #endif
928 #ifdef REPLACE_GETPASS
929 #define getpass(prompt) getsmbpass((prompt))
930 #endif
933 * Some older systems seem not to have MAXHOSTNAMELEN
934 * defined.
936 #ifndef MAXHOSTNAMELEN
937 #define MAXHOSTNAMELEN 254
938 #endif
940 /* yuck, I'd like a better way of doing this */
941 #define DIRP_SIZE (256 + 32)
944 * glibc on linux doesn't seem to have MSG_WAITALL
945 * defined. I think the kernel has it though..
948 #ifndef MSG_WAITALL
949 #define MSG_WAITALL 0
950 #endif
952 /* default socket options. Dave Miller thinks we should default to TCP_NODELAY
953 given the socket IO pattern that Samba uses */
954 #ifdef TCP_NODELAY
955 #define DEFAULT_SOCKET_OPTIONS "TCP_NODELAY"
956 #else
957 #define DEFAULT_SOCKET_OPTIONS ""
958 #endif
960 /* Load header file for libdl stuff */
962 #ifdef HAVE_DLFCN_H
963 #include <dlfcn.h>
964 #endif
966 /* Some POSIX definitions for those without */
968 #ifndef S_IFDIR
969 #define S_IFDIR 0x4000
970 #endif
971 #ifndef S_ISDIR
972 #define S_ISDIR(mode) ((mode & 0xF000) == S_IFDIR)
973 #endif
974 #ifndef S_IRWXU
975 #define S_IRWXU 00700 /* read, write, execute: owner */
976 #endif
977 #ifndef S_IRUSR
978 #define S_IRUSR 00400 /* read permission: owner */
979 #endif
980 #ifndef S_IWUSR
981 #define S_IWUSR 00200 /* write permission: owner */
982 #endif
983 #ifndef S_IXUSR
984 #define S_IXUSR 00100 /* execute permission: owner */
985 #endif
986 #ifndef S_IRWXG
987 #define S_IRWXG 00070 /* read, write, execute: group */
988 #endif
989 #ifndef S_IRGRP
990 #define S_IRGRP 00040 /* read permission: group */
991 #endif
992 #ifndef S_IWGRP
993 #define S_IWGRP 00020 /* write permission: group */
994 #endif
995 #ifndef S_IXGRP
996 #define S_IXGRP 00010 /* execute permission: group */
997 #endif
998 #ifndef S_IRWXO
999 #define S_IRWXO 00007 /* read, write, execute: other */
1000 #endif
1001 #ifndef S_IROTH
1002 #define S_IROTH 00004 /* read permission: other */
1003 #endif
1004 #ifndef S_IWOTH
1005 #define S_IWOTH 00002 /* write permission: other */
1006 #endif
1007 #ifndef S_IXOTH
1008 #define S_IXOTH 00001 /* execute permission: other */
1009 #endif
1011 /* For sys_adminlog(). */
1012 #ifndef LOG_EMERG
1013 #define LOG_EMERG 0 /* system is unusable */
1014 #endif
1016 #ifndef LOG_ALERT
1017 #define LOG_ALERT 1 /* action must be taken immediately */
1018 #endif
1020 #ifndef LOG_CRIT
1021 #define LOG_CRIT 2 /* critical conditions */
1022 #endif
1024 #ifndef LOG_ERR
1025 #define LOG_ERR 3 /* error conditions */
1026 #endif
1028 #ifndef LOG_WARNING
1029 #define LOG_WARNING 4 /* warning conditions */
1030 #endif
1032 #ifndef LOG_NOTICE
1033 #define LOG_NOTICE 5 /* normal but significant condition */
1034 #endif
1036 #ifndef LOG_INFO
1037 #define LOG_INFO 6 /* informational */
1038 #endif
1040 #ifndef LOG_DEBUG
1041 #define LOG_DEBUG 7 /* debug-level messages */
1042 #endif
1044 /* NetBSD doesn't have these */
1045 #ifndef SHM_R
1046 #define SHM_R 0400
1047 #endif
1049 #ifndef SHM_W
1050 #define SHM_W 0200
1051 #endif
1053 #if HAVE_KERNEL_SHARE_MODES
1054 #ifndef LOCK_MAND
1055 #define LOCK_MAND 32 /* This is a mandatory flock */
1056 #define LOCK_READ 64 /* ... Which allows concurrent read operations */
1057 #define LOCK_WRITE 128 /* ... Which allows concurrent write operations */
1058 #define LOCK_RW 192 /* ... Which allows concurrent read & write ops */
1059 #endif
1060 #endif
1062 extern int DEBUGLEVEL;
1064 #define MAX_SEC_CTX_DEPTH 8 /* Maximum number of security contexts */
1067 #ifdef GLIBC_HACK_FCNTL64
1068 /* this is a gross hack. 64 bit locking is completely screwed up on
1069 i386 Linux in glibc 2.1.95 (which ships with RedHat 7.0). This hack
1070 "fixes" the problem with the current 2.4.0test kernels
1072 #define fcntl fcntl64
1073 #undef F_SETLKW
1074 #undef F_SETLK
1075 #define F_SETLK 13
1076 #define F_SETLKW 14
1077 #endif
1079 /* Needed for sys_dlopen/sys_dlsym/sys_dlclose */
1080 #ifndef RTLD_GLOBAL
1081 #define RTLD_GLOBAL 0
1082 #endif
1084 #ifndef RTLD_LAZY
1085 #define RTLD_LAZY 0
1086 #endif
1088 #ifndef RTLD_NOW
1089 #define RTLD_NOW 0
1090 #endif
1092 /* add varargs prototypes with printf checking */
1093 int fdprintf(int , char *, ...) PRINTF_ATTRIBUTE(2,3);
1094 #ifndef HAVE_SNPRINTF_DECL
1095 int snprintf(char *,size_t ,const char *, ...) PRINTF_ATTRIBUTE(3,4);
1096 #endif
1097 #ifndef HAVE_ASPRINTF_DECL
1098 int asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3);
1099 #endif
1101 /* we used to use these fns, but now we have good replacements
1102 for snprintf and vsnprintf */
1103 #define slprintf snprintf
1104 #define vslprintf vsnprintf
1106 /* we need to use __va_copy() on some platforms */
1107 #ifdef HAVE_VA_COPY
1108 #define VA_COPY(dest, src) __va_copy(dest, src)
1109 #else
1110 #define VA_COPY(dest, src) (dest) = (src)
1111 #endif
1113 #endif /* _INCLUDES_H */