Fixed some more client SPOOLSS functions. The following
[samba.git] / source3 / include / includes.h
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
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 #endif
27
28 #include "local.h"
29
30 #ifdef AIX
31 #define DEFAULT_PRINTING PRINT_AIX
32 #define PRINTCAP_NAME "/etc/qconfig"
33 #endif
34
35 #ifdef HPUX
36 #define DEFAULT_PRINTING PRINT_HPUX
37 #endif
38
39 #ifdef QNX
40 #define DEFAULT_PRINTING PRINT_QNX
41 #endif
42
43 #ifdef SUNOS4
44 /* on SUNOS4 termios.h conflicts with sys/ioctl.h */
45 #undef HAVE_TERMIOS_H
46 #endif
47
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
56
57 #ifdef RELIANTUNIX
58 /*
59  * <unistd.h> has to be included before any other to get
60  * large file support on Reliant UNIX
61  */
62 #ifdef HAVE_UNISTD_H
63 #include <unistd.h>
64 #endif
65 #endif /* RELIANTUNIX */
66
67 #include <sys/types.h>
68
69 #ifdef TIME_WITH_SYS_TIME
70 #include <sys/time.h>
71 #include <time.h>
72 #else
73 #ifdef HAVE_SYS_TIME_H
74 #include <sys/time.h>
75 #else
76 #include <time.h>
77 #endif
78 #endif
79
80 #ifdef HAVE_SYS_RESOURCE_H
81 #include <sys/resource.h>
82 #endif
83
84 #ifdef HAVE_UNISTD_H
85 #include <unistd.h>
86 #endif
87
88 #include <stdio.h>
89 #include <stddef.h>
90
91 #ifdef HAVE_SYS_PARAM_H
92 #include <sys/param.h>
93 #endif
94
95 #ifdef HAVE_STDLIB_H
96 #include <stdlib.h>
97 #endif
98
99 #ifdef HAVE_SYS_SOCKET_H
100 #include <sys/socket.h>
101 #endif
102
103 #ifdef HAVE_SYS_UN_H
104 #include <sys/un.h>
105 #endif
106
107 #ifdef HAVE_SYS_SYSCALL_H
108 #include <sys/syscall.h>
109 #elif HAVE_SYSCALL_H
110 #include <syscall.h>
111 #endif
112
113 #ifdef HAVE_STRING_H
114 #include <string.h>
115 #endif
116
117 #ifdef HAVE_STRINGS_H
118 #include <strings.h>
119 #endif
120
121 #ifdef HAVE_MEMORY_H
122 #include <memory.h>
123 #endif
124
125 #ifdef HAVE_MALLOC_H
126 #include <malloc.h>
127 #endif
128
129 #ifdef HAVE_FCNTL_H
130 #include <fcntl.h>
131 #else
132 #ifdef HAVE_SYS_FCNTL_H
133 #include <sys/fcntl.h>
134 #endif
135 #endif
136
137 #include <sys/stat.h>
138
139 #ifdef HAVE_LIMITS_H
140 #include <limits.h>
141 #endif
142
143 #ifdef HAVE_SYS_IOCTL_H
144 #include <sys/ioctl.h>
145 #endif
146
147 #ifdef HAVE_SYS_FILIO_H
148 #include <sys/filio.h>
149 #endif
150
151 #include <signal.h>
152
153 #ifdef HAVE_SYS_WAIT_H
154 #include <sys/wait.h>
155 #endif
156 #ifdef HAVE_CTYPE_H
157 #include <ctype.h>
158 #endif
159 #ifdef HAVE_GRP_H
160 #include <grp.h>
161 #endif
162 #ifdef HAVE_SYS_PRIV_H
163 #include <sys/priv.h>
164 #endif
165 #ifdef HAVE_SYS_ID_H
166 #include <sys/id.h>
167 #endif
168
169 #include <errno.h>
170
171 #ifdef HAVE_UTIME_H
172 #include <utime.h>
173 #endif
174
175 #ifdef HAVE_SYS_SELECT_H
176 #include <sys/select.h>
177 #endif
178
179 #ifdef HAVE_SYS_MODE_H
180 /* apparently AIX needs this for S_ISLNK */
181 #ifndef S_ISLNK
182 #include <sys/mode.h>
183 #endif
184 #endif
185
186 #ifdef HAVE_GLOB_H
187 #include <glob.h>
188 #endif
189
190 #include <pwd.h>
191
192 #ifdef HAVE_STDARG_H
193 #include <stdarg.h>
194 #else
195 #include <varargs.h>
196 #endif
197
198 #include <netinet/in.h>
199 #include <arpa/inet.h>
200 #include <netdb.h>
201 #include <syslog.h>
202 #include <sys/file.h>
203
204 #ifdef HAVE_NETINET_TCP_H
205 #include <netinet/tcp.h>
206 #endif
207
208 /*
209  * The next three defines are needed to access the IPTOS_* options
210  * on some systems.
211  */
212
213 #ifdef HAVE_NETINET_IN_SYSTM_H
214 #include <netinet/in_systm.h>
215 #endif
216
217 #ifdef HAVE_NETINET_IN_IP_H
218 #include <netinet/in_ip.h>
219 #endif
220
221 #ifdef HAVE_NETINET_IP_H
222 #include <netinet/ip.h>
223 #endif
224
225 #if defined(HAVE_TERMIOS_H)
226 /* POSIX terminal handling. */
227 #include <termios.h>
228 #elif defined(HAVE_TERMIO_H)
229 /* Older SYSV terminal handling - don't use if we can avoid it. */
230 #include <termio.h>
231 #elif defined(HAVE_SYS_TERMIO_H)
232 /* Older SYSV terminal handling - don't use if we can avoid it. */
233 #include <sys/termio.h>
234 #endif
235
236 #if HAVE_DIRENT_H
237 # include <dirent.h>
238 # define NAMLEN(dirent) strlen((dirent)->d_name)
239 #else
240 # define dirent direct
241 # define NAMLEN(dirent) (dirent)->d_namlen
242 # if HAVE_SYS_NDIR_H
243 #  include <sys/ndir.h>
244 # endif
245 # if HAVE_SYS_DIR_H
246 #  include <sys/dir.h>
247 # endif
248 # if HAVE_NDIR_H
249 #  include <ndir.h>
250 # endif
251 #endif
252
253 #ifdef HAVE_SYS_MMAN_H
254 #include <sys/mman.h>
255 #endif
256
257 #ifdef HAVE_NET_IF_H
258 #include <net/if.h>
259 #endif
260
261
262 #ifdef HAVE_SYS_MOUNT_H
263 #include <sys/mount.h>
264 #endif
265
266 #ifdef HAVE_SYS_VFS_H
267 #include <sys/vfs.h>
268 #endif
269
270 #ifdef HAVE_SYS_ACL_H
271 #include <sys/acl.h>
272 #endif
273
274 #ifdef HAVE_SYS_FS_S5PARAM_H 
275 #include <sys/fs/s5param.h>
276 #endif
277
278 #if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
279 #include <sys/filsys.h> 
280 #endif
281
282 #ifdef HAVE_SYS_STATFS_H
283 # include <sys/statfs.h>
284 #endif
285
286 #ifdef HAVE_DUSTAT_H              
287 #include <sys/dustat.h>
288 #endif
289
290 #ifdef HAVE_SYS_STATVFS_H          
291 #include <sys/statvfs.h>
292 #endif
293
294 #ifdef HAVE_SHADOW_H
295 #include <shadow.h>
296 #endif
297
298 #ifdef HAVE_GETPWANAM
299 #include <sys/label.h>
300 #include <sys/audit.h>
301 #include <pwdadj.h>
302 #endif
303
304 #ifdef HAVE_SYS_SECURITY_H
305 #include <sys/security.h>
306 #include <prot.h>
307 #define PASSWORD_LENGTH 16
308 #endif  /* HAVE_SYS_SECURITY_H */
309
310 #ifdef HAVE_COMPAT_H
311 #include <compat.h>
312 #endif
313
314 #ifdef HAVE_STROPTS_H
315 #include <stropts.h>
316 #endif
317
318 #ifdef HAVE_POLL_H
319 #include <poll.h>
320 #endif
321
322 #ifdef HAVE_SYS_CAPABILITY_H
323 #include <sys/capability.h>
324 #endif
325
326 #if defined(HAVE_RPC_RPC_H)
327 /*
328  * Check for AUTH_ERROR define conflict with rpc/rpc.h in prot.h.
329  */
330 #if defined(HAVE_SYS_SECURITY_H) && defined(HAVE_RPC_AUTH_ERROR_CONFLICT)
331 #undef AUTH_ERROR
332 #endif
333 #include <rpc/rpc.h>
334 #endif
335
336 #if defined(HAVE_YP_GET_DEFAULT_DOMAIN) && defined(HAVE_SETNETGRENT) && defined(HAVE_ENDNETGRENT) && defined(HAVE_GETNETGRENT)
337 #define HAVE_NETGROUP 1
338 #endif
339
340 #if defined (HAVE_NETGROUP)
341 #if defined(HAVE_RPCSVC_YP_PROT_H)
342 #include <rpcsvc/yp_prot.h>
343 #endif
344 #if defined(HAVE_RPCSVC_YPCLNT_H)
345 #include <rpcsvc/ypclnt.h>
346 #endif
347 #endif /* HAVE_NETGROUP */
348
349 /*
350  * Define VOLATILE if needed.
351  */
352
353 #if defined(HAVE_VOLATILE)
354 #define VOLATILE volatile
355 #else
356 #define VOLATILE
357 #endif
358
359 /*
360  * Define SIG_ATOMIC_T if needed.
361  */
362
363 #if defined(HAVE_SIG_ATOMIC_T_TYPE)
364 #define SIG_ATOMIC_T sig_atomic_t
365 #else
366 #define SIG_ATOMIC_T int
367 #endif
368
369 #ifndef uchar
370 #define uchar unsigned char
371 #endif
372
373 #ifdef HAVE_UNSIGNED_CHAR
374 #define schar signed char
375 #else
376 #define schar char
377 #endif
378
379 /*
380    Samba needs type definitions for int16, int32, uint16 and uint32.
381
382    Normally these are signed and unsigned 16 and 32 bit integers, but
383    they actually only need to be at least 16 and 32 bits
384    respectively. Thus if your word size is 8 bytes just defining them
385    as signed and unsigned int will work.
386 */
387
388 #ifndef uint8
389 #define uint8 unsigned char
390 #endif
391
392 #if !defined(int16) && !defined(HAVE_INT16_FROM_RPC_RPC_H)
393 #if (SIZEOF_SHORT == 4)
394 #define int16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
395 #else /* SIZEOF_SHORT != 4 */
396 #define int16 short
397 #endif /* SIZEOF_SHORT != 4 */
398 #endif
399
400 /*
401  * Note we duplicate the size tests in the unsigned 
402  * case as int16 may be a typedef from rpc/rpc.h
403  */
404
405 #if !defined(uint16) && !defined(HAVE_UINT16_FROM_RPC_RPC_H)
406 #if (SIZEOF_SHORT == 4)
407 #define uint16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
408 #else /* SIZEOF_SHORT != 4 */
409 #define uint16 unsigned short
410 #endif /* SIZEOF_SHORT != 4 */
411 #endif
412
413 #if !defined(int32) && !defined(HAVE_INT32_FROM_RPC_RPC_H)
414 #if (SIZEOF_INT == 4)
415 #define int32 int
416 #elif (SIZEOF_LONG == 4)
417 #define int32 long
418 #elif (SIZEOF_SHORT == 4)
419 #define int32 short
420 #endif
421 #endif
422
423 /*
424  * Note we duplicate the size tests in the unsigned 
425  * case as int32 may be a typedef from rpc/rpc.h
426  */
427
428 #if !defined(uint32) && !defined(HAVE_UINT32_FROM_RPC_RPC_H)
429 #if (SIZEOF_INT == 4)
430 #define uint32 unsigned int
431 #elif (SIZEOF_LONG == 4)
432 #define uint32 unsigned long
433 #elif (SIZEOF_SHORT == 4)
434 #define uint32 unsigned short
435 #endif
436 #endif
437
438 /*
439  * Types for devices, inodes and offsets.
440  */
441
442 #ifndef SMB_DEV_T
443 #define SMB_DEV_T dev_t
444 #endif
445
446 /*
447  * Setup the correctly sized inode type.
448  */
449
450 #ifndef SMB_INO_T
451 #  if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_INO64_T)
452 #    define SMB_INO_T ino64_t
453 #  else
454 #    define SMB_INO_T ino_t
455 #  endif
456 #endif
457
458 #ifndef LARGE_SMB_INO_T
459 #  if (defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_INO64_T)) || (defined(SIZEOF_INO_T) && (SIZEOF_INO_T == 8))
460 #    define LARGE_SMB_INO_T 1
461 #  endif
462 #endif
463
464 #ifdef LARGE_SMB_INO_T
465 #define SINO_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
466 #else 
467 #define SINO_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
468 #endif
469
470 #ifndef SMB_OFF_T
471 #  if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T)
472 #    define SMB_OFF_T off64_t
473 #  else
474 #    define SMB_OFF_T off_t
475 #  endif
476 #endif
477
478 /* this should really be a 64 bit type if possible */
479 #define br_off SMB_BIG_UINT
480
481 #define SMB_OFF_T_BITS (sizeof(SMB_OFF_T)*8)
482
483 /*
484  * Set the define that tells us if we can do 64 bit
485  * NT SMB calls.
486  */
487
488 #ifndef LARGE_SMB_OFF_T
489 #  if (defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T)) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8))
490 #    define LARGE_SMB_OFF_T 1
491 #  endif
492 #endif
493
494 #ifdef LARGE_SMB_OFF_T
495 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
496 #else 
497 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
498 #endif
499
500 /*
501  * Type for stat structure.
502  */
503
504 #ifndef SMB_STRUCT_STAT
505 #  if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STAT64) && defined(HAVE_OFF64_T)
506 #    define SMB_STRUCT_STAT struct stat64
507 #  else
508 #    define SMB_STRUCT_STAT struct stat
509 #  endif
510 #endif
511
512 /*
513  * Type for dirent structure.
514  */
515
516 #ifndef SMB_STRUCT_DIRENT
517 #  if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_DIRENT64)
518 #    define SMB_STRUCT_DIRENT struct dirent64
519 #  else
520 #    define SMB_STRUCT_DIRENT struct dirent
521 #  endif
522 #endif
523
524 /*
525  * Defines for 64 bit fcntl locks.
526  */
527
528 #ifndef SMB_STRUCT_FLOCK
529 #  if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
530 #    define SMB_STRUCT_FLOCK struct flock64
531 #  else
532 #    define SMB_STRUCT_FLOCK struct flock
533 #  endif
534 #endif
535
536 #ifndef SMB_F_SETLKW
537 #  if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
538 #    define SMB_F_SETLKW F_SETLKW64
539 #  else
540 #    define SMB_F_SETLKW F_SETLKW
541 #  endif
542 #endif
543
544 #ifndef SMB_F_SETLK
545 #  if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
546 #    define SMB_F_SETLK F_SETLK64
547 #  else
548 #    define SMB_F_SETLK F_SETLK
549 #  endif
550 #endif
551
552 #ifndef SMB_F_GETLK
553 #  if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
554 #    define SMB_F_GETLK F_GETLK64
555 #  else
556 #    define SMB_F_GETLK F_GETLK
557 #  endif
558 #endif
559
560 #if defined(HAVE_LONGLONG)
561 #define SMB_BIG_UINT unsigned long long
562 #define SMB_BIG_INT long long
563 #define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
564 #else
565 #define SMB_BIG_UINT unsigned long
566 #define SMB_BIG_INT long
567 #define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
568 #endif
569
570 #define SMB_BIG_UINT_BITS (sizeof(SMB_BIG_UINT)*8)
571
572 #ifndef MIN
573 #define MIN(a,b) ((a)<(b)?(a):(b))
574 #endif
575
576 #ifndef MAX
577 #define MAX(a,b) ((a)>(b)?(a):(b))
578 #endif
579
580 #ifndef HAVE_STRERROR
581 extern char *sys_errlist[];
582 #define strerror(i) sys_errlist[i]
583 #endif
584
585 #ifndef HAVE_STRCHR
586 # define strchr                 index
587 # define strrchr                rindex
588 #endif
589
590 #ifndef HAVE_ERRNO_DECL
591 extern int errno;
592 #endif
593
594 #ifdef HAVE_BROKEN_GETGROUPS
595 #define GID_T int
596 #else
597 #define GID_T gid_t
598 #endif
599
600 #ifndef NGROUPS_MAX
601 #define NGROUPS_MAX 32 /* Guess... */
602 #endif
603
604 /* Lists, trees, caching, database... */
605 #include "ubi_sLinkList.h"
606 #include "ubi_dLinkList.h"
607 #include "dlinklist.h"
608 #include "../tdb/tdb.h"
609 #include "talloc.h"
610 #include "interfaces.h"
611 #include "hash.h"
612 #include "trans2.h"
613 #include "nterr.h"
614 #include "secrets.h"
615 #include "util_list.h"
616
617 #ifndef UBI_BINTREE_H
618 #include "ubi_Cache.h"
619 #endif /* UBI_BINTREE_H */
620
621 #include "debugparse.h"
622
623 #include "version.h"
624 #include "smb.h"
625 #include "smbw.h"
626 #include "nameserv.h"
627
628 #include "byteorder.h"
629
630 #include "kanji.h"
631 #include "charset.h"
632
633 #include "ntdomain.h"
634
635 #include "msdfs.h"
636
637 #ifdef WITH_PROFILE
638 #include "profile.h"
639 #endif
640
641 #ifndef MAXCODEPAGELINES
642 #define MAXCODEPAGELINES 256
643 #endif
644
645 /*
646  * Type for wide character dirent structure.
647  * Only d_name is defined by POSIX.
648  */
649
650 typedef struct smb_wdirent {
651         wpstring        d_name;
652 } SMB_STRUCT_WDIRENT;
653
654 /*
655  * Type for wide character passwd structure.
656  */
657
658 typedef struct smb_wpasswd {
659         wfstring       pw_name;
660         char           *pw_passwd;
661         uid_t          pw_uid;
662         gid_t          pw_gid;
663         wpstring       pw_gecos;
664         wpstring       pw_dir;
665         wpstring       pw_shell;
666 } SMB_STRUCT_WPASSWD;
667
668 /* Defines for wisXXX functions. */
669 #define UNI_UPPER    0x1
670 #define UNI_LOWER    0x2
671 #define UNI_DIGIT    0x4
672 #define UNI_XDIGIT   0x8
673 #define UNI_SPACE    0x10
674
675 #ifdef HAVE_NSS_H
676 #include <nss.h>
677 #else
678
679 /* Minimal needed to compile.. */
680
681 enum nss_status {
682         NSS_STATUS_SUCCESS,
683         NSS_STATUS_NOTFOUND,
684         NSS_STATUS_UNAVAIL
685 };
686
687 #endif
688
689 /***** automatically generated prototypes *****/
690 #include "proto.h"
691
692 /* String routines */
693
694 #include "safe_string.h"
695
696 #ifdef __COMPAR_FN_T
697 #define QSORT_CAST (__compar_fn_t)
698 #endif
699
700 #ifndef QSORT_CAST
701 #define QSORT_CAST (int (*)(const void *, const void *))
702 #endif
703
704 /* this guess needs to be improved (tridge) */
705 #if (defined(STAT_STATVFS) || defined(STAT_STATVFS64)) && !defined(SYSV)
706 #define SYSV 1
707 #endif
708
709 #ifndef DEFAULT_PRINTING
710 #ifdef HAVE_LIBCUPS
711 #define DEFAULT_PRINTING PRINT_CUPS
712 #define PRINTCAP_NAME "cups"
713 #elif defined(SYSV)
714 #define DEFAULT_PRINTING PRINT_SYSV
715 #define PRINTCAP_NAME "lpstat"
716 #else
717 #define DEFAULT_PRINTING PRINT_BSD
718 #define PRINTCAP_NAME "/etc/printcap"
719 #endif
720 #endif
721
722 #ifndef PRINTCAP_NAME
723 #define PRINTCAP_NAME "/etc/printcap"
724 #endif
725
726 #ifndef SIGCLD
727 #define SIGCLD SIGCHLD
728 #endif
729
730 #ifndef MAP_FILE
731 #define MAP_FILE 0
732 #endif
733
734 #if (!defined(WITH_NISPLUS) && !defined(WITH_LDAP))
735 #define USE_SMBPASS_DB 1
736 #endif
737
738 #if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
739 #define OSF1_ENH_SEC 1
740 #endif
741
742 #ifndef ALLOW_CHANGE_PASSWORD
743 #if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
744 #define ALLOW_CHANGE_PASSWORD 1
745 #endif
746 #endif
747
748 /* what is the longest significant password available on your system? 
749  Knowing this speeds up password searches a lot */
750 #ifndef PASSWORD_LENGTH
751 #define PASSWORD_LENGTH 8
752 #endif
753
754 #ifdef REPLACE_INET_NTOA
755 #define inet_ntoa rep_inet_ntoa
756 #endif
757
758 #ifndef HAVE_PIPE
759 #define SYNC_DNS 1
760 #endif
761
762 #ifndef MAXPATHLEN
763 #define MAXPATHLEN 256
764 #endif
765
766 #ifndef SEEK_SET
767 #define SEEK_SET 0
768 #endif
769
770 #ifndef INADDR_LOOPBACK
771 #define INADDR_LOOPBACK 0x7f000001
772 #endif
773
774 #ifndef INADDR_NONE
775 #define INADDR_NONE 0xffffffff
776 #endif
777
778 #ifndef HAVE_CRYPT
779 #define crypt ufc_crypt
780 #endif
781
782 #ifndef O_ACCMODE
783 #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
784 #endif
785
786 #if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
787 #define ULTRIX_AUTH 1
788 #endif
789
790 #ifdef HAVE_LIBREADLINE
791 #  ifdef HAVE_READLINE_READLINE_H
792 #    include <readline/readline.h>
793 #    ifdef HAVE_READLINE_HISTORY_H
794 #      include <readline/history.h>
795 #    endif
796 #  else
797 #    ifdef HAVE_READLINE_H
798 #      include <readline.h>
799 #      ifdef HAVE_HISTORY_H
800 #        include <history.h>
801 #      endif
802 #    else
803 #      undef HAVE_LIBREADLINE
804 #    endif
805 #  endif
806 #endif
807
808 #ifndef HAVE_STRDUP
809 char *strdup(const char *s);
810 #endif
811
812 #ifndef HAVE_MEMMOVE
813 void *memmove(void *dest,const void *src,int size);
814 #endif
815
816 #ifndef HAVE_INITGROUPS
817 int initgroups(char *name,gid_t id);
818 #endif
819
820 #ifndef HAVE_RENAME
821 int rename(const char *zfrom, const char *zto);
822 #endif
823
824 #ifndef HAVE_MKTIME
825 time_t mktime(struct tm *t);
826 #endif
827
828 #ifndef HAVE_FTRUNCATE
829 int ftruncate(int f,long l);
830 #endif
831
832 #ifndef HAVE_STRTOUL
833 unsigned long strtoul(const char *nptr, char **endptr, int base);
834 #endif
835
836 #if (defined(USE_SETRESUID) && !defined(HAVE_SETRESUID_DECL))
837 /* stupid glibc */
838 int setresuid(uid_t ruid, uid_t euid, uid_t suid);
839 #endif
840 #if (defined(USE_SETRESUID) && !defined(HAVE_SETRESGID_DECL))
841 int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
842 #endif
843
844 #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
845 #define bzero(a,b) memset((a),'\0',(b))
846 #endif
847
848 #ifdef REPLACE_GETPASS
849 #define getpass(prompt) getsmbpass((prompt))
850 #endif
851
852 /*
853  * Some older systems seem not to have MAXHOSTNAMELEN
854  * defined.
855  */
856 #ifndef MAXHOSTNAMELEN
857 #define MAXHOSTNAMELEN 254
858 #endif
859
860 /* yuck, I'd like a better way of doing this */
861 #define DIRP_SIZE (256 + 32)
862
863 /*
864  * glibc on linux doesn't seem to have MSG_WAITALL
865  * defined. I think the kernel has it though..
866  */
867
868 #ifndef MSG_WAITALL
869 #define MSG_WAITALL 0
870 #endif
871
872 /* default socket options. Dave Miller thinks we should default to TCP_NODELAY
873    given the socket IO pattern that Samba uses */
874 #ifdef TCP_NODELAY
875 #define DEFAULT_SOCKET_OPTIONS "TCP_NODELAY"
876 #else
877 #define DEFAULT_SOCKET_OPTIONS ""
878 #endif
879
880 /* Load header file for libdl stuff */
881
882 #ifdef HAVE_LIBDL
883 #include <dlfcn.h>
884 #endif
885
886 /* Some POSIX definitions for those without */
887  
888 #ifndef S_IFDIR
889 #define S_IFDIR         0x4000
890 #endif
891 #ifndef S_ISDIR
892 #define S_ISDIR(mode)   ((mode & 0xF000) == S_IFDIR)
893 #endif
894 #ifndef S_IRWXU
895 #define S_IRWXU 00700           /* read, write, execute: owner */
896 #endif
897 #ifndef S_IRUSR
898 #define S_IRUSR 00400           /* read permission: owner */
899 #endif
900 #ifndef S_IWUSR
901 #define S_IWUSR 00200           /* write permission: owner */
902 #endif
903 #ifndef S_IXUSR
904 #define S_IXUSR 00100           /* execute permission: owner */
905 #endif
906 #ifndef S_IRWXG
907 #define S_IRWXG 00070           /* read, write, execute: group */
908 #endif
909 #ifndef S_IRGRP
910 #define S_IRGRP 00040           /* read permission: group */
911 #endif
912 #ifndef S_IWGRP
913 #define S_IWGRP 00020           /* write permission: group */
914 #endif
915 #ifndef S_IXGRP
916 #define S_IXGRP 00010           /* execute permission: group */
917 #endif
918 #ifndef S_IRWXO
919 #define S_IRWXO 00007           /* read, write, execute: other */
920 #endif
921 #ifndef S_IROTH
922 #define S_IROTH 00004           /* read permission: other */
923 #endif
924 #ifndef S_IWOTH
925 #define S_IWOTH 00002           /* write permission: other */
926 #endif
927 #ifndef S_IXOTH
928 #define S_IXOTH 00001           /* execute permission: other */
929 #endif
930
931 /* Some systems (SCO) treat UNIX domain sockets as FIFOs */
932
933 #ifndef S_IFSOCK
934 #define S_IFSOCK S_IFIFO
935 #endif
936 #ifndef S_ISSOCK
937 #define S_ISSOCK(mode)  ((mode & S_IFSOCK) == S_IFSOCK)
938 #endif
939
940 #if HAVE_KERNEL_SHARE_MODES
941 #ifndef LOCK_MAND 
942 #define LOCK_MAND       32      /* This is a mandatory flock */
943 #define LOCK_READ       64      /* ... Which allows concurrent read operations */
944 #define LOCK_WRITE      128     /* ... Which allows concurrent write operations */
945 #define LOCK_RW         192     /* ... Which allows concurrent read & write ops */
946 #endif
947 #endif
948
949 extern int DEBUGLEVEL;
950
951 #define MAX_SEC_CTX_DEPTH 8    /* Maximum number of security contexts */
952
953 #endif /* _INCLUDES_H */
954