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