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