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) && !defined(__OpenBSD__)
206 /***************************************************************************
207 Here come some platform specific sections
208 ***************************************************************************/
212 #include <arpa/inet.h>
216 #include <netinet/in.h>
218 #define _LINUX_C_LIB_VERSION_MAJOR 6
220 #include <rpcsvc/ypclnt.h>
222 #include <netinet/tcp.h>
223 #include <netinet/ip.h>
225 #define SIGNAL_CAST (__sighandler_t)
230 #define USE_SIGPROCMASK
234 /* SETFS disabled until we can check on some bug reports */
235 #if _LINUX_C_LIB_VERSION_MAJOR >= 5
240 #if _LINUX_C_LIB_VERSION_MAJOR < 5
242 #define crypt pw_encrypt
249 #define SIGNAL_CAST (void (*)(int))
250 #include <netinet/tcp.h>
252 #include <sys/acct.h>
256 #include <sys/wait.h>
258 /* #include <termios.h> */
262 #define mktime timelocal
263 typedef unsigned short mode_t;
268 #ifndef REPLACE_GETPASS
269 #define REPLACE_GETPASS
274 #ifndef USE_SIGPROCMASK
275 #define USE_SIGPROCMASK
281 /* SunOS doesn't have POSIX atexit */
282 #define atexit on_exit
289 #include <sys/acct.h>
290 #include <sys/statfs.h>
291 #include <sys/statvfs.h>
292 #include <sys/filio.h>
293 #include <sys/sockio.h>
294 #include <netinet/in_systm.h>
295 #include <netinet/tcp.h>
296 #include <netinet/ip.h>
298 #include <arpa/inet.h>
299 #include <rpcsvc/ypclnt.h>
301 #include <sys/stropts.h>
304 #endif /* USE_LIBDES */
305 extern int gettimeofday (struct timeval *, void *);
306 extern int gethostname (char *name, int namelen);
307 extern int innetgr (const char *, const char *, const char *, const char *);
309 #define SIGNAL_CAST (void (*)(int))
314 #define REPLACE_STRLEN
320 #ifndef REPLACE_GETPASS
321 #define REPLACE_GETPASS
322 #endif /* REPLACE_GETPASS */
323 #define USE_SIGPROCMASK
329 #include <nfs/nfs_clnt.h>
331 #include <netinet/tcp.h>
338 #define SIGNAL_CAST (void(*)(int))
345 #include <netinet/tcp.h>
346 #include <sys/statfs.h>
352 #define SIGNAL_CAST (void (*)())
360 #if defined(SGI5) || defined(SGI6)
361 #include <arpa/inet.h>
362 #include <netinet/tcp.h>
363 #include <netinet/in_systm.h>
364 #include <netinet/ip.h>
365 #include <sys/statvfs.h>
374 #define SIGNAL_CAST (void (*)())
383 #include <bsd/net/soioctl.h>
387 #include <sys/statfs.h>
388 #include <sys/wait.h>
389 #include <sys/termio.h>
390 #define SIGNAL_CAST (void (*)())
392 extern struct group *getgrnam();
393 extern struct passwd *getpwnam();
396 #define REPLACE_STRSTR
404 #include <sys/statfs.h>
405 #include <sys/statvfs.h>
410 #define SIGNAL_CAST (void (*)(int))
420 #include <sys/statfs.h>
421 #include <sys/statvfs.h>
423 #include <sys/filio.h>
425 #include <sys/sockio.h>
426 #include <netinet/tcp.h>
431 #define SIGNAL_CAST (void (*)(int))
445 char *mktemp(char *); /* No standard include */
446 #include <netinet/in.h>
447 #include <arpa/inet.h> /* both for inet_ntoa */
448 #define SIGNAL_CAST ( void (*) (int) )
452 #include <netinet/tcp.h>
455 #include <sys/types.h>
456 #include <sys/security.h>
459 #define PASSWORD_LENGTH 16
460 #define NEED_AUTH_PARAMETERS
461 #endif /* OSF1_ENH_SEC */
469 #define SIGNAL_CAST (void (*)())
470 #include <sys/fcntl.h>
471 #include <sys/statfs.h>
479 #ifndef REPLACE_GETPASS
480 #define REPLACE_GETPASS
481 #endif /* REPLACE_GETPASS */
489 #include <netinet/tcp.h>
490 #define SIGNAL_CAST (void (*)())
497 #include <netinet/tcp.h>
498 /* you may not need this */
500 #define SIGNAL_CAST (void (*)())
502 #define REPLACE_INNETGR
508 #include <arpa/inet.h>
510 #include <netinet/tcp.h>
511 #include <netinet/in_systm.h>
512 #include <netinet/ip.h>
513 #define SIGNAL_CAST (void (*)())
521 #define HAVE_GETTIMEOFDAY
522 #define HAVE_PATHCONF
523 #define HAVE_GETGRNAM 1
528 #include <netinet/tcp.h>
530 #define SIGNAL_CAST (void (*)())
532 #define REPLACE_INNETGR
534 #define HAVE_PATHCONF
535 #define HAVE_GETGRNAM 1
536 #define HAVE_GETTIMEOFDAY
545 #include <sys/select.h>
547 #include <sys/statfs.h>
550 #include <sys/priv.h>
551 #include <netinet/tcp.h>
556 #define SIGNAL_CAST (void (*)())
557 #define DEFAULT_PRINTING PRINT_AIX
558 /* we undef this because sys/param.h is broken in aix. uggh. */
559 #undef MAXHOSTNAMELEN
568 #include <sys/types.h>
569 #include <sys/termios.h>
570 #include <netinet/tcp.h>
571 #ifdef HPUX_10_TRUSTED
572 #include <hpsecurity.h>
574 #define NEED_AUTH_PARAMETERS
576 #define SIGNAL_CAST (void (*)(__harg))
577 #ifndef HPUX10 /* This is only needed for HPUX 9.x */
578 #define SELECT_CAST (int *)
582 #define WAIT3_CAST2 (int *)
588 #define DEFAULT_PRINTING PRINT_HPUX
589 /* Ken Weiss <krweiss@ucdavis.edu> tells us that SIGCLD_IGNORE is
591 /* #define SIGCLD_IGNORE */
599 #include <sys/types.h>
600 #include <sys/statfs.h>
601 #include <sys/stat.h>
603 #include <sys/socket.h>
606 #define SIGNAL_CAST (void (*)(int))
623 #include <sys/statfs.h>
624 #include <sys/statvfs.h>
627 #include <sys/sockio.h>
628 #include <netinet/tcp.h>
633 #define SIGNAL_CAST (void (*)(int))
637 #define seteuid(uid) setreuid(-1,uid)
640 #define setegid(gid) setregid(-1,gid)
646 #include <sys/types.h>
650 #define bzero(b,len) memset(b,0,len)
664 #define bzero(b,len) memset(b,0,len)
673 #define SIGNAL_CAST (void (*)(int))
674 #define WAIT3_CAST1 (union wait *)
683 #include <sys/statfs.h>
687 #define SIGNAL_CAST (void (*)())
688 #define HAVE_FCNTL_LOCK 0
689 #define HAVE_GETTIMEOFDAY
696 #include <sys/netinet/tcp.h>
697 #include <sys/netinet/in_systm.h>
698 #include <sys/netinet/ip.h>
703 #include <sys/statfs.h>
704 #include <sys/stropts.h>
711 #include <rpcsvc/ypclnt.h>
712 #endif /* NETGROUP */
714 #include <sys/security.h>
715 #include <sys/audit.h>
717 #define crypt bigcrypt
718 #endif /* SecureWare */
719 #define SIGNAL_CAST (void (*)(int))
724 #define setuid(u) setreuid(u,-1)
725 #define seteuid(u) setreuid(-1,u)
728 #define ftruncate(f,l) syscall(0x0a28,f,l)
730 #define NO_INITGROUPS
732 #endif /* SCO3_2_2 */
735 #define HAVE_PATHCONF
741 /* Definitions for RiscIX */
743 #define SIGNAL_CAST (void (*)(int))
744 #include <sys/dirent.h>
745 #include <sys/acct.h>
750 #define HAVE_GETTIMEOFDAY
758 #include <net/errno.h>
762 #include <sys/statfs.h>
764 #include <sys/sioctl.h>
767 #include <netinet/tcp.h>
768 #define FIONREAD FIORDCHK
771 #define SIGNAL_CAST (void (*)(int))
791 #define SIGNAL_CAST (void (*)(int))
792 char *strdup (char *);
805 #define SIGNAL_CAST (void (*)(int))
806 char *strdup (char *);
817 #include <sys/statfs.h>
818 #include <sys/stropts.h>
819 #define NO_GET_BROADCAST
825 #define PF_INET AF_INET
827 #define ftruncate(f,l) chsize(f,l)
831 #include <netinet/tcp.h>
832 #include <arpa/inet.h>
837 #define DONT_REINSTALL_SIG
840 #define SIGNAL_CAST (_SigFunc_Ptr_t)
843 extern char *mktemp(char *);
844 extern int fsync(int);
845 extern int seteuid(uid_t);
846 extern int setgroups(int, int *);
847 extern int initgroups(char *, int);
848 extern int statfs(char *, struct statfs *);
849 extern int setegid(gid_t);
850 extern int getopt(int, char *const *, const char *);
851 extern int chroot(char *);
852 extern int gettimeofday(struct timeval *, struct timezone *);
853 extern int gethostname(char *, int);
854 extern char *crypt(char *, char *);
855 extern char *getpass(char *);
860 #define MAXPATHLEN 1024
864 #include <sys/statfs.h>
865 #define SIGNAL_CAST (void (*)(int))
866 #define SIGCLD_IGNORE
867 #define HAVE_FCNTL_LOCK 1
877 #include <sys/fcntl.h>
878 #include <sys/statfs.h>
883 #define ptrdiff_t int
884 #define HAVE_GETGRNAM 0
889 #define NO_INITGROUPS
897 #define REPLACE_MKTIME
898 #define REPLACE_RENAME
899 #define REPLACE_STRSTR
906 #include <sys/statfs.h>
907 #include <sys/select.h>
910 #define SIGNAL_CAST (void (*)())
912 #define NO_INITGROUPS
914 #define HAVE_TIMEZONE
917 #define HAVE_FCNTL_LOCK 1
918 #define DEFAULT_PRINTING PRINT_QNX
926 #include <sys/timeb.h>
932 #include <sys/statfs.h>
935 #define SIGNAL_CAST (void (*)())
936 #define HAVE_FCNTL_LOCK 0
938 #define NO_GET_BROADCAST
941 #define NO_INITGROUPS
946 #define strcasecmp stricmp
947 #define strncasecmp strnicmp
952 #define SIGNAL_CAST (void (*)())
953 #define WAIT3_CAST1 (union wait *)
956 #include <resource.h>
960 #include <sys/statfs.h>
967 #define SIGNAL_CAST (void (*)(int))
970 #include <sys/select.h>
974 #include <sys/statfs.h>
975 #include <sys/bsdioctl.h>
979 #include <arpa/inet.h>
982 #include <netinet/tcp.h>
983 #include <sys/acct.h>
984 #include <sys/fcntl.h>
985 #include <sys/filio.h>
986 #include <sys/sockio.h>
987 #include <netinet/in_systm.h>
988 #include <netinet/ip.h>
989 #include <sys/termios.h>
991 #include <sys/timeb.h>
993 #define SIGNAL_CAST (void (*)(int))
997 #define USE_SIGPROCMASK
1001 #define HAVE_FCNTL_LOCK 0
1002 #define HAVE_GETTIMEOFDAY
1003 #define HAVE_PATHCONF
1005 #define HAVE_NO_PROC
1006 #define NO_FORK_DEBUG
1008 #define HAVE_VFORK 1
1011 /* For UnixWare 2.x's ia_uinfo routines. (tangent@cyberport.com) */
1018 /*******************************************************************
1019 end of the platform specific sections
1020 ********************************************************************/
1022 #if defined(USE_MMAP) || defined(FAST_SHARE_MODES)
1023 #include <sys/mman.h>
1027 #define NEED_AUTH_PARAMETERS
1030 #ifdef REPLACE_GETPASS
1031 extern char *getsmbpass(char *);
1032 #define getpass(s) getsmbpass(s)
1035 #ifdef REPLACE_INNETGR
1036 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
1040 #define FD_SETSIZE 255
1047 /* Now for some other grungy stuff */
1049 struct spwd { /* fake shadow password structure */
1056 #define bzero(p,s) memset(p,0,s)
1060 #ifndef HAVE_MEMMOVE
1062 #define memmove(d,s,n) MemMove(d,s,n)
1067 #include <sys/dir.h>
1070 /* some unixes have ENOTTY instead of TIOCNOTTY */
1073 #define TIOCNOTTY ENOTTY
1081 /* if undefined then use bsd or sysv printing */
1082 #ifndef DEFAULT_PRINTING
1084 #define DEFAULT_PRINTING PRINT_SYSV
1086 #define DEFAULT_PRINTING PRINT_BSD
1090 /* This defines the name of the printcap file. It is MOST UNLIKELY that
1091 this will change BUT! Specifying a file with the format of a printcap
1092 file but containing only a subset of the printers actually in your real
1093 printcap file is a quick-n-dirty way to allow dynamic access to a subset
1094 of available printers.
1096 #ifndef PRINTCAP_NAME
1098 #define PRINTCAP_NAME "/etc/qconfig"
1100 #define PRINTCAP_NAME "lpstat"
1102 #define PRINTCAP_NAME "/etc/printcap"
1108 #include <sys/ipc.h>
1109 #include <sys/sem.h>
1110 #include <sys/shm.h>
1114 struct semid_ds *buf;
1115 unsigned short *array;
1121 #include <afs/stds.h>
1122 #include <afs/kautils.h>
1126 #include <dce/dce_error.h>
1127 #include <dce/sec_login.h>
1143 extern char *sys_errlist[];
1144 #define strerror(i) sys_errlist[i]
1149 #define perror(m) printf("%s: %s\n",m,strerror(errno))
1152 #ifndef MAXHOSTNAMELEN
1153 #define MAXHOSTNAMELEN 255
1156 #include "version.h"
1158 #include "nameserv.h"
1159 #include "ubiqx/ubi_dLinkList.h"
1161 #include "byteorder.h"
1164 #include "charset.h"
1166 /***** automatically generated prototypes *****/
1172 #define S_IFREG 0100000
1176 #define S_ISREG(x) ((S_IFREG & (x))!=0)
1180 #define S_ISDIR(x) ((S_IFDIR & (x))!=0)
1183 #if !defined(S_ISLNK) && defined(S_IFLNK)
1184 #define S_ISLNK(x) ((S_IFLNK & (x))!=0)
1188 #define crypt ufc_crypt
1191 #ifdef REPLACE_STRLEN
1192 #define strlen(s) Strlen(s)
1195 #ifdef REPLACE_STRSTR
1196 #define strstr(s,p) Strstr(s,p)
1199 #ifdef REPLACE_MKTIME
1200 #define mktime(t) Mktime(t)
1204 #define NGROUPS_MAX 128
1208 #define EDQUOT ENOSPC
1211 #ifndef HAVE_GETGRNAM
1212 #define HAVE_GETGRNAM 1
1219 /* default to using ftruncate workaround as this is safer than assuming
1220 it works and getting lots of bug reports */
1221 #ifndef FTRUNCATE_CAN_EXTEND
1222 #define FTRUNCATE_CAN_EXTEND 0
1225 /* maybe this unix doesn't separate RD and WR locks? */
1227 #define F_RDLCK F_WRLCK
1231 #define ENOTSOCK EINVAL
1235 #define SIGCLD SIGCHLD
1242 #ifndef HAVE_FCNTL_LOCK
1243 #define HAVE_FCNTL_LOCK 1
1247 #define WAIT3_CAST2 (struct rusage *)
1251 #define WAIT3_CAST1 (int *)
1255 #define QSORT_CAST (int (*)())
1258 #ifndef INADDR_LOOPBACK
1259 #define INADDR_LOOPBACK 0x7f000001
1260 #endif /* INADDR_LOOPBACK */
1262 /* this is a rough check to see if this machine has a lstat() call.
1263 it is not guaranteed to work */
1264 #if !defined(S_ISLNK)
1268 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1275 #define geteuid() getuid()
1276 #define getegid() getgid()
1277 #define seteuid(x) setuid(x)
1278 #define setegid(x) setgid(x)
1282 #if (HAVE_FCNTL_LOCK == 0)
1283 /* since there is no locking available, system includes */
1284 /* for DomainOS 10.4 do not contain any of the following */
1285 /* #define's. So, to satisfy the compiler, add these */
1286 /* #define's, although they arn't really necessary. */
1291 #endif /* HAVE_FCNTL_LOCK == 0 */
1294 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1295 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1299 #define strcpy(dest,src) StrCpy(dest,src)
1303 #include "mem_man/mem_man.h"