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)
201 /* this might be different on different systems */
206 #include <sys/quota.h>
209 #include <sys/quota.h>
213 #include <sys/quota.h>
228 /***************************************************************************
229 Here come some platform specific sections
230 ***************************************************************************/
234 #include <arpa/inet.h>
238 #include <netinet/in.h>
239 #ifndef NO_ASMSIGNALH
240 #include <asm/signal.h>
242 #define SIGNAL_CAST (__sighandler_t)
249 #define crypt pw_encrypt
255 #define SIGNAL_CAST (void (*)(int))
256 #include <netinet/tcp.h>
258 #include <sys/acct.h>
262 #include <sys/wait.h>
264 /* #include <termios.h> */
268 #define mktime timelocal
269 typedef unsigned short mode_t;
274 #define REPLACE_GETPASS
282 #include <sys/acct.h>
283 #include <sys/statfs.h>
284 #include <sys/statvfs.h>
285 #include <sys/filio.h>
286 #include <sys/sockio.h>
287 #include <netinet/in_systm.h>
288 #include <netinet/tcp.h>
289 #include <netinet/ip.h>
291 #include <arpa/inet.h>
292 #include <rpcsvc/ypclnt.h>
295 extern int gettimeofday (struct timeval *, void *);
296 extern int gethostname (char *name, int namelen);
297 extern int innetgr (const char *, const char *, const char *, const char *);
299 #define SIGNAL_CAST (void (*)(int))
304 #define REPLACE_STRLEN
308 #define REPLACE_GETPASS
314 #include <nfs/nfs_clnt.h>
316 #include <netinet/tcp.h>
323 #define SIGNAL_CAST (void(*)(int))
329 #include <netinet/tcp.h>
330 #include <sys/statfs.h>
336 #define SIGNAL_CAST (void (*)())
343 #include <netinet/tcp.h>
344 #include <sys/statvfs.h>
353 #define SIGNAL_CAST (void (*)())
360 #include <bsd/net/soioctl.h>
364 #include <sys/statfs.h>
365 #include <sys/wait.h>
366 #include <sys/termio.h>
367 #define SIGNAL_CAST (void (*)())
369 extern struct group *getgrnam();
370 extern struct passwd *getpwnam();
373 #define REPLACE_STRSTR
381 #include <sys/statfs.h>
382 #include <sys/statvfs.h>
387 #define SIGNAL_CAST (void (*)(int))
397 #include <sys/statfs.h>
398 #include <sys/statvfs.h>
400 #include <sys/filio.h>
402 #include <sys/sockio.h>
403 #include <netinet/tcp.h>
408 #define SIGNAL_CAST (void (*)(int))
420 char *mktemp(char *); /* No standard include */
421 #include <netinet/in.h>
422 #include <arpa/inet.h> /* both for inet_ntoa */
423 #define SIGNAL_CAST ( void (*) (int) )
426 #include <netinet/tcp.h>
429 #include <sys/types.h>
430 #include <sys/security.h>
433 #define PASSWORD_LENGTH 16
434 #define NEED_AUTH_PARAMETERS
435 #endif /* OSF1_ENH_SEC */
441 #define SIGNAL_CAST (void (*)())
442 #include <sys/fcntl.h>
443 #include <sys/statfs.h>
451 #define REPLACE_GETPASS
459 #include <netinet/tcp.h>
460 #define SIGNAL_CAST (void (*)())
467 #include <netinet/tcp.h>
468 /* you may not need this */
470 #define SIGNAL_CAST (void (*)())
472 #define REPLACE_INNETGR
479 #include <netinet/tcp.h>
480 #include <netinet/in_systm.h>
481 #include <netinet/ip.h>
482 #define SIGNAL_CAST (void (*)())
484 #define REPLACE_INNETGR
492 #include <sys/select.h>
494 #include <sys/statfs.h>
497 #include <sys/priv.h>
498 #include <netinet/tcp.h>
501 #define SIGNAL_CAST (void (*)())
502 #define DEFAULT_PRINTING PRINT_AIX
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))
552 #include <sys/types.h>
556 #define bzero(b,len) memset(b,0,len)
570 #define bzero(b,len) memset(b,0,len)
578 #define SIGNAL_CAST (void (*)(int))
579 #define WAIT3_CAST1 (union wait *)
588 #include <sys/statfs.h>
592 #define SIGNAL_CAST (void (*)())
593 #define HAVE_FCNTL_LOCK 0
594 #define HAVE_GETTIMEOFDAY
601 #include <sys/netinet/tcp.h>
602 #include <sys/netinet/in_systm.h>
603 #include <sys/netinet/ip.h>
607 #include <sys/statfs.h>
608 #include <sys/stropts.h>
614 #include <rpcsvc/ypclnt.h>
617 #include <sys/security.h>
618 #include <sys/audit.h>
620 #define crypt bigcrypt
623 #define ftruncate(f,l) syscall(0x0a28,f,l)
625 #define SIGNAL_CAST (void (*)(int))
639 #define NO_INITGROUPS
641 #define HAVE_PATHCONF
647 /* Definitions for RiscIX */
649 #define SIGNAL_CAST (void (*)(int))
650 #include <sys/dirent.h>
651 #include <sys/acct.h>
656 #define HAVE_GETTIMEOFDAY
664 #include <net/errno.h>
668 #include <sys/statfs.h>
670 #include <sys/sioctl.h>
673 #include <netinet/tcp.h>
674 #define FIONREAD FIORDCHK
677 #define SIGNAL_CAST (void (*)(int))
697 #define SIGNAL_CAST (void (*)(int))
698 char *strdup (char *);
711 #define SIGNAL_CAST (void (*)(int))
712 char *strdup (char *);
723 #include <sys/statfs.h>
724 #include <sys/stropts.h>
725 #define NO_GET_BROADCAST
731 #define PF_INET AF_INET
733 #define ftruncate(f,l) chsize(f,l)
737 #define SIGNAL_CAST (void (*)(int))
738 #include <netinet/tcp.h>
739 #include <arpa/inet.h>
744 #define DONT_REINSTALL_SIG
747 #define SIGNAL_CAST (_SigFunc_Ptr_t)
750 extern char *mktemp(char *);
751 extern int fsync(int);
752 extern int seteuid(uid_t);
753 extern int setgroups(int, int *);
754 extern int initgroups(char *, int);
755 extern int statfs(char *, struct statfs *);
756 extern int setegid(gid_t);
757 extern int getopt(int, char *const *, const char *);
758 extern int chroot(char *);
759 extern int gettimeofday(struct timeval *, struct timezone *);
760 extern int gethostname(char *, int);
761 extern char *crypt(char *, char *);
762 extern char *getpass(char *);
767 #define MAXPATHLEN 1024
771 #include <sys/statfs.h>
772 #define SIGNAL_CAST (void (*)(int))
773 #define SIGCLD_IGNORE
774 #define HAVE_FCNTL_LOCK 1
784 #include <sys/fcntl.h>
785 #include <sys/statfs.h>
790 #define ptrdiff_t int
791 #define HAVE_GETGRNAM 0
796 #define NO_INITGROUPS
804 #define REPLACE_MKTIME
805 #define REPLACE_RENAME
806 #define REPLACE_STRSTR
813 #include <sys/statfs.h>
814 #include <sys/select.h>
817 #define SIGNAL_CAST (void (*)())
819 #define NO_INITGROUPS
821 #define HAVE_TIMEZONE
824 #define HAVE_FCNTL_LOCK 1
825 #define DEFAULT_PRINTING PRINT_QNX
833 #include <sys/timeb.h>
839 #include <sys/statfs.h>
842 #define SIGNAL_CAST (void (*)())
843 #define HAVE_FCNTL_LOCK 0
845 #define NO_GET_BROADCAST
848 #define NO_INITGROUPS
853 #define strcasecmp stricmp
854 #define strncasecmp strnicmp
859 #define SIGNAL_CAST (void (*)())
860 #define WAIT3_CAST1 (union wait *)
863 #include <resource.h>
867 #include <sys/statfs.h>
873 /*******************************************************************
874 end of the platform specific sections
875 ********************************************************************/
878 #define NEED_AUTH_PARAMETERS
881 #ifdef REPLACE_GETPASS
882 extern char *getsmbpass(char *);
883 #define getpass(s) getsmbpass(s)
886 #ifdef REPLACE_INNETGR
887 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
891 #define FD_SETSIZE 255
895 #define MAXINT ((((unsigned)1)<<(sizeof(int)*8-1))-1)
902 /* Now for some other grungy stuff */
904 struct spwd { /* fake shadow password structure */
911 #define bzero(p,s) memset(p,0,s)
917 #define memmove(d,s,n) MemMove(d,s,n)
925 /* some unixes have ENOTTY instead of TIOCNOTTY */
928 #define TIOCNOTTY ENOTTY
936 /* if undefined then use bsd or sysv printing */
937 #ifndef DEFAULT_PRINTING
939 #define DEFAULT_PRINTING PRINT_SYSV
941 #define DEFAULT_PRINTING PRINT_BSD
947 #include <afs/stds.h>
948 #include <afs/kautils.h>
952 #include <dce/dce_error.h>
953 #include <dce/sec_login.h>
965 extern char *sys_errlist[];
966 #define strerror(i) sys_errlist[i]
971 #define perror(m) printf("%s: %s\n",m,strerror(errno))
974 #ifndef MAXHOSTNAMELEN
975 #define MAXHOSTNAMELEN 255
980 #include "byteorder.h"
989 #define S_IFREG 0100000
993 #define S_ISREG(x) ((S_IFREG & x)!=0)
997 #define S_ISDIR(x) ((S_IFDIR & x)!=0)
1001 #define crypt ufc_crypt
1004 #ifdef REPLACE_STRLEN
1005 #define strlen(s) Strlen(s)
1008 #ifdef REPLACE_STRSTR
1009 #define strstr(s,p) Strstr(s,p)
1012 #ifdef REPLACE_MKTIME
1013 #define mktime(t) Mktime(t)
1017 #define NGROUPS_MAX 128
1021 #define EDQUOT ENOSPC
1024 #ifndef HAVE_GETGRNAM
1025 #define HAVE_GETGRNAM 1
1032 /* default to using ftruncate workaround as this is safer than assuming
1033 it works and getting lots of bug reports */
1034 #ifndef FTRUNCATE_CAN_EXTEND
1035 #define FTRUNCATE_CAN_EXTEND 0
1038 /* maybe this unix doesn't separate RD and WR locks? */
1040 #define F_RDLCK F_WRLCK
1044 #define ENOTSOCK EINVAL
1048 #define SIGCLD SIGCHLD
1051 #ifndef HAVE_FCNTL_LOCK
1052 #define HAVE_FCNTL_LOCK 1
1056 #define WAIT3_CAST2 (struct rusage *)
1060 #define WAIT3_CAST1 (int *)
1064 #define QSORT_CAST (int (*)())
1067 /* this is a rough check to see if this machine has a lstat() call.
1068 it is not guaranteed to work */
1069 #if !(defined(S_ISLNK) || defined(S_IFLNK))
1073 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1080 #define geteuid() getuid()
1081 #define getegid() getgid()
1082 #define seteuid(x) setuid(x)
1083 #define setegid(x) setgid(x)
1087 #if (HAVE_FCNTL_LOCK == 0)
1088 /* since there is no locking available, system includes */
1089 /* for DomainOS 10.4 do not contain any of the following */
1090 /* #define's. So, to satisfy the compiler, add these */
1091 /* #define's, although they arn't really necessary. */
1096 #endif /* HAVE_FCNTL_LOCK == 0 */
1099 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1100 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1104 #define strcpy(dest,src) StrCpy(dest,src)
1108 /* possibly wrap the malloc calls */
1111 /* undo the old malloc def if necessary */
1113 #define xx_old_malloc malloc
1117 #define malloc(size) malloc_wrapped(size,__FILE__,__LINE__)
1119 /* undo the old realloc def if necessary */
1121 #define xx_old_realloc realloc
1125 #define realloc(ptr,size) realloc_wrapped(ptr,size,__FILE__,__LINE__)
1127 /* undo the old free def if necessary */
1129 #define xx_old_free free
1133 #define free(ptr) free_wrapped(ptr,__FILE__,__LINE__)
1135 /* and the malloc prototypes */
1136 void *malloc_wrapped(int,char *,int);
1137 void *realloc_wrapped(void *,int,char *,int);
1138 void free_wrapped(void *,char *,int);
1144 /* undo the old memcpy def if necessary */
1146 #define xx_old_memcpy memcpy
1150 #define memcpy(d,s,l) memcpy_wrapped(d,s,l,__FILE__,__LINE__)
1151 void *memcpy_wrapped(void *d,void *s,int l,char *fname,int line);