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