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>
186 #include <net/route.h>
187 #include <sys/mbuf.h>
193 #if defined(GETPWANAM)
194 #include <sys/types.h>
195 #include <sys/label.h>
196 #include <sys/audit.h>
200 #if defined(SHADOW_PWD) && !defined(NETBSD) && !defined(FreeBSD) && !defined(CONVEX) && !defined(__OpenBSD__)
210 /***************************************************************************
211 Here come some platform specific sections
212 ***************************************************************************/
216 #include <arpa/inet.h>
220 #include <netinet/in.h>
222 #define _LINUX_C_LIB_VERSION_MAJOR 6
224 #include <rpcsvc/ypclnt.h>
226 #include <netinet/tcp.h>
227 #include <netinet/ip.h>
230 #define QSORT_CAST (int (*)(const void *, const void *))
231 #endif /* QSORT_CAST */
232 #define SIGNAL_CAST (__sighandler_t)
237 #define USE_SIGPROCMASK
241 /* SETFS disabled until we can check on some bug reports */
242 #if _LINUX_C_LIB_VERSION_MAJOR >= 5
247 #if _LINUX_C_LIB_VERSION_MAJOR < 5
249 #define crypt pw_encrypt
256 #define SIGNAL_CAST (void (*)(int))
257 #include <netinet/tcp.h>
259 #include <sys/acct.h>
263 #include <sys/wait.h>
265 /* #include <termios.h> */
269 #define mktime timelocal
270 typedef unsigned short mode_t;
275 #ifndef REPLACE_GETPASS
276 #define REPLACE_GETPASS
281 #ifndef USE_SIGPROCMASK
282 #define USE_SIGPROCMASK
288 /* SunOS doesn't have POSIX atexit */
289 #define atexit on_exit
296 #include <sys/acct.h>
297 #include <sys/statfs.h>
298 #include <sys/statvfs.h>
299 #include <sys/filio.h>
300 #include <sys/sockio.h>
301 #include <netinet/in_systm.h>
302 #include <netinet/tcp.h>
303 #include <netinet/ip.h>
305 #include <arpa/inet.h>
306 #include <rpcsvc/ypclnt.h>
308 #include <sys/stropts.h>
309 #if !defined(USE_LIBDES) && !defined(KRB4_AUTH)
311 #endif /* !USE_LIBDES && !KRB4_AUTH */
312 extern int gettimeofday (struct timeval *, void *);
313 extern int gethostname (char *name, int namelen);
314 extern int innetgr (const char *, const char *, const char *, const char *);
316 #define SIGNAL_CAST (void (*)(int))
321 #define REPLACE_STRLEN
327 #ifndef REPLACE_GETPASS
328 #define REPLACE_GETPASS
329 #endif /* REPLACE_GETPASS */
330 #define USE_SIGPROCMASK
336 #include <nfs/nfs_clnt.h>
338 #include <netinet/tcp.h>
345 #define SIGNAL_CAST (void(*)(int))
352 #include <netinet/tcp.h>
353 #include <sys/statfs.h>
359 #define SIGNAL_CAST (void (*)())
367 #if defined(SGI5) || defined(SGI6)
368 #include <arpa/inet.h>
369 #include <netinet/tcp.h>
370 #include <netinet/in_systm.h>
371 #include <netinet/ip.h>
372 #include <sys/statvfs.h>
381 #define SIGNAL_CAST (void (*)())
387 #define QSORT_CAST (int (*)(const void *, const void *))
388 #endif /* QSORT_CAST */
393 #include <bsd/net/soioctl.h>
397 #include <sys/statfs.h>
398 #include <sys/wait.h>
399 #include <sys/termio.h>
400 #define SIGNAL_CAST (void (*)())
402 extern struct group *getgrnam();
403 extern struct passwd *getpwnam();
406 #define REPLACE_STRSTR
414 #include <sys/statfs.h>
415 #include <sys/statvfs.h>
420 #define SIGNAL_CAST (void (*)(int))
430 #include <sys/statfs.h>
431 #include <sys/statvfs.h>
433 #include <sys/filio.h>
435 #include <sys/sockio.h>
436 #include <netinet/tcp.h>
441 #define SIGNAL_CAST (void (*)(int))
455 char *mktemp(char *); /* No standard include */
456 #include <netinet/in.h>
457 #include <arpa/inet.h> /* both for inet_ntoa */
458 #define SIGNAL_CAST ( void (*) (int) )
462 #include <netinet/tcp.h>
465 #include <sys/types.h>
466 #include <sys/security.h>
469 #define PASSWORD_LENGTH 16
470 #define NEED_AUTH_PARAMETERS
471 #endif /* OSF1_ENH_SEC */
479 #define SIGNAL_CAST (void (*)())
480 #include <sys/fcntl.h>
481 #include <sys/statfs.h>
489 #ifndef REPLACE_GETPASS
490 #define REPLACE_GETPASS
491 #endif /* REPLACE_GETPASS */
499 #include <netinet/tcp.h>
500 #define SIGNAL_CAST (void (*)())
508 #ifdef ALLOW_CHANGE_PASSWORD
510 #endif /* ALLOW_CHANGE_PASSWORD */
511 #else /* NetBSD1_3 */
513 #endif /* NetBSD1_3 */
514 #include <netinet/tcp.h>
515 /* you may not need this */
517 #define SIGNAL_CAST (void (*)())
519 #define REPLACE_INNETGR
524 #include <arpa/inet.h>
526 #include <netinet/tcp.h>
527 #include <netinet/in_systm.h>
528 #include <netinet/ip.h>
536 #define SIGNAL_CAST (void (*)(int))
543 #define HAVE_GETTIMEOFDAY
544 #define HAVE_PATHCONF
545 #define HAVE_GETGRNAM 1
546 #define QSORT_CAST (int (*)(const void *, const void *))
549 #define O_SYNC O_FSYNC
550 #else /* defined(O_FSYNC) */
552 #endif /* defined(O_FSYNC) */
553 #endif /* !defined(O_SYNC) */
558 #include <netinet/tcp.h>
560 #define SIGNAL_CAST (void (*)())
562 #define REPLACE_INNETGR
564 #define HAVE_PATHCONF
565 #define HAVE_GETGRNAM 1
566 #define HAVE_GETTIMEOFDAY
575 #include <sys/select.h>
577 #include <sys/statfs.h>
580 #include <sys/priv.h>
581 /* According to AIX 4.1 man pages, inet_ntoa needs the following headers */
582 #include <sys/socket.h>
583 #include <netinet/in.h>
584 #include <arpa/inet.h>
585 #include <netinet/tcp.h>
590 #define SIGNAL_CAST (void (*)())
591 #define DEFAULT_PRINTING PRINT_AIX
592 /* we undef this because sys/param.h is broken in aix. uggh. */
593 #undef MAXHOSTNAMELEN
602 #include <sys/types.h>
603 #include <sys/termios.h>
604 #include <netinet/tcp.h>
605 #include <arpa/inet.h> /* needed for inet_ntoa proto */
606 #ifdef HPUX_10_TRUSTED
607 #include <hpsecurity.h>
609 #define NEED_AUTH_PARAMETERS
611 #define SIGNAL_CAST (void (*)(__harg))
612 #ifndef HPUX10 /* This is only needed for HPUX 9.x */
613 #define SELECT_CAST (int *)
617 #define WAIT3_CAST2 (int *)
623 #define DEFAULT_PRINTING PRINT_HPUX
624 /* Ken Weiss <krweiss@ucdavis.edu> tells us that SIGCLD_IGNORE is
626 /* #define SIGCLD_IGNORE */
627 #define USE_SIGPROCMASK /* Needed to stop zombie processes on HPUX 9.x and 10.x.*/
635 #include <sys/types.h>
636 #include <sys/statfs.h>
637 #include <sys/stat.h>
639 #include <sys/socket.h>
642 #define SIGNAL_CAST (void (*)(int))
659 #include <sys/statfs.h>
660 #include <sys/statvfs.h>
663 #include <sys/sockio.h>
664 #include <netinet/tcp.h>
669 #define SIGNAL_CAST (void (*)(int))
673 #define seteuid(uid) setreuid(-1,uid)
676 #define setegid(gid) setregid(-1,gid)
682 #include <sys/types.h>
686 #define bzero(b,len) memset(b,0,len)
700 #define bzero(b,len) memset(b,0,len)
709 #define SIGNAL_CAST (void (*)(int))
710 #define WAIT3_CAST1 (union wait *)
719 #include <sys/statfs.h>
723 #define SIGNAL_CAST (void (*)())
724 #define HAVE_FCNTL_LOCK 0
725 #define HAVE_GETTIMEOFDAY
732 #include <sys/netinet/tcp.h>
733 #include <sys/netinet/in_systm.h>
734 #include <sys/netinet/ip.h>
739 #include <sys/statfs.h>
740 #include <sys/stropts.h>
747 #include <rpcsvc/ypclnt.h>
748 #endif /* NETGROUP */
750 #include <sys/security.h>
751 #include <sys/audit.h>
753 #define crypt bigcrypt
754 #endif /* SecureWare */
755 #define SIGNAL_CAST (void (*)(int))
760 #define setuid(u) setreuid(u,-1)
761 #define seteuid(u) setreuid(-1,u)
764 #define ftruncate(f,l) syscall(0x0a28,f,l)
766 #define NO_INITGROUPS
768 #endif /* SCO3_2_2 */
771 #define HAVE_PATHCONF
777 /* Definitions for RiscIX */
779 #define SIGNAL_CAST (void (*)(int))
780 #include <sys/dirent.h>
781 #include <sys/acct.h>
786 #define HAVE_GETTIMEOFDAY
794 #include <net/errno.h>
798 #include <sys/statfs.h>
800 #include <sys/sioctl.h>
803 #include <netinet/tcp.h>
804 #define FIONREAD FIORDCHK
807 #define SIGNAL_CAST (void (*)(int))
827 #define SIGNAL_CAST (void (*)(int))
828 char *strdup (char *);
841 #define SIGNAL_CAST (void (*)(int))
842 char *strdup (char *);
853 #include <sys/statfs.h>
854 #include <sys/stropts.h>
855 #define NO_GET_BROADCAST
861 #define PF_INET AF_INET
863 #define ftruncate(f,l) chsize(f,l)
867 #include <netinet/tcp.h>
868 #include <arpa/inet.h>
873 #define DONT_REINSTALL_SIG
876 #define SIGNAL_CAST (_SigFunc_Ptr_t)
879 extern char *mktemp(char *);
880 extern int fsync(int);
881 extern int seteuid(uid_t);
882 extern int setgroups(int, int *);
883 extern int initgroups(char *, int);
884 extern int statfs(char *, struct statfs *);
885 extern int setegid(gid_t);
886 extern int getopt(int, char *const *, const char *);
887 extern int chroot(char *);
888 extern int gettimeofday(struct timeval *, struct timezone *);
889 extern int gethostname(char *, int);
890 extern char *crypt(char *, char *);
891 extern char *getpass(char *);
896 #define MAXPATHLEN 1024
900 #include <sys/statfs.h>
901 #define SIGNAL_CAST (void (*)(int))
902 #define SIGCLD_IGNORE
903 #define HAVE_FCNTL_LOCK 1
913 #include <sys/fcntl.h>
914 #include <sys/statfs.h>
919 #define ptrdiff_t int
920 #define HAVE_GETGRNAM 0
925 #define NO_INITGROUPS
933 #define REPLACE_MKTIME
934 #define REPLACE_RENAME
935 #define REPLACE_STRSTR
942 #include <sys/statfs.h>
943 #include <sys/select.h>
946 #define SIGNAL_CAST (void (*)())
948 #define NO_INITGROUPS
950 #define HAVE_TIMEZONE
953 #define HAVE_FCNTL_LOCK 1
954 #define DEFAULT_PRINTING PRINT_QNX
962 #include <sys/timeb.h>
968 #include <sys/statfs.h>
971 #define SIGNAL_CAST (void (*)())
972 #define HAVE_FCNTL_LOCK 0
974 #define NO_GET_BROADCAST
977 #define NO_INITGROUPS
982 #define strcasecmp stricmp
983 #define strncasecmp strnicmp
988 #define SIGNAL_CAST (void (*)())
989 #define WAIT3_CAST1 (union wait *)
992 #include <resource.h>
996 #include <sys/statfs.h>
1003 #define SIGNAL_CAST (void (*)(int))
1005 #include <sys/dir.h>
1006 #include <sys/select.h>
1010 #include <sys/statfs.h>
1011 #include <sys/bsdioctl.h>
1015 #include <arpa/inet.h>
1018 #include <netinet/tcp.h>
1019 #include <sys/acct.h>
1020 #include <sys/fcntl.h>
1021 #include <sys/filio.h>
1022 #include <sys/sockio.h>
1023 #include <netinet/in_systm.h>
1024 #include <netinet/ip.h>
1025 #include <sys/termios.h>
1027 #include <sys/timeb.h>
1029 #define SIGNAL_CAST (void (*)(int))
1032 #define HAVE_MEMMOVE
1033 #define USE_SIGPROCMASK
1037 #define HAVE_FCNTL_LOCK 0
1038 #define HAVE_GETTIMEOFDAY
1039 #define HAVE_PATHCONF
1041 #define HAVE_NO_PROC
1042 #define NO_FORK_DEBUG
1044 #define HAVE_VFORK 1
1047 /* For UnixWare 2.x's ia_uinfo routines. (tangent@cyberport.com) */
1054 /*******************************************************************
1055 end of the platform specific sections
1056 ********************************************************************/
1058 #if defined(USE_MMAP) || defined(FAST_SHARE_MODES)
1059 #include <sys/mman.h>
1063 #define NEED_AUTH_PARAMETERS
1066 #ifdef REPLACE_GETPASS
1067 extern char *getsmbpass(char *);
1068 #define getpass(s) getsmbpass(s)
1071 #ifdef REPLACE_INNETGR
1072 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
1076 #define FD_SETSIZE 255
1083 /* Now for some other grungy stuff */
1085 struct spwd { /* fake shadow password structure */
1092 #define bzero(p,s) memset(p,0,s)
1096 #ifndef HAVE_MEMMOVE
1098 #define memmove(d,s,n) MemMove(d,s,n)
1103 #include <sys/dir.h>
1106 /* some unixes have ENOTTY instead of TIOCNOTTY */
1109 #define TIOCNOTTY ENOTTY
1117 /* if undefined then use bsd or sysv printing */
1118 #ifndef DEFAULT_PRINTING
1120 #define DEFAULT_PRINTING PRINT_SYSV
1122 #define DEFAULT_PRINTING PRINT_BSD
1126 /* This defines the name of the printcap file. It is MOST UNLIKELY that
1127 this will change BUT! Specifying a file with the format of a printcap
1128 file but containing only a subset of the printers actually in your real
1129 printcap file is a quick-n-dirty way to allow dynamic access to a subset
1130 of available printers.
1132 #ifndef PRINTCAP_NAME
1134 #define PRINTCAP_NAME "/etc/qconfig"
1136 #define PRINTCAP_NAME "lpstat"
1138 #define PRINTCAP_NAME "/etc/printcap"
1144 #include <sys/ipc.h>
1145 #include <sys/sem.h>
1146 #include <sys/shm.h>
1150 struct semid_ds *buf;
1151 unsigned short *array;
1154 #if defined(HPUX) && defined(HPUX10)
1158 #endif /* HPUX && HPUX10 */
1162 #include <afs/stds.h>
1163 #include <afs/kautils.h>
1167 #include <dce/dce_error.h>
1168 #include <dce/sec_login.h>
1188 extern char *sys_errlist[];
1189 #define strerror(i) sys_errlist[i]
1194 #define perror(m) printf("%s: %s\n",m,strerror(errno))
1197 #ifndef MAXHOSTNAMELEN
1198 #define MAXHOSTNAMELEN 255
1201 #include "version.h"
1203 #include "nameserv.h"
1204 #include "ubiqx/ubi_dLinkList.h"
1206 #include "byteorder.h"
1209 #include "charset.h"
1211 #ifndef MAXCODEPAGELINES
1212 #define MAXCODEPAGELINES 256
1215 /***** automatically generated prototypes *****/
1221 #define S_IFREG 0100000
1225 #define S_ISREG(x) ((S_IFREG & (x))!=0)
1229 #define S_ISDIR(x) ((S_IFDIR & (x))!=0)
1232 #if !defined(S_ISLNK) && defined(S_IFLNK)
1233 #define S_ISLNK(x) ((S_IFLNK & (x))!=0)
1237 #define crypt ufc_crypt
1240 #ifdef REPLACE_STRLEN
1241 #define strlen(s) Strlen(s)
1244 #ifdef REPLACE_STRSTR
1245 #define strstr(s,p) Strstr(s,p)
1248 #ifdef REPLACE_MKTIME
1249 #define mktime(t) Mktime(t)
1253 #define NGROUPS_MAX 128
1257 #define EDQUOT ENOSPC
1260 #ifndef HAVE_GETGRNAM
1261 #define HAVE_GETGRNAM 1
1268 /* default to using ftruncate workaround as this is safer than assuming
1269 it works and getting lots of bug reports */
1270 #ifndef FTRUNCATE_CAN_EXTEND
1271 #define FTRUNCATE_CAN_EXTEND 0
1274 /* maybe this unix doesn't separate RD and WR locks? */
1276 #define F_RDLCK F_WRLCK
1280 #define ENOTSOCK EINVAL
1284 #define SIGCLD SIGCHLD
1291 #ifndef HAVE_FCNTL_LOCK
1292 #define HAVE_FCNTL_LOCK 1
1296 #define WAIT3_CAST2 (struct rusage *)
1300 #define WAIT3_CAST1 (int *)
1304 #define QSORT_CAST (int (*)())
1307 #ifndef INADDR_LOOPBACK
1308 #define INADDR_LOOPBACK 0x7f000001
1309 #endif /* INADDR_LOOPBACK */
1311 /* this is a rough check to see if this machine has a lstat() call.
1312 it is not guaranteed to work */
1313 #if !defined(S_ISLNK)
1317 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1324 #define geteuid() getuid()
1325 #define getegid() getgid()
1326 #define seteuid(x) setuid(x)
1327 #define setegid(x) setgid(x)
1331 #if (HAVE_FCNTL_LOCK == 0)
1332 /* since there is no locking available, system includes */
1333 /* for DomainOS 10.4 do not contain any of the following */
1334 /* #define's. So, to satisfy the compiler, add these */
1335 /* #define's, although they arn't really necessary. */
1340 #endif /* HAVE_FCNTL_LOCK == 0 */
1343 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1344 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1348 #define strcpy(dest,src) StrCpy(dest,src)
1352 #include "mem_man/mem_man.h"