4 Unix SMB/Netbios implementation.
6 Machine customisation and include handling
7 Copyright (C) Andrew Tridgell 1994-1997
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>
145 #include <sys/ioctl.h>
148 #include <posix/utime.h>
149 #include <bsd/sys/time.h>
150 #include <bsd/netinet/in.h>
152 #include <sys/time.h>
153 #include <netinet/in.h>
158 #include <sys/file.h>
159 #include <sys/stat.h>
160 #include <sys/param.h>
163 #include <sys/resource.h>
166 #include <sys/mount.h>
177 #include <sys/wait.h>
179 #include <sys/stream.h>
183 #include <bsd/net/if.h>
189 #if defined(GETPWANAM)
190 #include <sys/types.h>
191 #include <sys/label.h>
192 #include <sys/audit.h>
196 #if defined(SHADOW_PWD) && !defined(NETBSD) && !defined(FreeBSD) && !defined(CONVEX)
206 /***************************************************************************
207 Here come some platform specific sections
208 ***************************************************************************/
212 #include <arpa/inet.h>
216 #include <netinet/in.h>
217 #ifndef NO_ASMSIGNALH
218 #include <asm/signal.h>
220 #define SIGNAL_CAST (__sighandler_t)
225 #define USE_SIGPROCMASK
228 /* SETFS disabled until we can check on some bug reports */
229 #if _LINUX_C_LIB_VERSION_MAJOR >= 5
234 #if _LINUX_C_LIB_VERSION_MAJOR < 5
236 #define crypt pw_encrypt
243 #define SIGNAL_CAST (void (*)(int))
244 #include <netinet/tcp.h>
246 #include <sys/acct.h>
250 #include <sys/wait.h>
252 /* #include <termios.h> */
256 #define mktime timelocal
257 typedef unsigned short mode_t
;
262 #ifndef REPLACE_GETPASS
263 #define REPLACE_GETPASS
268 #ifndef USE_SIGPROCMASK
269 #define USE_SIGPROCMASK
274 /* SunOS doesn't have POSIX atexit */
275 #define atexit on_exit
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>
294 #include <sys/stropts.h>
297 #endif /* USE_LIBDES */
298 extern int gettimeofday (struct timeval
*, void *);
299 extern int gethostname (char *name
, int namelen
);
300 extern int innetgr (const char *, const char *, const char *, const char *);
302 #define SIGNAL_CAST (void (*)(int))
307 #define REPLACE_STRLEN
311 #define REPLACE_GETPASS
312 #define USE_SIGPROCMASK
318 #include <nfs/nfs_clnt.h>
320 #include <netinet/tcp.h>
327 #define SIGNAL_CAST (void(*)(int))
334 #include <netinet/tcp.h>
335 #include <sys/statfs.h>
341 #define SIGNAL_CAST (void (*)())
349 #include <arpa/inet.h>
350 #include <netinet/tcp.h>
351 #include <netinet/in_systm.h>
352 #include <netinet/ip.h>
353 #include <sys/statvfs.h>
362 #define SIGNAL_CAST (void (*)())
370 #include <bsd/net/soioctl.h>
374 #include <sys/statfs.h>
375 #include <sys/wait.h>
376 #include <sys/termio.h>
377 #define SIGNAL_CAST (void (*)())
379 extern struct group
*getgrnam();
380 extern struct passwd
*getpwnam();
383 #define REPLACE_STRSTR
391 #include <sys/statfs.h>
392 #include <sys/statvfs.h>
397 #define SIGNAL_CAST (void (*)(int))
407 #include <sys/statfs.h>
408 #include <sys/statvfs.h>
410 #include <sys/filio.h>
412 #include <sys/sockio.h>
413 #include <netinet/tcp.h>
418 #define SIGNAL_CAST (void (*)(int))
430 char *mktemp(char *); /* No standard include */
431 #include <netinet/in.h>
432 #include <arpa/inet.h> /* both for inet_ntoa */
433 #define SIGNAL_CAST ( void (*) (int) )
437 #include <netinet/tcp.h>
440 #include <sys/types.h>
441 #include <sys/security.h>
444 #define PASSWORD_LENGTH 16
445 #define NEED_AUTH_PARAMETERS
446 #endif /* OSF1_ENH_SEC */
452 #define SIGNAL_CAST (void (*)())
453 #include <sys/fcntl.h>
454 #include <sys/statfs.h>
462 #define REPLACE_GETPASS
470 #include <netinet/tcp.h>
471 #define SIGNAL_CAST (void (*)())
478 #include <netinet/tcp.h>
479 /* you may not need this */
481 #define SIGNAL_CAST (void (*)())
483 #define REPLACE_INNETGR
489 #include <arpa/inet.h>
491 #include <netinet/tcp.h>
492 #include <netinet/in_systm.h>
493 #include <netinet/ip.h>
494 #define SIGNAL_CAST (void (*)())
502 #define HAVE_GETTIMEOFDAY
503 #define HAVE_PATHCONF
504 #define HAVE_GETGRNAM 1
512 #include <sys/select.h>
514 #include <sys/statfs.h>
517 #include <sys/priv.h>
518 #include <netinet/tcp.h>
523 #define SIGNAL_CAST (void (*)())
524 #define DEFAULT_PRINTING PRINT_AIX
525 /* we undef this because sys/param.h is broken in aix. uggh. */
526 #undef MAXHOSTNAMELEN
535 #include <sys/types.h>
536 #include <sys/termios.h>
537 #include <netinet/tcp.h>
538 #ifdef HPUX_10_TRUSTED
539 #include <hpsecurity.h>
541 #define NEED_AUTH_PARAMETERS
543 #define SIGNAL_CAST (void (*)(__harg))
544 #define SELECT_CAST (int *)
547 #define WAIT3_CAST2 (int *)
551 #define DEFAULT_PRINTING PRINT_HPUX
552 #define SIGCLD_IGNORE
560 #include <sys/types.h>
561 #include <sys/statfs.h>
562 #include <sys/stat.h>
564 #include <sys/socket.h>
567 #define SIGNAL_CAST (void (*)(int))
584 #include <sys/statfs.h>
585 #include <sys/statvfs.h>
588 #include <sys/sockio.h>
589 #include <netinet/tcp.h>
594 #define SIGNAL_CAST (void (*)(int))
598 #define seteuid(uid) setreuid(-1,uid)
601 #define setegid(gid) setregid(-1,gid)
607 #include <sys/types.h>
611 #define bzero(b,len) memset(b,0,len)
625 #define bzero(b,len) memset(b,0,len)
634 #define SIGNAL_CAST (void (*)(int))
635 #define WAIT3_CAST1 (union wait *)
644 #include <sys/statfs.h>
648 #define SIGNAL_CAST (void (*)())
649 #define HAVE_FCNTL_LOCK 0
650 #define HAVE_GETTIMEOFDAY
657 #include <sys/netinet/tcp.h>
658 #include <sys/netinet/in_systm.h>
659 #include <sys/netinet/ip.h>
663 #include <sys/statfs.h>
664 #include <sys/stropts.h>
671 #include <rpcsvc/ypclnt.h>
672 #endif /* NETGROUP */
674 #include <sys/security.h>
675 #include <sys/audit.h>
677 #define crypt bigcrypt
678 #endif /* SecureWare */
679 #define SIGNAL_CAST (void (*)(int))
684 #define setuid(u) setreuid(u,-1)
685 #define seteuid(u) setreuid(-1,u)
688 #define ftruncate(f,l) syscall(0x0a28,f,l)
690 #define NO_INITGROUPS
692 #endif /* SCO3_2_2 */
695 #define HAVE_PATHCONF
701 /* Definitions for RiscIX */
703 #define SIGNAL_CAST (void (*)(int))
704 #include <sys/dirent.h>
705 #include <sys/acct.h>
710 #define HAVE_GETTIMEOFDAY
718 #include <net/errno.h>
722 #include <sys/statfs.h>
724 #include <sys/sioctl.h>
727 #include <netinet/tcp.h>
728 #define FIONREAD FIORDCHK
731 #define SIGNAL_CAST (void (*)(int))
751 #define SIGNAL_CAST (void (*)(int))
752 char *strdup (char *);
765 #define SIGNAL_CAST (void (*)(int))
766 char *strdup (char *);
777 #include <sys/statfs.h>
778 #include <sys/stropts.h>
779 #define NO_GET_BROADCAST
785 #define PF_INET AF_INET
787 #define ftruncate(f,l) chsize(f,l)
791 #include <netinet/tcp.h>
792 #include <arpa/inet.h>
797 #define DONT_REINSTALL_SIG
800 #define SIGNAL_CAST (_SigFunc_Ptr_t)
803 extern char *mktemp(char *);
804 extern int fsync(int);
805 extern int seteuid(uid_t
);
806 extern int setgroups(int, int *);
807 extern int initgroups(char *, int);
808 extern int statfs(char *, struct statfs
*);
809 extern int setegid(gid_t
);
810 extern int getopt(int, char *const *, const char *);
811 extern int chroot(char *);
812 extern int gettimeofday(struct timeval
*, struct timezone
*);
813 extern int gethostname(char *, int);
814 extern char *crypt(char *, char *);
815 extern char *getpass(char *);
820 #define MAXPATHLEN 1024
824 #include <sys/statfs.h>
825 #define SIGNAL_CAST (void (*)(int))
826 #define SIGCLD_IGNORE
827 #define HAVE_FCNTL_LOCK 1
837 #include <sys/fcntl.h>
838 #include <sys/statfs.h>
843 #define ptrdiff_t int
844 #define HAVE_GETGRNAM 0
849 #define NO_INITGROUPS
857 #define REPLACE_MKTIME
858 #define REPLACE_RENAME
859 #define REPLACE_STRSTR
866 #include <sys/statfs.h>
867 #include <sys/select.h>
870 #define SIGNAL_CAST (void (*)())
872 #define NO_INITGROUPS
874 #define HAVE_TIMEZONE
877 #define HAVE_FCNTL_LOCK 1
878 #define DEFAULT_PRINTING PRINT_QNX
886 #include <sys/timeb.h>
892 #include <sys/statfs.h>
895 #define SIGNAL_CAST (void (*)())
896 #define HAVE_FCNTL_LOCK 0
898 #define NO_GET_BROADCAST
901 #define NO_INITGROUPS
906 #define strcasecmp stricmp
907 #define strncasecmp strnicmp
912 #define SIGNAL_CAST (void (*)())
913 #define WAIT3_CAST1 (union wait *)
916 #include <resource.h>
920 #include <sys/statfs.h>
927 #define SIGNAL_CAST (void (*)(int))
930 #include <sys/select.h>
934 #include <sys/statfs.h>
935 #include <sys/bsdioctl.h>
939 #include <arpa/inet.h>
942 #include <netinet/tcp.h>
943 #include <sys/acct.h>
944 #include <sys/fcntl.h>
945 #include <sys/filio.h>
946 #include <sys/sockio.h>
947 #include <netinet/in_systm.h>
948 #include <netinet/ip.h>
949 #include <sys/termios.h>
951 #include <sys/timeb.h>
953 #define SIGNAL_CAST (void (*)(int))
957 #define USE_SIGPROCMASK
961 #define HAVE_FCNTL_LOCK 0
962 #define HAVE_GETTIMEOFDAY
963 #define HAVE_PATHCONF
966 #define NO_FORK_DEBUG
971 /* For UnixWare 2.x's ia_uinfo routines. (tangent@cyberport.com) */
978 /*******************************************************************
979 end of the platform specific sections
980 ********************************************************************/
982 #if defined(USE_MMAP) || defined(FAST_SHARE_MODES)
983 #include <sys/mman.h>
987 #define NEED_AUTH_PARAMETERS
990 #ifdef REPLACE_GETPASS
991 extern char *getsmbpass(char *);
992 #define getpass(s) getsmbpass(s)
995 #ifdef REPLACE_INNETGR
996 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
1000 #define FD_SETSIZE 255
1007 /* Now for some other grungy stuff */
1009 struct spwd
{ /* fake shadow password structure */
1016 #define bzero(p,s) memset(p,0,s)
1020 #ifndef HAVE_MEMMOVE
1022 #define memmove(d,s,n) MemMove(d,s,n)
1027 #include <sys/dir.h>
1030 /* some unixes have ENOTTY instead of TIOCNOTTY */
1033 #define TIOCNOTTY ENOTTY
1041 /* if undefined then use bsd or sysv printing */
1042 #ifndef DEFAULT_PRINTING
1044 #define DEFAULT_PRINTING PRINT_SYSV
1046 #define DEFAULT_PRINTING PRINT_BSD
1052 #include <afs/stds.h>
1053 #include <afs/kautils.h>
1057 #include <dce/dce_error.h>
1058 #include <dce/sec_login.h>
1074 extern char *sys_errlist
[];
1075 #define strerror(i) sys_errlist[i]
1080 #define perror(m) printf("%s: %s\n",m,strerror(errno))
1083 #ifndef MAXHOSTNAMELEN
1084 #define MAXHOSTNAMELEN 255
1087 #include "version.h"
1089 #include "nameserv.h"
1091 #include "byteorder.h"
1094 #include "charset.h"
1097 #define S_IFREG 0100000
1101 #define S_ISREG(x) ((S_IFREG & x)!=0)
1105 #define S_ISDIR(x) ((S_IFDIR & x)!=0)
1108 #if !defined(S_ISLNK) && defined(S_IFLNK)
1109 #define S_ISLNK(x) ((S_IFLNK & x)!=0)
1113 #define crypt ufc_crypt
1116 #ifdef REPLACE_STRLEN
1117 #define strlen(s) Strlen(s)
1120 #ifdef REPLACE_STRSTR
1121 #define strstr(s,p) Strstr(s,p)
1124 #ifdef REPLACE_MKTIME
1125 #define mktime(t) Mktime(t)
1129 #define NGROUPS_MAX 128
1133 #define EDQUOT ENOSPC
1136 #ifndef HAVE_GETGRNAM
1137 #define HAVE_GETGRNAM 1
1144 /* default to using ftruncate workaround as this is safer than assuming
1145 it works and getting lots of bug reports */
1146 #ifndef FTRUNCATE_CAN_EXTEND
1147 #define FTRUNCATE_CAN_EXTEND 0
1150 /* maybe this unix doesn't separate RD and WR locks? */
1152 #define F_RDLCK F_WRLCK
1156 #define ENOTSOCK EINVAL
1160 #define SIGCLD SIGCHLD
1167 #ifndef HAVE_FCNTL_LOCK
1168 #define HAVE_FCNTL_LOCK 1
1172 #define WAIT3_CAST2 (struct rusage *)
1176 #define WAIT3_CAST1 (int *)
1180 #define QSORT_CAST (int (*)())
1183 /* this is a rough check to see if this machine has a lstat() call.
1184 it is not guaranteed to work */
1185 #if !(defined(S_ISLNK) || defined(S_IFLNK))
1189 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1196 #define geteuid() getuid()
1197 #define getegid() getgid()
1198 #define seteuid(x) setuid(x)
1199 #define setegid(x) setgid(x)
1203 #if (HAVE_FCNTL_LOCK == 0)
1204 /* since there is no locking available, system includes */
1205 /* for DomainOS 10.4 do not contain any of the following */
1206 /* #define's. So, to satisfy the compiler, add these */
1207 /* #define's, although they arn't really necessary. */
1212 #endif /* HAVE_FCNTL_LOCK == 0 */
1215 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1216 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1220 #define strcpy(dest,src) StrCpy(dest,src)
1224 /* possibly wrap the malloc calls */
1227 /* undo the old malloc def if necessary */
1229 #define xx_old_malloc malloc
1233 #define malloc(size) malloc_wrapped(size,__FILE__,__LINE__)
1235 /* undo the old realloc def if necessary */
1237 #define xx_old_realloc realloc
1241 #define realloc(ptr,size) realloc_wrapped(ptr,size,__FILE__,__LINE__)
1243 /* undo the old free def if necessary */
1245 #define xx_old_free free
1249 #define free(ptr) free_wrapped(ptr,__FILE__,__LINE__)
1251 /* and the malloc prototypes */
1252 void *malloc_wrapped(int,char *,int);
1253 void *realloc_wrapped(void *,int,char *,int);
1254 void free_wrapped(void *,char *,int);
1260 /* undo the old memcpy def if necessary */
1262 #define xx_old_memcpy memcpy
1266 #define memcpy(d,s,l) memcpy_wrapped(d,s,l,__FILE__,__LINE__)
1267 void *memcpy_wrapped(void *d
,void *s
,int l
,char *fname
,int line
);