4 Unix SMB/Netbios implementation.
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.
28 #define DEFAULT_PRINTING PRINT_AIX
32 #define DEFAULT_PRINTING PRINT_HPUX
36 #define DEFAULT_PRINTING PRINT_QNX
40 #define REPLACE_GETPASS
41 /* on SUNOS4 termios.h conflicts with sys/ioctl.h */
46 #define REPLACE_GETPASS
50 #include <sys/types.h>
52 #ifdef TIME_WITH_SYS_TIME
56 #ifdef HAVE_SYS_TIME_H
63 #ifdef HAVE_SYS_RESOURCE_H
64 #include <sys/resource.h>
74 #ifdef HAVE_SYS_PARAM_H
75 #include <sys/param.h>
82 #ifdef HAVE_SYS_SOCKET_H
83 #include <sys/socket.h>
105 #ifdef HAVE_SYS_FCNTL_H
106 #include <sys/fcntl.h>
110 #include <sys/stat.h>
116 #ifdef HAVE_SYS_IOCTL_H
117 #include <sys/ioctl.h>
120 #ifdef HAVE_SYS_FILIO_H
121 #include <sys/filio.h>
126 #ifdef HAVE_SYS_WAIT_H
127 #include <sys/wait.h>
145 #ifdef HAVE_SYS_SELECT_H
146 #include <sys/select.h>
149 #ifdef HAVE_SYS_MODE_H
150 /* apparently AIX needs this for S_ISLNK */
152 #include <sys/mode.h>
169 #include <netinet/in.h>
170 #include <arpa/inet.h>
173 #include <sys/file.h>
175 #ifdef HAVE_NETINET_TCP_H
176 #include <netinet/tcp.h>
179 #ifdef HAVE_TERMIOS_H
185 # define NAMLEN(dirent) strlen((dirent)->d_name)
187 # define dirent direct
188 # define NAMLEN(dirent) (dirent)->d_namlen
190 # include <sys/ndir.h>
193 # include <sys/dir.h>
200 #ifdef HAVE_SHARED_MMAP
201 #include <sys/mman.h>
215 #ifdef HAVE_SYS_MOUNT_H
216 #include <sys/mount.h>
219 #ifdef HAVE_SYS_VFS_H
223 #ifdef HAVE_SYS_FS_S5PARAM_H
224 #include <sys/fs/s5param.h>
227 #if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
228 #include <sys/filsys.h>
231 #ifdef HAVE_SYS_STATFS_H
232 # include <sys/statfs.h>
236 #include <sys/dustat.h>
239 #ifdef HAVE_SYS_STATVFS_H
240 #include <sys/statvfs.h>
247 #ifdef HAVE_GETPWANAM
248 #include <sys/label.h>
249 #include <sys/audit.h>
253 #ifdef HAVE_SYS_SECURITY_H
254 #include <sys/security.h>
256 #define PASSWORD_LENGTH 16
257 #endif /* HAVE_SYS_SECURITY_H */
263 #ifdef HAVE_STROPTS_H
272 #define uchar unsigned char
275 #ifdef HAVE_UNSIGNED_CHAR
276 #define schar signed char
282 Samba needs type definitions for int16, int32, uint16 and uint32.
284 Normally these are signed and unsigned 16 and 32 bit integers, but
285 they actually only need to be at least 16 and 32 bits
286 respectively. Thus if your word size is 8 bytes just defining them
287 as signed and unsigned int will work.
291 #define uint8 unsigned char
295 #if (SIZEOF_SHORT == 4)
296 #define int16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
297 #else /* SIZEOF_SHORT != 4 */
299 #endif /* SIZEOF_SHORT != 4 */
303 #define uint16 unsigned int16
307 #if (SIZEOF_INT == 4)
309 #elif (SIZEOF_LONG == 4)
311 #elif (SIZEOF_SHORT == 4)
317 #define uint32 unsigned int32
321 * Types for devices, inodes and offsets.
325 #define SMB_DEV_T dev_t
329 * Setup the correctly sized inode type.
334 # define SMB_INO_T ino64_t
336 # define SMB_INO_T ino_t
340 #ifndef LARGE_SMB_INO_T
341 # if defined(HAVE_INO64_T) || (defined(SIZEOF_INO_T) && (SIZEOF_INO_T == 8))
342 # define LARGE_SMB_INO_T 1
348 # define SMB_OFF_T off64_t
350 # define SMB_OFF_T off_t
354 #define SMB_OFF_T_BITS (sizeof(SMB_OFF_T)*8)
357 * Set the define that tells us if we can do 64 bit
361 #ifndef LARGE_SMB_OFF_T
362 # if defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8))
363 # define LARGE_SMB_OFF_T 1
368 * Type for stat structure.
371 #ifndef SMB_STRUCT_STAT
372 # if defined(HAVE_STAT64) && defined(HAVE_OFF64_T)
373 # define SMB_STRUCT_STAT struct stat64
375 # define SMB_STRUCT_STAT struct stat
380 * Type for statvfs structure.
381 * Unfortunately, due to the make proto structure
382 * we still need to define this as void * for platforms
383 * that don't have either statvfs or statvfs64. JRA.
386 #ifndef SMB_STRUCT_STATVFS
387 # if defined(STAT_STATVFS64)
388 # define SMB_STRUCT_STATVFS struct statvfs64
389 # elif defined(STAT_STATVFS)
390 # define SMB_STRUCT_STATVFS struct statvfs
392 # define SMB_STRUCT_STATVFS void *
397 * Defines for 64 bit fcntl locks.
400 #ifndef SMB_STRUCT_FLOCK
401 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
402 # define SMB_STRUCT_FLOCK struct flock64
404 # define SMB_STRUCT_FLOCK struct flock
409 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
410 # define SMB_F_SETLKW F_SETLKW64
412 # define SMB_F_SETLKW F_SETLKW
417 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
418 # define SMB_F_SETLK F_SETLK64
420 # define SMB_F_SETLK F_SETLK
425 # if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
426 # define SMB_F_GETLK F_GETLK64
428 # define SMB_F_GETLK F_GETLK
432 #if defined(HAVE_LONGLONG)
433 #define SMB_BIG_UINT unsigned long long
434 #define SMB_BIG_INT long long
436 #define SMB_BIG_UINT unsigned long
437 #define SMB_BIG_INT long
441 #define MIN(a,b) ((a)<(b)?(a):(b))
445 #define MAX(a,b) ((a)>(b)?(a):(b))
448 #ifndef HAVE_STRERROR
449 extern char *sys_errlist[];
450 #define strerror(i) sys_errlist[i]
454 # define strchr index
455 # define strrchr rindex
458 #ifndef HAVE_ERRNO_DECL
462 #ifdef HAVE_BROKEN_GETGROUPS
469 /* Lists, trees, caching, datbase... */
470 #include "ubi_sLinkList.h"
471 #include "ubi_dLinkList.h"
472 #include "dlinklist.h"
474 #ifndef UBI_BINTREE_H
475 #include "ubi_Cache.h"
476 #endif /* UBI_BINTREE_H */
480 #include "nameserv.h"
482 #include "byteorder.h"
489 #ifndef MAXCODEPAGELINES
490 #define MAXCODEPAGELINES 256
493 /***** automatically generated prototypes *****/
499 #define strcpy(dest,src) __ERROR__XX__NEVER_USE_STRCPY___;
504 #define strcat(dest,src) __ERROR__XX__NEVER_USE_STRCAT___;
509 #define sprintf __ERROR__XX__NEVER_USE_SPRINTF__;
511 #define pstrcpy(d,s) safe_strcpy((d),(s),sizeof(pstring)-1)
512 #define pstrcat(d,s) safe_strcat((d),(s),sizeof(pstring)-1)
513 #define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
514 #define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1)
517 #define QSORT_CAST (__compar_fn_t)
521 #define QSORT_CAST (int (*)(const void *, const void *))
524 /* this guess needs to be improved (tridge) */
525 #if defined(STAT_STATVFS) && !defined(SYSV)
529 #ifndef DEFAULT_PRINTING
531 #define DEFAULT_PRINTING PRINT_SYSV
533 #define DEFAULT_PRINTING PRINT_BSD
538 #define SIGCLD SIGCHLD
541 #if (defined(HAVE_SYSV_IPC) || defined(HAVE_SHARED_MMAP))
542 #define FAST_SHARE_MODES 1
550 #ifndef HAVE_UNION_SEMUN
553 struct semid_ds *buf;
554 unsigned short *array;
559 #if (!defined(WITH_NISPLUS) && !defined(WITH_LDAP))
560 #define USE_SMBPASS_DB 1
563 #if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
564 #define OSF1_ENH_SEC 1
567 #if defined(HAVE_PAM_AUTHENTICATE) && defined(HAVE_SECURITY_PAM_APPL_H)
571 #if defined(HAVE_YP_GET_DEFAULT_DOMAIN)
572 #define HAVE_NETGROUP 1
575 #if defined (HAVE_NETGROUP) && defined(HAVE_RPCSVC_YPCLNT_H)
576 #include "rpcsvc/ypclnt.h"
579 #ifndef ALLOW_CHANGE_PASSWORD
580 #if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
581 #define ALLOW_CHANGE_PASSWORD 1
585 /* what is the longest significant password available on your system?
586 Knowing this speeds up password searches a lot */
587 #ifndef PASSWORD_LENGTH
588 #define PASSWORD_LENGTH 8
591 #ifdef REPLACE_INET_NTOA
592 #define inet_ntoa rep_inet_ntoa
600 #define MAXPATHLEN 256
607 #ifndef INADDR_LOOPBACK
608 #define INADDR_LOOPBACK 0x7f000001
612 #define INADDR_NONE 0xffffffff
616 #define crypt ufc_crypt
619 #if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
620 #define ULTRIX_AUTH 1
624 char *strdup(const char *s);
628 void *memmove(void *dest,const void *src,int size);
631 #ifndef HAVE_INITGROUPS
632 int initgroups(char *name,gid_t id);
636 int rename(const char *zfrom, const char *zto);
640 time_t mktime(struct tm *t);
643 #ifndef HAVE_FTRUNCATE
644 int ftruncate(int f,long l);
647 #if (defined(HAVE_SETRESUID) && !defined(HAVE_SETRESUID_DECL))
649 int setresuid(uid_t ruid, uid_t euid, uid_t suid);
650 int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
653 #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
654 #define bzero(a,b) memset((a),'\0',(b))
657 #endif /* _INCLUDES_H */