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 (*)())
517 #ifdef ALLOW_CHANGE_PASSWORD
519 #endif /* ALLOW_CHANGE_PASSWORD */
520 #else /* NetBSD1_3 */
522 #endif /* NetBSD1_3 */
523 #include <netinet/tcp.h>
524 /* you may not need this */
526 #define SIGNAL_CAST (void (*)())
528 #define REPLACE_INNETGR
533 #include <arpa/inet.h>
535 #include <netinet/tcp.h>
536 #include <netinet/in_systm.h>
537 #include <netinet/ip.h>
545 #define SIGNAL_CAST (void (*)(int))
552 #define HAVE_GETTIMEOFDAY
553 #define HAVE_PATHCONF
554 #define HAVE_GETGRNAM 1
555 #define HAVE_VSNPRINTF
556 #define QSORT_CAST (int (*)(const void *, const void *))
559 #define O_SYNC O_FSYNC
560 #else /* defined(O_FSYNC) */
562 #endif /* defined(O_FSYNC) */
563 #endif /* !defined(O_SYNC) */
568 #include <netinet/tcp.h>
570 #define SIGNAL_CAST (void (*)())
572 #define REPLACE_INNETGR
574 #define HAVE_PATHCONF
575 #define HAVE_GETGRNAM 1
576 #define HAVE_GETTIMEOFDAY
585 #include <sys/select.h>
587 #include <sys/statfs.h>
590 #include <sys/priv.h>
591 /* According to AIX 4.1 man pages, inet_ntoa needs the following headers */
592 #include <sys/socket.h>
593 #include <netinet/in.h>
594 #include <arpa/inet.h>
595 #include <netinet/tcp.h>
600 #define SIGNAL_CAST (void (*)())
601 #define DEFAULT_PRINTING PRINT_AIX
602 /* we undef this because sys/param.h is broken in aix. uggh. */
603 #undef MAXHOSTNAMELEN
612 #include <sys/types.h>
613 #include <sys/termios.h>
614 #include <netinet/tcp.h>
615 #include <arpa/inet.h> /* needed for inet_ntoa proto */
616 #ifdef HPUX_10_TRUSTED
617 #include <hpsecurity.h>
619 #define NEED_AUTH_PARAMETERS
621 #define SIGNAL_CAST (void (*)(__harg))
622 #ifndef HPUX10 /* This is only needed for HPUX 9.x */
623 #define SELECT_CAST (int *)
627 #define WAIT3_CAST2 (int *)
634 #define DEFAULT_PRINTING PRINT_HPUX
635 /* Ken Weiss <krweiss@ucdavis.edu> tells us that SIGCLD_IGNORE is
637 /* #define SIGCLD_IGNORE */
638 #define USE_SIGPROCMASK /* Needed to stop zombie processes on HPUX 9.x and 10.x.*/
646 #include <sys/types.h>
647 #include <sys/statfs.h>
648 #include <sys/stat.h>
650 #include <sys/socket.h>
653 #define SIGNAL_CAST (void (*)(int))
670 #include <sys/statfs.h>
671 #include <sys/statvfs.h>
674 #include <sys/sockio.h>
675 #include <netinet/tcp.h>
680 #define SIGNAL_CAST (void (*)(int))
684 #define seteuid(uid) setreuid(-1,uid)
687 #define setegid(gid) setregid(-1,gid)
693 #include <sys/types.h>
697 #define bzero(b,len) memset(b,0,len)
711 #define bzero(b,len) memset(b,0,len)
720 #define SIGNAL_CAST (void (*)(int))
721 #define WAIT3_CAST1 (union wait *)
730 #include <sys/statfs.h>
734 #define SIGNAL_CAST (void (*)())
735 #define HAVE_FCNTL_LOCK 0
736 #define HAVE_GETTIMEOFDAY
743 #include <sys/netinet/tcp.h>
744 #include <sys/netinet/in_systm.h>
745 #include <sys/netinet/ip.h>
750 #include <sys/statfs.h>
751 #include <sys/stropts.h>
758 #include <rpcsvc/ypclnt.h>
759 #endif /* NETGROUP */
761 #include <sys/security.h>
762 #include <sys/audit.h>
764 #define crypt bigcrypt
765 #endif /* SecureWare */
766 #define SIGNAL_CAST (void (*)(int))
771 #define setuid(u) setreuid(u,-1)
772 #define seteuid(u) setreuid(-1,u)
775 #define ftruncate(f,l) syscall(0x0a28,f,l)
777 #define NO_INITGROUPS
779 #endif /* SCO3_2_2 */
782 #define HAVE_PATHCONF
788 /* Definitions for RiscIX */
790 #define SIGNAL_CAST (void (*)(int))
791 #include <sys/dirent.h>
792 #include <sys/acct.h>
797 #define HAVE_GETTIMEOFDAY
805 #include <net/errno.h>
809 #include <sys/statfs.h>
811 #include <sys/sioctl.h>
814 #include <netinet/tcp.h>
815 #define FIONREAD FIORDCHK
818 #define SIGNAL_CAST (void (*)(int))
838 #define SIGNAL_CAST (void (*)(int))
839 char *strdup (char *);
852 #define SIGNAL_CAST (void (*)(int))
853 char *strdup (char *);
864 #include <sys/statfs.h>
865 #include <sys/stropts.h>
866 #define NO_GET_BROADCAST
872 #define PF_INET AF_INET
874 #define ftruncate(f,l) chsize(f,l)
878 #include <netinet/tcp.h>
879 #include <arpa/inet.h>
884 #define DONT_REINSTALL_SIG
887 #define SIGNAL_CAST (_SigFunc_Ptr_t)
890 extern char *mktemp(char *);
891 extern int fsync(int);
892 extern int seteuid(uid_t);
893 extern int setgroups(int, int *);
894 extern int initgroups(char *, int);
895 extern int statfs(char *, struct statfs *);
896 extern int setegid(gid_t);
897 extern int getopt(int, char *const *, const char *);
898 extern int chroot(char *);
899 extern int gettimeofday(struct timeval *, struct timezone *);
900 extern int gethostname(char *, int);
901 extern char *crypt(char *, char *);
902 extern char *getpass(char *);
907 #define MAXPATHLEN 1024
911 #include <sys/statfs.h>
912 #define SIGNAL_CAST (void (*)(int))
913 #define SIGCLD_IGNORE
914 #define HAVE_FCNTL_LOCK 1
924 #include <sys/fcntl.h>
925 #include <sys/statfs.h>
930 #define ptrdiff_t int
931 #define HAVE_GETGRNAM 0
936 #define NO_INITGROUPS
944 #define REPLACE_MKTIME
945 #define REPLACE_RENAME
946 #define REPLACE_STRSTR
953 #include <sys/statfs.h>
954 #include <sys/select.h>
957 #define SIGNAL_CAST (void (*)())
959 #define NO_INITGROUPS
961 #define HAVE_TIMEZONE
964 #define HAVE_FCNTL_LOCK 1
965 #define DEFAULT_PRINTING PRINT_QNX
973 #include <sys/timeb.h>
979 #include <sys/statfs.h>
982 #define SIGNAL_CAST (void (*)())
983 #define HAVE_FCNTL_LOCK 0
985 #define NO_GET_BROADCAST
988 #define NO_INITGROUPS
993 #define strcasecmp stricmp
994 #define strncasecmp strnicmp
999 #define SIGNAL_CAST (void (*)())
1000 #define WAIT3_CAST1 (union wait *)
1003 #include <resource.h>
1007 #include <sys/statfs.h>
1014 #define SIGNAL_CAST (void (*)(int))
1016 #include <sys/dir.h>
1017 #include <sys/select.h>
1021 #include <sys/statfs.h>
1022 #include <sys/bsdioctl.h>
1026 #include <arpa/inet.h>
1029 #include <netinet/tcp.h>
1030 #include <sys/acct.h>
1031 #include <sys/fcntl.h>
1032 #include <sys/filio.h>
1033 #include <sys/sockio.h>
1034 #include <netinet/in_systm.h>
1035 #include <netinet/ip.h>
1036 #include <sys/termios.h>
1038 #include <sys/timeb.h>
1040 #define SIGNAL_CAST (void (*)(int))
1043 #define HAVE_MEMMOVE
1044 #define USE_SIGPROCMASK
1048 #define HAVE_FCNTL_LOCK 0
1049 #define HAVE_GETTIMEOFDAY
1050 #define HAVE_PATHCONF
1052 #define HAVE_NO_PROC
1053 #define NO_FORK_DEBUG
1055 #define HAVE_VFORK 1
1058 /* For UnixWare 2.x's ia_uinfo routines. (tangent@cyberport.com) */
1065 /*******************************************************************
1066 end of the platform specific sections
1067 ********************************************************************/
1069 #if defined(USE_MMAP) || defined(FAST_SHARE_MODES)
1070 #include <sys/mman.h>
1074 #define NEED_AUTH_PARAMETERS
1077 #ifdef REPLACE_GETPASS
1078 extern char *getsmbpass(char *);
1079 #define getpass(s) getsmbpass(s)
1082 #ifdef REPLACE_INNETGR
1083 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
1087 #define FD_SETSIZE 255
1094 /* Now for some other grungy stuff */
1096 struct spwd { /* fake shadow password structure */
1103 #define bzero(p,s) memset(p,0,s)
1107 #ifndef HAVE_MEMMOVE
1109 #define memmove(d,s,n) MemMove(d,s,n)
1114 #include <sys/dir.h>
1117 /* some unixes have ENOTTY instead of TIOCNOTTY */
1120 #define TIOCNOTTY ENOTTY
1128 /* if undefined then use bsd or sysv printing */
1129 #ifndef DEFAULT_PRINTING
1131 #define DEFAULT_PRINTING PRINT_SYSV
1133 #define DEFAULT_PRINTING PRINT_BSD
1137 /* This defines the name of the printcap file. It is MOST UNLIKELY that
1138 this will change BUT! Specifying a file with the format of a printcap
1139 file but containing only a subset of the printers actually in your real
1140 printcap file is a quick-n-dirty way to allow dynamic access to a subset
1141 of available printers.
1143 #ifndef PRINTCAP_NAME
1145 #define PRINTCAP_NAME "/etc/qconfig"
1147 #define PRINTCAP_NAME "lpstat"
1149 #define PRINTCAP_NAME "/etc/printcap"
1155 #include <sys/ipc.h>
1156 #include <sys/sem.h>
1157 #include <sys/shm.h>
1161 struct semid_ds *buf;
1162 unsigned short *array;
1165 #if defined(HPUX) && defined(HPUX10)
1169 #endif /* HPUX && HPUX10 */
1173 #include <afs/stds.h>
1174 #include <afs/kautils.h>
1178 #include <dce/dce_error.h>
1179 #include <dce/sec_login.h>
1204 extern char *sys_errlist[];
1205 #define strerror(i) sys_errlist[i]
1210 #define perror(m) printf("%s: %s\n",m,strerror(errno))
1213 #ifndef MAXHOSTNAMELEN
1214 #define MAXHOSTNAMELEN 255
1217 #include "version.h"
1219 #include "nameserv.h"
1220 #include "ubiqx/ubi_dLinkList.h"
1222 #include "byteorder.h"
1225 #include "charset.h"
1227 #ifndef MAXCODEPAGELINES
1228 #define MAXCODEPAGELINES 256
1231 /***** automatically generated prototypes *****/
1237 #define S_IFREG 0100000
1241 #define S_ISREG(x) ((S_IFREG & (x))!=0)
1245 #define S_ISDIR(x) ((S_IFDIR & (x))!=0)
1248 #if !defined(S_ISLNK) && defined(S_IFLNK)
1249 #define S_ISLNK(x) ((S_IFLNK & (x))!=0)
1253 #define crypt ufc_crypt
1256 #ifdef REPLACE_STRLEN
1257 #define strlen(s) Strlen(s)
1260 #ifdef REPLACE_STRSTR
1261 #define strstr(s,p) Strstr(s,p)
1264 #ifdef REPLACE_MKTIME
1265 #define mktime(t) Mktime(t)
1269 #define NGROUPS_MAX 128
1273 #define EDQUOT ENOSPC
1276 #ifndef HAVE_GETGRNAM
1277 #define HAVE_GETGRNAM 1
1284 /* default to using ftruncate workaround as this is safer than assuming
1285 it works and getting lots of bug reports */
1286 #ifndef FTRUNCATE_CAN_EXTEND
1287 #define FTRUNCATE_CAN_EXTEND 0
1290 /* maybe this unix doesn't separate RD and WR locks? */
1292 #define F_RDLCK F_WRLCK
1296 #define ENOTSOCK EINVAL
1300 #define SIGCLD SIGCHLD
1307 #ifndef HAVE_FCNTL_LOCK
1308 #define HAVE_FCNTL_LOCK 1
1312 #define WAIT3_CAST2 (struct rusage *)
1316 #define WAIT3_CAST1 (int *)
1320 #define QSORT_CAST (int (*)())
1323 #ifndef INADDR_LOOPBACK
1324 #define INADDR_LOOPBACK 0x7f000001
1325 #endif /* INADDR_LOOPBACK */
1327 /* this is a rough check to see if this machine has a lstat() call.
1328 it is not guaranteed to work */
1329 #if !defined(S_ISLNK)
1333 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1340 #define geteuid() getuid()
1341 #define getegid() getgid()
1342 #define seteuid(x) setuid(x)
1343 #define setegid(x) setgid(x)
1347 #if (HAVE_FCNTL_LOCK == 0)
1348 /* since there is no locking available, system includes */
1349 /* for DomainOS 10.4 do not contain any of the following */
1350 /* #define's. So, to satisfy the compiler, add these */
1351 /* #define's, although they arn't really necessary. */
1356 #endif /* HAVE_FCNTL_LOCK == 0 */
1359 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1360 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1366 #define strcpy(dest,src) __ERROR__XX__NEVER_USE_STRCPY___;
1371 #define strcat(dest,src) __ERROR__XX__NEVER_USE_STRCAT___;
1375 #endif /* sprintf */
1376 #define sprintf __ERROR__XX__NEVER_USE_SPRINTF__;
1378 #define pstrcpy(d,s) safe_strcpy((d),(s),sizeof(pstring)-1)
1379 #define pstrcat(d,s) safe_strcat((d),(s),sizeof(pstring)-1)
1380 #define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
1381 #define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1)
1384 #include "mem_man/mem_man.h"
1385 #endif /* MEM_MAN */