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 (*)())
498 #ifdef ALLOW_CHANGE_PASSWORD
500 #endif /* ALLOW_CHANGE_PASSWORD */
501 #else /* NetBSD1_3 */
503 #endif /* NetBSD1_3 */
504 #include <netinet/tcp.h>
505 /* you may not need this */
507 #define SIGNAL_CAST (void (*)())
509 #define REPLACE_INNETGR
514 #include <arpa/inet.h>
516 #include <netinet/tcp.h>
517 #include <netinet/in_systm.h>
518 #include <netinet/ip.h>
525 #define SIGNAL_CAST (void (*)())
532 #define HAVE_GETTIMEOFDAY
533 #define HAVE_PATHCONF
534 #define HAVE_GETGRNAM 1
539 #include <netinet/tcp.h>
541 #define SIGNAL_CAST (void (*)())
543 #define REPLACE_INNETGR
545 #define HAVE_PATHCONF
546 #define HAVE_GETGRNAM 1
547 #define HAVE_GETTIMEOFDAY
556 #include <sys/select.h>
558 #include <sys/statfs.h>
561 #include <sys/priv.h>
562 /* According to AIX 4.1 man pages, inet_ntoa needs the following headers */
563 #include <sys/socket.h>
564 #include <netinet/in.h>
565 #include <arpa/inet.h>
566 #include <netinet/tcp.h>
571 #define SIGNAL_CAST (void (*)())
572 #define DEFAULT_PRINTING PRINT_AIX
573 /* we undef this because sys/param.h is broken in aix. uggh. */
574 #undef MAXHOSTNAMELEN
583 #include <sys/types.h>
584 #include <sys/termios.h>
585 #include <netinet/tcp.h>
586 #include <arpa/inet.h> /* needed for inet_ntoa proto */
587 #ifdef HPUX_10_TRUSTED
588 #include <hpsecurity.h>
590 #define NEED_AUTH_PARAMETERS
592 #define SIGNAL_CAST (void (*)(__harg))
593 #ifndef HPUX10 /* This is only needed for HPUX 9.x */
594 #define SELECT_CAST (int *)
598 #define WAIT3_CAST2 (int *)
604 #define DEFAULT_PRINTING PRINT_HPUX
605 /* Ken Weiss <krweiss@ucdavis.edu> tells us that SIGCLD_IGNORE is
607 /* #define SIGCLD_IGNORE */
608 #define USE_SIGPROCMASK /* Needed to stop zombie processes on HPUX 9.x and 10.x.*/
616 #include <sys/types.h>
617 #include <sys/statfs.h>
618 #include <sys/stat.h>
620 #include <sys/socket.h>
623 #define SIGNAL_CAST (void (*)(int))
640 #include <sys/statfs.h>
641 #include <sys/statvfs.h>
644 #include <sys/sockio.h>
645 #include <netinet/tcp.h>
650 #define SIGNAL_CAST (void (*)(int))
654 #define seteuid(uid) setreuid(-1,uid)
657 #define setegid(gid) setregid(-1,gid)
663 #include <sys/types.h>
667 #define bzero(b,len) memset(b,0,len)
681 #define bzero(b,len) memset(b,0,len)
690 #define SIGNAL_CAST (void (*)(int))
691 #define WAIT3_CAST1 (union wait *)
700 #include <sys/statfs.h>
704 #define SIGNAL_CAST (void (*)())
705 #define HAVE_FCNTL_LOCK 0
706 #define HAVE_GETTIMEOFDAY
713 #include <sys/netinet/tcp.h>
714 #include <sys/netinet/in_systm.h>
715 #include <sys/netinet/ip.h>
720 #include <sys/statfs.h>
721 #include <sys/stropts.h>
728 #include <rpcsvc/ypclnt.h>
729 #endif /* NETGROUP */
731 #include <sys/security.h>
732 #include <sys/audit.h>
734 #define crypt bigcrypt
735 #endif /* SecureWare */
736 #define SIGNAL_CAST (void (*)(int))
741 #define setuid(u) setreuid(u,-1)
742 #define seteuid(u) setreuid(-1,u)
745 #define ftruncate(f,l) syscall(0x0a28,f,l)
747 #define NO_INITGROUPS
749 #endif /* SCO3_2_2 */
752 #define HAVE_PATHCONF
758 /* Definitions for RiscIX */
760 #define SIGNAL_CAST (void (*)(int))
761 #include <sys/dirent.h>
762 #include <sys/acct.h>
767 #define HAVE_GETTIMEOFDAY
775 #include <net/errno.h>
779 #include <sys/statfs.h>
781 #include <sys/sioctl.h>
784 #include <netinet/tcp.h>
785 #define FIONREAD FIORDCHK
788 #define SIGNAL_CAST (void (*)(int))
808 #define SIGNAL_CAST (void (*)(int))
809 char *strdup (char *);
822 #define SIGNAL_CAST (void (*)(int))
823 char *strdup (char *);
834 #include <sys/statfs.h>
835 #include <sys/stropts.h>
836 #define NO_GET_BROADCAST
842 #define PF_INET AF_INET
844 #define ftruncate(f,l) chsize(f,l)
848 #include <netinet/tcp.h>
849 #include <arpa/inet.h>
854 #define DONT_REINSTALL_SIG
857 #define SIGNAL_CAST (_SigFunc_Ptr_t)
860 extern char *mktemp(char *);
861 extern int fsync(int);
862 extern int seteuid(uid_t);
863 extern int setgroups(int, int *);
864 extern int initgroups(char *, int);
865 extern int statfs(char *, struct statfs *);
866 extern int setegid(gid_t);
867 extern int getopt(int, char *const *, const char *);
868 extern int chroot(char *);
869 extern int gettimeofday(struct timeval *, struct timezone *);
870 extern int gethostname(char *, int);
871 extern char *crypt(char *, char *);
872 extern char *getpass(char *);
877 #define MAXPATHLEN 1024
881 #include <sys/statfs.h>
882 #define SIGNAL_CAST (void (*)(int))
883 #define SIGCLD_IGNORE
884 #define HAVE_FCNTL_LOCK 1
894 #include <sys/fcntl.h>
895 #include <sys/statfs.h>
900 #define ptrdiff_t int
901 #define HAVE_GETGRNAM 0
906 #define NO_INITGROUPS
914 #define REPLACE_MKTIME
915 #define REPLACE_RENAME
916 #define REPLACE_STRSTR
923 #include <sys/statfs.h>
924 #include <sys/select.h>
927 #define SIGNAL_CAST (void (*)())
929 #define NO_INITGROUPS
931 #define HAVE_TIMEZONE
934 #define HAVE_FCNTL_LOCK 1
935 #define DEFAULT_PRINTING PRINT_QNX
943 #include <sys/timeb.h>
949 #include <sys/statfs.h>
952 #define SIGNAL_CAST (void (*)())
953 #define HAVE_FCNTL_LOCK 0
955 #define NO_GET_BROADCAST
958 #define NO_INITGROUPS
963 #define strcasecmp stricmp
964 #define strncasecmp strnicmp
969 #define SIGNAL_CAST (void (*)())
970 #define WAIT3_CAST1 (union wait *)
973 #include <resource.h>
977 #include <sys/statfs.h>
984 #define SIGNAL_CAST (void (*)(int))
987 #include <sys/select.h>
991 #include <sys/statfs.h>
992 #include <sys/bsdioctl.h>
996 #include <arpa/inet.h>
999 #include <netinet/tcp.h>
1000 #include <sys/acct.h>
1001 #include <sys/fcntl.h>
1002 #include <sys/filio.h>
1003 #include <sys/sockio.h>
1004 #include <netinet/in_systm.h>
1005 #include <netinet/ip.h>
1006 #include <sys/termios.h>
1008 #include <sys/timeb.h>
1010 #define SIGNAL_CAST (void (*)(int))
1013 #define HAVE_MEMMOVE
1014 #define USE_SIGPROCMASK
1018 #define HAVE_FCNTL_LOCK 0
1019 #define HAVE_GETTIMEOFDAY
1020 #define HAVE_PATHCONF
1022 #define HAVE_NO_PROC
1023 #define NO_FORK_DEBUG
1025 #define HAVE_VFORK 1
1028 /* For UnixWare 2.x's ia_uinfo routines. (tangent@cyberport.com) */
1035 /*******************************************************************
1036 end of the platform specific sections
1037 ********************************************************************/
1039 #if defined(USE_MMAP) || defined(FAST_SHARE_MODES)
1040 #include <sys/mman.h>
1044 #define NEED_AUTH_PARAMETERS
1047 #ifdef REPLACE_GETPASS
1048 extern char *getsmbpass(char *);
1049 #define getpass(s) getsmbpass(s)
1052 #ifdef REPLACE_INNETGR
1053 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
1057 #define FD_SETSIZE 255
1064 /* Now for some other grungy stuff */
1066 struct spwd { /* fake shadow password structure */
1073 #define bzero(p,s) memset(p,0,s)
1077 #ifndef HAVE_MEMMOVE
1079 #define memmove(d,s,n) MemMove(d,s,n)
1084 #include <sys/dir.h>
1087 /* some unixes have ENOTTY instead of TIOCNOTTY */
1090 #define TIOCNOTTY ENOTTY
1098 /* if undefined then use bsd or sysv printing */
1099 #ifndef DEFAULT_PRINTING
1101 #define DEFAULT_PRINTING PRINT_SYSV
1103 #define DEFAULT_PRINTING PRINT_BSD
1107 /* This defines the name of the printcap file. It is MOST UNLIKELY that
1108 this will change BUT! Specifying a file with the format of a printcap
1109 file but containing only a subset of the printers actually in your real
1110 printcap file is a quick-n-dirty way to allow dynamic access to a subset
1111 of available printers.
1113 #ifndef PRINTCAP_NAME
1115 #define PRINTCAP_NAME "/etc/qconfig"
1117 #define PRINTCAP_NAME "lpstat"
1119 #define PRINTCAP_NAME "/etc/printcap"
1125 #include <sys/ipc.h>
1126 #include <sys/sem.h>
1127 #include <sys/shm.h>
1131 struct semid_ds *buf;
1132 unsigned short *array;
1138 #include <afs/stds.h>
1139 #include <afs/kautils.h>
1143 #include <dce/dce_error.h>
1144 #include <dce/sec_login.h>
1164 extern char *sys_errlist[];
1165 #define strerror(i) sys_errlist[i]
1170 #define perror(m) printf("%s: %s\n",m,strerror(errno))
1173 #ifndef MAXHOSTNAMELEN
1174 #define MAXHOSTNAMELEN 255
1177 #include "version.h"
1179 #include "nameserv.h"
1180 #include "ubiqx/ubi_dLinkList.h"
1182 #include "byteorder.h"
1185 #include "charset.h"
1187 #ifndef MAXCODEPAGELINES
1188 #define MAXCODEPAGELINES 256
1191 /***** automatically generated prototypes *****/
1197 #define S_IFREG 0100000
1201 #define S_ISREG(x) ((S_IFREG & (x))!=0)
1205 #define S_ISDIR(x) ((S_IFDIR & (x))!=0)
1208 #if !defined(S_ISLNK) && defined(S_IFLNK)
1209 #define S_ISLNK(x) ((S_IFLNK & (x))!=0)
1213 #define crypt ufc_crypt
1216 #ifdef REPLACE_STRLEN
1217 #define strlen(s) Strlen(s)
1220 #ifdef REPLACE_STRSTR
1221 #define strstr(s,p) Strstr(s,p)
1224 #ifdef REPLACE_MKTIME
1225 #define mktime(t) Mktime(t)
1229 #define NGROUPS_MAX 128
1233 #define EDQUOT ENOSPC
1236 #ifndef HAVE_GETGRNAM
1237 #define HAVE_GETGRNAM 1
1244 /* default to using ftruncate workaround as this is safer than assuming
1245 it works and getting lots of bug reports */
1246 #ifndef FTRUNCATE_CAN_EXTEND
1247 #define FTRUNCATE_CAN_EXTEND 0
1250 /* maybe this unix doesn't separate RD and WR locks? */
1252 #define F_RDLCK F_WRLCK
1256 #define ENOTSOCK EINVAL
1260 #define SIGCLD SIGCHLD
1267 #ifndef HAVE_FCNTL_LOCK
1268 #define HAVE_FCNTL_LOCK 1
1272 #define WAIT3_CAST2 (struct rusage *)
1276 #define WAIT3_CAST1 (int *)
1280 #define QSORT_CAST (int (*)())
1283 #ifndef INADDR_LOOPBACK
1284 #define INADDR_LOOPBACK 0x7f000001
1285 #endif /* INADDR_LOOPBACK */
1287 /* this is a rough check to see if this machine has a lstat() call.
1288 it is not guaranteed to work */
1289 #if !defined(S_ISLNK)
1293 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1300 #define geteuid() getuid()
1301 #define getegid() getgid()
1302 #define seteuid(x) setuid(x)
1303 #define setegid(x) setgid(x)
1307 #if (HAVE_FCNTL_LOCK == 0)
1308 /* since there is no locking available, system includes */
1309 /* for DomainOS 10.4 do not contain any of the following */
1310 /* #define's. So, to satisfy the compiler, add these */
1311 /* #define's, although they arn't really necessary. */
1316 #endif /* HAVE_FCNTL_LOCK == 0 */
1319 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1320 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1324 #define strcpy(dest,src) StrCpy(dest,src)
1328 #include "mem_man/mem_man.h"