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