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__)
213 /***************************************************************************
214 Here come some platform specific sections
215 ***************************************************************************/
219 #include <arpa/inet.h>
223 #include <netinet/in.h>
225 #define _LINUX_C_LIB_VERSION_MAJOR 6
227 #include <rpcsvc/ypclnt.h>
229 #include <netinet/tcp.h>
230 #include <netinet/ip.h>
233 #define QSORT_CAST (int (*)(const void *, const void *))
234 #endif /* QSORT_CAST */
235 #define SIGNAL_CAST (__sighandler_t)
240 #define HAVE_VSNPRINTF
241 #define USE_SIGPROCMASK
245 /* SETFS disabled until we can check on some bug reports */
246 #if _LINUX_C_LIB_VERSION_MAJOR >= 5
251 #if _LINUX_C_LIB_VERSION_MAJOR < 5
253 #define crypt pw_encrypt
260 #define SIGNAL_CAST (void (*)(int))
261 #include <netinet/tcp.h>
263 #include <sys/acct.h>
268 #include <sys/wait.h>
270 /* #include <termios.h> */
274 #define mktime timelocal
275 typedef unsigned short mode_t;
280 #ifndef REPLACE_GETPASS
281 #define REPLACE_GETPASS
286 #ifndef USE_SIGPROCMASK
287 #define USE_SIGPROCMASK
293 /* SunOS doesn't have POSIX atexit */
294 #define atexit on_exit
302 #include <sys/acct.h>
303 #include <sys/statfs.h>
304 #include <sys/statvfs.h>
305 #include <sys/filio.h>
306 #include <sys/sockio.h>
307 #include <netinet/in_systm.h>
308 #include <netinet/tcp.h>
309 #include <netinet/ip.h>
311 #include <arpa/inet.h>
312 #include <rpcsvc/ypclnt.h>
314 #include <sys/stropts.h>
315 #if !defined(USE_LIBDES) && !defined(KRB4_AUTH)
317 #endif /* !USE_LIBDES && !KRB4_AUTH */
318 extern int gettimeofday (struct timeval *, void *);
319 extern int gethostname (char *name, int namelen);
320 extern int innetgr (const char *, const char *, const char *, const char *);
322 #define SIGNAL_CAST (void (*)(int))
327 #define REPLACE_STRLEN
333 #ifndef REPLACE_GETPASS
334 #define REPLACE_GETPASS
335 #endif /* REPLACE_GETPASS */
336 #define USE_SIGPROCMASK
338 #define QSORT_CAST (int (*)(const void *, const void *))
339 #endif /* QSORT_CAST */
345 #include <nfs/nfs_clnt.h>
347 #include <netinet/tcp.h>
354 #define SIGNAL_CAST (void(*)(int))
361 #include <netinet/tcp.h>
362 #include <sys/statfs.h>
368 #define SIGNAL_CAST (void (*)())
376 #if defined(SGI5) || defined(SGI6)
377 #include <arpa/inet.h>
378 #include <netinet/tcp.h>
379 #include <netinet/in_systm.h>
380 #include <netinet/ip.h>
381 #include <sys/statvfs.h>
390 #define SIGNAL_CAST (void (*)())
396 #define QSORT_CAST (int (*)(const void *, const void *))
397 #endif /* QSORT_CAST */
402 #include <bsd/net/soioctl.h>
406 #include <sys/statfs.h>
407 #include <sys/wait.h>
408 #include <sys/termio.h>
409 #define SIGNAL_CAST (void (*)())
411 extern struct group *getgrnam();
412 extern struct passwd *getpwnam();
415 #define REPLACE_STRSTR
423 #include <sys/statfs.h>
424 #include <sys/statvfs.h>
429 #define SIGNAL_CAST (void (*)(int))
439 #include <sys/statfs.h>
440 #include <sys/statvfs.h>
442 #include <sys/filio.h>
444 #include <sys/sockio.h>
445 #include <netinet/tcp.h>
450 #define SIGNAL_CAST (void (*)(int))
464 char *mktemp(char *); /* No standard include */
465 #include <netinet/in.h>
466 #include <arpa/inet.h> /* both for inet_ntoa */
467 #define SIGNAL_CAST ( void (*) (int) )
471 #include <netinet/tcp.h>
474 #include <sys/types.h>
475 #include <sys/security.h>
478 #define PASSWORD_LENGTH 16
479 #define NEED_AUTH_PARAMETERS
480 #endif /* OSF1_ENH_SEC */
488 #define SIGNAL_CAST (void (*)())
489 #include <sys/fcntl.h>
490 #include <sys/statfs.h>
498 #ifndef REPLACE_GETPASS
499 #define REPLACE_GETPASS
500 #endif /* REPLACE_GETPASS */
508 #include <netinet/tcp.h>
509 #define SIGNAL_CAST (void (*)())
511 #define QSORT_CAST (int (*)(const void *, const void *))
518 #ifdef ALLOW_CHANGE_PASSWORD
520 #endif /* ALLOW_CHANGE_PASSWORD */
521 #else /* NetBSD1_3 */
523 #endif /* NetBSD1_3 */
524 #include <netinet/tcp.h>
525 #include <netinet/in_systm.h>
526 #include <netinet/ip.h>
527 /* you may not need this */
529 #define SIGNAL_CAST (void (*)())
531 #define REPLACE_INNETGR
536 #include <arpa/inet.h>
538 #include <netinet/tcp.h>
539 #include <netinet/in_systm.h>
540 #include <netinet/ip.h>
548 #define SIGNAL_CAST (void (*)(int))
555 #define HAVE_GETTIMEOFDAY
556 #define HAVE_PATHCONF
557 #define HAVE_GETGRNAM 1
558 #define HAVE_VSNPRINTF
559 #define QSORT_CAST (int (*)(const void *, const void *))
562 #define O_SYNC O_FSYNC
563 #else /* defined(O_FSYNC) */
565 #endif /* defined(O_FSYNC) */
566 #endif /* !defined(O_SYNC) */
571 #include <netinet/tcp.h>
573 #define SIGNAL_CAST (void (*)())
575 #define REPLACE_INNETGR
577 #define HAVE_PATHCONF
578 #define HAVE_GETGRNAM 1
579 #define HAVE_GETTIMEOFDAY
588 #include <sys/select.h>
590 #include <sys/statfs.h>
593 #include <sys/priv.h>
594 /* According to AIX 4.1 man pages, inet_ntoa needs the following headers */
595 #include <sys/socket.h>
596 #include <netinet/in.h>
597 #include <arpa/inet.h>
598 #include <netinet/tcp.h>
603 #define SIGNAL_CAST (void (*)())
604 #define DEFAULT_PRINTING PRINT_AIX
605 /* we undef this because sys/param.h is broken in aix. uggh. */
606 #undef MAXHOSTNAMELEN
615 #include <sys/types.h>
616 #include <sys/termios.h>
617 #include <netinet/tcp.h>
618 #include <arpa/inet.h> /* needed for inet_ntoa proto */
619 #ifdef HPUX_10_TRUSTED
620 #include <hpsecurity.h>
622 #define NEED_AUTH_PARAMETERS
624 #define SIGNAL_CAST (void (*)(__harg))
628 /* This is only needed for HPUX 9.x */
629 #define SELECT_CAST (int *)
633 #define WAIT3_CAST2 (int *)
639 #define DEFAULT_PRINTING PRINT_HPUX
640 /* Ken Weiss <krweiss@ucdavis.edu> tells us that SIGCLD_IGNORE is
642 /* #define SIGCLD_IGNORE */
643 #define USE_SIGPROCMASK /* Needed to stop zombie processes on HPUX 9.x and 10.x.*/
651 #include <sys/types.h>
652 #include <sys/statfs.h>
653 #include <sys/stat.h>
655 #include <sys/socket.h>
658 #define SIGNAL_CAST (void (*)(int))
675 #include <sys/statfs.h>
676 #include <sys/statvfs.h>
679 #include <sys/sockio.h>
680 #include <netinet/tcp.h>
685 #define SIGNAL_CAST (void (*)(int))
689 #define seteuid(uid) setreuid(-1,uid)
692 #define setegid(gid) setregid(-1,gid)
698 #include <sys/types.h>
702 #define bzero(b,len) memset(b,0,len)
724 #define SIGNAL_CAST (void (*)(int))
725 #define WAIT3_CAST1 (union wait *)
727 #define O_NONBLOCK O_NDELAY
735 #include <sys/statfs.h>
739 #define SIGNAL_CAST (void (*)())
740 #define HAVE_FCNTL_LOCK 0
741 #define HAVE_GETTIMEOFDAY
748 #include <sys/netinet/tcp.h>
749 #include <sys/netinet/in_systm.h>
750 #include <sys/netinet/ip.h>
755 #include <sys/statfs.h>
756 #include <sys/stropts.h>
763 #include <rpcsvc/ypclnt.h>
764 #endif /* NETGROUP */
766 #include <sys/security.h>
767 #include <sys/audit.h>
769 #define crypt bigcrypt
770 #endif /* SecureWare */
771 #define SIGNAL_CAST (void (*)(int))
776 #define setuid(u) setreuid(u,-1)
777 #define seteuid(u) setreuid(-1,u)
780 #define ftruncate(f,l) syscall(0x0a28,f,l)
782 #define NO_INITGROUPS
784 #endif /* SCO3_2_2 */
787 #define HAVE_PATHCONF
793 /* Definitions for RiscIX */
795 #define SIGNAL_CAST (void (*)(int))
796 #include <sys/dirent.h>
797 #include <sys/acct.h>
802 #define HAVE_GETTIMEOFDAY
810 #include <net/errno.h>
814 #include <sys/statfs.h>
816 #include <sys/sioctl.h>
819 #include <netinet/tcp.h>
820 #define FIONREAD FIORDCHK
823 #define SIGNAL_CAST (void (*)(int))
843 #define SIGNAL_CAST (void (*)(int))
844 char *strdup (char *);
857 #define SIGNAL_CAST (void (*)(int))
858 char *strdup (char *);
869 #include <sys/statfs.h>
870 #include <sys/stropts.h>
871 #define NO_GET_BROADCAST
877 #define PF_INET AF_INET
879 #define ftruncate(f,l) chsize(f,l)
883 #include <netinet/tcp.h>
884 #include <arpa/inet.h>
889 #define DONT_REINSTALL_SIG
892 #define SIGNAL_CAST (_SigFunc_Ptr_t)
895 extern char *mktemp(char *);
896 extern int fsync(int);
897 extern int seteuid(uid_t);
898 extern int setgroups(int, int *);
899 extern int initgroups(char *, int);
900 extern int statfs(char *, struct statfs *);
901 extern int setegid(gid_t);
902 extern int getopt(int, char *const *, const char *);
903 extern int chroot(char *);
904 extern int gettimeofday(struct timeval *, struct timezone *);
905 extern int gethostname(char *, int);
906 extern char *crypt(char *, char *);
907 extern char *getpass(char *);
912 #define MAXPATHLEN 1024
916 #include <sys/statfs.h>
917 #define SIGNAL_CAST (void (*)(int))
918 #define SIGCLD_IGNORE
919 #define HAVE_FCNTL_LOCK 1
929 #include <sys/fcntl.h>
930 #include <sys/statfs.h>
935 #define ptrdiff_t int
936 #define HAVE_GETGRNAM 0
941 #define NO_INITGROUPS
949 #define REPLACE_MKTIME
950 #define REPLACE_RENAME
951 #define REPLACE_STRSTR
958 #include <sys/statfs.h>
959 #include <sys/select.h>
962 #define SIGNAL_CAST (void (*)())
964 #define NO_INITGROUPS
966 #define HAVE_TIMEZONE
969 #define HAVE_FCNTL_LOCK 1
970 #define DEFAULT_PRINTING PRINT_QNX
978 #include <sys/timeb.h>
984 #include <sys/statfs.h>
987 #define SIGNAL_CAST (void (*)())
988 #define HAVE_FCNTL_LOCK 0
990 #define NO_GET_BROADCAST
993 #define NO_INITGROUPS
998 #define strcasecmp stricmp
999 #define strncasecmp strnicmp
1004 #define SIGNAL_CAST (void (*)())
1005 #define WAIT3_CAST1 (union wait *)
1008 #include <resource.h>
1012 #include <sys/statfs.h>
1019 #define SIGNAL_CAST (void (*)(int))
1021 #include <sys/dir.h>
1022 #include <sys/select.h>
1026 #include <sys/statfs.h>
1027 #include <sys/bsdioctl.h>
1031 #include <arpa/inet.h>
1034 #include <netinet/tcp.h>
1035 #include <sys/acct.h>
1036 #include <sys/fcntl.h>
1037 #include <sys/filio.h>
1038 #include <sys/sockio.h>
1039 #include <netinet/in_systm.h>
1040 #include <netinet/ip.h>
1041 #include <sys/termios.h>
1043 #include <sys/timeb.h>
1045 #define SIGNAL_CAST (void (*)(int))
1048 #define HAVE_MEMMOVE
1049 #define USE_SIGPROCMASK
1053 #define HAVE_FCNTL_LOCK 0
1054 #define HAVE_GETTIMEOFDAY
1055 #define HAVE_PATHCONF
1057 #define HAVE_NO_PROC
1058 #define NO_FORK_DEBUG
1060 #define HAVE_VFORK 1
1063 /* For UnixWare 2.x's ia_uinfo routines. (tangent@cyberport.com) */
1070 /*******************************************************************
1071 end of the platform specific sections
1072 ********************************************************************/
1074 #if (!defined(USE_LDAP_DB) && !defined(USE_NISPLUS_DB))
1075 #define USE_SMBPASS_DB
1078 #if defined(USE_MMAP) || defined(FAST_SHARE_MODES)
1079 #include <sys/mman.h>
1083 #define NEED_AUTH_PARAMETERS
1086 #ifdef REPLACE_GETPASS
1087 extern char *getsmbpass(char *);
1088 #define getpass(s) getsmbpass(s)
1091 #ifdef REPLACE_INNETGR
1092 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
1096 #define FD_SETSIZE 255
1103 /* Now for some other grungy stuff */
1105 struct spwd { /* fake shadow password structure */
1112 #define bzero(p,s) memset(p,0,s)
1116 #ifndef HAVE_MEMMOVE
1118 #define memmove(d,s,n) MemMove(d,s,n)
1123 #include <sys/dir.h>
1126 /* some unixes have ENOTTY instead of TIOCNOTTY */
1129 #define TIOCNOTTY ENOTTY
1137 /* if undefined then use bsd or sysv printing */
1138 #ifndef DEFAULT_PRINTING
1140 #define DEFAULT_PRINTING PRINT_SYSV
1142 #define DEFAULT_PRINTING PRINT_BSD
1146 /* This defines the name of the printcap file. It is MOST UNLIKELY that
1147 this will change BUT! Specifying a file with the format of a printcap
1148 file but containing only a subset of the printers actually in your real
1149 printcap file is a quick-n-dirty way to allow dynamic access to a subset
1150 of available printers.
1152 #ifndef PRINTCAP_NAME
1154 #define PRINTCAP_NAME "/etc/qconfig"
1156 #define PRINTCAP_NAME "lpstat"
1158 #define PRINTCAP_NAME "/etc/printcap"
1164 #include <sys/ipc.h>
1165 #include <sys/sem.h>
1166 #include <sys/shm.h>
1170 struct semid_ds *buf;
1171 unsigned short *array;
1174 #if defined(HPUX) && defined(HPUX10)
1178 #endif /* HPUX && HPUX10 */
1182 #include <afs/stds.h>
1183 #include <afs/kautils.h>
1187 #include <dce/dce_error.h>
1188 #include <dce/sec_login.h>
1208 extern char *sys_errlist[];
1209 #define strerror(i) sys_errlist[i]
1214 #define perror(m) printf("%s: %s\n",m,strerror(errno))
1217 #ifndef MAXHOSTNAMELEN
1218 #define MAXHOSTNAMELEN 255
1221 #include "version.h"
1223 #include "nameserv.h"
1225 #include "byteorder.h"
1228 #include "charset.h"
1230 #ifndef MAXCODEPAGELINES
1231 #define MAXCODEPAGELINES 256
1234 /***** automatically generated prototypes *****/
1240 #define S_IFREG 0100000
1244 #define S_ISREG(x) ((S_IFREG & (x))!=0)
1248 #define S_ISDIR(x) ((S_IFDIR & (x))!=0)
1251 #if !defined(S_ISLNK) && defined(S_IFLNK)
1252 #define S_ISLNK(x) ((S_IFLNK & (x))!=0)
1256 #define crypt ufc_crypt
1259 #ifdef REPLACE_STRLEN
1260 #define strlen(s) Strlen(s)
1263 #ifdef REPLACE_STRSTR
1264 #define strstr(s,p) Strstr(s,p)
1267 #ifdef REPLACE_MKTIME
1268 #define mktime(t) Mktime(t)
1272 #define NGROUPS_MAX 128
1276 #define EDQUOT ENOSPC
1279 #ifndef HAVE_GETGRNAM
1280 #define HAVE_GETGRNAM 1
1287 /* default to using ftruncate workaround as this is safer than assuming
1288 it works and getting lots of bug reports */
1289 #ifndef FTRUNCATE_CAN_EXTEND
1290 #define FTRUNCATE_CAN_EXTEND 0
1293 /* maybe this unix doesn't separate RD and WR locks? */
1295 #define F_RDLCK F_WRLCK
1299 #define ENOTSOCK EINVAL
1303 #define SIGCLD SIGCHLD
1310 #ifndef HAVE_FCNTL_LOCK
1311 #define HAVE_FCNTL_LOCK 1
1315 #define WAIT3_CAST2 (struct rusage *)
1319 #define WAIT3_CAST1 (int *)
1323 #define QSORT_CAST (int (*)())
1326 #ifndef INADDR_LOOPBACK
1327 #define INADDR_LOOPBACK 0x7f000001
1328 #endif /* INADDR_LOOPBACK */
1330 /* this is a rough check to see if this machine has a lstat() call.
1331 it is not guaranteed to work */
1332 #if !defined(S_ISLNK)
1336 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1343 #define geteuid() getuid()
1344 #define getegid() getgid()
1345 #define seteuid(x) setuid(x)
1346 #define setegid(x) setgid(x)
1350 #if (HAVE_FCNTL_LOCK == 0)
1351 /* since there is no locking available, system includes */
1352 /* for DomainOS 10.4 do not contain any of the following */
1353 /* #define's. So, to satisfy the compiler, add these */
1354 /* #define's, although they arn't really necessary. */
1359 #endif /* HAVE_FCNTL_LOCK == 0 */
1362 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1363 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1369 #define strcpy(dest,src) __ERROR__XX__NEVER_USE_STRCPY___;
1374 #define strcat(dest,src) __ERROR__XX__NEVER_USE_STRCAT___;
1378 #endif /* sprintf */
1379 #define sprintf __ERROR__XX__NEVER_USE_SPRINTF__;
1381 #define pstrcpy(d,s) safe_strcpy((d),(s),sizeof(pstring)-1)
1382 #define pstrcat(d,s) safe_strcat((d),(s),sizeof(pstring)-1)
1383 #define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
1384 #define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1)
1387 #include "mem_man/mem_man.h"
1388 #endif /* MEM_MAN */
1391 /* -------------------------------------------------------------------------- **
1392 * Lists, trees, and caching...
1394 #include "ubiqx/ubi_sLinkList.h"
1395 #include "ubiqx/ubi_dLinkList.h"
1397 #ifndef UBI_BINTREE_H
1398 #include "ubiqx/ubi_SplayTree.h"
1399 #include "ubiqx/ubi_Cache.h"
1400 #endif /* UBI_BINTREE_H */
1402 #endif /* _INCLUDES_H */