Makefile: Changes to split Solaris into Solaris2.3 and previous, and 2.4 and after...
[samba.git] / source / include / includes.h
1 #ifndef _INCLUDES_H
2 #define _INCLUDES_H
3 /* 
4    Unix SMB/Netbios implementation.
5    Version 1.9.
6    Machine customisation and include handling
7    Copyright (C) Andrew Tridgell 1994-1995
8    
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.
13    
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.
18    
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.
22 */
23 /*
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.
27 */
28
29
30 /* the first OS dependent section is to setup what includes will be used.
31    the main OS dependent section comes later on 
32 */
33
34 #ifdef ALTOS
35 #define NO_UTIMEH
36 #endif
37
38 #ifdef MIPS
39 #define POSIX_H
40 #define NO_UTIMEH
41 #endif
42
43 #ifdef sun386
44 #define NO_UTIMEH
45 #endif
46
47 #ifdef NEXT2
48 #define NO_UTIMEH
49 #endif
50
51 #ifdef NEXT3_0
52 #define NO_UTIMEH
53 #define NO_UNISTDH
54 #endif
55
56 #ifdef APOLLO
57 #define NO_UTIMEH
58 #define NO_SYSMOUNTH
59 #define NO_UNISTDH
60 #endif
61
62 #ifdef AIX
63 #define NO_SYSMOUNTH
64 #endif
65
66 #ifdef M88K_R3
67 #define SVR3H
68 #define NO_RESOURCEH
69 #endif
70
71 #ifdef DNIX
72 #define NO_SYSMOUNTH
73 #define NO_NETIFH
74 #define NO_RESOURCEH
75 #define PRIME_NMBD 0
76 #define NO_SETGROUPS
77 #endif
78
79
80 #ifdef ISC
81 #define SYSSTREAMH
82 #define NO_RESOURCEH
83 #endif
84
85 #ifdef QNX
86 #define NO_RESOURCEH
87 #define NO_SYSMOUNTH
88 #define USE_MMAP 1
89 #ifdef __386__
90    #define __i386__
91 #endif
92 #endif
93
94 #ifdef NEWS42
95 #define NO_UTIMEH
96 #define NO_STRFTIME
97 #define NO_UTIMBUF
98 #define REPLACE_MKTIME
99 #define NO_TM_NAME
100 #endif
101
102 #ifdef OS2
103 #define NO_SYSMOUNTH
104 #define NO_NETIFH
105 #endif
106
107 #ifdef LYNX
108 #define NO_SYSMOUNTH
109 #endif
110
111
112 #if (defined(SHADOW_PWD)||defined(OSF1_ENH_SEC)||defined(SecureWare)||defined(PWDAUTH))
113 #define PASSWORD_LENGTH 16
114 #endif
115
116 /* here is the general includes section - with some ifdefs generated 
117    by the previous section 
118 */
119 #include "local.h"
120 #include <stdio.h>
121 #ifdef POSIX_STDLIBH
122 #include <posix/stdlib.h>
123 #else
124 #include <stdlib.h>
125 #endif
126 #include <ctype.h>
127 #include <time.h>
128 #ifndef NO_UTIMEH
129 #include <utime.h>
130 #endif
131 #include <sys/types.h>
132
133 #ifdef SVR3H
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>
139 #endif
140
141 #include <sys/socket.h>
142 #ifdef AXPROC
143 #include <termio.h>
144 #endif
145 #include <sys/ioctl.h>
146 #include <stddef.h>
147 #ifdef POSIX_H
148 #include <posix/utime.h>
149 #include <bsd/sys/time.h>
150 #include <bsd/netinet/in.h>
151 #else
152 #include <sys/time.h>
153 #include <netinet/in.h>
154 #endif 
155 #include <netdb.h>
156 #include <signal.h>
157 #include <errno.h>
158 #include <sys/file.h>
159 #include <sys/stat.h>
160 #include <sys/param.h>
161 #include <grp.h>
162 #ifndef NO_RESOURCEH
163 #include <sys/resource.h>
164 #endif
165 #ifndef NO_SYSMOUNTH
166 #include <sys/mount.h>
167 #endif
168 #include <pwd.h>
169 #ifdef __STDC__
170 #include <stdarg.h>
171 #else
172 #include <varargs.h>
173 #endif
174 #ifndef NO_UNISTDH
175 #include <unistd.h>
176 #endif
177 #include <sys/wait.h>
178 #ifdef SYSSTREAMH
179 #include <sys/stream.h>
180 #endif
181 #ifndef NO_NETIFH
182 #ifdef POSIX_H
183 #include <bsd/net/if.h>
184 #else
185 #include <net/if.h>
186 #endif
187 #endif
188
189 #if defined(GETPWANAM)
190 #include <sys/types.h>
191 #include <sys/label.h>
192 #include <sys/audit.h>
193 #include <pwdadj.h>
194 #endif
195
196 #if defined(SHADOW_PWD) && !defined(NETBSD) && !defined(FreeBSD) && !defined(CONVEX)
197 #include <shadow.h>
198 #endif
199
200 #ifdef SYSLOG
201 #include <syslog.h>
202 #endif
203
204
205
206 /***************************************************************************
207 Here come some platform specific sections
208 ***************************************************************************/
209
210
211 #ifdef LINUX
212 #include <arpa/inet.h>
213 #include <dirent.h>
214 #include <string.h>
215 #include <sys/vfs.h>
216 #include <netinet/in.h>
217 #ifndef NO_ASMSIGNALH
218 #include <asm/signal.h>
219 #endif
220 #define SIGNAL_CAST (__sighandler_t)
221 #define USE_GETCWD
222 #define USE_SETSID
223 #define HAVE_BZERO
224 #define HAVE_MEMMOVE
225 #define USE_SIGPROCMASK
226 #define USE_WAITPID
227 #if 0
228 /* SETFS disabled until we can check on some bug reports */
229 #if _LINUX_C_LIB_VERSION_MAJOR >= 5
230 #define USE_SETFS
231 #endif
232 #endif
233 #ifdef SHADOW_PWD
234 #if _LINUX_C_LIB_VERSION_MAJOR < 5
235 #ifndef crypt
236 #define crypt pw_encrypt
237 #endif
238 #endif
239 #endif
240 #endif
241
242 #ifdef SUNOS4
243 #define SIGNAL_CAST (void (*)(int))
244 #include <netinet/tcp.h>
245 #include <dirent.h>
246 #include <sys/acct.h>
247 #include <sys/vfs.h>
248 #include <string.h>
249 #include <errno.h>
250 #include <sys/wait.h>
251 #include <signal.h>
252 /* #include <termios.h> */
253 #ifdef sun386
254 #define NO_STRFTIME
255 #define NO_UTIMBUF
256 #define mktime timelocal
257 typedef unsigned short mode_t;
258 #else
259 #include <utime.h>
260 #define NO_STRERROR
261 #endif
262 #ifndef REPLACE_GETPASS
263 #define REPLACE_GETPASS
264 #endif
265 #ifndef BSD_TERMIO
266 #define BSD_TERMIO
267 #endif
268 #ifndef USE_SIGPROCMASK
269 #define USE_SIGPROCMASK
270 #endif
271 #ifndef USE_WAITPID
272 #define USE_WAITPID
273 #endif
274 /* SunOS doesn't have POSIX atexit */
275 #define atexit on_exit
276 #endif
277
278
279 #ifdef SUNOS5
280 #include <fcntl.h>
281 #include <dirent.h>
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>
290 #include <string.h>
291 #include <arpa/inet.h>
292 #include <rpcsvc/ypclnt.h>
293 #include <crypt.h> 
294 #include <termios.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 *);
298 #define USE_SETVBUF
299 #define SIGNAL_CAST (void (*)(int))
300 #ifndef SYSV
301 #define SYSV
302 #endif
303 #define USE_WAITPID
304 #define REPLACE_STRLEN
305 #define USE_STATVFS
306 #define USE_GETCWD
307 #define USE_SETSID
308 #define REPLACE_GETPASS
309 #define USE_SIGPROCMASK
310 #endif
311
312
313 #ifdef ULTRIX
314 #include <strings.h>
315 #include <nfs/nfs_clnt.h>
316 #include <nfs/vfs.h>
317 #include <netinet/tcp.h>
318 #ifdef ULTRIX_AUTH
319 #include <auth.h>
320 #endif
321 char *getwd(char *);
322 #define NOSTRDUP
323 #ifdef __STDC__
324 #define SIGNAL_CAST (void(*)(int))
325 #endif
326 #define USE_DIRECT
327 #define USE_WAITPID
328 #endif
329
330 #ifdef SGI
331 #include <netinet/tcp.h>
332 #include <sys/statfs.h>
333 #include <string.h>
334 #include <signal.h>
335 #ifndef SYSV
336 #define SYSV
337 #endif
338 #define SIGNAL_CAST (void (*)())
339 #define STATFS4
340 #define USE_WAITPID
341 #define USE_DIRECT
342 #endif
343
344 #ifdef SGI5
345 #include <netinet/tcp.h>
346 #include <sys/statvfs.h>
347 #include <string.h>
348 #include <signal.h>
349 #include <dirent.h>
350 #define USE_WAITPID
351 #define NETGROUP 
352 #ifndef SYSV
353 #define SYSV
354 #endif
355 #define SIGNAL_CAST (void (*)())
356 #define USE_STATVFS
357 #define USE_WAITPID
358 #endif
359
360
361 #ifdef MIPS
362 #include <bsd/net/soioctl.h>
363 #include <string.h>
364 #include <dirent.h>
365 #include <fcntl.h>
366 #include <sys/statfs.h>
367 #include <sys/wait.h>
368 #include <sys/termio.h>
369 #define SIGNAL_CAST (void (*)())
370 typedef int mode_t;
371 extern struct group *getgrnam();
372 extern struct passwd *getpwnam();
373 #define STATFS4
374 #define NO_STRERROR
375 #define REPLACE_STRSTR
376 #endif /* MIPS */
377
378
379
380 #ifdef DGUX
381 #include <string.h>
382 #include <dirent.h>
383 #include <sys/statfs.h>
384 #include <sys/statvfs.h>
385 #include <fcntl.h>
386 #include <termios.h>
387 #define SYSV
388 #define USE_WAITPID
389 #define SIGNAL_CAST (void (*)(int))
390 #define STATFS4
391 #define USE_GETCWD
392 #endif
393
394
395 #ifdef SVR4
396 #include <string.h>
397 #include <sys/dir.h>
398 #include <dirent.h>
399 #include <sys/statfs.h>
400 #include <sys/statvfs.h>
401 #include <sys/vfs.h>
402 #include <sys/filio.h>
403 #include <fcntl.h>
404 #include <sys/sockio.h>
405 #include <netinet/tcp.h>
406 #include <stropts.h>
407 #include <termios.h>
408 #define SYSV
409 #define USE_WAITPID
410 #define SIGNAL_CAST (void (*)(int))
411 #define USE_STATVFS
412 #define USE_GETCWD
413 #define USE_SETSID
414 #endif
415
416
417 #ifdef OSF1
418 #include <termios.h>
419 #include <strings.h>
420 #include <dirent.h>
421 char *getwd(char *);
422 char *mktemp(char *); /* No standard include */
423 #include <netinet/in.h>
424 #include <arpa/inet.h> /* both for inet_ntoa */
425 #define SIGNAL_CAST ( void (*) (int) )
426 #define STATFS3
427 #define USE_F_FSIZE
428 #include <netinet/tcp.h>
429 #ifdef OSF1_ENH_SEC
430 #include <pwd.h>
431 #include <sys/types.h>
432 #include <sys/security.h>
433 #include <prot.h>
434 #include <unistd.h>
435 #define PASSWORD_LENGTH 16
436 #define NEED_AUTH_PARAMETERS
437 #endif  /* OSF1_ENH_SEC */
438 #endif
439
440
441 #ifdef CLIX
442 #include <dirent.h>
443 #define SIGNAL_CAST     (void (*)())
444 #include <sys/fcntl.h>
445 #include <sys/statfs.h>
446 #include <string.h>
447 #define NO_EID
448 #define USE_WAITPID
449 #define STATFS4
450 #define NO_FSYNC
451 #define USE_GETCWD
452 #define USE_SETSID
453 #define REPLACE_GETPASS
454 #define NO_GETRLIMIT
455 #endif  /* CLIX */
456
457
458
459 #ifdef BSDI
460 #include <string.h>
461 #include <netinet/tcp.h>
462 #define SIGNAL_CAST (void (*)())
463 #define USE_DIRECT
464 #endif
465
466
467 #ifdef NETBSD
468 #include <strings.h>
469 #include <netinet/tcp.h>
470 /* you may not need this */
471 #define NO_GETSPNAM
472 #define SIGNAL_CAST (void (*)())
473 #define USE_DIRECT
474 #define REPLACE_INNETGR
475 #endif 
476
477
478
479 #ifdef FreeBSD
480 #include <strings.h>
481 #include <netinet/tcp.h>
482 #include <netinet/in_systm.h>
483 #include <netinet/ip.h>
484 #define SIGNAL_CAST (void (*)())
485 #define USE_SETVBUF
486 #define USE_SETSID
487 #define USE_GETCWD
488 #define USE_WAITPID
489 #define USE_DIRECT
490 #define HAVE_MEMMOVE
491 #define HAVE_BZERO
492 #define HAVE_GETTIMEOFDAY
493 #define HAVE_PATHCONF
494 #define HAVE_GETGRNAM 1
495 #endif 
496
497
498
499 #ifdef AIX
500 #include <strings.h>
501 #include <sys/dir.h>
502 #include <sys/select.h>
503 #include <dirent.h>
504 #include <sys/statfs.h>
505 #include <sys/vfs.h>
506 #include <sys/id.h>
507 #include <sys/priv.h>
508 #include <netinet/tcp.h>
509 #include <locale.h>
510 #define SYSV
511 #define USE_WAITPID
512 #define USE_SIGBLOCK
513 #define SIGNAL_CAST (void (*)())
514 #define DEFAULT_PRINTING PRINT_AIX
515 /* we undef this because sys/param.h is broken in aix. uggh. */
516 #undef MAXHOSTNAMELEN
517 #endif
518
519
520 #ifdef HPUX
521 #include <string.h>
522 #include <dirent.h>
523 #include <fcntl.h>
524 #include <sys/vfs.h>
525 #include <sys/types.h>
526 #include <sys/termios.h>
527 #include <netinet/tcp.h>
528 #ifdef HPUX_10_TRUSTED
529 #include <hpsecurity.h>
530 #include <prot.h>
531 #define NEED_AUTH_PARAMETERS
532 #endif
533 #define SIGNAL_CAST (void (*)(__harg))
534 #define SELECT_CAST (int *)
535 #define SYSV
536 #define USE_WAITPID
537 #define WAIT3_CAST2 (int *)
538 #define USE_GETCWD
539 #define USE_SETSID
540 #define USE_SETRES
541 #define DEFAULT_PRINTING PRINT_HPUX
542 #define SIGCLD_IGNORE
543 #endif
544
545
546 #ifdef SEQUENT
547 #include <signal.h>
548 #include <string.h>
549 #include <dirent.h>
550 #include <sys/types.h>
551 #include <sys/statfs.h>
552 #include <sys/stat.h>
553 #include <sys/buf.h>
554 #include <sys/socket.h>
555 #include <unistd.h>
556 #include <fcntl.h>
557 #define SIGNAL_CAST (void (*)(int))
558 #define USE_WAITPID
559 #define USE_GETCWD
560 #define NO_EID
561 #define STATFS4
562 #define USE_DIRECT
563 #ifdef PTX4
564 #undef USE_DIRECT
565 #endif
566 #endif
567
568
569
570 #ifdef SEQUENT_PTX4
571 #include <string.h>
572 #include <sys/dir.h>
573 #include <dirent.h>
574 #include <sys/statfs.h>
575 #include <sys/statvfs.h>
576 #include <sys/vfs.h>
577 #include <fcntl.h>
578 #include <sys/sockio.h>
579 #include <netinet/tcp.h>
580 #include <stropts.h>
581 #include <termios.h>
582 #define SYSV
583 #define USE_WAITPID
584 #define SIGNAL_CAST (void (*)(int))
585 #define USE_STATVFS
586 #define USE_GETCWD
587 #ifndef seteuid
588 #define seteuid(uid) setreuid(-1,uid)
589 #endif
590 #ifndef setegid
591 #define setegid(gid) setregid(-1,gid)
592 #endif
593 #endif
594
595
596 #ifdef NEXT2
597 #include <sys/types.h>
598 #include <strings.h>
599 #include <dirent.h>
600 #include <sys/vfs.h>
601 #define bzero(b,len) memset(b,0,len)
602 #define mode_t int
603 #define NO_UTIMBUF
604 #include <libc.h>
605 #define NOSTRDUP
606 #define USE_DIRECT
607 #define USE_WAITPID
608 #endif 
609
610
611 #ifdef NEXT3_0
612 #include <strings.h>
613 #include <sys/dir.h>
614 #include <sys/vfs.h>
615 #define bzero(b,len) memset(b,0,len)
616 #define NO_UTIMBUF
617 #include <libc.h>
618 #define NOSTRDUP
619 #define USE_DIRECT
620 #define mode_t int
621 #define GID_TYPE int
622 #define gid_t int
623 #define pid_t int
624 #define SIGNAL_CAST (void (*)(int))
625 #define WAIT3_CAST1 (union wait *)
626 #define HAVE_GMTOFF
627 #endif
628
629
630
631 #ifdef APOLLO
632 #include <string.h>
633 #include <fcntl.h>
634 #include <sys/statfs.h>
635 #define NO_UTIMBUF
636 #define USE_DIRECT
637 #define USE_GETCWD
638 #define SIGNAL_CAST     (void (*)())
639 #define HAVE_FCNTL_LOCK 0
640 #define HAVE_GETTIMEOFDAY
641 #define STATFS4
642 #endif
643
644
645
646 #ifdef SCO
647 #include <sys/netinet/tcp.h>
648 #include <sys/netinet/in_systm.h>
649 #include <sys/netinet/ip.h>
650 #include <dirent.h>
651 #include <string.h>
652 #include <fcntl.h>
653 #include <sys/statfs.h>
654 #include <sys/stropts.h>
655 #include <limits.h>
656 #include <locale.h>
657 #ifdef EVEREST
658 #include <unistd.h> 
659 #endif
660 #ifdef NETGROUP
661 #include <rpcsvc/ypclnt.h>
662 #endif
663 #ifdef SecureWare
664 #include <sys/security.h>
665 #include <sys/audit.h>
666 #include <prot.h>
667 #define crypt bigcrypt
668 #endif
669 #ifndef EVEREST
670  #define ftruncate(f,l) syscall(0x0a28,f,l)
671 #endif 
672 #define SIGNAL_CAST (void (*)(int))
673 #define USE_WAITPID
674 #define USE_GETCWD
675 #define USE_SETSID
676 #ifdef SCO3_2_2
677 #define NO_EID
678 #else
679 #ifndef EVEREST
680 #define USE_IFREQ
681 #endif
682 #endif
683 #define STATFS4
684 #define NO_FSYNC
685 #ifndef EVEREST
686 #define NO_INITGROUPS
687 #endif
688 #define HAVE_PATHCONF
689 #define NO_GETRLIMIT
690 #endif
691
692
693
694 /* Definitions for RiscIX */
695 #ifdef RiscIX
696 #define SIGNAL_CAST (void (*)(int))
697 #include <sys/dirent.h>
698 #include <sys/acct.h>
699 #include <sys/vfs.h>
700 #include <string.h>
701 #include <utime.h>
702 #include <signal.h>
703 #define HAVE_GETTIMEOFDAY
704 #define NOSTRCASECMP
705 #define NOSTRDUP
706 #endif
707
708
709
710 #ifdef ISC
711 #include <net/errno.h>
712 #include <string.h>
713 #include <sys/dir.h>
714 #include <dirent.h>
715 #include <sys/statfs.h>
716 #include <fcntl.h>
717 #include <sys/sioctl.h>
718 #include <stropts.h>
719 #include <limits.h>
720 #include <netinet/tcp.h>
721 #define FIONREAD FIORDCHK
722 #define SYSV
723 #define USE_WAITPID
724 #define SIGNAL_CAST (void (*)(int))
725 #define USE_GETCWD
726 #define USE_SETSID
727 #define USE_IFREQ
728 #define NO_FTRUNCATE
729 #define STATFS4
730 #define NO_FSYNC
731 #endif
732
733
734
735 #ifdef AUX
736 #include <fstab.h>
737 #include <string.h>
738 #include <dirent.h>
739 #include <sys/vfs.h>
740 #include <fcntl.h>
741 #include <termios.h>
742 #define SYSV
743 #define USE_WAITPID
744 #define SIGNAL_CAST (void (*)(int))
745 char *strdup (char *);
746 #define USE_GETCWD
747 #endif
748
749
750 #ifdef M88K_R3
751 #include <string.h>
752 #include <dirent.h>
753 #include <fcntl.h>
754 #include <termios.h>
755 #define STATFS4
756 #define SYSV
757 #define USE_WAITPID
758 #define SIGNAL_CAST (void (*)(int))
759 char *strdup (char *);
760 #define USE_GETCWD
761 #define NO_FSYNC
762 #define NO_EID
763 #endif
764
765
766 #ifdef DNIX
767 #include <dirent.h>
768 #include <string.h>
769 #include <fcntl.h>
770 #include <sys/statfs.h>
771 #include <sys/stropts.h>
772 #define NO_GET_BROADCAST
773 #define USE_WAITPID
774 #define USE_GETCWD
775 #define USE_SETSID
776 #define STATFS4
777 #define NO_EID
778 #define PF_INET AF_INET
779 #define NO_STRERROR
780 #define ftruncate(f,l) chsize(f,l)
781 #endif /* DNIX */
782
783 #ifdef CONVEX
784 #include <netinet/tcp.h>
785 #include <arpa/inet.h>
786 #include <dirent.h>
787 #include <string.h>
788 #include <sys/vfs.h>
789 #include <fcntl.h>
790 #define DONT_REINSTALL_SIG
791 #define USE_SIGBLOCK
792 #define USE_WAITPID
793 #define SIGNAL_CAST (_SigFunc_Ptr_t)
794 #define NO_GETSPNAM
795 #define HAVE_MEMMOVE
796 extern char *mktemp(char *);
797 extern int  fsync(int);
798 extern int  seteuid(uid_t);
799 extern int  setgroups(int, int *);
800 extern int  initgroups(char *, int);
801 extern int  statfs(char *, struct statfs *);
802 extern int  setegid(gid_t);
803 extern int  getopt(int, char *const *, const char *);
804 extern int  chroot(char *);
805 extern int  gettimeofday(struct timeval *, struct timezone *);
806 extern int  gethostname(char *, int);
807 extern char *crypt(char *, char *);
808 extern char *getpass(char *);
809 #endif
810
811
812 #ifdef CRAY
813 #define MAXPATHLEN 1024
814 #include <dirent.h>
815 #include <string.h>
816 #include <fcntl.h>
817 #include <sys/statfs.h>
818 #define SIGNAL_CAST (void (*)(int))
819 #define SIGCLD_IGNORE
820 #define HAVE_FCNTL_LOCK 1
821 #define USE_SETSID
822 #define STATFS4
823 #endif
824
825
826 #ifdef ALTOS
827 #include <unistd.h>
828 #include <string.h>
829 #include <dirent.h>
830 #include <sys/fcntl.h>
831 #include <sys/statfs.h>
832 #define        const
833 #define        uid_t           int
834 #define        gid_t           int
835 #define        mode_t          int
836 #define        ptrdiff_t       int
837 #define HAVE_GETGRNAM  0
838 #define NO_EID
839 #define NO_FSYNC
840 #define        NO_FTRUNCATE
841 #define        NO_GETRLIMIT
842 #define        NO_INITGROUPS
843 #define NO_SELECT
844 #define NO_SETGROUPS
845 #define NO_STRERROR
846 #define NO_STRFTIME
847 #define        NO_TM_NAME
848 #define NO_UTIMEH
849 #define NOSTRCASECMP
850 #define REPLACE_MKTIME
851 #define REPLACE_RENAME
852 #define REPLACE_STRSTR
853 #define STATFS4
854 #define        USE_GETCWD
855 #endif
856
857 #ifdef QNX
858 #define STATFS4
859 #include <sys/statfs.h>
860 #include <sys/select.h>
861 #include <signal.h>
862 #include <sys/dir.h>
863 #define SIGNAL_CAST (void (*)())
864 #define USE_WAITPID
865 #define NO_INITGROUPS
866 #define NO_SETGROUPS
867 #define HAVE_TIMEZONE
868 #define USE_GETCWD
869 #define USE_SETSID
870 #define HAVE_FCNTL_LOCK 1
871 #define DEFAULT_PRINTING PRINT_QNX
872 #endif
873
874
875 #ifdef NEWS42
876 #include <string.h>
877 #include <dirent.h>
878 #include <sys/vfs.h>
879 #include <sys/timeb.h>
880 typedef int mode_t;
881 #endif
882
883 #ifdef OS2
884 #include <dirent.h>
885 #include <sys/statfs.h>
886 #include <string.h>
887 #include <limits.h>
888 #define SIGNAL_CAST (void (*)())
889 #define HAVE_FCNTL_LOCK 0
890 #define USE_WAITPID
891 #define NO_GET_BROADCAST
892 #define NO_EID
893 #define NO_SETGROUPS
894 #define NO_INITGROUPS
895 #define NO_CRYPT
896 #define NO_STATFS
897 #define NO_CHROOT
898 #define NO_CHOWN
899 #define strcasecmp stricmp
900 #define strncasecmp strnicmp
901 #endif
902
903
904 #ifdef LYNX
905 #define SIGNAL_CAST (void (*)())
906 #define WAIT3_CAST1 (union wait *)
907 #define STATFS4
908 #include <fcntl.h>
909 #include <resource.h>
910 #include <stat.h>
911 #include <string.h>
912 #include <dirent.h>
913 #include <sys/statfs.h>
914 #define USE_GETCWD
915 #define USE_GETSID
916 #endif
917
918
919 #ifdef BOS
920 #define SIGNAL_CAST (void (*)(int))
921 #include <string.h>
922 #include <sys/dir.h>
923 #include <sys/select.h>
924 #include <dirent.h>
925 #include <fcntl.h>
926 #include <signal.h>
927 #include <sys/statfs.h>
928 #include <sys/bsdioctl.h>
929 #endif
930
931 #ifdef AMIGA
932 #include <arpa/inet.h>
933 #include <dirent.h>
934 #include <string.h>
935 #include <netinet/tcp.h>
936 #include <sys/acct.h>
937 #include <sys/fcntl.h>
938 #include <sys/filio.h>
939 #include <sys/sockio.h>
940 #include <netinet/in_systm.h>
941 #include <netinet/ip.h>
942 #include <sys/termios.h>
943 #include <limits.h>
944 #include <sys/timeb.h>
945
946 #define SIGNAL_CAST (void (*)(int))
947 #define USE_GETCWD
948 #define HAVE_BZERO
949 #define HAVE_MEMMOVE
950 #define USE_SIGPROCMASK
951 #define USE_WAITPID
952 #define USE_DIRECT
953 #define USE_F_FSIZE
954 #define HAVE_FCNTL_LOCK 0
955 #define HAVE_GETTIMEOFDAY
956 #define HAVE_PATHCONF
957
958 #define HAVE_NO_PROC
959 #define NO_FORK_DEBUG
960 #define HAVE_FORK 0
961 #define HAVE_VFORK 1
962 #endif
963
964
965 /*******************************************************************
966 end of the platform specific sections
967 ********************************************************************/
968
969 #if defined(USE_MMAP) || FAST_SHARE_MODES
970 #include <sys/mman.h>
971 #endif
972
973 #ifdef SecureWare
974 #define NEED_AUTH_PARAMETERS
975 #endif
976
977 #ifdef REPLACE_GETPASS
978 extern char    *getsmbpass(char *);
979 #define getpass(s) getsmbpass(s)
980 #endif
981
982 #ifdef REPLACE_INNETGR
983 #define innetgr(group,host,user,dom) InNetGr(group,host,user,dom)
984 #endif
985
986 #ifndef FD_SETSIZE
987 #define FD_SETSIZE 255
988 #endif
989
990 #ifndef __STDC__
991 #define const
992 #endif
993
994 /* Now for some other grungy stuff */
995 #ifdef NO_GETSPNAM
996 struct spwd { /* fake shadow password structure */
997        char *sp_pwdp;
998 };
999 #endif
1000
1001 #ifndef HAVE_BZERO
1002 #ifndef bzero
1003 #define bzero(p,s) memset(p,0,s)
1004 #endif
1005 #endif
1006
1007 #ifndef HAVE_MEMMOVE
1008 #ifndef memmove
1009 #define memmove(d,s,n) MemMove(d,s,n)
1010 #endif
1011 #endif
1012
1013 #ifdef USE_DIRECT
1014 #include <sys/dir.h>
1015 #endif
1016
1017 /* some unixes have ENOTTY instead of TIOCNOTTY */
1018 #ifndef TIOCNOTTY
1019 #ifdef ENOTTY
1020 #define TIOCNOTTY ENOTTY
1021 #endif
1022 #endif
1023
1024 #ifndef SIGHUP
1025 #define SIGHUP 1
1026 #endif
1027
1028 /* if undefined then use bsd or sysv printing */
1029 #ifndef DEFAULT_PRINTING
1030 #ifdef SYSV
1031 #define DEFAULT_PRINTING PRINT_SYSV
1032 #else
1033 #define DEFAULT_PRINTING PRINT_BSD
1034 #endif
1035 #endif
1036
1037
1038 #ifdef AFS_AUTH
1039 #include <afs/stds.h>
1040 #include <afs/kautils.h>
1041 #endif
1042
1043 #ifdef DFS_AUTH
1044 #include <dce/dce_error.h>
1045 #include <dce/sec_login.h>
1046 #endif
1047
1048 #ifdef NO_UTIMBUF
1049 struct utimbuf {
1050   time_t actime;
1051   time_t modtime;
1052 };
1053 #endif
1054
1055 #ifdef NO_STRERROR
1056 #ifndef strerror
1057 extern char *sys_errlist[];
1058 #define strerror(i) sys_errlist[i]
1059 #endif
1060 #endif
1061
1062 #ifndef perror
1063 #define perror(m) printf("%s: %s\n",m,strerror(errno))
1064 #endif
1065
1066 #ifndef MAXHOSTNAMELEN
1067 #define MAXHOSTNAMELEN 255
1068 #endif
1069
1070 #include "version.h"
1071 #include "smb.h"
1072 #include "nameserv.h"
1073 #include "proto.h"
1074 #include "byteorder.h"
1075
1076 #include "kanji.h"
1077 #include "charset.h"
1078
1079 #ifndef S_IFREG
1080 #define S_IFREG 0100000
1081 #endif
1082
1083 #ifndef S_ISREG
1084 #define S_ISREG(x) ((S_IFREG & x)!=0)
1085 #endif
1086
1087 #ifndef S_ISDIR
1088 #define S_ISDIR(x) ((S_IFDIR & x)!=0)
1089 #endif
1090
1091 #ifdef UFC_CRYPT
1092 #define crypt ufc_crypt
1093 #endif
1094
1095 #ifdef REPLACE_STRLEN
1096 #define strlen(s) Strlen(s)
1097 #endif
1098
1099 #ifdef REPLACE_STRSTR
1100 #define strstr(s,p) Strstr(s,p)
1101 #endif
1102
1103 #ifdef REPLACE_MKTIME
1104 #define mktime(t) Mktime(t)
1105 #endif
1106
1107 #ifndef NGROUPS_MAX
1108 #define NGROUPS_MAX 128
1109 #endif
1110
1111 #ifndef EDQUOT
1112 #define EDQUOT ENOSPC
1113 #endif
1114
1115 #ifndef HAVE_GETGRNAM
1116 #define HAVE_GETGRNAM 1
1117 #endif
1118
1119 #ifndef SOL_TCP
1120 #define SOL_TCP 6
1121 #endif
1122
1123 /* default to using ftruncate workaround as this is safer than assuming
1124 it works and getting lots of bug reports */
1125 #ifndef FTRUNCATE_CAN_EXTEND
1126 #define FTRUNCATE_CAN_EXTEND 0
1127 #endif
1128
1129 /* maybe this unix doesn't separate RD and WR locks? */
1130 #ifndef F_RDLCK
1131 #define F_RDLCK F_WRLCK
1132 #endif
1133
1134 #ifndef ENOTSOCK
1135 #define ENOTSOCK EINVAL
1136 #endif
1137
1138 #ifndef SIGCLD
1139 #define SIGCLD SIGCHLD
1140 #endif 
1141
1142 #ifndef MAP_FILE
1143 #define MAP_FILE 0
1144 #endif
1145
1146 #ifndef HAVE_FCNTL_LOCK
1147 #define HAVE_FCNTL_LOCK 1
1148 #endif
1149
1150 #ifndef WAIT3_CAST2
1151 #define WAIT3_CAST2 (struct rusage *)
1152 #endif
1153
1154 #ifndef WAIT3_CAST1
1155 #define WAIT3_CAST1 (int *)
1156 #endif
1157
1158 #ifndef QSORT_CAST
1159 #define QSORT_CAST (int (*)())
1160 #endif
1161
1162 /* this is a rough check to see if this machine has a lstat() call.
1163    it is not guaranteed to work */
1164 #if !(defined(S_ISLNK) || defined(S_IFLNK))
1165 #define lstat stat
1166 #endif
1167
1168 /* Not all systems declare ERRNO in errno.h... and some systems #define it! */
1169 #ifndef errno
1170 extern int errno;
1171 #endif 
1172
1173
1174 #ifdef NO_EID
1175 #define geteuid() getuid()
1176 #define getegid() getgid()
1177 #define seteuid(x) setuid(x)
1178 #define setegid(x) setgid(x)
1179 #endif
1180
1181
1182 #if (HAVE_FCNTL_LOCK == 0)
1183 /* since there is no locking available, system includes  */
1184 /* for DomainOS 10.4 do not contain any of the following */
1185 /* #define's. So, to satisfy the compiler, add these     */
1186 /* #define's, although they arn't really necessary.      */
1187 #define F_GETLK 0
1188 #define F_SETLK 0
1189 #define F_WRLCK 0
1190 #define F_UNLCK 0
1191 #endif /* HAVE_FCNTL_LOCK == 0 */
1192
1193 #ifdef NOSTRCASECMP
1194 #define strcasecmp(s1,s2) StrCaseCmp(s1,s2)
1195 #define strncasecmp(s1,s2,n) StrnCaseCmp(s1,s2,n)
1196 #endif
1197
1198 #ifndef strcpy
1199 #define strcpy(dest,src) StrCpy(dest,src)
1200 #endif
1201
1202
1203 /* possibly wrap the malloc calls */
1204 #if WRAP_MALLOC
1205
1206 /* undo the old malloc def if necessary */
1207 #ifdef malloc
1208 #define xx_old_malloc malloc
1209 #undef malloc
1210 #endif
1211
1212 #define malloc(size) malloc_wrapped(size,__FILE__,__LINE__)
1213
1214 /* undo the old realloc def if necessary */
1215 #ifdef realloc
1216 #define xx_old_realloc realloc
1217 #undef realloc
1218 #endif
1219
1220 #define realloc(ptr,size) realloc_wrapped(ptr,size,__FILE__,__LINE__)
1221
1222 /* undo the old free def if necessary */
1223 #ifdef free
1224 #define xx_old_free free
1225 #undef free
1226 #endif
1227
1228 #define free(ptr) free_wrapped(ptr,__FILE__,__LINE__)
1229
1230 /* and the malloc prototypes */
1231 void *malloc_wrapped(int,char *,int);
1232 void *realloc_wrapped(void *,int,char *,int);
1233 void free_wrapped(void *,char *,int);
1234
1235 #endif
1236
1237
1238 #if WRAP_MEMCPY
1239 /* undo the old memcpy def if necessary */
1240 #ifdef memcpy
1241 #define xx_old_memcpy memcpy
1242 #undef memcpy
1243 #endif
1244
1245 #define memcpy(d,s,l) memcpy_wrapped(d,s,l,__FILE__,__LINE__)
1246 void *memcpy_wrapped(void *d,void *s,int l,char *fname,int line);
1247 #endif
1248
1249 #endif