Code indentation.
[midnight-commander.git] / src / vfs / smbfs / helpers / include / includes.h
blob8d481ad1d5d6c9f03e43170187790c0932e4d594
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 */
9 #ifndef NO_CONFIG_H /* for some tests */
10 #include "config.h"
11 #endif
13 #include "local.h"
15 #ifdef AIX
16 #define DEFAULT_PRINTING PRINT_AIX
17 #define PRINTCAP_NAME "/etc/qconfig"
18 #endif
20 #ifdef HPUX
21 #define DEFAULT_PRINTING PRINT_HPUX
22 #endif
24 #ifdef QNX
25 #define DEFAULT_PRINTING PRINT_QNX
26 #endif
28 #include <sys/types.h>
29 #include <fcntl.h>
30 #include <sys/stat.h>
31 #include <sys/time.h>
32 #include <time.h>
33 #include <unistd.h>
34 #include <stdio.h>
35 #include <stddef.h>
36 #include <stdlib.h>
37 #include <signal.h>
38 #include <sys/wait.h>
40 #ifdef HAVE_SYS_RESOURCE_H
41 #include <sys/resource.h>
42 #endif
44 #ifdef HAVE_SYS_PARAM_H
45 #include <sys/param.h>
46 #endif
48 #ifdef HAVE_SYS_SOCKET_H
49 #include <sys/socket.h>
50 #endif
52 #ifdef HAVE_SYS_SYSCALL_H
53 #include <sys/syscall.h>
54 #elif HAVE_SYSCALL_H
55 #include <syscall.h>
56 #endif
58 #ifdef HAVE_STRING_H
59 #include <string.h>
60 #endif
62 #ifdef HAVE_STRINGS_H
63 #include <strings.h>
64 #endif
66 #ifdef HAVE_MEMORY_H
67 #include <memory.h>
68 #endif
70 #ifdef MEM_MAN
71 #include "../mem_man/mem_man.h"
72 #else
73 #ifdef HAVE_MALLOC_H
74 #include <malloc.h>
75 #endif
76 #endif
78 #ifdef HAVE_LIMITS_H
79 #include <limits.h>
80 #endif
82 #ifdef HAVE_SYS_IOCTL_H
83 #include <sys/ioctl.h>
84 #endif
86 #ifdef HAVE_SYS_FILIO_H
87 #include <sys/filio.h>
88 #endif
91 #ifdef HAVE_CTYPE_H
92 #include <ctype.h>
93 #endif
94 #include <grp.h>
95 #ifdef HAVE_SYS_ID_H
96 #include <sys/id.h>
97 #endif
99 /* AIX 4.1 and previous needs this for setpriv */
100 #if defined(HAVE_SETPRIV) && defined(HAVE_SYS_PRIV_H)
101 #include <sys/priv.h>
102 #endif
104 #include <errno.h>
106 #ifdef HAVE_UTIME_H
107 #include <utime.h>
108 #endif
110 #ifdef HAVE_SYS_SELECT_H
111 #include <sys/select.h>
112 #endif
114 #ifdef HAVE_SYS_MODE_H
115 /* apparently AIX needs this for S_ISLNK */
116 #ifndef S_ISLNK
117 #include <sys/mode.h>
118 #endif
119 #endif
121 #ifdef HAVE_GLOB_H
122 #include <glob.h>
123 #endif
125 #include <pwd.h>
127 #ifdef HAVE_STDARG_H
128 #include <stdarg.h>
129 #else
130 #include <varargs.h>
131 #endif
133 #include <netinet/in.h>
134 #include <arpa/inet.h>
135 #include <netdb.h>
136 #include <syslog.h>
137 #include <sys/file.h>
139 #ifdef HAVE_NETINET_TCP_H
140 #include <netinet/tcp.h>
141 #endif
144 * The next two defines are needed to the IPTOS_* options
145 * on some systems.
148 #ifdef HAVE_NETINET_IN_SYSTM_H
149 #include <netinet/in_systm.h>
150 #endif
152 #ifdef HAVE_NETINET_IN_IP_H
153 #include <netinet/ip.h>
154 #endif
156 /* POSIX terminal handling. */
157 #include <termios.h>
159 #include <dirent.h>
161 #ifdef HAVE_SYS_MMAN_H
162 #include <sys/mman.h>
163 #endif
165 #ifdef HAVE_SYSV_IPC
166 #include <sys/ipc.h>
167 #include <sys/shm.h>
168 #include <sys/sem.h>
169 #endif
171 #ifdef HAVE_NET_IF_H
172 #include <net/if.h>
173 #endif
176 #ifdef HAVE_SYS_MOUNT_H
177 #include <sys/mount.h>
178 #endif
180 #ifdef HAVE_SYS_VFS_H
181 #include <sys/vfs.h>
182 #endif
184 #ifdef HAVE_SYS_ACL_H
185 #include <sys/acl.h>
186 #endif
188 #ifdef HAVE_SYS_FS_S5PARAM_H
189 #include <sys/fs/s5param.h>
190 #endif
192 #if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
193 #include <sys/filsys.h>
194 #endif
196 #ifdef HAVE_SYS_STATFS_H
197 #include <sys/statfs.h>
198 #endif
200 #ifdef HAVE_DUSTAT_H
201 #include <sys/dustat.h>
202 #endif
204 #ifdef HAVE_SYS_STATVFS_H
205 #include <sys/statvfs.h>
206 #endif
208 #ifdef HAVE_SHADOW_H
209 #include <shadow.h>
210 #endif
212 #ifdef HAVE_GETPWANAM
213 #include <sys/label.h>
214 #include <sys/audit.h>
215 #include <pwdadj.h>
216 #endif
218 #ifdef HAVE_SYS_SECURITY_H
219 #include <sys/security.h>
220 #include <prot.h>
221 #define PASSWORD_LENGTH 16
222 #endif /* HAVE_SYS_SECURITY_H */
224 #ifdef HAVE_COMPAT_H
225 #include <compat.h>
226 #endif
228 #ifdef HAVE_STROPTS_H
229 #include <stropts.h>
230 #endif
232 #ifdef HAVE_POLL_H
233 #include <poll.h>
234 #endif
236 #if defined(HAVE_RPC_RPC_H)
238 * Check for AUTH_ERROR define conflict with rpc/rpc.h in prot.h.
240 #if defined(HAVE_SYS_SECURITY_H) && defined(HAVE_RPC_AUTH_ERROR_CONFLICT)
241 #undef AUTH_ERROR
242 #endif
243 #include <rpc/rpc.h>
244 #endif
246 #if defined(HAVE_YP_GET_DEFAULT_DOMAIN) && defined(HAVE_SETNETGRENT) && defined(HAVE_ENDNETGRENT) && defined(HAVE_GETNETGRENT)
247 #define HAVE_NETGROUP 1
248 #endif
250 #if defined (HAVE_NETGROUP)
251 #if defined(HAVE_RPCSVC_YP_PROT_H)
252 #include <rpcsvc/yp_prot.h>
253 #endif
254 #if defined(HAVE_RPCSVC_YPCLNT_H)
255 #include <rpcsvc/ypclnt.h>
256 #endif
257 #endif /* HAVE_NETGROUP */
259 #ifndef uchar
260 #define uchar unsigned char
261 #endif
263 #define schar signed char
266 Samba needs type definitions for int16, int32, uint16 and uint32.
268 Normally these are signed and unsigned 16 and 32 bit integers, but
269 they actually only need to be at least 16 and 32 bits
270 respectively. Thus if your word size is 8 bytes just defining them
271 as signed and unsigned int will work.
274 #ifndef uint8
275 #define uint8 unsigned char
276 #endif
278 #if !defined(int16) && !defined(HAVE_INT16_FROM_RPC_RPC_H)
279 #if (SIZEOF_SHORT == 4)
280 #define int16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
281 #else /* SIZEOF_SHORT != 4 */
282 #define int16 short
283 #endif /* SIZEOF_SHORT != 4 */
284 #endif
287 * Note we duplicate the size tests in the unsigned
288 * case as int16 may be a typedef from rpc/rpc.h
291 #if !defined(uint16) && !defined(HAVE_UINT16_FROM_RPC_RPC_H)
292 #if (SIZEOF_SHORT == 4)
293 #define uint16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
294 #else /* SIZEOF_SHORT != 4 */
295 #define uint16 unsigned short
296 #endif /* SIZEOF_SHORT != 4 */
297 #endif
299 #if !defined(int32) && !defined(HAVE_INT32_FROM_RPC_RPC_H)
300 #if (SIZEOF_INT == 4)
301 #define int32 int
302 #elif (SIZEOF_LONG == 4)
303 #define int32 long
304 #elif (SIZEOF_SHORT == 4)
305 #define int32 short
306 #endif
307 #endif
310 * Note we duplicate the size tests in the unsigned
311 * case as int32 may be a typedef from rpc/rpc.h
314 #if !defined(uint32) && !defined(HAVE_UINT32_FROM_RPC_RPC_H)
315 #if (SIZEOF_INT == 4)
316 #define uint32 unsigned int
317 #elif (SIZEOF_LONG == 4)
318 #define uint32 unsigned long
319 #elif (SIZEOF_SHORT == 4)
320 #define uint32 unsigned short
321 #endif
322 #endif
325 * Types for devices, inodes and offsets.
328 #ifndef SMB_DEV_T
329 #define SMB_DEV_T dev_t
330 #endif
333 * Setup the correctly sized inode type.
336 #ifndef SMB_INO_T
337 #define SMB_INO_T ino_t
338 #endif
340 #ifndef LARGE_SMB_INO_T
341 #if defined(SIZEOF_INO_T) && (SIZEOF_INO_T == 8)
342 #define LARGE_SMB_INO_T 1
343 #endif
344 #endif
346 #ifdef LARGE_SMB_INO_T
347 #define SINO_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
348 #else
349 #define SINO_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
350 #endif
352 #ifndef SMB_OFF_T
353 #define SMB_OFF_T off_t
354 #endif
356 #define SMB_OFF_T_BITS (sizeof(SMB_OFF_T)*8)
359 * Set the define that tells us if we can do 64 bit
360 * NT SMB calls.
363 #ifndef LARGE_SMB_OFF_T
364 #if defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)
365 #define LARGE_SMB_OFF_T 1
366 #endif
367 #endif
369 #ifdef LARGE_SMB_OFF_T
370 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
371 #else
372 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
373 #endif
376 * Type for stat structure.
379 #ifndef SMB_STRUCT_STAT
380 #define SMB_STRUCT_STAT struct stat
381 #endif
384 * Type for dirent structure.
387 #ifndef SMB_STRUCT_DIRENT
388 #define SMB_STRUCT_DIRENT struct dirent
389 #endif
392 * Defines for 64 bit fcntl locks.
395 #ifndef SMB_STRUCT_FLOCK
396 #define SMB_STRUCT_FLOCK struct flock
397 #endif
399 #ifndef SMB_F_SETLKW
400 #define SMB_F_SETLKW F_SETLKW
401 #endif
403 #ifndef SMB_F_SETLK
404 #define SMB_F_SETLK F_SETLK
405 #endif
407 #ifndef SMB_F_GETLK
408 #define SMB_F_GETLK F_GETLK
409 #endif
411 #if defined(HAVE_LONGLONG)
412 #define SMB_BIG_UINT unsigned long long
413 #define SMB_BIG_INT long long
414 #define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
415 #else
416 #define SMB_BIG_UINT unsigned long
417 #define SMB_BIG_INT long
418 #define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
419 #endif
421 #ifndef MIN
422 #define MIN(a,b) ((a)<(b)?(a):(b))
423 #endif
425 #ifndef MAX
426 #define MAX(a,b) ((a)>(b)?(a):(b))
427 #endif
429 #ifdef HAVE_BROKEN_GETGROUPS
430 #define GID_T int
431 #else
432 #define GID_T gid_t
433 #endif
436 #include "version.h"
437 #include "smb.h"
438 #include "nameserv.h"
440 #include "byteorder.h"
442 #include "kanji.h"
443 #include "charset.h"
445 #include "nterr.h"
447 #ifndef MAXCODEPAGELINES
448 #define MAXCODEPAGELINES 256
449 #endif
451 /***** automatically generated prototypes *****/
452 #include "proto.h"
454 #ifdef sprintf
455 #undef sprintf
456 #endif /* sprintf */
457 #define sprintf __ERROR__XX__NEVER_USE_SPRINTF__;
459 #define pstrcpy(d,s) safe_strcpy((d),(s),sizeof(pstring)-1)
460 #define pstrcat(d,s) safe_strcat((d),(s),sizeof(pstring)-1)
461 #define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
462 #define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1)
464 #ifdef __COMPAR_FN_T
465 #define QSORT_CAST (__compar_fn_t)
466 #endif
468 #ifndef QSORT_CAST
469 #define QSORT_CAST (int (*)(const void *, const void *))
470 #endif
472 /* this guess needs to be improved (tridge) */
473 #if (defined(STAT_STATVFS) || defined(STAT_STATVFS64)) && !defined(SYSV)
474 #define SYSV 1
475 #endif
477 #ifndef DEFAULT_PRINTING
478 #ifdef SYSV
479 #define DEFAULT_PRINTING PRINT_SYSV
480 #define PRINTCAP_NAME "lpstat"
481 #else
482 #define DEFAULT_PRINTING PRINT_BSD
483 #define PRINTCAP_NAME "/etc/printcap"
484 #endif
485 #endif
487 #ifndef PRINTCAP_NAME
488 #define PRINTCAP_NAME "/etc/printcap"
489 #endif
491 #ifndef SIGCLD
492 #define SIGCLD SIGCHLD
493 #endif
495 #if (defined(HAVE_SYSV_IPC) || defined(HAVE_SHARED_MMAP))
496 #define FAST_SHARE_MODES 1
497 #endif
499 #ifndef MAP_FILE
500 #define MAP_FILE 0
501 #endif
503 #if (!defined(WITH_NISPLUS) && !defined(WITH_LDAP))
504 #define USE_SMBPASS_DB 1
505 #endif
507 #if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
508 #define OSF1_ENH_SEC 1
509 #endif
511 #ifndef ALLOW_CHANGE_PASSWORD
512 #if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
513 #define ALLOW_CHANGE_PASSWORD 1
514 #endif
515 #endif
517 /* what is the longest significant password available on your system?
518 Knowing this speeds up password searches a lot */
519 #ifndef PASSWORD_LENGTH
520 #define PASSWORD_LENGTH 8
521 #endif
523 #ifndef HAVE_PIPE
524 #define SYNC_DNS 1
525 #endif
527 #ifndef MAXPATHLEN
528 #define MAXPATHLEN 256
529 #endif
531 #ifndef SEEK_SET
532 #define SEEK_SET 0
533 #endif
535 #ifndef INADDR_LOOPBACK
536 #define INADDR_LOOPBACK 0x7f000001
537 #endif
539 #ifndef INADDR_NONE
540 #define INADDR_NONE 0xffffffff
541 #endif
543 #ifndef O_ACCMODE
544 #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
545 #endif
547 #if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
548 #define ULTRIX_AUTH 1
549 #endif
551 #ifndef HAVE_INITGROUPS
552 int initgroups (char *name, gid_t id);
553 #endif
555 #ifndef HAVE_RENAME
556 int rename (const char *zfrom, const char *zto);
557 #endif
559 #ifndef HAVE_MKTIME
560 time_t mktime (struct tm *t);
561 #endif
563 #ifndef HAVE_STRTOUL
564 unsigned long strtoul (const char *nptr, char **endptr, int base);
565 #endif
567 #ifdef REPLACE_GETPASS
568 #define getpass(prompt) getsmbpass((prompt))
569 #endif
572 * Some older systems seem not to have MAXHOSTNAMELEN
573 * defined.
575 #ifndef MAXHOSTNAMELEN
576 #define MAXHOSTNAMELEN 254
577 #endif
579 /* yuck, I'd like a better way of doing this */
580 #define DIRP_SIZE (256 + 32)
582 #endif /* _INCLUDES_H */