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(FreeBSD) && !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
225 /* SETFS disabled until we can check on some bug reports */
226 #if _LINUX_C_LIB_VERSION_MAJOR >= 5
231 #if _LINUX_C_LIB_VERSION_MAJOR < 5
233 #define crypt pw_encrypt
240 #define SIGNAL_CAST (void (*)(int))
241 #include <netinet/tcp.h>
243 #include <sys/acct.h>
247 #include <sys/wait.h>
249 /* #include <termios.h> */
253 #define mktime timelocal
254 typedef unsigned short mode_t;
259 #define REPLACE_GETPASS
261 #define USE_SIGPROCMASK
269 #include <sys/acct.h>
270 #include <sys/statfs.h>
271 #include <sys/statvfs.h>
272 #include <sys/filio.h>
273 #include <sys/sockio.h>
274 #include <netinet/in_systm.h>
275 #include <netinet/tcp.h>
276 #include <netinet/ip.h>
278 #include <arpa/inet.h>
279 #include <rpcsvc/ypclnt.h>
282 extern int gettimeofday (struct timeval *, void *);
283 extern int gethostname (char *name, int namelen);
284 extern int innetgr (const char *, const char *, const char *, const char *);
286 #define SIGNAL_CAST (void (*)(int))
291 #define REPLACE_STRLEN
295 #define REPLACE_GETPASS
296 #define USE_SIGPROCMASK
302 #include <nfs/nfs_clnt.h>
304 #include <netinet/tcp.h>
311 #define SIGNAL_CAST (void(*)(int))
318 #include <netinet/tcp.h>
319 #include <sys/statfs.h>
325 #define SIGNAL_CAST (void (*)())
332 #include <netinet/tcp.h>
333 #include <sys/statvfs.h>
342 #define SIGNAL_CAST (void (*)())
349 #include <bsd/net/soioctl.h>
353 #include <sys/statfs.h>
354 #include <sys/wait.h>
355 #include <sys/termio.h>
356 #define SIGNAL_CAST (void (*)())
358 extern struct group *getgrnam();
359 extern struct passwd *getpwnam();
362 #define REPLACE_STRSTR
370 #include <sys/statfs.h>
371 #include <sys/statvfs.h>
376 #define SIGNAL_CAST (void (*)(int))
386 #include <sys/statfs.h>
387 #include <sys/statvfs.h>
389 #include <sys/filio.h>
391 #include <sys/sockio.h>
392 #include <netinet/tcp.h>
397 #define SIGNAL_CAST (void (*)(int))
409 char *mktemp(char *); /* No standard include */
410 #include <netinet/in.h>
411 #include <arpa/inet.h> /* both for inet_ntoa */
412 #define SIGNAL_CAST ( void (*) (int) )
415 #include <netinet/tcp.h>
418 #include <sys/types.h>
419 #include <sys/security.h>
422 #define PASSWORD_LENGTH 16
423 #define NEED_AUTH_PARAMETERS
424 #endif /* OSF1_ENH_SEC */
430 #define SIGNAL_CAST (void (*)())
431 #include <sys/fcntl.h>
432 #include <sys/statfs.h>
440 #define REPLACE_GETPASS
448 #include <netinet/tcp.h>
449 #define SIGNAL_CAST (void (*)())
456 #include <netinet/tcp.h>
457 /* you may not need this */
459 #define SIGNAL_CAST (void (*)())
461 #define REPLACE_INNETGR
468 #include <netinet/tcp.h>
469 #include <netinet/in_systm.h>
470 #include <netinet/ip.h>
471 #define SIGNAL_CAST (void (*)())
479 #define HAVE_GETTIMEOFDAY
480 #define HAVE_PATHCONF
481 #define HAVE_GETGRNAM 1
489 #include <sys/select.h>
491 #include <sys/statfs.h>
494 #include <sys/priv.h>
495 #include <netinet/tcp.h>
499 #define SIGNAL_CAST (void (*)())
500 #define DEFAULT_PRINTING PRINT_AIX
501 /* we undef this because sys/param.h is broken in aix. uggh. */
502 #undef MAXHOSTNAMELEN
511 #include <sys/types.h>
512 #include <sys/termios.h>
513 #include <netinet/tcp.h>
514 #ifdef HPUX_10_TRUSTED
515 #include <hpsecurity.h>
517 #define NEED_AUTH_PARAMETERS
519 #define SIGNAL_CAST (void (*)(__harg))
520 #define SELECT_CAST (int *)
523 #define WAIT3_CAST2 (int *)
527 #define DEFAULT_PRINTING PRINT_HPUX
528 #define SIGCLD_IGNORE
536 #include <sys/types.h>
537 #include <sys/statfs.h>
538 #include <sys/stat.h>
540 #include <sys/socket.h>
543 #define SIGNAL_CAST (void (*)(int))
560 #include <sys/statfs.h>
561 #include <sys/statvfs.h>
564 #include <sys/sockio.h>
565 #include <netinet/tcp.h>
570 #define SIGNAL_CAST (void (*)(int))
574 #define seteuid(uid) setreuid(-1,uid)
577 #define setegid(gid) setregid(-1,gid)
583 #include <sys/types.h>
587 #define bzero(b,len) memset(b,0,len)
601 #define bzero(b,len) memset(b,0,len)
610 #define SIGNAL_CAST (void (*)(int))
611 #define WAIT3_CAST1 (union wait *)
620 #include <sys/statfs.h>
624 #define SIGNAL_CAST (void (*)())
625 #define HAVE_FCNTL_LOCK 0
626 #define HAVE_GETTIMEOFDAY
633 #include <sys/netinet/tcp.h>
634 #include <sys/netinet/in_systm.h>
635 #include <sys/netinet/ip.h>
639 #include <sys/statfs.h>
640 #include <sys/stropts.h>
646 #include <rpcsvc/ypclnt.h>
649 #include <sys/security.h>
650 #include <sys/audit.h>
652 #define crypt bigcrypt
655 #define ftruncate(f,l) syscall(0x0a28,f,l)
657 #define SIGNAL_CAST (void (*)(int))
671 #define NO_INITGROUPS
673 #define HAVE_PATHCONF
679 /* Definitions for RiscIX */
681 #define SIGNAL_CAST (void (*)(int))
682 #include <sys/dirent.h>
683 #include <sys/acct.h>
688 #define HAVE_GETTIMEOFDAY
696 #include <net/errno.h>
700 #include <sys/statfs.h>
702 #include <sys/sioctl.h>
705 #include <netinet/tcp.h>
706 #define FIONREAD FIORDCHK
709 #define SIGNAL_CAST (void (*)(int))
729 #define SIGNAL_CAST (void (*)(int))
730 char *strdup (char *);
743 #define SIGNAL_CAST (void (*)(int))
744 char *strdup (char *);
755 #include <sys/statfs.h>
756 #include <sys/stropts.h>
757 #define NO_GET_BROADCAST
763 #define PF_INET AF_INET
765 #define ftruncate(f,l) chsize(f,l)
769 #include <netinet/tcp.h>
770 #include <arpa/inet.h>
775 #define DONT_REINSTALL_SIG
778 #define SIGNAL_CAST (_SigFunc_Ptr_t)
781 extern char *mktemp(char *);
782 extern int fsync(int);
783 extern int seteuid(uid_t);
784 extern int setgroups(int, int *);
785 extern int initgroups(char *, int);
786 extern int statfs(char *, struct statfs *);
787 extern int setegid(gid_t);
788 extern int getopt(int, char *const *, const char *);
789 extern int chroot(char *);
790 extern int gettimeofday(struct timeval *, struct timezone *);
791 extern int gethostname(char *, int);
792 extern char *crypt(char *, char *);
793 extern char *getpass(char *);
798 #define MAXPATHLEN 1024
802 #include <sys/statfs.h>
803 #define SIGNAL_CAST (void (*)(int))
804 #define SIGCLD_IGNORE
805 #define HAVE_FCNTL_LOCK 1
815 #include <sys/fcntl.h>
816 #include <sys/statfs.h>
821 #define ptrdiff_t int
822 #define HAVE_GETGRNAM 0
827 #define NO_INITGROUPS
835 #define REPLACE_MKTIME
836 #define REPLACE_RENAME
837 #define REPLACE_STRSTR
844 #include <sys/statfs.h>
845 #include <sys/select.h>
848 #define SIGNAL_CAST (void (*)())
850 #define NO_INITGROUPS
852 #define HAVE_TIMEZONE
855 #define HAVE_FCNTL_LOCK 1
856 #define DEFAULT_PRINTING PRINT_QNX
864 #include <sys/timeb.h>
870 #include <sys/statfs.h>
873 #define SIGNAL_CAST (void (*)())
874 #define HAVE_FCNTL_LOCK 0
876 #define NO_GET_BROADCAST
879 #define NO_INITGROUPS
884 #define strcasecmp stricmp
885 #define strncasecmp strnicmp
890 #define SIGNAL_CAST (void (*)())
891 #define WAIT3_CAST1 (union wait *)
894 #include <resource.h>
898 #include <sys/statfs.h>
905 #define SIGNAL_CAST (void (*)(int))
908 #include <sys/select.h>
912 #include <sys/statfs.h>
913 #include <sys/bsdioctl.h>
918 /*******************************************************************
919 end of the platform specific sections
920 ********************************************************************/
922 #if defined(USE_MMAP) || FAST_SHARE_MODES
923 #include <sys/mman.h>
927 #define NEED_AUTH_PARAMETERS
930 #ifdef REPLACE_GETPASS
931 extern char *getsmbpass(char *);
932 #define getpass(s) getsmbpass(s)
935 #ifdef REPLACE_INNETGR
936 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
940 #define FD_SETSIZE 255
947 /* Now for some other grungy stuff */
949 struct spwd { /* fake shadow password structure */
956 #define bzero(p,s) memset(p,0,s)
962 #define memmove(d,s,n) MemMove(d,s,n)
970 /* some unixes have ENOTTY instead of TIOCNOTTY */
973 #define TIOCNOTTY ENOTTY
981 /* if undefined then use bsd or sysv printing */
982 #ifndef DEFAULT_PRINTING
984 #define DEFAULT_PRINTING PRINT_SYSV
986 #define DEFAULT_PRINTING PRINT_BSD
992 #include <afs/stds.h>
993 #include <afs/kautils.h>
997 #include <dce/dce_error.h>
998 #include <dce/sec_login.h>
1010 extern char *sys_errlist[];
1011 #define strerror(i) sys_errlist[i]
1016 #define perror(m) printf("%s: %s\n",m,strerror(errno))
1019 #ifndef MAXHOSTNAMELEN
1020 #define MAXHOSTNAMELEN 255
1023 #include "version.h"
1025 #include "nameserv.h"
1027 #include "byteorder.h"
1030 #include "charset.h"
1033 #define S_IFREG 0100000
1037 #define S_ISREG(x) ((S_IFREG & x)!=0)
1041 #define S_ISDIR(x) ((S_IFDIR & x)!=0)
1045 #define crypt ufc_crypt
1048 #ifdef REPLACE_STRLEN
1049 #define strlen(s) Strlen(s)
1052 #ifdef REPLACE_STRSTR
1053 #define strstr(s,p) Strstr(s,p)
1056 #ifdef REPLACE_MKTIME
1057 #define mktime(t) Mktime(t)
1061 #define NGROUPS_MAX 128
1065 #define EDQUOT ENOSPC
1068 #ifndef HAVE_GETGRNAM
1069 #define HAVE_GETGRNAM 1
1076 /* default to using ftruncate workaround as this is safer than assuming
1077 it works and getting lots of bug reports */
1078 #ifndef FTRUNCATE_CAN_EXTEND
1079 #define FTRUNCATE_CAN_EXTEND 0
1082 /* maybe this unix doesn't separate RD and WR locks? */
1084 #define F_RDLCK F_WRLCK
1088 #define ENOTSOCK EINVAL
1092 #define SIGCLD SIGCHLD
1099 #ifndef HAVE_FCNTL_LOCK
1100 #define HAVE_FCNTL_LOCK 1
1104 #define WAIT3_CAST2 (struct rusage *)
1108 #define WAIT3_CAST1 (int *)
1112 #define QSORT_CAST (int (*)())
1115 /* this is a rough check to see if this machine has a lstat() call.
1116 it is not guaranteed to work */
1117 #if !(defined(S_ISLNK) || defined(S_IFLNK))
1121 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1128 #define geteuid() getuid()
1129 #define getegid() getgid()
1130 #define seteuid(x) setuid(x)
1131 #define setegid(x) setgid(x)
1135 #if (HAVE_FCNTL_LOCK == 0)
1136 /* since there is no locking available, system includes */
1137 /* for DomainOS 10.4 do not contain any of the following */
1138 /* #define's. So, to satisfy the compiler, add these */
1139 /* #define's, although they arn't really necessary. */
1144 #endif /* HAVE_FCNTL_LOCK == 0 */
1147 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1148 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1152 #define strcpy(dest,src) StrCpy(dest,src)
1156 /* possibly wrap the malloc calls */
1159 /* undo the old malloc def if necessary */
1161 #define xx_old_malloc malloc
1165 #define malloc(size) malloc_wrapped(size,__FILE__,__LINE__)
1167 /* undo the old realloc def if necessary */
1169 #define xx_old_realloc realloc
1173 #define realloc(ptr,size) realloc_wrapped(ptr,size,__FILE__,__LINE__)
1175 /* undo the old free def if necessary */
1177 #define xx_old_free free
1181 #define free(ptr) free_wrapped(ptr,__FILE__,__LINE__)
1183 /* and the malloc prototypes */
1184 void *malloc_wrapped(int,char *,int);
1185 void *realloc_wrapped(void *,int,char *,int);
1186 void free_wrapped(void *,char *,int);
1192 /* undo the old memcpy def if necessary */
1194 #define xx_old_memcpy memcpy
1198 #define memcpy(d,s,l) memcpy_wrapped(d,s,l,__FILE__,__LINE__)
1199 void *memcpy_wrapped(void *d,void *s,int l,char *fname,int line);