4 Unix SMB/Netbios implementation.
6 Machine customisation and include handling
7 Copyright (C) Andrew Tridgell 1994-1995
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 This file does all the #includes's. This makes it easier to
25 port to a new unix. Hopefully a port will only have to edit the Makefile
26 and add a section for the new unix below.
30 /* the first OS dependent section is to setup what includes will be used.
31 the main OS dependent section comes later on
98 #define REPLACE_MKTIME
112 #if (defined(SHADOW_PWD)||defined(OSF1_ENH_SEC)||defined(SecureWare)||defined(PWDAUTH))
113 #define PASSWORD_LENGTH 16
116 /* here is the general includes section - with some ifdefs generated
117 by the previous section
122 #include <posix/stdlib.h>
131 #include <sys/types.h>
134 #include <sys/statfs.h>
135 #include <sys/stream.h>
136 #include <netinet/types.h>
137 #include <netinet/ether.h>
138 #include <netinet/ip_if.h>
141 #include <sys/socket.h>
142 #include <sys/ioctl.h>
145 #include <posix/utime.h>
146 #include <bsd/sys/time.h>
147 #include <bsd/netinet/in.h>
149 #include <sys/time.h>
150 #include <netinet/in.h>
155 #include <sys/file.h>
156 #include <sys/stat.h>
157 #include <sys/param.h>
160 #include <sys/resource.h>
163 #include <sys/mount.h>
174 #include <sys/wait.h>
176 #include <sys/stream.h>
180 #include <bsd/net/if.h>
186 #if defined(GETPWANAM)
187 #include <sys/types.h>
188 #include <sys/label.h>
189 #include <sys/audit.h>
193 #if defined(SHADOW_PWD) && !defined(NETBSD) && !defined(CONVEX)
203 /***************************************************************************
204 Here come some platform specific sections
205 ***************************************************************************/
209 #include <arpa/inet.h>
213 #include <netinet/in.h>
214 #ifndef NO_ASMSIGNALH
215 #include <asm/signal.h>
217 #define SIGNAL_CAST (__sighandler_t)
222 #define USE_SIGPROCMASK
224 /* SETFS disabled until we can check on some bug reports */
225 #if _LINUX_C_LIB_VERSION_MAJOR >= 5
230 #if _LINUX_C_LIB_VERSION_MAJOR < 5
232 #define crypt pw_encrypt
239 #define SIGNAL_CAST (void (*)(int))
240 #include <netinet/tcp.h>
242 #include <sys/acct.h>
246 #include <sys/wait.h>
248 /* #include <termios.h> */
252 #define mktime timelocal
253 typedef unsigned short mode_t;
258 #define REPLACE_GETPASS
260 #define USE_SIGPROCMASK
267 #include <sys/acct.h>
268 #include <sys/statfs.h>
269 #include <sys/statvfs.h>
270 #include <sys/filio.h>
271 #include <sys/sockio.h>
272 #include <netinet/in_systm.h>
273 #include <netinet/tcp.h>
274 #include <netinet/ip.h>
276 #include <arpa/inet.h>
277 #include <rpcsvc/ypclnt.h>
280 extern int gettimeofday (struct timeval *, void *);
281 extern int gethostname (char *name, int namelen);
282 extern int innetgr (const char *, const char *, const char *, const char *);
284 #define SIGNAL_CAST (void (*)(int))
289 #define REPLACE_STRLEN
293 #define REPLACE_GETPASS
294 #define USE_SIGPROCMASK
300 #include <nfs/nfs_clnt.h>
302 #include <netinet/tcp.h>
309 #define SIGNAL_CAST (void(*)(int))
315 #include <netinet/tcp.h>
316 #include <sys/statfs.h>
322 #define SIGNAL_CAST (void (*)())
329 #include <netinet/tcp.h>
330 #include <sys/statvfs.h>
339 #define SIGNAL_CAST (void (*)())
346 #include <bsd/net/soioctl.h>
350 #include <sys/statfs.h>
351 #include <sys/wait.h>
352 #include <sys/termio.h>
353 #define SIGNAL_CAST (void (*)())
355 extern struct group *getgrnam();
356 extern struct passwd *getpwnam();
359 #define REPLACE_STRSTR
367 #include <sys/statfs.h>
368 #include <sys/statvfs.h>
373 #define SIGNAL_CAST (void (*)(int))
383 #include <sys/statfs.h>
384 #include <sys/statvfs.h>
386 #include <sys/filio.h>
388 #include <sys/sockio.h>
389 #include <netinet/tcp.h>
394 #define SIGNAL_CAST (void (*)(int))
406 char *mktemp(char *); /* No standard include */
407 #include <netinet/in.h>
408 #include <arpa/inet.h> /* both for inet_ntoa */
409 #define SIGNAL_CAST ( void (*) (int) )
412 #include <netinet/tcp.h>
415 #include <sys/types.h>
416 #include <sys/security.h>
419 #define PASSWORD_LENGTH 16
420 #define NEED_AUTH_PARAMETERS
421 #endif /* OSF1_ENH_SEC */
427 #define SIGNAL_CAST (void (*)())
428 #include <sys/fcntl.h>
429 #include <sys/statfs.h>
437 #define REPLACE_GETPASS
445 #include <netinet/tcp.h>
446 #define SIGNAL_CAST (void (*)())
453 #include <netinet/tcp.h>
454 /* you may not need this */
456 #define SIGNAL_CAST (void (*)())
458 #define REPLACE_INNETGR
465 #include <netinet/tcp.h>
466 #include <netinet/in_systm.h>
467 #include <netinet/ip.h>
468 #define SIGNAL_CAST (void (*)())
477 #include <sys/select.h>
479 #include <sys/statfs.h>
482 #include <sys/priv.h>
483 #include <netinet/tcp.h>
487 #define SIGNAL_CAST (void (*)())
488 #define DEFAULT_PRINTING PRINT_AIX
489 /* we undef this because sys/param.h is broken in aix. uggh. */
490 #undef MAXHOSTNAMELEN
499 #include <sys/types.h>
500 #include <sys/termios.h>
501 #include <netinet/tcp.h>
502 #ifdef HPUX_10_TRUSTED
503 #include <hpsecurity.h>
505 #define NEED_AUTH_PARAMETERS
507 #define SIGNAL_CAST (void (*)(__harg))
508 #define SELECT_CAST (int *)
511 #define WAIT3_CAST2 (int *)
515 #define DEFAULT_PRINTING PRINT_HPUX
516 #define SIGCLD_IGNORE
524 #include <sys/types.h>
525 #include <sys/statfs.h>
526 #include <sys/stat.h>
528 #include <sys/socket.h>
531 #define SIGNAL_CAST (void (*)(int))
548 #include <sys/statfs.h>
549 #include <sys/statvfs.h>
552 #include <sys/sockio.h>
553 #include <netinet/tcp.h>
558 #define SIGNAL_CAST (void (*)(int))
562 #define seteuid(uid) setreuid(-1,uid)
565 #define setegid(gid) setregid(-1,gid)
571 #include <sys/types.h>
575 #define bzero(b,len) memset(b,0,len)
589 #define bzero(b,len) memset(b,0,len)
598 #define SIGNAL_CAST (void (*)(int))
599 #define WAIT3_CAST1 (union wait *)
608 #include <sys/statfs.h>
612 #define SIGNAL_CAST (void (*)())
613 #define HAVE_FCNTL_LOCK 0
614 #define HAVE_GETTIMEOFDAY
621 #include <sys/netinet/tcp.h>
622 #include <sys/netinet/in_systm.h>
623 #include <sys/netinet/ip.h>
627 #include <sys/statfs.h>
628 #include <sys/stropts.h>
634 #include <rpcsvc/ypclnt.h>
637 #include <sys/security.h>
638 #include <sys/audit.h>
640 #define crypt bigcrypt
643 #define ftruncate(f,l) syscall(0x0a28,f,l)
645 #define SIGNAL_CAST (void (*)(int))
659 #define NO_INITGROUPS
661 #define HAVE_PATHCONF
667 /* Definitions for RiscIX */
669 #define SIGNAL_CAST (void (*)(int))
670 #include <sys/dirent.h>
671 #include <sys/acct.h>
676 #define HAVE_GETTIMEOFDAY
684 #include <net/errno.h>
688 #include <sys/statfs.h>
690 #include <sys/sioctl.h>
693 #include <netinet/tcp.h>
694 #define FIONREAD FIORDCHK
697 #define SIGNAL_CAST (void (*)(int))
717 #define SIGNAL_CAST (void (*)(int))
718 char *strdup (char *);
731 #define SIGNAL_CAST (void (*)(int))
732 char *strdup (char *);
743 #include <sys/statfs.h>
744 #include <sys/stropts.h>
745 #define NO_GET_BROADCAST
751 #define PF_INET AF_INET
753 #define ftruncate(f,l) chsize(f,l)
757 #include <netinet/tcp.h>
758 #include <arpa/inet.h>
763 #define DONT_REINSTALL_SIG
766 #define SIGNAL_CAST (_SigFunc_Ptr_t)
769 extern char *mktemp(char *);
770 extern int fsync(int);
771 extern int seteuid(uid_t);
772 extern int setgroups(int, int *);
773 extern int initgroups(char *, int);
774 extern int statfs(char *, struct statfs *);
775 extern int setegid(gid_t);
776 extern int getopt(int, char *const *, const char *);
777 extern int chroot(char *);
778 extern int gettimeofday(struct timeval *, struct timezone *);
779 extern int gethostname(char *, int);
780 extern char *crypt(char *, char *);
781 extern char *getpass(char *);
786 #define MAXPATHLEN 1024
790 #include <sys/statfs.h>
791 #define SIGNAL_CAST (void (*)(int))
792 #define SIGCLD_IGNORE
793 #define HAVE_FCNTL_LOCK 1
803 #include <sys/fcntl.h>
804 #include <sys/statfs.h>
809 #define ptrdiff_t int
810 #define HAVE_GETGRNAM 0
815 #define NO_INITGROUPS
823 #define REPLACE_MKTIME
824 #define REPLACE_RENAME
825 #define REPLACE_STRSTR
832 #include <sys/statfs.h>
833 #include <sys/select.h>
836 #define SIGNAL_CAST (void (*)())
838 #define NO_INITGROUPS
840 #define HAVE_TIMEZONE
843 #define HAVE_FCNTL_LOCK 1
844 #define DEFAULT_PRINTING PRINT_QNX
852 #include <sys/timeb.h>
858 #include <sys/statfs.h>
861 #define SIGNAL_CAST (void (*)())
862 #define HAVE_FCNTL_LOCK 0
864 #define NO_GET_BROADCAST
867 #define NO_INITGROUPS
872 #define strcasecmp stricmp
873 #define strncasecmp strnicmp
878 #define SIGNAL_CAST (void (*)())
879 #define WAIT3_CAST1 (union wait *)
882 #include <resource.h>
886 #include <sys/statfs.h>
893 #define SIGNAL_CAST (void (*)(int))
896 #include <sys/select.h>
900 #include <sys/statfs.h>
901 #include <sys/bsdioctl.h>
906 /*******************************************************************
907 end of the platform specific sections
908 ********************************************************************/
910 #if defined(USE_MMAP) || FAST_SHARE_MODES
911 #include <sys/mman.h>
915 #define NEED_AUTH_PARAMETERS
918 #ifdef REPLACE_GETPASS
919 extern char *getsmbpass(char *);
920 #define getpass(s) getsmbpass(s)
923 #ifdef REPLACE_INNETGR
924 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
928 #define FD_SETSIZE 255
935 /* Now for some other grungy stuff */
937 struct spwd { /* fake shadow password structure */
944 #define bzero(p,s) memset(p,0,s)
950 #define memmove(d,s,n) MemMove(d,s,n)
958 /* some unixes have ENOTTY instead of TIOCNOTTY */
961 #define TIOCNOTTY ENOTTY
969 /* if undefined then use bsd or sysv printing */
970 #ifndef DEFAULT_PRINTING
972 #define DEFAULT_PRINTING PRINT_SYSV
974 #define DEFAULT_PRINTING PRINT_BSD
980 #include <afs/stds.h>
981 #include <afs/kautils.h>
985 #include <dce/dce_error.h>
986 #include <dce/sec_login.h>
998 extern char *sys_errlist[];
999 #define strerror(i) sys_errlist[i]
1004 #define perror(m) printf("%s: %s\n",m,strerror(errno))
1007 #ifndef MAXHOSTNAMELEN
1008 #define MAXHOSTNAMELEN 255
1011 #include "version.h"
1013 #include "nameserv.h"
1015 #include "byteorder.h"
1018 #include "charset.h"
1021 #define S_IFREG 0100000
1025 #define S_ISREG(x) ((S_IFREG & x)!=0)
1029 #define S_ISDIR(x) ((S_IFDIR & x)!=0)
1033 #define crypt ufc_crypt
1036 #ifdef REPLACE_STRLEN
1037 #define strlen(s) Strlen(s)
1040 #ifdef REPLACE_STRSTR
1041 #define strstr(s,p) Strstr(s,p)
1044 #ifdef REPLACE_MKTIME
1045 #define mktime(t) Mktime(t)
1049 #define NGROUPS_MAX 128
1053 #define EDQUOT ENOSPC
1056 #ifndef HAVE_GETGRNAM
1057 #define HAVE_GETGRNAM 1
1064 /* default to using ftruncate workaround as this is safer than assuming
1065 it works and getting lots of bug reports */
1066 #ifndef FTRUNCATE_CAN_EXTEND
1067 #define FTRUNCATE_CAN_EXTEND 0
1070 /* maybe this unix doesn't separate RD and WR locks? */
1072 #define F_RDLCK F_WRLCK
1076 #define ENOTSOCK EINVAL
1080 #define SIGCLD SIGCHLD
1083 #ifndef HAVE_FCNTL_LOCK
1084 #define HAVE_FCNTL_LOCK 1
1088 #define WAIT3_CAST2 (struct rusage *)
1092 #define WAIT3_CAST1 (int *)
1096 #define QSORT_CAST (int (*)())
1099 /* this is a rough check to see if this machine has a lstat() call.
1100 it is not guaranteed to work */
1101 #if !(defined(S_ISLNK) || defined(S_IFLNK))
1105 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1112 #define geteuid() getuid()
1113 #define getegid() getgid()
1114 #define seteuid(x) setuid(x)
1115 #define setegid(x) setgid(x)
1119 #if (HAVE_FCNTL_LOCK == 0)
1120 /* since there is no locking available, system includes */
1121 /* for DomainOS 10.4 do not contain any of the following */
1122 /* #define's. So, to satisfy the compiler, add these */
1123 /* #define's, although they arn't really necessary. */
1128 #endif /* HAVE_FCNTL_LOCK == 0 */
1131 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1132 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1136 #define strcpy(dest,src) StrCpy(dest,src)
1140 /* possibly wrap the malloc calls */
1143 /* undo the old malloc def if necessary */
1145 #define xx_old_malloc malloc
1149 #define malloc(size) malloc_wrapped(size,__FILE__,__LINE__)
1151 /* undo the old realloc def if necessary */
1153 #define xx_old_realloc realloc
1157 #define realloc(ptr,size) realloc_wrapped(ptr,size,__FILE__,__LINE__)
1159 /* undo the old free def if necessary */
1161 #define xx_old_free free
1165 #define free(ptr) free_wrapped(ptr,__FILE__,__LINE__)
1167 /* and the malloc prototypes */
1168 void *malloc_wrapped(int,char *,int);
1169 void *realloc_wrapped(void *,int,char *,int);
1170 void free_wrapped(void *,char *,int);
1176 /* undo the old memcpy def if necessary */
1178 #define xx_old_memcpy memcpy
1182 #define memcpy(d,s,l) memcpy_wrapped(d,s,l,__FILE__,__LINE__)
1183 void *memcpy_wrapped(void *d,void *s,int l,char *fname,int line);