the first cut of the internal messaging system.
[import/samba-cvsimport.git] / source / 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 "messages.h"
616 #include "util_list.h"
617
618 #ifndef UBI_BINTREE_H
619 #include "ubi_Cache.h"
620 #endif /* UBI_BINTREE_H */
621
622 #include "debugparse.h"
623
624 #include "version.h"
625 #include "smb.h"
626 #include "smbw.h"
627 #include "nameserv.h"
628
629 #include "byteorder.h"
630
631 #include "kanji.h"
632 #include "charset.h"
633
634 #include "ntdomain.h"
635
636 #include "msdfs.h"
637
638 #ifdef WITH_PROFILE
639 #include "profile.h"
640 #endif
641
642 #ifndef MAXCODEPAGELINES
643 #define MAXCODEPAGELINES 256
644 #endif
645
646 /*
647  * Type for wide character dirent structure.
648  * Only d_name is defined by POSIX.
649  */
650
651 typedef struct smb_wdirent {
652         wpstring        d_name;
653 } SMB_STRUCT_WDIRENT;
654
655 /*
656  * Type for wide character passwd structure.
657  */
658
659 typedef struct smb_wpasswd {
660         wfstring       pw_name;
661         char           *pw_passwd;
662         uid_t          pw_uid;
663         gid_t          pw_gid;
664         wpstring       pw_gecos;
665         wpstring       pw_dir;
666         wpstring       pw_shell;
667 } SMB_STRUCT_WPASSWD;
668
669 /* Defines for wisXXX functions. */
670 #define UNI_UPPER    0x1
671 #define UNI_LOWER    0x2
672 #define UNI_DIGIT    0x4
673 #define UNI_XDIGIT   0x8
674 #define UNI_SPACE    0x10
675
676 #ifdef HAVE_NSS_H
677 #include <nss.h>
678 #else
679
680 /* Minimal needed to compile.. */
681
682 enum nss_status {
683         NSS_STATUS_SUCCESS,
684         NSS_STATUS_NOTFOUND,
685         NSS_STATUS_UNAVAIL
686 };
687
688 #endif
689
690 /***** automatically generated prototypes *****/
691 #include "proto.h"
692
693 /* String routines */
694
695 #include "safe_string.h"
696
697 #ifdef __COMPAR_FN_T
698 #define QSORT_CAST (__compar_fn_t)
699 #endif
700
701 #ifndef QSORT_CAST
702 #define QSORT_CAST (int (*)(const void *, const void *))
703 #endif
704
705 /* this guess needs to be improved (tridge) */
706 #if (defined(STAT_STATVFS) || defined(STAT_STATVFS64)) && !defined(SYSV)
707 #define SYSV 1
708 #endif
709
710 #ifndef DEFAULT_PRINTING
711 #ifdef HAVE_LIBCUPS
712 #define DEFAULT_PRINTING PRINT_CUPS
713 #define PRINTCAP_NAME "cups"
714 #elif defined(SYSV)
715 #define DEFAULT_PRINTING PRINT_SYSV
716 #define PRINTCAP_NAME "lpstat"
717 #else
718 #define DEFAULT_PRINTING PRINT_BSD
719 #define PRINTCAP_NAME "/etc/printcap"
720 #endif
721 #endif
722
723 #ifndef PRINTCAP_NAME
724 #define PRINTCAP_NAME "/etc/printcap"
725 #endif
726
727 #ifndef SIGCLD
728 #define SIGCLD SIGCHLD
729 #endif
730
731 #ifndef MAP_FILE
732 #define MAP_FILE 0
733 #endif
734
735 #if (!defined(WITH_NISPLUS) && !defined(WITH_LDAP))
736 #define USE_SMBPASS_DB 1
737 #endif
738
739 #if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
740 #define OSF1_ENH_SEC 1
741 #endif
742
743 #ifndef ALLOW_CHANGE_PASSWORD
744 #if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
745 #define ALLOW_CHANGE_PASSWORD 1
746 #endif
747 #endif
748
749 /* what is the longest significant password available on your system? 
750  Knowing this speeds up password searches a lot */
751 #ifndef PASSWORD_LENGTH
752 #define PASSWORD_LENGTH 8
753 #endif
754
755 #ifdef REPLACE_INET_NTOA
756 #define inet_ntoa rep_inet_ntoa
757 #endif
758
759 #ifndef HAVE_PIPE
760 #define SYNC_DNS 1
761 #endif
762
763 #ifndef MAXPATHLEN
764 #define MAXPATHLEN 256
765 #endif
766
767 #ifndef SEEK_SET
768 #define SEEK_SET 0
769 #endif
770
771 #ifndef INADDR_LOOPBACK
772 #define INADDR_LOOPBACK 0x7f000001
773 #endif
774
775 #ifndef INADDR_NONE
776 #define INADDR_NONE 0xffffffff
777 #endif
778
779 #ifndef HAVE_CRYPT
780 #define crypt ufc_crypt
781 #endif
782
783 #ifndef O_ACCMODE
784 #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
785 #endif
786
787 #if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
788 #define ULTRIX_AUTH 1
789 #endif
790
791 #ifdef HAVE_LIBREADLINE
792 #  ifdef HAVE_READLINE_READLINE_H
793 #    include <readline/readline.h>
794 #    ifdef HAVE_READLINE_HISTORY_H
795 #      include <readline/history.h>
796 #    endif
797 #  else
798 #    ifdef HAVE_READLINE_H
799 #      include <readline.h>
800 #      ifdef HAVE_HISTORY_H
801 #        include <history.h>
802 #      endif
803 #    else
804 #      undef HAVE_LIBREADLINE
805 #    endif
806 #  endif
807 #endif
808
809 #ifndef HAVE_STRDUP
810 char *strdup(const char *s);
811 #endif
812
813 #ifndef HAVE_MEMMOVE
814 void *memmove(void *dest,const void *src,int size);
815 #endif
816
817 #ifndef HAVE_INITGROUPS
818 int initgroups(char *name,gid_t id);
819 #endif
820
821 #ifndef HAVE_RENAME
822 int rename(const char *zfrom, const char *zto);
823 #endif
824
825 #ifndef HAVE_MKTIME
826 time_t mktime(struct tm *t);
827 #endif
828
829 #ifndef HAVE_FTRUNCATE
830 int ftruncate(int f,long l);
831 #endif
832
833 #ifndef HAVE_STRTOUL
834 unsigned long strtoul(const char *nptr, char **endptr, int base);
835 #endif
836
837 #if (defined(USE_SETRESUID) && !defined(HAVE_SETRESUID_DECL))
838 /* stupid glibc */
839 int setresuid(uid_t ruid, uid_t euid, uid_t suid);
840 #endif
841 #if (defined(USE_SETRESUID) && !defined(HAVE_SETRESGID_DECL))
842 int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
843 #endif
844
845 #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
846 #define bzero(a,b) memset((a),'\0',(b))
847 #endif
848
849 #ifdef REPLACE_GETPASS
850 #define getpass(prompt) getsmbpass((prompt))
851 #endif
852
853 /*
854  * Some older systems seem not to have MAXHOSTNAMELEN
855  * defined.
856  */
857 #ifndef MAXHOSTNAMELEN
858 #define MAXHOSTNAMELEN 254
859 #endif
860
861 /* yuck, I'd like a better way of doing this */
862 #define DIRP_SIZE (256 + 32)
863
864 /*
865  * glibc on linux doesn't seem to have MSG_WAITALL
866  * defined. I think the kernel has it though..
867  */
868
869 #ifndef MSG_WAITALL
870 #define MSG_WAITALL 0
871 #endif
872
873 /* default socket options. Dave Miller thinks we should default to TCP_NODELAY
874    given the socket IO pattern that Samba uses */
875 #ifdef TCP_NODELAY
876 #define DEFAULT_SOCKET_OPTIONS "TCP_NODELAY"
877 #else
878 #define DEFAULT_SOCKET_OPTIONS ""
879 #endif
880
881 /* Load header file for libdl stuff */
882
883 #ifdef HAVE_LIBDL
884 #include <dlfcn.h>
885 #endif
886
887 /* Some POSIX definitions for those without */
888  
889 #ifndef S_IFDIR
890 #define S_IFDIR         0x4000
891 #endif
892 #ifndef S_ISDIR
893 #define S_ISDIR(mode)   ((mode & 0xF000) == S_IFDIR)
894 #endif
895 #ifndef S_IRWXU
896 #define S_IRWXU 00700           /* read, write, execute: owner */
897 #endif
898 #ifndef S_IRUSR
899 #define S_IRUSR 00400           /* read permission: owner */
900 #endif
901 #ifndef S_IWUSR
902 #define S_IWUSR 00200           /* write permission: owner */
903 #endif
904 #ifndef S_IXUSR
905 #define S_IXUSR 00100           /* execute permission: owner */
906 #endif
907 #ifndef S_IRWXG
908 #define S_IRWXG 00070           /* read, write, execute: group */
909 #endif
910 #ifndef S_IRGRP
911 #define S_IRGRP 00040           /* read permission: group */
912 #endif
913 #ifndef S_IWGRP
914 #define S_IWGRP 00020           /* write permission: group */
915 #endif
916 #ifndef S_IXGRP
917 #define S_IXGRP 00010           /* execute permission: group */
918 #endif
919 #ifndef S_IRWXO
920 #define S_IRWXO 00007           /* read, write, execute: other */
921 #endif
922 #ifndef S_IROTH
923 #define S_IROTH 00004           /* read permission: other */
924 #endif
925 #ifndef S_IWOTH
926 #define S_IWOTH 00002           /* write permission: other */
927 #endif
928 #ifndef S_IXOTH
929 #define S_IXOTH 00001           /* execute permission: other */
930 #endif
931
932 /* Some systems (SCO) treat UNIX domain sockets as FIFOs */
933
934 #ifndef S_IFSOCK
935 #define S_IFSOCK S_IFIFO
936 #endif
937 #ifndef S_ISSOCK
938 #define S_ISSOCK(mode)  ((mode & S_IFSOCK) == S_IFSOCK)
939 #endif
940
941 #if HAVE_KERNEL_SHARE_MODES
942 #ifndef LOCK_MAND 
943 #define LOCK_MAND       32      /* This is a mandatory flock */
944 #define LOCK_READ       64      /* ... Which allows concurrent read operations */
945 #define LOCK_WRITE      128     /* ... Which allows concurrent write operations */
946 #define LOCK_RW         192     /* ... Which allows concurrent read & write ops */
947 #endif
948 #endif
949
950 extern int DEBUGLEVEL;
951
952 #define MAX_SEC_CTX_DEPTH 8    /* Maximum number of security contexts */
953
954 #endif /* _INCLUDES_H */
955