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