4 Unix SMB/Netbios implementation.
6 Machine customisation and include handling
7 Copyright (C) Andrew Tridgell 1994-1995
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>
142 #include <sys/ioctl.h>
145 #include <posix/utime.h>
146 #include <bsd/sys/time.h>
147 #include <bsd/netinet/in.h>
149 #include <sys/time.h>
150 #include <netinet/in.h>
155 #include <sys/file.h>
156 #include <sys/stat.h>
157 #include <sys/param.h>
160 #include <sys/resource.h>
163 #include <sys/mount.h>
174 #include <sys/wait.h>
176 #include <sys/stream.h>
180 #include <bsd/net/if.h>
187 #include <sys/mman.h>
190 #if defined(GETPWANAM)
191 #include <sys/types.h>
192 #include <sys/label.h>
193 #include <sys/audit.h>
197 #if defined(SHADOW_PWD) && !defined(NETBSD) && !defined(CONVEX)
201 /* this might be different on different systems */
206 #include <sys/quota.h>
209 #include <sys/quota.h>
213 #include <sys/quota.h>
228 /***************************************************************************
229 Here come some platform specific sections
230 ***************************************************************************/
234 #include <arpa/inet.h>
238 #include <netinet/in.h>
239 #ifndef NO_ASMSIGNALH
240 #include <asm/signal.h>
242 #define SIGNAL_CAST (__sighandler_t)
249 #define crypt pw_encrypt
255 #define SIGNAL_CAST (void (*)(int))
256 #include <netinet/tcp.h>
258 #include <sys/acct.h>
262 #include <sys/wait.h>
264 /* #include <termios.h> */
268 #define mktime timelocal
269 typedef unsigned short mode_t;
274 #define REPLACE_GETPASS
282 #include <sys/acct.h>
283 #include <sys/statfs.h>
284 #include <sys/statvfs.h>
285 #include <sys/filio.h>
286 #include <sys/sockio.h>
287 #include <netinet/in_systm.h>
288 #include <netinet/tcp.h>
289 #include <netinet/ip.h>
291 #include <arpa/inet.h>
292 #include <rpcsvc/ypclnt.h>
295 extern int gettimeofday (struct timeval *, void *);
296 extern int gethostname (char *name, int namelen);
297 extern int innetgr (const char *, const char *, const char *, const char *);
299 #define SIGNAL_CAST (void (*)(int))
304 #define REPLACE_STRLEN
308 #define REPLACE_GETPASS
314 #include <nfs/nfs_clnt.h>
316 #include <netinet/tcp.h>
323 #define SIGNAL_CAST (void(*)(int))
329 #include <netinet/tcp.h>
330 #include <sys/statfs.h>
336 #define SIGNAL_CAST (void (*)())
343 #include <netinet/tcp.h>
344 #include <sys/statvfs.h>
353 #define SIGNAL_CAST (void (*)())
360 #include <bsd/net/soioctl.h>
364 #include <sys/statfs.h>
365 #include <sys/wait.h>
366 #include <sys/termio.h>
367 #define SIGNAL_CAST (void (*)())
369 extern struct group *getgrnam();
370 extern struct passwd *getpwnam();
373 #define REPLACE_STRSTR
381 #include <sys/statfs.h>
382 #include <sys/statvfs.h>
387 #define SIGNAL_CAST (void (*)(int))
397 #include <sys/statfs.h>
398 #include <sys/statvfs.h>
400 #include <sys/filio.h>
402 #include <sys/sockio.h>
403 #include <netinet/tcp.h>
408 #define SIGNAL_CAST (void (*)(int))
420 char *mktemp(char *); /* No standard include */
421 #include <netinet/in.h>
422 #include <arpa/inet.h> /* both for inet_ntoa */
423 #define SIGNAL_CAST ( void (*) (int) )
426 #include <netinet/tcp.h>
429 #include <sys/types.h>
430 #include <sys/security.h>
433 #define PASSWORD_LENGTH 16
434 #define NEED_AUTH_PARAMETERS
435 #endif /* OSF1_ENH_SEC */
441 #define SIGNAL_CAST (void (*)())
442 #include <sys/fcntl.h>
443 #include <sys/statfs.h>
451 #define REPLACE_GETPASS
459 #include <netinet/tcp.h>
460 #define SIGNAL_CAST (void (*)())
467 #include <netinet/tcp.h>
468 /* you may not need this */
470 #define SIGNAL_CAST (void (*)())
472 #define REPLACE_INNETGR
479 #include <netinet/tcp.h>
480 #include <netinet/in_systm.h>
481 #include <netinet/ip.h>
482 #define SIGNAL_CAST (void (*)())
491 #include <sys/select.h>
493 #include <sys/statfs.h>
496 #include <sys/priv.h>
497 #include <netinet/tcp.h>
500 #define SIGNAL_CAST (void (*)())
501 #define DEFAULT_PRINTING PRINT_AIX
510 #include <sys/types.h>
511 #include <sys/termios.h>
512 #include <netinet/tcp.h>
513 #ifdef HPUX_10_TRUSTED
514 #include <hpsecurity.h>
516 #define NEED_AUTH_PARAMETERS
518 #define SIGNAL_CAST (void (*)(__harg))
519 #define SELECT_CAST (int *)
522 #define WAIT3_CAST2 (int *)
526 #define DEFAULT_PRINTING PRINT_HPUX
527 #define SIGCLD_IGNORE
535 #include <sys/types.h>
536 #include <sys/statfs.h>
537 #include <sys/stat.h>
539 #include <sys/socket.h>
542 #define SIGNAL_CAST (void (*)(int))
554 #include <sys/statfs.h>
555 #include <sys/statvfs.h>
558 #include <sys/sockio.h>
559 #include <netinet/tcp.h>
564 #define SIGNAL_CAST (void (*)(int))
568 #define seteuid(uid) setreuid(-1,uid)
571 #define setegid(gid) setregid(-1,gid)
577 #include <sys/types.h>
581 #define bzero(b,len) memset(b,0,len)
595 #define bzero(b,len) memset(b,0,len)
603 #define SIGNAL_CAST (void (*)(int))
604 #define WAIT3_CAST1 (union wait *)
613 #include <sys/statfs.h>
617 #define SIGNAL_CAST (void (*)())
618 #define HAVE_FCNTL_LOCK 0
619 #define HAVE_GETTIMEOFDAY
626 #include <sys/netinet/tcp.h>
627 #include <sys/netinet/in_systm.h>
628 #include <sys/netinet/ip.h>
632 #include <sys/statfs.h>
633 #include <sys/stropts.h>
639 #include <rpcsvc/ypclnt.h>
642 #include <sys/security.h>
643 #include <sys/audit.h>
645 #define crypt bigcrypt
648 #define ftruncate(f,l) syscall(0x0a28,f,l)
650 #define SIGNAL_CAST (void (*)(int))
664 #define NO_INITGROUPS
666 #define HAVE_PATHCONF
672 /* Definitions for RiscIX */
674 #define SIGNAL_CAST (void (*)(int))
675 #include <sys/dirent.h>
676 #include <sys/acct.h>
681 #define HAVE_GETTIMEOFDAY
689 #include <net/errno.h>
693 #include <sys/statfs.h>
695 #include <sys/sioctl.h>
698 #include <netinet/tcp.h>
699 #define FIONREAD FIORDCHK
702 #define SIGNAL_CAST (void (*)(int))
722 #define SIGNAL_CAST (void (*)(int))
723 char *strdup (char *);
736 #define SIGNAL_CAST (void (*)(int))
737 char *strdup (char *);
748 #include <sys/statfs.h>
749 #include <sys/stropts.h>
750 #define NO_GET_BROADCAST
756 #define PF_INET AF_INET
758 #define ftruncate(f,l) chsize(f,l)
762 #include <netinet/tcp.h>
763 #include <arpa/inet.h>
768 #define DONT_REINSTALL_SIG
771 #define SIGNAL_CAST (_SigFunc_Ptr_t)
774 extern char *mktemp(char *);
775 extern int fsync(int);
776 extern int seteuid(uid_t);
777 extern int setgroups(int, int *);
778 extern int initgroups(char *, int);
779 extern int statfs(char *, struct statfs *);
780 extern int setegid(gid_t);
781 extern int getopt(int, char *const *, const char *);
782 extern int chroot(char *);
783 extern int gettimeofday(struct timeval *, struct timezone *);
784 extern int gethostname(char *, int);
785 extern char *crypt(char *, char *);
786 extern char *getpass(char *);
791 #define MAXPATHLEN 1024
795 #include <sys/statfs.h>
796 #define SIGNAL_CAST (void (*)(int))
797 #define SIGCLD_IGNORE
798 #define HAVE_FCNTL_LOCK 1
808 #include <sys/fcntl.h>
809 #include <sys/statfs.h>
814 #define ptrdiff_t int
815 #define HAVE_GETGRNAM 0
820 #define NO_INITGROUPS
828 #define REPLACE_MKTIME
829 #define REPLACE_RENAME
830 #define REPLACE_STRSTR
837 #include <sys/statfs.h>
838 #include <sys/select.h>
841 #define SIGNAL_CAST (void (*)())
843 #define NO_INITGROUPS
845 #define HAVE_TIMEZONE
848 #define HAVE_FCNTL_LOCK 1
849 #define DEFAULT_PRINTING PRINT_QNX
857 #include <sys/timeb.h>
863 #include <sys/statfs.h>
866 #define SIGNAL_CAST (void (*)())
867 #define HAVE_FCNTL_LOCK 0
869 #define NO_GET_BROADCAST
872 #define NO_INITGROUPS
877 #define strcasecmp stricmp
878 #define strncasecmp strnicmp
883 #define SIGNAL_CAST (void (*)())
884 #define WAIT3_CAST1 (union wait *)
887 #include <resource.h>
891 #include <sys/statfs.h>
897 /*******************************************************************
898 end of the platform specific sections
899 ********************************************************************/
902 #define NEED_AUTH_PARAMETERS
905 #ifdef REPLACE_GETPASS
906 extern char *getsmbpass(char *);
907 #define getpass(s) getsmbpass(s)
910 #ifdef REPLACE_INNETGR
911 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
915 #define FD_SETSIZE 255
919 #define MAXINT ((((unsigned)1)<<(sizeof(int)*8-1))-1)
926 /* Now for some other grungy stuff */
928 struct spwd { /* fake shadow password structure */
935 #define bzero(p,s) memset(p,0,s)
941 #define memmove(d,s,n) MemMove(d,s,n)
949 /* some unixes have ENOTTY instead of TIOCNOTTY */
952 #define TIOCNOTTY ENOTTY
960 /* if undefined then use bsd or sysv printing */
961 #ifndef DEFAULT_PRINTING
963 #define DEFAULT_PRINTING PRINT_SYSV
965 #define DEFAULT_PRINTING PRINT_BSD
971 #include <afs/stds.h>
972 #include <afs/kautils.h>
976 #include <dce/dce_error.h>
977 #include <dce/sec_login.h>
989 extern char *sys_errlist[];
990 #define strerror(i) sys_errlist[i]
995 #define perror(m) printf("%s: %s\n",m,strerror(errno))
998 #ifndef MAXHOSTNAMELEN
999 #define MAXHOSTNAMELEN 255
1002 #include "version.h"
1004 #include "byteorder.h"
1006 #include "smbpass.h"
1010 #include "charset.h"
1013 #define S_IFREG 0100000
1017 #define S_ISREG(x) ((S_IFREG & x)!=0)
1021 #define S_ISDIR(x) ((S_IFDIR & x)!=0)
1025 #define crypt ufc_crypt
1028 #ifdef REPLACE_STRLEN
1029 #define strlen(s) Strlen(s)
1032 #ifdef REPLACE_STRSTR
1033 #define strstr(s,p) Strstr(s,p)
1036 #ifdef REPLACE_MKTIME
1037 #define mktime(t) Mktime(t)
1041 #define NGROUPS_MAX 128
1045 #define EDQUOT ENOSPC
1048 #ifndef HAVE_GETGRNAM
1049 #define HAVE_GETGRNAM 1
1056 /* default to using ftruncate workaround as this is safer than assuming
1057 it works and getting lots of bug reports */
1058 #ifndef FTRUNCATE_CAN_EXTEND
1059 #define FTRUNCATE_CAN_EXTEND 0
1062 /* maybe this unix doesn't separate RD and WR locks? */
1064 #define F_RDLCK F_WRLCK
1068 #define ENOTSOCK EINVAL
1072 #define SIGCLD SIGCHLD
1075 #ifndef HAVE_FCNTL_LOCK
1076 #define HAVE_FCNTL_LOCK 1
1080 #define WAIT3_CAST2 (struct rusage *)
1084 #define WAIT3_CAST1 (int *)
1088 #define QSORT_CAST (int (*)())
1091 /* this is a rough check to see if this machine has a lstat() call.
1092 it is not guaranteed to work */
1093 #if !(defined(S_ISLNK) || defined(S_IFLNK))
1097 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1104 #define geteuid() getuid()
1105 #define getegid() getgid()
1106 #define seteuid(x) setuid(x)
1107 #define setegid(x) setgid(x)
1111 #if (HAVE_FCNTL_LOCK == 0)
1112 /* since there is no locking available, system includes */
1113 /* for DomainOS 10.4 do not contain any of the following */
1114 /* #define's. So, to satisfy the compiler, add these */
1115 /* #define's, although they arn't really necessary. */
1120 #endif /* HAVE_FCNTL_LOCK == 0 */
1123 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1124 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1128 #define strcpy(dest,src) StrCpy(dest,src)
1132 /* possibly wrap the malloc calls */
1135 /* undo the old malloc def if necessary */
1137 #define xx_old_malloc malloc
1141 #define malloc(size) malloc_wrapped(size,__FILE__,__LINE__)
1143 /* undo the old realloc def if necessary */
1145 #define xx_old_realloc realloc
1149 #define realloc(ptr,size) realloc_wrapped(ptr,size,__FILE__,__LINE__)
1151 /* undo the old free def if necessary */
1153 #define xx_old_free free
1157 #define free(ptr) free_wrapped(ptr,__FILE__,__LINE__)
1159 /* and the malloc prototypes */
1160 void *malloc_wrapped(int,char *,int);
1161 void *realloc_wrapped(void *,int,char *,int);
1162 void free_wrapped(void *,char *,int);
1168 /* undo the old memcpy def if necessary */
1170 #define xx_old_memcpy memcpy
1174 #define memcpy(d,s,l) memcpy_wrapped(d,s,l,__FILE__,__LINE__)
1175 void *memcpy_wrapped(void *d,void *s,int l,char *fname,int line);