4 Unix SMB/Netbios implementation.
6 Machine customisation and include handling
7 Copyright (C) Andrew Tridgell 1994-1998
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>
302 #if !defined(USE_LIBDES) && !defined(KRB4_AUTH)
304 #endif /* !USE_LIBDES && !KRB4_AUTH */
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>
518 #define SIGNAL_CAST (void (*)())
525 #define HAVE_GETTIMEOFDAY
526 #define HAVE_PATHCONF
527 #define HAVE_GETGRNAM 1
532 #include <netinet/tcp.h>
534 #define SIGNAL_CAST (void (*)())
536 #define REPLACE_INNETGR
538 #define HAVE_PATHCONF
539 #define HAVE_GETGRNAM 1
540 #define HAVE_GETTIMEOFDAY
549 #include <sys/select.h>
551 #include <sys/statfs.h>
554 #include <sys/priv.h>
555 /* According to AIX 4.1 man pages, inet_ntoa needs the following headers */
556 #include <sys/socket.h>
557 #include <netinet/in.h>
558 #include <arpa/inet.h>
559 #include <netinet/tcp.h>
564 #define SIGNAL_CAST (void (*)())
565 #define DEFAULT_PRINTING PRINT_AIX
566 /* we undef this because sys/param.h is broken in aix. uggh. */
567 #undef MAXHOSTNAMELEN
576 #include <sys/types.h>
577 #include <sys/termios.h>
578 #include <netinet/tcp.h>
579 #include <arpa/inet.h> /* needed for inet_ntoa proto */
580 #ifdef HPUX_10_TRUSTED
581 #include <hpsecurity.h>
583 #define NEED_AUTH_PARAMETERS
585 #define SIGNAL_CAST (void (*)(__harg))
586 #ifndef HPUX10 /* This is only needed for HPUX 9.x */
587 #define SELECT_CAST (int *)
591 #define WAIT3_CAST2 (int *)
597 #define DEFAULT_PRINTING PRINT_HPUX
598 /* Ken Weiss <krweiss@ucdavis.edu> tells us that SIGCLD_IGNORE is
600 /* #define SIGCLD_IGNORE */
608 #include <sys/types.h>
609 #include <sys/statfs.h>
610 #include <sys/stat.h>
612 #include <sys/socket.h>
615 #define SIGNAL_CAST (void (*)(int))
632 #include <sys/statfs.h>
633 #include <sys/statvfs.h>
636 #include <sys/sockio.h>
637 #include <netinet/tcp.h>
642 #define SIGNAL_CAST (void (*)(int))
646 #define seteuid(uid) setreuid(-1,uid)
649 #define setegid(gid) setregid(-1,gid)
655 #include <sys/types.h>
659 #define bzero(b,len) memset(b,0,len)
673 #define bzero(b,len) memset(b,0,len)
682 #define SIGNAL_CAST (void (*)(int))
683 #define WAIT3_CAST1 (union wait *)
692 #include <sys/statfs.h>
696 #define SIGNAL_CAST (void (*)())
697 #define HAVE_FCNTL_LOCK 0
698 #define HAVE_GETTIMEOFDAY
705 #include <sys/netinet/tcp.h>
706 #include <sys/netinet/in_systm.h>
707 #include <sys/netinet/ip.h>
712 #include <sys/statfs.h>
713 #include <sys/stropts.h>
720 #include <rpcsvc/ypclnt.h>
721 #endif /* NETGROUP */
723 #include <sys/security.h>
724 #include <sys/audit.h>
726 #define crypt bigcrypt
727 #endif /* SecureWare */
728 #define SIGNAL_CAST (void (*)(int))
733 #define setuid(u) setreuid(u,-1)
734 #define seteuid(u) setreuid(-1,u)
737 #define ftruncate(f,l) syscall(0x0a28,f,l)
739 #define NO_INITGROUPS
741 #endif /* SCO3_2_2 */
744 #define HAVE_PATHCONF
750 /* Definitions for RiscIX */
752 #define SIGNAL_CAST (void (*)(int))
753 #include <sys/dirent.h>
754 #include <sys/acct.h>
759 #define HAVE_GETTIMEOFDAY
767 #include <net/errno.h>
771 #include <sys/statfs.h>
773 #include <sys/sioctl.h>
776 #include <netinet/tcp.h>
777 #define FIONREAD FIORDCHK
780 #define SIGNAL_CAST (void (*)(int))
800 #define SIGNAL_CAST (void (*)(int))
801 char *strdup (char *);
814 #define SIGNAL_CAST (void (*)(int))
815 char *strdup (char *);
826 #include <sys/statfs.h>
827 #include <sys/stropts.h>
828 #define NO_GET_BROADCAST
834 #define PF_INET AF_INET
836 #define ftruncate(f,l) chsize(f,l)
840 #include <netinet/tcp.h>
841 #include <arpa/inet.h>
846 #define DONT_REINSTALL_SIG
849 #define SIGNAL_CAST (_SigFunc_Ptr_t)
852 extern char *mktemp(char *);
853 extern int fsync(int);
854 extern int seteuid(uid_t);
855 extern int setgroups(int, int *);
856 extern int initgroups(char *, int);
857 extern int statfs(char *, struct statfs *);
858 extern int setegid(gid_t);
859 extern int getopt(int, char *const *, const char *);
860 extern int chroot(char *);
861 extern int gettimeofday(struct timeval *, struct timezone *);
862 extern int gethostname(char *, int);
863 extern char *crypt(char *, char *);
864 extern char *getpass(char *);
869 #define MAXPATHLEN 1024
873 #include <sys/statfs.h>
874 #define SIGNAL_CAST (void (*)(int))
875 #define SIGCLD_IGNORE
876 #define HAVE_FCNTL_LOCK 1
886 #include <sys/fcntl.h>
887 #include <sys/statfs.h>
892 #define ptrdiff_t int
893 #define HAVE_GETGRNAM 0
898 #define NO_INITGROUPS
906 #define REPLACE_MKTIME
907 #define REPLACE_RENAME
908 #define REPLACE_STRSTR
915 #include <sys/statfs.h>
916 #include <sys/select.h>
919 #define SIGNAL_CAST (void (*)())
921 #define NO_INITGROUPS
923 #define HAVE_TIMEZONE
926 #define HAVE_FCNTL_LOCK 1
927 #define DEFAULT_PRINTING PRINT_QNX
935 #include <sys/timeb.h>
941 #include <sys/statfs.h>
944 #define SIGNAL_CAST (void (*)())
945 #define HAVE_FCNTL_LOCK 0
947 #define NO_GET_BROADCAST
950 #define NO_INITGROUPS
955 #define strcasecmp stricmp
956 #define strncasecmp strnicmp
961 #define SIGNAL_CAST (void (*)())
962 #define WAIT3_CAST1 (union wait *)
965 #include <resource.h>
969 #include <sys/statfs.h>
976 #define SIGNAL_CAST (void (*)(int))
979 #include <sys/select.h>
983 #include <sys/statfs.h>
984 #include <sys/bsdioctl.h>
988 #include <arpa/inet.h>
991 #include <netinet/tcp.h>
992 #include <sys/acct.h>
993 #include <sys/fcntl.h>
994 #include <sys/filio.h>
995 #include <sys/sockio.h>
996 #include <netinet/in_systm.h>
997 #include <netinet/ip.h>
998 #include <sys/termios.h>
1000 #include <sys/timeb.h>
1002 #define SIGNAL_CAST (void (*)(int))
1005 #define HAVE_MEMMOVE
1006 #define USE_SIGPROCMASK
1010 #define HAVE_FCNTL_LOCK 0
1011 #define HAVE_GETTIMEOFDAY
1012 #define HAVE_PATHCONF
1014 #define HAVE_NO_PROC
1015 #define NO_FORK_DEBUG
1017 #define HAVE_VFORK 1
1020 /* For UnixWare 2.x's ia_uinfo routines. (tangent@cyberport.com) */
1027 /*******************************************************************
1028 end of the platform specific sections
1029 ********************************************************************/
1031 #if defined(USE_MMAP) || defined(FAST_SHARE_MODES)
1032 #include <sys/mman.h>
1036 #define NEED_AUTH_PARAMETERS
1039 #ifdef REPLACE_GETPASS
1040 extern char *getsmbpass(char *);
1041 #define getpass(s) getsmbpass(s)
1044 #ifdef REPLACE_INNETGR
1045 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
1049 #define FD_SETSIZE 255
1056 /* Now for some other grungy stuff */
1058 struct spwd { /* fake shadow password structure */
1065 #define bzero(p,s) memset(p,0,s)
1069 #ifndef HAVE_MEMMOVE
1071 #define memmove(d,s,n) MemMove(d,s,n)
1076 #include <sys/dir.h>
1079 /* some unixes have ENOTTY instead of TIOCNOTTY */
1082 #define TIOCNOTTY ENOTTY
1090 /* if undefined then use bsd or sysv printing */
1091 #ifndef DEFAULT_PRINTING
1093 #define DEFAULT_PRINTING PRINT_SYSV
1095 #define DEFAULT_PRINTING PRINT_BSD
1099 /* This defines the name of the printcap file. It is MOST UNLIKELY that
1100 this will change BUT! Specifying a file with the format of a printcap
1101 file but containing only a subset of the printers actually in your real
1102 printcap file is a quick-n-dirty way to allow dynamic access to a subset
1103 of available printers.
1105 #ifndef PRINTCAP_NAME
1107 #define PRINTCAP_NAME "/etc/qconfig"
1109 #define PRINTCAP_NAME "lpstat"
1111 #define PRINTCAP_NAME "/etc/printcap"
1117 #include <sys/ipc.h>
1118 #include <sys/sem.h>
1119 #include <sys/shm.h>
1123 struct semid_ds *buf;
1124 unsigned short *array;
1130 #include <afs/stds.h>
1131 #include <afs/kautils.h>
1135 #include <dce/dce_error.h>
1136 #include <dce/sec_login.h>
1156 extern char *sys_errlist[];
1157 #define strerror(i) sys_errlist[i]
1162 #define perror(m) printf("%s: %s\n",m,strerror(errno))
1165 #ifndef MAXHOSTNAMELEN
1166 #define MAXHOSTNAMELEN 255
1169 #include "version.h"
1171 #include "nameserv.h"
1172 #include "ubiqx/ubi_dLinkList.h"
1174 #include "byteorder.h"
1177 #include "charset.h"
1179 #ifndef MAXCODEPAGELINES
1180 #define MAXCODEPAGELINES 256
1183 /***** automatically generated prototypes *****/
1189 #define S_IFREG 0100000
1193 #define S_ISREG(x) ((S_IFREG & (x))!=0)
1197 #define S_ISDIR(x) ((S_IFDIR & (x))!=0)
1200 #if !defined(S_ISLNK) && defined(S_IFLNK)
1201 #define S_ISLNK(x) ((S_IFLNK & (x))!=0)
1205 #define crypt ufc_crypt
1208 #ifdef REPLACE_STRLEN
1209 #define strlen(s) Strlen(s)
1212 #ifdef REPLACE_STRSTR
1213 #define strstr(s,p) Strstr(s,p)
1216 #ifdef REPLACE_MKTIME
1217 #define mktime(t) Mktime(t)
1221 #define NGROUPS_MAX 128
1225 #define EDQUOT ENOSPC
1228 #ifndef HAVE_GETGRNAM
1229 #define HAVE_GETGRNAM 1
1236 /* default to using ftruncate workaround as this is safer than assuming
1237 it works and getting lots of bug reports */
1238 #ifndef FTRUNCATE_CAN_EXTEND
1239 #define FTRUNCATE_CAN_EXTEND 0
1242 /* maybe this unix doesn't separate RD and WR locks? */
1244 #define F_RDLCK F_WRLCK
1248 #define ENOTSOCK EINVAL
1252 #define SIGCLD SIGCHLD
1259 #ifndef HAVE_FCNTL_LOCK
1260 #define HAVE_FCNTL_LOCK 1
1264 #define WAIT3_CAST2 (struct rusage *)
1268 #define WAIT3_CAST1 (int *)
1272 #define QSORT_CAST (int (*)())
1275 #ifndef INADDR_LOOPBACK
1276 #define INADDR_LOOPBACK 0x7f000001
1277 #endif /* INADDR_LOOPBACK */
1279 /* this is a rough check to see if this machine has a lstat() call.
1280 it is not guaranteed to work */
1281 #if !defined(S_ISLNK)
1285 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1292 #define geteuid() getuid()
1293 #define getegid() getgid()
1294 #define seteuid(x) setuid(x)
1295 #define setegid(x) setgid(x)
1299 #if (HAVE_FCNTL_LOCK == 0)
1300 /* since there is no locking available, system includes */
1301 /* for DomainOS 10.4 do not contain any of the following */
1302 /* #define's. So, to satisfy the compiler, add these */
1303 /* #define's, although they arn't really necessary. */
1308 #endif /* HAVE_FCNTL_LOCK == 0 */
1311 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1312 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1316 #define strcpy(dest,src) StrCpy(dest,src)
1320 #include "mem_man/mem_man.h"