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
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 (*)())
480 #include <sys/select.h>
482 #include <sys/statfs.h>
485 #include <sys/priv.h>
486 #include <netinet/tcp.h>
490 #define SIGNAL_CAST (void (*)())
491 #define DEFAULT_PRINTING PRINT_AIX
492 /* we undef this because sys/param.h is broken in aix. uggh. */
493 #undef MAXHOSTNAMELEN
502 #include <sys/types.h>
503 #include <sys/termios.h>
504 #include <netinet/tcp.h>
505 #ifdef HPUX_10_TRUSTED
506 #include <hpsecurity.h>
508 #define NEED_AUTH_PARAMETERS
510 #define SIGNAL_CAST (void (*)(__harg))
511 #define SELECT_CAST (int *)
514 #define WAIT3_CAST2 (int *)
518 #define DEFAULT_PRINTING PRINT_HPUX
519 #define SIGCLD_IGNORE
527 #include <sys/types.h>
528 #include <sys/statfs.h>
529 #include <sys/stat.h>
531 #include <sys/socket.h>
534 #define SIGNAL_CAST (void (*)(int))
551 #include <sys/statfs.h>
552 #include <sys/statvfs.h>
555 #include <sys/sockio.h>
556 #include <netinet/tcp.h>
561 #define SIGNAL_CAST (void (*)(int))
565 #define seteuid(uid) setreuid(-1,uid)
568 #define setegid(gid) setregid(-1,gid)
574 #include <sys/types.h>
578 #define bzero(b,len) memset(b,0,len)
592 #define bzero(b,len) memset(b,0,len)
601 #define SIGNAL_CAST (void (*)(int))
602 #define WAIT3_CAST1 (union wait *)
611 #include <sys/statfs.h>
615 #define SIGNAL_CAST (void (*)())
616 #define HAVE_FCNTL_LOCK 0
617 #define HAVE_GETTIMEOFDAY
624 #include <sys/netinet/tcp.h>
625 #include <sys/netinet/in_systm.h>
626 #include <sys/netinet/ip.h>
630 #include <sys/statfs.h>
631 #include <sys/stropts.h>
637 #include <rpcsvc/ypclnt.h>
640 #include <sys/security.h>
641 #include <sys/audit.h>
643 #define crypt bigcrypt
646 #define ftruncate(f,l) syscall(0x0a28,f,l)
648 #define SIGNAL_CAST (void (*)(int))
662 #define NO_INITGROUPS
664 #define HAVE_PATHCONF
670 /* Definitions for RiscIX */
672 #define SIGNAL_CAST (void (*)(int))
673 #include <sys/dirent.h>
674 #include <sys/acct.h>
679 #define HAVE_GETTIMEOFDAY
687 #include <net/errno.h>
691 #include <sys/statfs.h>
693 #include <sys/sioctl.h>
696 #include <netinet/tcp.h>
697 #define FIONREAD FIORDCHK
700 #define SIGNAL_CAST (void (*)(int))
720 #define SIGNAL_CAST (void (*)(int))
721 char *strdup (char *);
734 #define SIGNAL_CAST (void (*)(int))
735 char *strdup (char *);
746 #include <sys/statfs.h>
747 #include <sys/stropts.h>
748 #define NO_GET_BROADCAST
754 #define PF_INET AF_INET
756 #define ftruncate(f,l) chsize(f,l)
760 #include <netinet/tcp.h>
761 #include <arpa/inet.h>
766 #define DONT_REINSTALL_SIG
769 #define SIGNAL_CAST (_SigFunc_Ptr_t)
772 extern char *mktemp(char *);
773 extern int fsync(int);
774 extern int seteuid(uid_t
);
775 extern int setgroups(int, int *);
776 extern int initgroups(char *, int);
777 extern int statfs(char *, struct statfs
*);
778 extern int setegid(gid_t
);
779 extern int getopt(int, char *const *, const char *);
780 extern int chroot(char *);
781 extern int gettimeofday(struct timeval
*, struct timezone
*);
782 extern int gethostname(char *, int);
783 extern char *crypt(char *, char *);
784 extern char *getpass(char *);
789 #define MAXPATHLEN 1024
793 #include <sys/statfs.h>
794 #define SIGNAL_CAST (void (*)(int))
795 #define SIGCLD_IGNORE
796 #define HAVE_FCNTL_LOCK 1
806 #include <sys/fcntl.h>
807 #include <sys/statfs.h>
812 #define ptrdiff_t int
813 #define HAVE_GETGRNAM 0
818 #define NO_INITGROUPS
826 #define REPLACE_MKTIME
827 #define REPLACE_RENAME
828 #define REPLACE_STRSTR
835 #include <sys/statfs.h>
836 #include <sys/select.h>
839 #define SIGNAL_CAST (void (*)())
841 #define NO_INITGROUPS
843 #define HAVE_TIMEZONE
846 #define HAVE_FCNTL_LOCK 1
847 #define DEFAULT_PRINTING PRINT_QNX
855 #include <sys/timeb.h>
861 #include <sys/statfs.h>
864 #define SIGNAL_CAST (void (*)())
865 #define HAVE_FCNTL_LOCK 0
867 #define NO_GET_BROADCAST
870 #define NO_INITGROUPS
875 #define strcasecmp stricmp
876 #define strncasecmp strnicmp
881 #define SIGNAL_CAST (void (*)())
882 #define WAIT3_CAST1 (union wait *)
885 #include <resource.h>
889 #include <sys/statfs.h>
896 #define SIGNAL_CAST (void (*)(int))
899 #include <sys/select.h>
903 #include <sys/statfs.h>
904 #include <sys/bsdioctl.h>
909 /*******************************************************************
910 end of the platform specific sections
911 ********************************************************************/
913 #if defined(USE_MMAP) || FAST_SHARE_MODES
914 #include <sys/mman.h>
918 #define NEED_AUTH_PARAMETERS
921 #ifdef REPLACE_GETPASS
922 extern char *getsmbpass(char *);
923 #define getpass(s) getsmbpass(s)
926 #ifdef REPLACE_INNETGR
927 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
931 #define FD_SETSIZE 255
938 /* Now for some other grungy stuff */
940 struct spwd
{ /* fake shadow password structure */
947 #define bzero(p,s) memset(p,0,s)
953 #define memmove(d,s,n) MemMove(d,s,n)
961 /* some unixes have ENOTTY instead of TIOCNOTTY */
964 #define TIOCNOTTY ENOTTY
972 /* if undefined then use bsd or sysv printing */
973 #ifndef DEFAULT_PRINTING
975 #define DEFAULT_PRINTING PRINT_SYSV
977 #define DEFAULT_PRINTING PRINT_BSD
983 #include <afs/stds.h>
984 #include <afs/kautils.h>
988 #include <dce/dce_error.h>
989 #include <dce/sec_login.h>
1001 extern char *sys_errlist
[];
1002 #define strerror(i) sys_errlist[i]
1007 #define perror(m) printf("%s: %s\n",m,strerror(errno))
1010 #ifndef MAXHOSTNAMELEN
1011 #define MAXHOSTNAMELEN 255
1014 #include "version.h"
1016 #include "nameserv.h"
1018 #include "byteorder.h"
1021 #include "charset.h"
1024 #define S_IFREG 0100000
1028 #define S_ISREG(x) ((S_IFREG & x)!=0)
1032 #define S_ISDIR(x) ((S_IFDIR & x)!=0)
1036 #define crypt ufc_crypt
1039 #ifdef REPLACE_STRLEN
1040 #define strlen(s) Strlen(s)
1043 #ifdef REPLACE_STRSTR
1044 #define strstr(s,p) Strstr(s,p)
1047 #ifdef REPLACE_MKTIME
1048 #define mktime(t) Mktime(t)
1052 #define NGROUPS_MAX 128
1056 #define EDQUOT ENOSPC
1059 #ifndef HAVE_GETGRNAM
1060 #define HAVE_GETGRNAM 1
1067 /* default to using ftruncate workaround as this is safer than assuming
1068 it works and getting lots of bug reports */
1069 #ifndef FTRUNCATE_CAN_EXTEND
1070 #define FTRUNCATE_CAN_EXTEND 0
1073 /* maybe this unix doesn't separate RD and WR locks? */
1075 #define F_RDLCK F_WRLCK
1079 #define ENOTSOCK EINVAL
1083 #define SIGCLD SIGCHLD
1090 #ifndef HAVE_FCNTL_LOCK
1091 #define HAVE_FCNTL_LOCK 1
1095 #define WAIT3_CAST2 (struct rusage *)
1099 #define WAIT3_CAST1 (int *)
1103 #define QSORT_CAST (int (*)())
1106 /* this is a rough check to see if this machine has a lstat() call.
1107 it is not guaranteed to work */
1108 #if !(defined(S_ISLNK) || defined(S_IFLNK))
1112 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1119 #define geteuid() getuid()
1120 #define getegid() getgid()
1121 #define seteuid(x) setuid(x)
1122 #define setegid(x) setgid(x)
1126 #if (HAVE_FCNTL_LOCK == 0)
1127 /* since there is no locking available, system includes */
1128 /* for DomainOS 10.4 do not contain any of the following */
1129 /* #define's. So, to satisfy the compiler, add these */
1130 /* #define's, although they arn't really necessary. */
1135 #endif /* HAVE_FCNTL_LOCK == 0 */
1138 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1139 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1143 #define strcpy(dest,src) StrCpy(dest,src)
1147 /* possibly wrap the malloc calls */
1150 /* undo the old malloc def if necessary */
1152 #define xx_old_malloc malloc
1156 #define malloc(size) malloc_wrapped(size,__FILE__,__LINE__)
1158 /* undo the old realloc def if necessary */
1160 #define xx_old_realloc realloc
1164 #define realloc(ptr,size) realloc_wrapped(ptr,size,__FILE__,__LINE__)
1166 /* undo the old free def if necessary */
1168 #define xx_old_free free
1172 #define free(ptr) free_wrapped(ptr,__FILE__,__LINE__)
1174 /* and the malloc prototypes */
1175 void *malloc_wrapped(int,char *,int);
1176 void *realloc_wrapped(void *,int,char *,int);
1177 void free_wrapped(void *,char *,int);
1183 /* undo the old memcpy def if necessary */
1185 #define xx_old_memcpy memcpy
1189 #define memcpy(d,s,l) memcpy_wrapped(d,s,l,__FILE__,__LINE__)
1190 void *memcpy_wrapped(void *d
,void *s
,int l
,char *fname
,int line
);