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