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>
187 #include <sys/mman.h>
190 #if defined(GETPWANAM)
191 #include <sys/types.h>
192 #include <sys/label.h>
193 #include <sys/audit.h>
197 #if defined(SHADOW_PWD) && !defined(NETBSD) && !defined(CONVEX)
207 /***************************************************************************
208 Here come some platform specific sections
209 ***************************************************************************/
213 #include <arpa/inet.h>
217 #include <netinet/in.h>
218 #ifndef NO_ASMSIGNALH
219 #include <asm/signal.h>
221 #define SIGNAL_CAST (__sighandler_t)
229 #define crypt pw_encrypt
235 #define SIGNAL_CAST (void (*)(int))
236 #include <netinet/tcp.h>
238 #include <sys/acct.h>
242 #include <sys/wait.h>
244 /* #include <termios.h> */
248 #define mktime timelocal
249 typedef unsigned short mode_t;
254 #define REPLACE_GETPASS
262 #include <sys/acct.h>
263 #include <sys/statfs.h>
264 #include <sys/statvfs.h>
265 #include <sys/filio.h>
266 #include <sys/sockio.h>
267 #include <netinet/in_systm.h>
268 #include <netinet/tcp.h>
269 #include <netinet/ip.h>
271 #include <arpa/inet.h>
272 #include <rpcsvc/ypclnt.h>
275 extern int gettimeofday (struct timeval *, void *);
276 extern int gethostname (char *name, int namelen);
277 extern int innetgr (const char *, const char *, const char *, const char *);
279 #define SIGNAL_CAST (void (*)(int))
284 #define REPLACE_STRLEN
288 #define REPLACE_GETPASS
294 #include <nfs/nfs_clnt.h>
296 #include <netinet/tcp.h>
303 #define SIGNAL_CAST (void(*)(int))
309 #include <netinet/tcp.h>
310 #include <sys/statfs.h>
316 #define SIGNAL_CAST (void (*)())
323 #include <netinet/tcp.h>
324 #include <sys/statvfs.h>
333 #define SIGNAL_CAST (void (*)())
340 #include <bsd/net/soioctl.h>
344 #include <sys/statfs.h>
345 #include <sys/wait.h>
346 #include <sys/termio.h>
347 #define SIGNAL_CAST (void (*)())
349 extern struct group *getgrnam();
350 extern struct passwd *getpwnam();
353 #define REPLACE_STRSTR
361 #include <sys/statfs.h>
362 #include <sys/statvfs.h>
367 #define SIGNAL_CAST (void (*)(int))
377 #include <sys/statfs.h>
378 #include <sys/statvfs.h>
380 #include <sys/filio.h>
382 #include <sys/sockio.h>
383 #include <netinet/tcp.h>
388 #define SIGNAL_CAST (void (*)(int))
400 char *mktemp(char *); /* No standard include */
401 #include <netinet/in.h>
402 #include <arpa/inet.h> /* both for inet_ntoa */
403 #define SIGNAL_CAST ( void (*) (int) )
406 #include <netinet/tcp.h>
409 #include <sys/types.h>
410 #include <sys/security.h>
413 #define PASSWORD_LENGTH 16
414 #define NEED_AUTH_PARAMETERS
415 #endif /* OSF1_ENH_SEC */
421 #define SIGNAL_CAST (void (*)())
422 #include <sys/fcntl.h>
423 #include <sys/statfs.h>
431 #define REPLACE_GETPASS
439 #include <netinet/tcp.h>
440 #define SIGNAL_CAST (void (*)())
447 #include <netinet/tcp.h>
448 /* you may not need this */
450 #define SIGNAL_CAST (void (*)())
452 #define REPLACE_INNETGR
459 #include <netinet/tcp.h>
460 #include <netinet/in_systm.h>
461 #include <netinet/ip.h>
462 #define SIGNAL_CAST (void (*)())
471 #include <sys/select.h>
473 #include <sys/statfs.h>
476 #include <sys/priv.h>
477 #include <netinet/tcp.h>
480 #define SIGNAL_CAST (void (*)())
481 #define DEFAULT_PRINTING PRINT_AIX
482 /* we undef this because sys/param.h is broken in aix. uggh. */
483 #undef MAXHOSTNAMELEN
492 #include <sys/types.h>
493 #include <sys/termios.h>
494 #include <netinet/tcp.h>
495 #ifdef HPUX_10_TRUSTED
496 #include <hpsecurity.h>
498 #define NEED_AUTH_PARAMETERS
500 #define SIGNAL_CAST (void (*)(__harg))
501 #define SELECT_CAST (int *)
504 #define WAIT3_CAST2 (int *)
508 #define DEFAULT_PRINTING PRINT_HPUX
509 #define SIGCLD_IGNORE
517 #include <sys/types.h>
518 #include <sys/statfs.h>
519 #include <sys/stat.h>
521 #include <sys/socket.h>
524 #define SIGNAL_CAST (void (*)(int))
536 #include <sys/statfs.h>
537 #include <sys/statvfs.h>
540 #include <sys/sockio.h>
541 #include <netinet/tcp.h>
546 #define SIGNAL_CAST (void (*)(int))
550 #define seteuid(uid) setreuid(-1,uid)
553 #define setegid(gid) setregid(-1,gid)
559 #include <sys/types.h>
563 #define bzero(b,len) memset(b,0,len)
577 #define bzero(b,len) memset(b,0,len)
585 #define SIGNAL_CAST (void (*)(int))
586 #define WAIT3_CAST1 (union wait *)
595 #include <sys/statfs.h>
599 #define SIGNAL_CAST (void (*)())
600 #define HAVE_FCNTL_LOCK 0
601 #define HAVE_GETTIMEOFDAY
608 #include <sys/netinet/tcp.h>
609 #include <sys/netinet/in_systm.h>
610 #include <sys/netinet/ip.h>
614 #include <sys/statfs.h>
615 #include <sys/stropts.h>
621 #include <rpcsvc/ypclnt.h>
624 #include <sys/security.h>
625 #include <sys/audit.h>
627 #define crypt bigcrypt
630 #define ftruncate(f,l) syscall(0x0a28,f,l)
632 #define SIGNAL_CAST (void (*)(int))
646 #define NO_INITGROUPS
648 #define HAVE_PATHCONF
654 /* Definitions for RiscIX */
656 #define SIGNAL_CAST (void (*)(int))
657 #include <sys/dirent.h>
658 #include <sys/acct.h>
663 #define HAVE_GETTIMEOFDAY
671 #include <net/errno.h>
675 #include <sys/statfs.h>
677 #include <sys/sioctl.h>
680 #include <netinet/tcp.h>
681 #define FIONREAD FIORDCHK
684 #define SIGNAL_CAST (void (*)(int))
704 #define SIGNAL_CAST (void (*)(int))
705 char *strdup (char *);
718 #define SIGNAL_CAST (void (*)(int))
719 char *strdup (char *);
730 #include <sys/statfs.h>
731 #include <sys/stropts.h>
732 #define NO_GET_BROADCAST
738 #define PF_INET AF_INET
740 #define ftruncate(f,l) chsize(f,l)
744 #include <netinet/tcp.h>
745 #include <arpa/inet.h>
750 #define DONT_REINSTALL_SIG
753 #define SIGNAL_CAST (_SigFunc_Ptr_t)
756 extern char *mktemp(char *);
757 extern int fsync(int);
758 extern int seteuid(uid_t);
759 extern int setgroups(int, int *);
760 extern int initgroups(char *, int);
761 extern int statfs(char *, struct statfs *);
762 extern int setegid(gid_t);
763 extern int getopt(int, char *const *, const char *);
764 extern int chroot(char *);
765 extern int gettimeofday(struct timeval *, struct timezone *);
766 extern int gethostname(char *, int);
767 extern char *crypt(char *, char *);
768 extern char *getpass(char *);
773 #define MAXPATHLEN 1024
777 #include <sys/statfs.h>
778 #define SIGNAL_CAST (void (*)(int))
779 #define SIGCLD_IGNORE
780 #define HAVE_FCNTL_LOCK 1
790 #include <sys/fcntl.h>
791 #include <sys/statfs.h>
796 #define ptrdiff_t int
797 #define HAVE_GETGRNAM 0
802 #define NO_INITGROUPS
810 #define REPLACE_MKTIME
811 #define REPLACE_RENAME
812 #define REPLACE_STRSTR
819 #include <sys/statfs.h>
820 #include <sys/select.h>
823 #define SIGNAL_CAST (void (*)())
825 #define NO_INITGROUPS
827 #define HAVE_TIMEZONE
830 #define HAVE_FCNTL_LOCK 1
831 #define DEFAULT_PRINTING PRINT_QNX
839 #include <sys/timeb.h>
845 #include <sys/statfs.h>
848 #define SIGNAL_CAST (void (*)())
849 #define HAVE_FCNTL_LOCK 0
851 #define NO_GET_BROADCAST
854 #define NO_INITGROUPS
859 #define strcasecmp stricmp
860 #define strncasecmp strnicmp
865 #define SIGNAL_CAST (void (*)())
866 #define WAIT3_CAST1 (union wait *)
869 #include <resource.h>
873 #include <sys/statfs.h>
879 /*******************************************************************
880 end of the platform specific sections
881 ********************************************************************/
884 #define NEED_AUTH_PARAMETERS
887 #ifdef REPLACE_GETPASS
888 extern char *getsmbpass(char *);
889 #define getpass(s) getsmbpass(s)
892 #ifdef REPLACE_INNETGR
893 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
897 #define FD_SETSIZE 255
901 #define MAXINT ((((unsigned)1)<<(sizeof(int)*8-1))-1)
908 /* Now for some other grungy stuff */
910 struct spwd { /* fake shadow password structure */
917 #define bzero(p,s) memset(p,0,s)
923 #define memmove(d,s,n) MemMove(d,s,n)
931 /* some unixes have ENOTTY instead of TIOCNOTTY */
934 #define TIOCNOTTY ENOTTY
942 /* if undefined then use bsd or sysv printing */
943 #ifndef DEFAULT_PRINTING
945 #define DEFAULT_PRINTING PRINT_SYSV
947 #define DEFAULT_PRINTING PRINT_BSD
953 #include <afs/stds.h>
954 #include <afs/kautils.h>
958 #include <dce/dce_error.h>
959 #include <dce/sec_login.h>
971 extern char *sys_errlist[];
972 #define strerror(i) sys_errlist[i]
977 #define perror(m) printf("%s: %s\n",m,strerror(errno))
980 #ifndef MAXHOSTNAMELEN
981 #define MAXHOSTNAMELEN 255
986 #include "byteorder.h"
995 #define S_IFREG 0100000
999 #define S_ISREG(x) ((S_IFREG & x)!=0)
1003 #define S_ISDIR(x) ((S_IFDIR & x)!=0)
1007 #define crypt ufc_crypt
1010 #ifdef REPLACE_STRLEN
1011 #define strlen(s) Strlen(s)
1014 #ifdef REPLACE_STRSTR
1015 #define strstr(s,p) Strstr(s,p)
1018 #ifdef REPLACE_MKTIME
1019 #define mktime(t) Mktime(t)
1023 #define NGROUPS_MAX 128
1027 #define EDQUOT ENOSPC
1030 #ifndef HAVE_GETGRNAM
1031 #define HAVE_GETGRNAM 1
1038 /* default to using ftruncate workaround as this is safer than assuming
1039 it works and getting lots of bug reports */
1040 #ifndef FTRUNCATE_CAN_EXTEND
1041 #define FTRUNCATE_CAN_EXTEND 0
1044 /* maybe this unix doesn't separate RD and WR locks? */
1046 #define F_RDLCK F_WRLCK
1050 #define ENOTSOCK EINVAL
1054 #define SIGCLD SIGCHLD
1057 #ifndef HAVE_FCNTL_LOCK
1058 #define HAVE_FCNTL_LOCK 1
1062 #define WAIT3_CAST2 (struct rusage *)
1066 #define WAIT3_CAST1 (int *)
1070 #define QSORT_CAST (int (*)())
1073 /* this is a rough check to see if this machine has a lstat() call.
1074 it is not guaranteed to work */
1075 #if !(defined(S_ISLNK) || defined(S_IFLNK))
1079 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1086 #define geteuid() getuid()
1087 #define getegid() getgid()
1088 #define seteuid(x) setuid(x)
1089 #define setegid(x) setgid(x)
1093 #if (HAVE_FCNTL_LOCK == 0)
1094 /* since there is no locking available, system includes */
1095 /* for DomainOS 10.4 do not contain any of the following */
1096 /* #define's. So, to satisfy the compiler, add these */
1097 /* #define's, although they arn't really necessary. */
1102 #endif /* HAVE_FCNTL_LOCK == 0 */
1105 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1106 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1110 #define strcpy(dest,src) StrCpy(dest,src)
1114 /* possibly wrap the malloc calls */
1117 /* undo the old malloc def if necessary */
1119 #define xx_old_malloc malloc
1123 #define malloc(size) malloc_wrapped(size,__FILE__,__LINE__)
1125 /* undo the old realloc def if necessary */
1127 #define xx_old_realloc realloc
1131 #define realloc(ptr,size) realloc_wrapped(ptr,size,__FILE__,__LINE__)
1133 /* undo the old free def if necessary */
1135 #define xx_old_free free
1139 #define free(ptr) free_wrapped(ptr,__FILE__,__LINE__)
1141 /* and the malloc prototypes */
1142 void *malloc_wrapped(int,char *,int);
1143 void *realloc_wrapped(void *,int,char *,int);
1144 void free_wrapped(void *,char *,int);
1150 /* undo the old memcpy def if necessary */
1152 #define xx_old_memcpy memcpy
1156 #define memcpy(d,s,l) memcpy_wrapped(d,s,l,__FILE__,__LINE__)
1157 void *memcpy_wrapped(void *d,void *s,int l,char *fname,int line);