oops, I ot the return type of putenv() wrong
[Samba/gbeck.git] / source / include / includes.h
blob59d43d8a365882381dc78677ab3c776e690c94fe
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
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.
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.
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.
24 #ifndef NO_CONFIG_H /* for some tests */
25 #include "config.h"
26 #endif
28 #include "local.h"
30 #ifdef AIX
31 #define DEFAULT_PRINTING PRINT_AIX
32 #endif
34 #ifdef HPUX
35 #define DEFAULT_PRINTING PRINT_HPUX
36 #endif
38 #ifdef QNX
39 #define DEFAULT_PRINTING PRINT_QNX
40 #endif
42 #ifdef SUNOS4
43 /* on SUNOS4 termios.h conflicts with sys/ioctl.h */
44 #undef HAVE_TERMIOS_H
45 #endif
48 #include <sys/types.h>
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
61 #ifdef HAVE_SYS_RESOURCE_H
62 #include <sys/resource.h>
63 #endif
65 #ifdef HAVE_UNISTD_H
66 #include <unistd.h>
67 #endif
69 #include <stdio.h>
70 #include <stddef.h>
72 #ifdef HAVE_SYS_PARAM_H
73 #include <sys/param.h>
74 #endif
76 #ifdef HAVE_STDLIB_H
77 #include <stdlib.h>
78 #endif
80 #ifdef HAVE_SYS_SOCKET_H
81 #include <sys/socket.h>
82 #endif
84 #ifdef HAVE_SYS_SYSCALL_H
85 #include <sys/syscall.h>
86 #elif HAVE_SYSCALL_H
87 #include <syscall.h>
88 #endif
90 #ifdef HAVE_STRING_H
91 #include <string.h>
92 #endif
94 #ifdef HAVE_STRINGS_H
95 #include <strings.h>
96 #endif
98 #ifdef HAVE_MEMORY_H
99 #include <memory.h>
100 #endif
102 #ifdef HAVE_MALLOC_H
103 #include <malloc.h>
104 #endif
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
114 #include <sys/stat.h>
116 #ifdef HAVE_LIMITS_H
117 #include <limits.h>
118 #endif
120 #ifdef HAVE_SYS_IOCTL_H
121 #include <sys/ioctl.h>
122 #endif
124 #ifdef HAVE_SYS_FILIO_H
125 #include <sys/filio.h>
126 #endif
128 #include <signal.h>
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
143 #include <errno.h>
145 #ifdef HAVE_UTIME_H
146 #include <utime.h>
147 #endif
149 #ifdef HAVE_SYS_SELECT_H
150 #include <sys/select.h>
151 #endif
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
160 #ifdef HAVE_GLOB
161 #include <glob.h>
162 #endif
164 #include <pwd.h>
165 #include <grp.h>
167 #ifdef HAVE_STDARG_H
168 #include <stdarg.h>
169 #else
170 #include <varargs.h>
171 #endif
173 #include <netinet/in.h>
174 #include <arpa/inet.h>
175 #include <netdb.h>
176 #include <syslog.h>
177 #include <sys/file.h>
179 #ifdef HAVE_NETINET_TCP_H
180 #include <netinet/tcp.h>
181 #endif
183 #ifdef HAVE_TERMIOS_H
184 #include <termios.h>
185 #endif
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
204 #ifdef HAVE_SHARED_MMAP
205 #include <sys/mman.h>
206 #endif
208 #ifdef HAVE_SYSV_IPC
209 #include <sys/ipc.h>
210 #include <sys/shm.h>
211 #include <sys/sem.h>
212 #endif
214 #ifdef HAVE_NET_IF_H
215 #include <net/if.h>
216 #endif
219 #ifdef HAVE_SYS_MOUNT_H
220 #include <sys/mount.h>
221 #endif
223 #ifdef HAVE_SYS_VFS_H
224 #include <sys/vfs.h>
225 #endif
227 #ifdef HAVE_SYS_ACL_H
228 #include <sys/acl.h>
229 #endif
231 #ifdef HAVE_SYS_FS_S5PARAM_H
232 #include <sys/fs/s5param.h>
233 #endif
235 #if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
236 #include <sys/filsys.h>
237 #endif
239 #ifdef HAVE_SYS_STATFS_H
240 # include <sys/statfs.h>
241 #endif
243 #ifdef HAVE_DUSTAT_H
244 #include <sys/dustat.h>
245 #endif
247 #ifdef HAVE_SYS_STATVFS_H
248 #include <sys/statvfs.h>
249 #endif
251 #ifdef HAVE_SHADOW_H
252 #include <shadow.h>
253 #endif
255 #ifdef HAVE_GETPWANAM
256 #include <sys/label.h>
257 #include <sys/audit.h>
258 #include <pwdadj.h>
259 #endif
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 */
267 #ifdef HAVE_COMPAT_H
268 #include <compat.h>
269 #endif
271 #ifdef HAVE_STROPTS_H
272 #include <stropts.h>
273 #endif
275 #ifdef HAVE_POLL_H
276 #include <poll.h>
277 #endif
279 #ifdef HAVE_SYS_CAPABILITY_H
280 #include <sys/capability.h>
281 #endif
283 #ifndef uchar
284 #define uchar unsigned char
285 #endif
287 #ifdef HAVE_UNSIGNED_CHAR
288 #define schar signed char
289 #else
290 #define schar char
291 #endif
294 Samba needs type definitions for int16, int32, uint16 and uint32.
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.
302 #ifndef uint8
303 #define uint8 unsigned char
304 #endif
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
314 #ifndef uint16
315 #define uint16 unsigned int16
316 #endif
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
328 #ifndef uint32
329 #define uint32 unsigned int32
330 #endif
333 * Types for devices, inodes and offsets.
336 #ifndef SMB_DEV_T
337 #define SMB_DEV_T dev_t
338 #endif
341 * Setup the correctly sized inode type.
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
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
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
366 #define SMB_OFF_T_BITS (sizeof(SMB_OFF_T)*8)
369 * Set the define that tells us if we can do 64 bit
370 * NT SMB calls.
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
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
386 * Type for stat structure.
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
398 * Defines for 64 bit fcntl locks.
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
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
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
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
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
441 #ifndef MIN
442 #define MIN(a,b) ((a)<(b)?(a):(b))
443 #endif
445 #ifndef MAX
446 #define MAX(a,b) ((a)>(b)?(a):(b))
447 #endif
449 #ifndef HAVE_STRERROR
450 extern char *sys_errlist[];
451 #define strerror(i) sys_errlist[i]
452 #endif
454 #ifndef HAVE_STRCHR
455 # define strchr index
456 # define strrchr rindex
457 #endif
459 #ifndef HAVE_ERRNO_DECL
460 extern int errno;
461 #endif
463 #ifdef HAVE_BROKEN_GETGROUPS
464 #define GID_T int
465 #else
466 #define GID_T gid_t
467 #endif
470 /* Lists, trees, caching, datbase... */
471 #include "ubi_sLinkList.h"
472 #include "ubi_dLinkList.h"
473 #include "dlinklist.h"
475 #ifndef UBI_BINTREE_H
476 #include "ubi_Cache.h"
477 #endif /* UBI_BINTREE_H */
479 #include "version.h"
480 #include "smb.h"
481 #include "smbw.h"
482 #include "nameserv.h"
484 #include "byteorder.h"
486 #include "kanji.h"
487 #include "charset.h"
489 #include "nterr.h"
491 #ifndef MAXCODEPAGELINES
492 #define MAXCODEPAGELINES 256
493 #endif
495 /***** automatically generated prototypes *****/
496 #include "proto.h"
498 #ifdef strcpy
499 #undef strcpy
500 #endif /* strcpy */
501 #define strcpy(dest,src) __ERROR__XX__NEVER_USE_STRCPY___;
503 #ifdef strcat
504 #undef strcat
505 #endif /* strcat */
506 #define strcat(dest,src) __ERROR__XX__NEVER_USE_STRCAT___;
508 #ifdef sprintf
509 #undef sprintf
510 #endif /* sprintf */
511 #define sprintf __ERROR__XX__NEVER_USE_SPRINTF__;
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)
518 #ifdef __COMPAR_FN_T
519 #define QSORT_CAST (__compar_fn_t)
520 #endif
522 #ifndef QSORT_CAST
523 #define QSORT_CAST (int (*)(const void *, const void *))
524 #endif
526 /* this guess needs to be improved (tridge) */
527 #if defined(STAT_STATVFS) && !defined(SYSV)
528 #define SYSV 1
529 #endif
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
539 #ifndef SIGCLD
540 #define SIGCLD SIGCHLD
541 #endif
543 #if (defined(HAVE_SYSV_IPC) || defined(HAVE_SHARED_MMAP))
544 #define FAST_SHARE_MODES 1
545 #endif
547 #ifndef MAP_FILE
548 #define MAP_FILE 0
549 #endif
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;
558 #endif
559 #endif
561 #if (!defined(WITH_NISPLUS) && !defined(WITH_LDAP))
562 #define USE_SMBPASS_DB 1
563 #endif
565 #if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
566 #define OSF1_ENH_SEC 1
567 #endif
569 #if defined(HAVE_PAM_AUTHENTICATE) && defined(HAVE_SECURITY_PAM_APPL_H)
570 #define HAVE_PAM 1
571 #endif
573 #if defined(HAVE_YP_GET_DEFAULT_DOMAIN)
574 #define HAVE_NETGROUP 1
575 #endif
577 #if defined (HAVE_NETGROUP) && defined(HAVE_RPCSVC_YPCLNT_H)
578 #include "rpcsvc/ypclnt.h"
579 #endif
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
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
593 #ifdef REPLACE_INET_NTOA
594 #define inet_ntoa rep_inet_ntoa
595 #endif
597 #ifndef HAVE_PIPE
598 #define SYNC_DNS 1
599 #endif
601 #ifndef MAXPATHLEN
602 #define MAXPATHLEN 256
603 #endif
605 #ifndef SEEK_SET
606 #define SEEK_SET 0
607 #endif
609 #ifndef INADDR_LOOPBACK
610 #define INADDR_LOOPBACK 0x7f000001
611 #endif
613 #ifndef INADDR_NONE
614 #define INADDR_NONE 0xffffffff
615 #endif
617 #ifndef HAVE_CRYPT
618 #define crypt ufc_crypt
619 #endif
621 #ifndef O_ACCMODE
622 #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
623 #endif
625 #if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
626 #define ULTRIX_AUTH 1
627 #endif
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
647 #ifndef HAVE_STRDUP
648 char *strdup(const char *s);
649 #endif
651 #ifndef HAVE_MEMMOVE
652 void *memmove(void *dest,const void *src,int size);
653 #endif
655 #ifndef HAVE_INITGROUPS
656 int initgroups(char *name,gid_t id);
657 #endif
659 #ifndef HAVE_RENAME
660 int rename(const char *zfrom, const char *zto);
661 #endif
663 #ifndef HAVE_MKTIME
664 time_t mktime(struct tm *t);
665 #endif
667 #ifndef HAVE_FTRUNCATE
668 int ftruncate(int f,long l);
669 #endif
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
677 #if (defined(HAVE_CRYPT) && !defined(HAVE_CRYPT_DECL))
678 /* stupid glibc */
679 int crypt(const char *key, const char *salt);
680 #endif
682 #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
683 #define bzero(a,b) memset((a),'\0',(b))
684 #endif
686 #ifdef REPLACE_GETPASS
687 #define getpass(prompt) getsmbpass((prompt))
688 #endif
690 /* yuck, I'd like a better way of doing this */
691 #define DIRP_SIZE (256 + 32)
693 #endif /* _INCLUDES_H */