config: Fix crypt prototype on RedHat Linux.
[ira/wip.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 #ifndef NO_CONFIG_H /* for some tests */
25 #include "config.h"
26 #endif
27
28 #include "local.h"
29
30 #ifdef AIX
31 #define DEFAULT_PRINTING PRINT_AIX
32 #endif
33
34 #ifdef HPUX
35 #define DEFAULT_PRINTING PRINT_HPUX
36 #endif
37
38 #ifdef QNX
39 #define DEFAULT_PRINTING PRINT_QNX
40 #endif
41
42 #ifdef SUNOS4
43 /* on SUNOS4 termios.h conflicts with sys/ioctl.h */
44 #undef HAVE_TERMIOS_H
45 #endif
46
47
48 #include <sys/types.h>
49
50 #ifdef TIME_WITH_SYS_TIME
51 #include <sys/time.h>
52 #include <time.h>
53 #else
54 #ifdef HAVE_SYS_TIME_H
55 #include <sys/time.h>
56 #else
57 #include <time.h>
58 #endif
59 #endif
60
61 #ifdef HAVE_SYS_RESOURCE_H
62 #include <sys/resource.h>
63 #endif
64
65 #ifdef HAVE_UNISTD_H
66 #include <unistd.h>
67 #endif
68
69 #include <stdio.h>
70 #include <stddef.h>
71
72 #ifdef HAVE_SYS_PARAM_H
73 #include <sys/param.h>
74 #endif
75
76 #ifdef HAVE_STDLIB_H
77 #include <stdlib.h>
78 #endif
79
80 #ifdef HAVE_SYS_SOCKET_H
81 #include <sys/socket.h>
82 #endif
83
84 #ifdef HAVE_SYS_SYSCALL_H
85 #include <sys/syscall.h>
86 #elif HAVE_SYSCALL_H
87 #include <syscall.h>
88 #endif
89
90 #ifdef HAVE_STRING_H
91 #include <string.h>
92 #endif
93
94 #ifdef HAVE_STRINGS_H
95 #include <strings.h>
96 #endif
97
98 #ifdef HAVE_MEMORY_H
99 #include <memory.h>
100 #endif
101
102 #ifdef HAVE_MALLOC_H
103 #include <malloc.h>
104 #endif
105
106 #ifdef HAVE_FCNTL_H
107 #include <fcntl.h>
108 #else
109 #ifdef HAVE_SYS_FCNTL_H
110 #include <sys/fcntl.h>
111 #endif
112 #endif
113
114 #include <sys/stat.h>
115
116 #ifdef HAVE_LIMITS_H
117 #include <limits.h>
118 #endif
119
120 #ifdef HAVE_SYS_IOCTL_H
121 #include <sys/ioctl.h>
122 #endif
123
124 #ifdef HAVE_SYS_FILIO_H
125 #include <sys/filio.h>
126 #endif
127
128 #include <signal.h>
129
130 #ifdef HAVE_SYS_WAIT_H
131 #include <sys/wait.h>
132 #endif
133 #ifdef HAVE_CTYPE_H
134 #include <ctype.h>
135 #endif
136 #ifdef HAVE_GRP_H
137 #include <grp.h>
138 #endif
139 #ifdef HAVE_SYS_ID_H
140 #include <sys/id.h>
141 #endif
142
143 #include <errno.h>
144
145 #ifdef HAVE_UTIME_H
146 #include <utime.h>
147 #endif
148
149 #ifdef HAVE_SYS_SELECT_H
150 #include <sys/select.h>
151 #endif
152
153 #ifdef HAVE_SYS_MODE_H
154 /* apparently AIX needs this for S_ISLNK */
155 #ifndef S_ISLNK
156 #include <sys/mode.h>
157 #endif
158 #endif
159
160 #ifdef HAVE_GLOB
161 #include <glob.h>
162 #endif
163
164 #include <pwd.h>
165 #include <grp.h>
166
167 #ifdef HAVE_STDARG_H
168 #include <stdarg.h>
169 #else
170 #include <varargs.h>
171 #endif
172
173 #include <netinet/in.h>
174 #include <arpa/inet.h>
175 #include <netdb.h>
176 #include <syslog.h>
177 #include <sys/file.h>
178
179 #ifdef HAVE_NETINET_TCP_H
180 #include <netinet/tcp.h>
181 #endif
182
183 #ifdef HAVE_TERMIOS_H
184 #include <termios.h>
185 #endif
186
187 #if HAVE_DIRENT_H
188 # include <dirent.h>
189 # define NAMLEN(dirent) strlen((dirent)->d_name)
190 #else
191 # define dirent direct
192 # define NAMLEN(dirent) (dirent)->d_namlen
193 # if HAVE_SYS_NDIR_H
194 #  include <sys/ndir.h>
195 # endif
196 # if HAVE_SYS_DIR_H
197 #  include <sys/dir.h>
198 # endif
199 # if HAVE_NDIR_H
200 #  include <ndir.h>
201 # endif
202 #endif
203
204 #ifdef HAVE_SHARED_MMAP
205 #include <sys/mman.h>
206 #endif
207
208 #ifdef HAVE_SYSV_IPC
209 #include <sys/ipc.h>
210 #include <sys/shm.h>
211 #include <sys/sem.h>
212 #endif
213
214 #ifdef HAVE_NET_IF_H
215 #include <net/if.h>
216 #endif
217
218
219 #ifdef HAVE_SYS_MOUNT_H
220 #include <sys/mount.h>
221 #endif
222
223 #ifdef HAVE_SYS_VFS_H
224 #include <sys/vfs.h>
225 #endif
226
227 #ifdef HAVE_SYS_ACL_H
228 #include <sys/acl.h>
229 #endif
230
231 #ifdef HAVE_SYS_FS_S5PARAM_H 
232 #include <sys/fs/s5param.h>
233 #endif
234
235 #if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
236 #include <sys/filsys.h> 
237 #endif
238
239 #ifdef HAVE_SYS_STATFS_H
240 # include <sys/statfs.h>
241 #endif
242
243 #ifdef HAVE_DUSTAT_H              
244 #include <sys/dustat.h>
245 #endif
246
247 #ifdef HAVE_SYS_STATVFS_H          
248 #include <sys/statvfs.h>
249 #endif
250
251 #ifdef HAVE_SHADOW_H
252 #include <shadow.h>
253 #endif
254
255 #ifdef HAVE_GETPWANAM
256 #include <sys/label.h>
257 #include <sys/audit.h>
258 #include <pwdadj.h>
259 #endif
260
261 #ifdef HAVE_SYS_SECURITY_H
262 #include <sys/security.h>
263 #include <prot.h>
264 #define PASSWORD_LENGTH 16
265 #endif  /* HAVE_SYS_SECURITY_H */
266
267 #ifdef HAVE_COMPAT_H
268 #include <compat.h>
269 #endif
270
271 #ifdef HAVE_STROPTS_H
272 #include <stropts.h>
273 #endif
274
275 #ifdef HAVE_POLL_H
276 #include <poll.h>
277 #endif
278
279 #ifdef HAVE_SYS_CAPABILITY_H
280 #include <sys/capability.h>
281 #endif
282
283 #ifndef uchar
284 #define uchar unsigned char
285 #endif
286
287 #ifdef HAVE_UNSIGNED_CHAR
288 #define schar signed char
289 #else
290 #define schar char
291 #endif
292
293 /*
294    Samba needs type definitions for int16, int32, uint16 and uint32.
295
296    Normally these are signed and unsigned 16 and 32 bit integers, but
297    they actually only need to be at least 16 and 32 bits
298    respectively. Thus if your word size is 8 bytes just defining them
299    as signed and unsigned int will work.
300 */
301
302 #ifndef uint8
303 #define uint8 unsigned char
304 #endif
305
306 #ifndef int16
307 #if (SIZEOF_SHORT == 4)
308 #define int16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
309 #else /* SIZEOF_SHORT != 4 */
310 #define int16 short
311 #endif /* SIZEOF_SHORT != 4 */
312 #endif
313
314 #ifndef uint16
315 #define uint16 unsigned int16
316 #endif
317
318 #ifndef int32
319 #if (SIZEOF_INT == 4)
320 #define int32 int
321 #elif (SIZEOF_LONG == 4)
322 #define int32 long
323 #elif (SIZEOF_SHORT == 4)
324 #define int32 short
325 #endif
326 #endif
327
328 #ifndef uint32
329 #define uint32 unsigned int32
330 #endif
331
332 /*
333  * Types for devices, inodes and offsets.
334  */
335
336 #ifndef SMB_DEV_T
337 #define SMB_DEV_T dev_t
338 #endif
339
340 /*
341  * Setup the correctly sized inode type.
342  */
343
344 #ifndef SMB_INO_T
345 #  ifdef HAVE_INO64_T
346 #    define SMB_INO_T ino64_t
347 #  else
348 #    define SMB_INO_T ino_t
349 #  endif
350 #endif
351
352 #ifndef LARGE_SMB_INO_T
353 #  if defined(HAVE_INO64_T) || (defined(SIZEOF_INO_T) && (SIZEOF_INO_T == 8))
354 #    define LARGE_SMB_INO_T 1
355 #  endif
356 #endif
357
358 #ifndef SMB_OFF_T
359 #  ifdef HAVE_OFF64_T
360 #    define SMB_OFF_T off64_t
361 #  else
362 #    define SMB_OFF_T off_t
363 #  endif
364 #endif
365
366 #define SMB_OFF_T_BITS (sizeof(SMB_OFF_T)*8)
367
368 /*
369  * Set the define that tells us if we can do 64 bit
370  * NT SMB calls.
371  */
372
373 #ifndef LARGE_SMB_OFF_T
374 #  if defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8))
375 #    define LARGE_SMB_OFF_T 1
376 #  endif
377 #endif
378
379 #ifdef LARGE_SMB_OFF_T
380 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
381 #else 
382 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
383 #endif
384
385 /*
386  * Type for stat structure.
387  */
388
389 #ifndef SMB_STRUCT_STAT
390 #  if defined(HAVE_STAT64) && defined(HAVE_OFF64_T)
391 #    define SMB_STRUCT_STAT struct stat64
392 #  else
393 #    define SMB_STRUCT_STAT struct stat
394 #  endif
395 #endif
396
397 /*
398  * Defines for 64 bit fcntl locks.
399  */
400
401 #ifndef SMB_STRUCT_FLOCK
402 #  if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
403 #    define SMB_STRUCT_FLOCK struct flock64
404 #  else
405 #    define SMB_STRUCT_FLOCK struct flock
406 #  endif
407 #endif
408
409 #ifndef SMB_F_SETLKW
410 #  if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
411 #    define SMB_F_SETLKW F_SETLKW64
412 #  else
413 #    define SMB_F_SETLKW F_SETLKW
414 #  endif
415 #endif
416
417 #ifndef SMB_F_SETLK
418 #  if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
419 #    define SMB_F_SETLK F_SETLK64
420 #  else
421 #    define SMB_F_SETLK F_SETLK
422 #  endif
423 #endif
424
425 #ifndef SMB_F_GETLK
426 #  if defined(HAVE_STRUCT_FLOCK64) && defined(HAVE_OFF64_T)
427 #    define SMB_F_GETLK F_GETLK64
428 #  else
429 #    define SMB_F_GETLK F_GETLK
430 #  endif
431 #endif
432
433 #if defined(HAVE_LONGLONG)
434 #define SMB_BIG_UINT unsigned long long
435 #define SMB_BIG_INT long long
436 #else
437 #define SMB_BIG_UINT unsigned long
438 #define SMB_BIG_INT long
439 #endif
440
441 #ifndef MIN
442 #define MIN(a,b) ((a)<(b)?(a):(b))
443 #endif
444
445 #ifndef MAX
446 #define MAX(a,b) ((a)>(b)?(a):(b))
447 #endif
448
449 #ifndef HAVE_STRERROR
450 extern char *sys_errlist[];
451 #define strerror(i) sys_errlist[i]
452 #endif
453
454 #ifndef HAVE_STRCHR
455 # define strchr                 index
456 # define strrchr                rindex
457 #endif
458
459 #ifndef HAVE_ERRNO_DECL
460 extern int errno;
461 #endif
462
463 #ifdef HAVE_BROKEN_GETGROUPS
464 #define GID_T int
465 #else
466 #define GID_T gid_t
467 #endif
468
469
470 /* Lists, trees, caching, datbase... */
471 #include "ubi_sLinkList.h"
472 #include "ubi_dLinkList.h"
473 #include "dlinklist.h"
474
475 #ifndef UBI_BINTREE_H
476 #include "ubi_Cache.h"
477 #endif /* UBI_BINTREE_H */
478
479 #include "version.h"
480 #include "smb.h"
481 #include "smbw.h"
482 #include "nameserv.h"
483
484 #include "byteorder.h"
485
486 #include "kanji.h"
487 #include "charset.h"
488
489 #include "nterr.h"
490
491 #ifndef MAXCODEPAGELINES
492 #define MAXCODEPAGELINES 256
493 #endif
494
495 /***** automatically generated prototypes *****/
496 #include "proto.h"
497
498 #ifdef strcpy
499 #undef strcpy
500 #endif /* strcpy */
501 #define strcpy(dest,src) __ERROR__XX__NEVER_USE_STRCPY___;
502
503 #ifdef strcat
504 #undef strcat
505 #endif /* strcat */
506 #define strcat(dest,src) __ERROR__XX__NEVER_USE_STRCAT___;
507
508 #ifdef sprintf
509 #undef sprintf
510 #endif /* sprintf */
511 #define sprintf __ERROR__XX__NEVER_USE_SPRINTF__;
512
513 #define pstrcpy(d,s) safe_strcpy((d),(s),sizeof(pstring)-1)
514 #define pstrcat(d,s) safe_strcat((d),(s),sizeof(pstring)-1)
515 #define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
516 #define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1)
517
518 #ifdef __COMPAR_FN_T
519 #define QSORT_CAST (__compar_fn_t)
520 #endif
521
522 #ifndef QSORT_CAST
523 #define QSORT_CAST (int (*)(const void *, const void *))
524 #endif
525
526 /* this guess needs to be improved (tridge) */
527 #if defined(STAT_STATVFS) && !defined(SYSV)
528 #define SYSV 1
529 #endif
530
531 #ifndef DEFAULT_PRINTING
532 #ifdef SYSV
533 #define DEFAULT_PRINTING PRINT_SYSV
534 #else
535 #define DEFAULT_PRINTING PRINT_BSD
536 #endif
537 #endif
538
539 #ifndef SIGCLD
540 #define SIGCLD SIGCHLD
541 #endif
542
543 #if (defined(HAVE_SYSV_IPC) || defined(HAVE_SHARED_MMAP))
544 #define FAST_SHARE_MODES 1
545 #endif
546
547 #ifndef MAP_FILE
548 #define MAP_FILE 0
549 #endif
550
551 #ifdef HAVE_SYSV_IPC
552 #ifndef HAVE_UNION_SEMUN
553 union semun {
554         int val;
555         struct semid_ds *buf;
556         unsigned short *array;
557 };
558 #endif
559 #endif
560
561 #if (!defined(WITH_NISPLUS) && !defined(WITH_LDAP))
562 #define USE_SMBPASS_DB 1
563 #endif
564
565 #if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
566 #define OSF1_ENH_SEC 1
567 #endif
568
569 #if defined(HAVE_PAM_AUTHENTICATE) && defined(HAVE_SECURITY_PAM_APPL_H)
570 #define HAVE_PAM 1
571 #endif
572
573 #if defined(HAVE_YP_GET_DEFAULT_DOMAIN)
574 #define HAVE_NETGROUP 1
575 #endif
576
577 #if defined (HAVE_NETGROUP) && defined(HAVE_RPCSVC_YPCLNT_H)
578 #include "rpcsvc/ypclnt.h"
579 #endif
580
581 #ifndef ALLOW_CHANGE_PASSWORD
582 #if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
583 #define ALLOW_CHANGE_PASSWORD 1
584 #endif
585 #endif
586
587 /* what is the longest significant password available on your system? 
588  Knowing this speeds up password searches a lot */
589 #ifndef PASSWORD_LENGTH
590 #define PASSWORD_LENGTH 8
591 #endif
592
593 #ifdef REPLACE_INET_NTOA
594 #define inet_ntoa rep_inet_ntoa
595 #endif
596
597 #ifndef HAVE_PIPE
598 #define SYNC_DNS 1
599 #endif
600
601 #ifndef MAXPATHLEN
602 #define MAXPATHLEN 256
603 #endif
604
605 #ifndef SEEK_SET
606 #define SEEK_SET 0
607 #endif
608
609 #ifndef INADDR_LOOPBACK
610 #define INADDR_LOOPBACK 0x7f000001
611 #endif
612
613 #ifndef INADDR_NONE
614 #define INADDR_NONE 0xffffffff
615 #endif
616
617 #ifndef HAVE_CRYPT
618 #define crypt ufc_crypt
619 #endif
620
621 #ifndef O_ACCMODE
622 #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
623 #endif
624
625 #if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
626 #define ULTRIX_AUTH 1
627 #endif
628
629 #ifdef HAVE_LIBREADLINE
630 #  ifdef HAVE_READLINE_READLINE_H
631 #    include <readline/readline.h>
632 #    ifdef HAVE_READLINE_HISTORY_H
633 #      include <readline/history.h>
634 #    endif
635 #  else
636 #    ifdef HAVE_READLINE_H
637 #      include <readline.h>
638 #      ifdef HAVE_HISTORY_H
639 #        include <history.h>
640 #      endif
641 #    else
642 #      undef HAVE_LIBREADLINE
643 #    endif
644 #  endif
645 #endif
646
647 #ifndef HAVE_STRDUP
648 char *strdup(const char *s);
649 #endif
650
651 #ifndef HAVE_MEMMOVE
652 void *memmove(void *dest,const void *src,int size);
653 #endif
654
655 #ifndef HAVE_INITGROUPS
656 int initgroups(char *name,gid_t id);
657 #endif
658
659 #ifndef HAVE_RENAME
660 int rename(const char *zfrom, const char *zto);
661 #endif
662
663 #ifndef HAVE_MKTIME
664 time_t mktime(struct tm *t);
665 #endif
666
667 #ifndef HAVE_FTRUNCATE
668 int ftruncate(int f,long l);
669 #endif
670
671 #if (defined(HAVE_SETRESUID) && !defined(HAVE_SETRESUID_DECL))
672 /* stupid glibc */
673 int setresuid(uid_t ruid, uid_t euid, uid_t suid);
674 int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
675 #endif
676
677 #if (defined(HAVE_CRYPT) && !defined(HAVE_CRYPT_DECL))
678 /* stupid glibc */
679 int crypt(const char *key, const char *salt);
680 #endif
681
682 #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
683 #define bzero(a,b) memset((a),'\0',(b))
684 #endif
685
686 #ifdef REPLACE_GETPASS
687 #define getpass(prompt) getsmbpass((prompt))
688 #endif
689
690 /* yuck, I'd like a better way of doing this */
691 #define DIRP_SIZE (256 + 32)
692
693 #endif /* _INCLUDES_H */