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