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