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(USE_MMAP) || defined(FAST_SHARE_MODES)
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)
226 #define USE_SIGPROCMASK
228 /* SETFS disabled until we can check on some bug reports */
229 #if _LINUX_C_LIB_VERSION_MAJOR >= 5
235 #define crypt pw_encrypt
241 #define SIGNAL_CAST (void (*)(int))
242 #include <netinet/tcp.h>
244 #include <sys/acct.h>
248 #include <sys/wait.h>
250 /* #include <termios.h> */
254 #define mktime timelocal
255 typedef unsigned short mode_t;
260 #define REPLACE_GETPASS
262 #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))
317 #include <netinet/tcp.h>
318 #include <sys/statfs.h>
324 #define SIGNAL_CAST (void (*)())
331 #include <netinet/tcp.h>
332 #include <sys/statvfs.h>
341 #define SIGNAL_CAST (void (*)())
348 #include <bsd/net/soioctl.h>
352 #include <sys/statfs.h>
353 #include <sys/wait.h>
354 #include <sys/termio.h>
355 #define SIGNAL_CAST (void (*)())
357 extern struct group *getgrnam();
358 extern struct passwd *getpwnam();
361 #define REPLACE_STRSTR
369 #include <sys/statfs.h>
370 #include <sys/statvfs.h>
375 #define SIGNAL_CAST (void (*)(int))
385 #include <sys/statfs.h>
386 #include <sys/statvfs.h>
388 #include <sys/filio.h>
390 #include <sys/sockio.h>
391 #include <netinet/tcp.h>
396 #define SIGNAL_CAST (void (*)(int))
408 char *mktemp(char *); /* No standard include */
409 #include <netinet/in.h>
410 #include <arpa/inet.h> /* both for inet_ntoa */
411 #define SIGNAL_CAST ( void (*) (int) )
414 #include <netinet/tcp.h>
417 #include <sys/types.h>
418 #include <sys/security.h>
421 #define PASSWORD_LENGTH 16
422 #define NEED_AUTH_PARAMETERS
423 #endif /* OSF1_ENH_SEC */
429 #define SIGNAL_CAST (void (*)())
430 #include <sys/fcntl.h>
431 #include <sys/statfs.h>
439 #define REPLACE_GETPASS
447 #include <netinet/tcp.h>
448 #define SIGNAL_CAST (void (*)())
455 #include <netinet/tcp.h>
456 /* you may not need this */
458 #define SIGNAL_CAST (void (*)())
460 #define REPLACE_INNETGR
467 #include <netinet/tcp.h>
468 #include <netinet/in_systm.h>
469 #include <netinet/ip.h>
470 #define SIGNAL_CAST (void (*)())
479 #include <sys/select.h>
481 #include <sys/statfs.h>
484 #include <sys/priv.h>
485 #include <netinet/tcp.h>
489 #define SIGNAL_CAST (void (*)())
490 #define DEFAULT_PRINTING PRINT_AIX
491 /* we undef this because sys/param.h is broken in aix. uggh. */
492 #undef MAXHOSTNAMELEN
501 #include <sys/types.h>
502 #include <sys/termios.h>
503 #include <netinet/tcp.h>
504 #ifdef HPUX_10_TRUSTED
505 #include <hpsecurity.h>
507 #define NEED_AUTH_PARAMETERS
509 #define SIGNAL_CAST (void (*)(__harg))
510 #define SELECT_CAST (int *)
513 #define WAIT3_CAST2 (int *)
517 #define DEFAULT_PRINTING PRINT_HPUX
518 #define SIGCLD_IGNORE
526 #include <sys/types.h>
527 #include <sys/statfs.h>
528 #include <sys/stat.h>
530 #include <sys/socket.h>
533 #define SIGNAL_CAST (void (*)(int))
550 #include <sys/statfs.h>
551 #include <sys/statvfs.h>
554 #include <sys/sockio.h>
555 #include <netinet/tcp.h>
560 #define SIGNAL_CAST (void (*)(int))
564 #define seteuid(uid) setreuid(-1,uid)
567 #define setegid(gid) setregid(-1,gid)
573 #include <sys/types.h>
577 #define bzero(b,len) memset(b,0,len)
591 #define bzero(b,len) memset(b,0,len)
600 #define SIGNAL_CAST (void (*)(int))
601 #define WAIT3_CAST1 (union wait *)
610 #include <sys/statfs.h>
614 #define SIGNAL_CAST (void (*)())
615 #define HAVE_FCNTL_LOCK 0
616 #define HAVE_GETTIMEOFDAY
623 #include <sys/netinet/tcp.h>
624 #include <sys/netinet/in_systm.h>
625 #include <sys/netinet/ip.h>
629 #include <sys/statfs.h>
630 #include <sys/stropts.h>
636 #include <rpcsvc/ypclnt.h>
639 #include <sys/security.h>
640 #include <sys/audit.h>
642 #define crypt bigcrypt
645 #define ftruncate(f,l) syscall(0x0a28,f,l)
647 #define SIGNAL_CAST (void (*)(int))
661 #define NO_INITGROUPS
663 #define HAVE_PATHCONF
669 /* Definitions for RiscIX */
671 #define SIGNAL_CAST (void (*)(int))
672 #include <sys/dirent.h>
673 #include <sys/acct.h>
678 #define HAVE_GETTIMEOFDAY
686 #include <net/errno.h>
690 #include <sys/statfs.h>
692 #include <sys/sioctl.h>
695 #include <netinet/tcp.h>
696 #define FIONREAD FIORDCHK
699 #define SIGNAL_CAST (void (*)(int))
719 #define SIGNAL_CAST (void (*)(int))
720 char *strdup (char *);
733 #define SIGNAL_CAST (void (*)(int))
734 char *strdup (char *);
745 #include <sys/statfs.h>
746 #include <sys/stropts.h>
747 #define NO_GET_BROADCAST
753 #define PF_INET AF_INET
755 #define ftruncate(f,l) chsize(f,l)
759 #include <netinet/tcp.h>
760 #include <arpa/inet.h>
765 #define DONT_REINSTALL_SIG
768 #define SIGNAL_CAST (_SigFunc_Ptr_t)
771 extern char *mktemp(char *);
772 extern int fsync(int);
773 extern int seteuid(uid_t);
774 extern int setgroups(int, int *);
775 extern int initgroups(char *, int);
776 extern int statfs(char *, struct statfs *);
777 extern int setegid(gid_t);
778 extern int getopt(int, char *const *, const char *);
779 extern int chroot(char *);
780 extern int gettimeofday(struct timeval *, struct timezone *);
781 extern int gethostname(char *, int);
782 extern char *crypt(char *, char *);
783 extern char *getpass(char *);
788 #define MAXPATHLEN 1024
792 #include <sys/statfs.h>
793 #define SIGNAL_CAST (void (*)(int))
794 #define SIGCLD_IGNORE
795 #define HAVE_FCNTL_LOCK 1
805 #include <sys/fcntl.h>
806 #include <sys/statfs.h>
811 #define ptrdiff_t int
812 #define HAVE_GETGRNAM 0
817 #define NO_INITGROUPS
825 #define REPLACE_MKTIME
826 #define REPLACE_RENAME
827 #define REPLACE_STRSTR
834 #include <sys/statfs.h>
835 #include <sys/select.h>
838 #define SIGNAL_CAST (void (*)())
840 #define NO_INITGROUPS
842 #define HAVE_TIMEZONE
845 #define HAVE_FCNTL_LOCK 1
846 #define DEFAULT_PRINTING PRINT_QNX
854 #include <sys/timeb.h>
860 #include <sys/statfs.h>
863 #define SIGNAL_CAST (void (*)())
864 #define HAVE_FCNTL_LOCK 0
866 #define NO_GET_BROADCAST
869 #define NO_INITGROUPS
874 #define strcasecmp stricmp
875 #define strncasecmp strnicmp
880 #define SIGNAL_CAST (void (*)())
881 #define WAIT3_CAST1 (union wait *)
884 #include <resource.h>
888 #include <sys/statfs.h>
894 /*******************************************************************
895 end of the platform specific sections
896 ********************************************************************/
899 #define NEED_AUTH_PARAMETERS
902 #ifdef REPLACE_GETPASS
903 extern char *getsmbpass(char *);
904 #define getpass(s) getsmbpass(s)
907 #ifdef REPLACE_INNETGR
908 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
912 #define FD_SETSIZE 255
919 /* Now for some other grungy stuff */
921 struct spwd { /* fake shadow password structure */
928 #define bzero(p,s) memset(p,0,s)
934 #define memmove(d,s,n) MemMove(d,s,n)
942 /* some unixes have ENOTTY instead of TIOCNOTTY */
945 #define TIOCNOTTY ENOTTY
953 /* if undefined then use bsd or sysv printing */
954 #ifndef DEFAULT_PRINTING
956 #define DEFAULT_PRINTING PRINT_SYSV
958 #define DEFAULT_PRINTING PRINT_BSD
964 #include <afs/stds.h>
965 #include <afs/kautils.h>
969 #include <dce/dce_error.h>
970 #include <dce/sec_login.h>
982 extern char *sys_errlist[];
983 #define strerror(i) sys_errlist[i]
988 #define perror(m) printf("%s: %s\n",m,strerror(errno))
991 #ifndef MAXHOSTNAMELEN
992 #define MAXHOSTNAMELEN 255
997 #include "nameserv.h"
999 #include "byteorder.h"
1002 #include "charset.h"
1005 #define S_IFREG 0100000
1009 #define S_ISREG(x) ((S_IFREG & x)!=0)
1013 #define S_ISDIR(x) ((S_IFDIR & x)!=0)
1017 #define crypt ufc_crypt
1020 #ifdef REPLACE_STRLEN
1021 #define strlen(s) Strlen(s)
1024 #ifdef REPLACE_STRSTR
1025 #define strstr(s,p) Strstr(s,p)
1028 #ifdef REPLACE_MKTIME
1029 #define mktime(t) Mktime(t)
1033 #define NGROUPS_MAX 128
1037 #define EDQUOT ENOSPC
1040 #ifndef HAVE_GETGRNAM
1041 #define HAVE_GETGRNAM 1
1048 /* default to using ftruncate workaround as this is safer than assuming
1049 it works and getting lots of bug reports */
1050 #ifndef FTRUNCATE_CAN_EXTEND
1051 #define FTRUNCATE_CAN_EXTEND 0
1054 /* maybe this unix doesn't separate RD and WR locks? */
1056 #define F_RDLCK F_WRLCK
1060 #define ENOTSOCK EINVAL
1064 #define SIGCLD SIGCHLD
1067 #ifndef HAVE_FCNTL_LOCK
1068 #define HAVE_FCNTL_LOCK 1
1072 #define WAIT3_CAST2 (struct rusage *)
1076 #define WAIT3_CAST1 (int *)
1080 #define QSORT_CAST (int (*)())
1083 /* this is a rough check to see if this machine has a lstat() call.
1084 it is not guaranteed to work */
1085 #if !(defined(S_ISLNK) || defined(S_IFLNK))
1089 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1096 #define geteuid() getuid()
1097 #define getegid() getgid()
1098 #define seteuid(x) setuid(x)
1099 #define setegid(x) setgid(x)
1103 #if (HAVE_FCNTL_LOCK == 0)
1104 /* since there is no locking available, system includes */
1105 /* for DomainOS 10.4 do not contain any of the following */
1106 /* #define's. So, to satisfy the compiler, add these */
1107 /* #define's, although they arn't really necessary. */
1112 #endif /* HAVE_FCNTL_LOCK == 0 */
1115 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1116 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1120 #define strcpy(dest,src) StrCpy(dest,src)
1124 /* possibly wrap the malloc calls */
1127 /* undo the old malloc def if necessary */
1129 #define xx_old_malloc malloc
1133 #define malloc(size) malloc_wrapped(size,__FILE__,__LINE__)
1135 /* undo the old realloc def if necessary */
1137 #define xx_old_realloc realloc
1141 #define realloc(ptr,size) realloc_wrapped(ptr,size,__FILE__,__LINE__)
1143 /* undo the old free def if necessary */
1145 #define xx_old_free free
1149 #define free(ptr) free_wrapped(ptr,__FILE__,__LINE__)
1151 /* and the malloc prototypes */
1152 void *malloc_wrapped(int,char *,int);
1153 void *realloc_wrapped(void *,int,char *,int);
1154 void free_wrapped(void *,char *,int);
1160 /* undo the old memcpy def if necessary */
1162 #define xx_old_memcpy memcpy
1166 #define memcpy(d,s,l) memcpy_wrapped(d,s,l,__FILE__,__LINE__)
1167 void *memcpy_wrapped(void *d,void *s,int l,char *fname,int line);