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>
267 #include <sys/wait.h>
269 /* #include <termios.h> */
273 #define mktime timelocal
274 typedef unsigned short mode_t;
279 #ifndef REPLACE_GETPASS
280 #define REPLACE_GETPASS
285 #ifndef USE_SIGPROCMASK
286 #define USE_SIGPROCMASK
292 /* SunOS doesn't have POSIX atexit */
293 #define atexit on_exit
300 #include <sys/acct.h>
301 #include <sys/statfs.h>
302 #include <sys/statvfs.h>
303 #include <sys/filio.h>
304 #include <sys/sockio.h>
305 #include <netinet/in_systm.h>
306 #include <netinet/tcp.h>
307 #include <netinet/ip.h>
309 #include <arpa/inet.h>
310 #include <rpcsvc/ypclnt.h>
312 #include <sys/stropts.h>
313 #if !defined(USE_LIBDES) && !defined(KRB4_AUTH)
315 #endif /* !USE_LIBDES && !KRB4_AUTH */
316 extern int gettimeofday (struct timeval *, void *);
317 extern int gethostname (char *name, int namelen);
318 extern int innetgr (const char *, const char *, const char *, const char *);
320 #define SIGNAL_CAST (void (*)(int))
325 #define REPLACE_STRLEN
331 #ifndef REPLACE_GETPASS
332 #define REPLACE_GETPASS
333 #endif /* REPLACE_GETPASS */
334 #define USE_SIGPROCMASK
340 #include <nfs/nfs_clnt.h>
342 #include <netinet/tcp.h>
349 #define SIGNAL_CAST (void(*)(int))
356 #include <netinet/tcp.h>
357 #include <sys/statfs.h>
363 #define SIGNAL_CAST (void (*)())
371 #if defined(SGI5) || defined(SGI6)
372 #include <arpa/inet.h>
373 #include <netinet/tcp.h>
374 #include <netinet/in_systm.h>
375 #include <netinet/ip.h>
376 #include <sys/statvfs.h>
385 #define SIGNAL_CAST (void (*)())
391 #define QSORT_CAST (int (*)(const void *, const void *))
392 #endif /* QSORT_CAST */
397 #include <bsd/net/soioctl.h>
401 #include <sys/statfs.h>
402 #include <sys/wait.h>
403 #include <sys/termio.h>
404 #define SIGNAL_CAST (void (*)())
406 extern struct group *getgrnam();
407 extern struct passwd *getpwnam();
410 #define REPLACE_STRSTR
418 #include <sys/statfs.h>
419 #include <sys/statvfs.h>
424 #define SIGNAL_CAST (void (*)(int))
434 #include <sys/statfs.h>
435 #include <sys/statvfs.h>
437 #include <sys/filio.h>
439 #include <sys/sockio.h>
440 #include <netinet/tcp.h>
445 #define SIGNAL_CAST (void (*)(int))
459 char *mktemp(char *); /* No standard include */
460 #include <netinet/in.h>
461 #include <arpa/inet.h> /* both for inet_ntoa */
462 #define SIGNAL_CAST ( void (*) (int) )
466 #include <netinet/tcp.h>
469 #include <sys/types.h>
470 #include <sys/security.h>
473 #define PASSWORD_LENGTH 16
474 #define NEED_AUTH_PARAMETERS
475 #endif /* OSF1_ENH_SEC */
483 #define SIGNAL_CAST (void (*)())
484 #include <sys/fcntl.h>
485 #include <sys/statfs.h>
493 #ifndef REPLACE_GETPASS
494 #define REPLACE_GETPASS
495 #endif /* REPLACE_GETPASS */
503 #include <netinet/tcp.h>
504 #define SIGNAL_CAST (void (*)())
512 #ifdef ALLOW_CHANGE_PASSWORD
514 #endif /* ALLOW_CHANGE_PASSWORD */
515 #else /* NetBSD1_3 */
517 #endif /* NetBSD1_3 */
518 #include <netinet/tcp.h>
519 /* you may not need this */
521 #define SIGNAL_CAST (void (*)())
523 #define REPLACE_INNETGR
528 #include <arpa/inet.h>
530 #include <netinet/tcp.h>
531 #include <netinet/in_systm.h>
532 #include <netinet/ip.h>
540 #define SIGNAL_CAST (void (*)(int))
547 #define HAVE_GETTIMEOFDAY
548 #define HAVE_PATHCONF
549 #define HAVE_GETGRNAM 1
550 #define QSORT_CAST (int (*)(const void *, const void *))
553 #define O_SYNC O_FSYNC
554 #else /* defined(O_FSYNC) */
556 #endif /* defined(O_FSYNC) */
557 #endif /* !defined(O_SYNC) */
562 #include <netinet/tcp.h>
564 #define SIGNAL_CAST (void (*)())
566 #define REPLACE_INNETGR
568 #define HAVE_PATHCONF
569 #define HAVE_GETGRNAM 1
570 #define HAVE_GETTIMEOFDAY
579 #include <sys/select.h>
581 #include <sys/statfs.h>
584 #include <sys/priv.h>
585 /* According to AIX 4.1 man pages, inet_ntoa needs the following headers */
586 #include <sys/socket.h>
587 #include <netinet/in.h>
588 #include <arpa/inet.h>
589 #include <netinet/tcp.h>
594 #define SIGNAL_CAST (void (*)())
595 #define DEFAULT_PRINTING PRINT_AIX
596 /* we undef this because sys/param.h is broken in aix. uggh. */
597 #undef MAXHOSTNAMELEN
606 #include <sys/types.h>
607 #include <sys/termios.h>
608 #include <netinet/tcp.h>
609 #include <arpa/inet.h> /* needed for inet_ntoa proto */
610 #ifdef HPUX_10_TRUSTED
611 #include <hpsecurity.h>
613 #define NEED_AUTH_PARAMETERS
615 #define SIGNAL_CAST (void (*)(__harg))
616 #ifndef HPUX10 /* This is only needed for HPUX 9.x */
617 #define SELECT_CAST (int *)
621 #define WAIT3_CAST2 (int *)
627 #define DEFAULT_PRINTING PRINT_HPUX
628 /* Ken Weiss <krweiss@ucdavis.edu> tells us that SIGCLD_IGNORE is
630 /* #define SIGCLD_IGNORE */
631 #define USE_SIGPROCMASK /* Needed to stop zombie processes on HPUX 9.x and 10.x.*/
639 #include <sys/types.h>
640 #include <sys/statfs.h>
641 #include <sys/stat.h>
643 #include <sys/socket.h>
646 #define SIGNAL_CAST (void (*)(int))
663 #include <sys/statfs.h>
664 #include <sys/statvfs.h>
667 #include <sys/sockio.h>
668 #include <netinet/tcp.h>
673 #define SIGNAL_CAST (void (*)(int))
677 #define seteuid(uid) setreuid(-1,uid)
680 #define setegid(gid) setregid(-1,gid)
686 #include <sys/types.h>
690 #define bzero(b,len) memset(b,0,len)
704 #define bzero(b,len) memset(b,0,len)
713 #define SIGNAL_CAST (void (*)(int))
714 #define WAIT3_CAST1 (union wait *)
723 #include <sys/statfs.h>
727 #define SIGNAL_CAST (void (*)())
728 #define HAVE_FCNTL_LOCK 0
729 #define HAVE_GETTIMEOFDAY
736 #include <sys/netinet/tcp.h>
737 #include <sys/netinet/in_systm.h>
738 #include <sys/netinet/ip.h>
743 #include <sys/statfs.h>
744 #include <sys/stropts.h>
751 #include <rpcsvc/ypclnt.h>
752 #endif /* NETGROUP */
754 #include <sys/security.h>
755 #include <sys/audit.h>
757 #define crypt bigcrypt
758 #endif /* SecureWare */
759 #define SIGNAL_CAST (void (*)(int))
764 #define setuid(u) setreuid(u,-1)
765 #define seteuid(u) setreuid(-1,u)
768 #define ftruncate(f,l) syscall(0x0a28,f,l)
770 #define NO_INITGROUPS
772 #endif /* SCO3_2_2 */
775 #define HAVE_PATHCONF
781 /* Definitions for RiscIX */
783 #define SIGNAL_CAST (void (*)(int))
784 #include <sys/dirent.h>
785 #include <sys/acct.h>
790 #define HAVE_GETTIMEOFDAY
798 #include <net/errno.h>
802 #include <sys/statfs.h>
804 #include <sys/sioctl.h>
807 #include <netinet/tcp.h>
808 #define FIONREAD FIORDCHK
811 #define SIGNAL_CAST (void (*)(int))
831 #define SIGNAL_CAST (void (*)(int))
832 char *strdup (char *);
845 #define SIGNAL_CAST (void (*)(int))
846 char *strdup (char *);
857 #include <sys/statfs.h>
858 #include <sys/stropts.h>
859 #define NO_GET_BROADCAST
865 #define PF_INET AF_INET
867 #define ftruncate(f,l) chsize(f,l)
871 #include <netinet/tcp.h>
872 #include <arpa/inet.h>
877 #define DONT_REINSTALL_SIG
880 #define SIGNAL_CAST (_SigFunc_Ptr_t)
883 extern char *mktemp(char *);
884 extern int fsync(int);
885 extern int seteuid(uid_t);
886 extern int setgroups(int, int *);
887 extern int initgroups(char *, int);
888 extern int statfs(char *, struct statfs *);
889 extern int setegid(gid_t);
890 extern int getopt(int, char *const *, const char *);
891 extern int chroot(char *);
892 extern int gettimeofday(struct timeval *, struct timezone *);
893 extern int gethostname(char *, int);
894 extern char *crypt(char *, char *);
895 extern char *getpass(char *);
900 #define MAXPATHLEN 1024
904 #include <sys/statfs.h>
905 #define SIGNAL_CAST (void (*)(int))
906 #define SIGCLD_IGNORE
907 #define HAVE_FCNTL_LOCK 1
917 #include <sys/fcntl.h>
918 #include <sys/statfs.h>
923 #define ptrdiff_t int
924 #define HAVE_GETGRNAM 0
929 #define NO_INITGROUPS
937 #define REPLACE_MKTIME
938 #define REPLACE_RENAME
939 #define REPLACE_STRSTR
946 #include <sys/statfs.h>
947 #include <sys/select.h>
950 #define SIGNAL_CAST (void (*)())
952 #define NO_INITGROUPS
954 #define HAVE_TIMEZONE
957 #define HAVE_FCNTL_LOCK 1
958 #define DEFAULT_PRINTING PRINT_QNX
966 #include <sys/timeb.h>
972 #include <sys/statfs.h>
975 #define SIGNAL_CAST (void (*)())
976 #define HAVE_FCNTL_LOCK 0
978 #define NO_GET_BROADCAST
981 #define NO_INITGROUPS
986 #define strcasecmp stricmp
987 #define strncasecmp strnicmp
992 #define SIGNAL_CAST (void (*)())
993 #define WAIT3_CAST1 (union wait *)
996 #include <resource.h>
1000 #include <sys/statfs.h>
1007 #define SIGNAL_CAST (void (*)(int))
1009 #include <sys/dir.h>
1010 #include <sys/select.h>
1014 #include <sys/statfs.h>
1015 #include <sys/bsdioctl.h>
1019 #include <arpa/inet.h>
1022 #include <netinet/tcp.h>
1023 #include <sys/acct.h>
1024 #include <sys/fcntl.h>
1025 #include <sys/filio.h>
1026 #include <sys/sockio.h>
1027 #include <netinet/in_systm.h>
1028 #include <netinet/ip.h>
1029 #include <sys/termios.h>
1031 #include <sys/timeb.h>
1033 #define SIGNAL_CAST (void (*)(int))
1036 #define HAVE_MEMMOVE
1037 #define USE_SIGPROCMASK
1041 #define HAVE_FCNTL_LOCK 0
1042 #define HAVE_GETTIMEOFDAY
1043 #define HAVE_PATHCONF
1045 #define HAVE_NO_PROC
1046 #define NO_FORK_DEBUG
1048 #define HAVE_VFORK 1
1051 /* For UnixWare 2.x's ia_uinfo routines. (tangent@cyberport.com) */
1058 /*******************************************************************
1059 end of the platform specific sections
1060 ********************************************************************/
1062 #if defined(USE_MMAP) || defined(FAST_SHARE_MODES)
1063 #include <sys/mman.h>
1067 #define NEED_AUTH_PARAMETERS
1070 #ifdef REPLACE_GETPASS
1071 extern char *getsmbpass(char *);
1072 #define getpass(s) getsmbpass(s)
1075 #ifdef REPLACE_INNETGR
1076 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
1080 #define FD_SETSIZE 255
1087 /* Now for some other grungy stuff */
1089 struct spwd { /* fake shadow password structure */
1096 #define bzero(p,s) memset(p,0,s)
1100 #ifndef HAVE_MEMMOVE
1102 #define memmove(d,s,n) MemMove(d,s,n)
1107 #include <sys/dir.h>
1110 /* some unixes have ENOTTY instead of TIOCNOTTY */
1113 #define TIOCNOTTY ENOTTY
1121 /* if undefined then use bsd or sysv printing */
1122 #ifndef DEFAULT_PRINTING
1124 #define DEFAULT_PRINTING PRINT_SYSV
1126 #define DEFAULT_PRINTING PRINT_BSD
1130 /* This defines the name of the printcap file. It is MOST UNLIKELY that
1131 this will change BUT! Specifying a file with the format of a printcap
1132 file but containing only a subset of the printers actually in your real
1133 printcap file is a quick-n-dirty way to allow dynamic access to a subset
1134 of available printers.
1136 #ifndef PRINTCAP_NAME
1138 #define PRINTCAP_NAME "/etc/qconfig"
1140 #define PRINTCAP_NAME "lpstat"
1142 #define PRINTCAP_NAME "/etc/printcap"
1148 #include <sys/ipc.h>
1149 #include <sys/sem.h>
1150 #include <sys/shm.h>
1154 struct semid_ds *buf;
1155 unsigned short *array;
1158 #if defined(HPUX) && defined(HPUX10)
1162 #endif /* HPUX && HPUX10 */
1166 #include <afs/stds.h>
1167 #include <afs/kautils.h>
1171 #include <dce/dce_error.h>
1172 #include <dce/sec_login.h>
1197 extern char *sys_errlist[];
1198 #define strerror(i) sys_errlist[i]
1203 #define perror(m) printf("%s: %s\n",m,strerror(errno))
1206 #ifndef MAXHOSTNAMELEN
1207 #define MAXHOSTNAMELEN 255
1210 #include "version.h"
1212 #include "nameserv.h"
1213 #include "ubiqx/ubi_dLinkList.h"
1215 #include "byteorder.h"
1218 #include "charset.h"
1220 #ifndef MAXCODEPAGELINES
1221 #define MAXCODEPAGELINES 256
1224 /***** automatically generated prototypes *****/
1230 #define S_IFREG 0100000
1234 #define S_ISREG(x) ((S_IFREG & (x))!=0)
1238 #define S_ISDIR(x) ((S_IFDIR & (x))!=0)
1241 #if !defined(S_ISLNK) && defined(S_IFLNK)
1242 #define S_ISLNK(x) ((S_IFLNK & (x))!=0)
1246 #define crypt ufc_crypt
1249 #ifdef REPLACE_STRLEN
1250 #define strlen(s) Strlen(s)
1253 #ifdef REPLACE_STRSTR
1254 #define strstr(s,p) Strstr(s,p)
1257 #ifdef REPLACE_MKTIME
1258 #define mktime(t) Mktime(t)
1262 #define NGROUPS_MAX 128
1266 #define EDQUOT ENOSPC
1269 #ifndef HAVE_GETGRNAM
1270 #define HAVE_GETGRNAM 1
1277 /* default to using ftruncate workaround as this is safer than assuming
1278 it works and getting lots of bug reports */
1279 #ifndef FTRUNCATE_CAN_EXTEND
1280 #define FTRUNCATE_CAN_EXTEND 0
1283 /* maybe this unix doesn't separate RD and WR locks? */
1285 #define F_RDLCK F_WRLCK
1289 #define ENOTSOCK EINVAL
1293 #define SIGCLD SIGCHLD
1300 #ifndef HAVE_FCNTL_LOCK
1301 #define HAVE_FCNTL_LOCK 1
1305 #define WAIT3_CAST2 (struct rusage *)
1309 #define WAIT3_CAST1 (int *)
1313 #define QSORT_CAST (int (*)())
1316 #ifndef INADDR_LOOPBACK
1317 #define INADDR_LOOPBACK 0x7f000001
1318 #endif /* INADDR_LOOPBACK */
1320 /* this is a rough check to see if this machine has a lstat() call.
1321 it is not guaranteed to work */
1322 #if !defined(S_ISLNK)
1326 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1333 #define geteuid() getuid()
1334 #define getegid() getgid()
1335 #define seteuid(x) setuid(x)
1336 #define setegid(x) setgid(x)
1340 #if (HAVE_FCNTL_LOCK == 0)
1341 /* since there is no locking available, system includes */
1342 /* for DomainOS 10.4 do not contain any of the following */
1343 /* #define's. So, to satisfy the compiler, add these */
1344 /* #define's, although they arn't really necessary. */
1349 #endif /* HAVE_FCNTL_LOCK == 0 */
1352 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1353 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1357 #define strcpy(dest,src) StrCpy(dest,src)
1361 #include "mem_man/mem_man.h"