an initial fix for handling sparse files in smbd
[import/samba-cvsimport.git] / source / include / includes.h
index e2edb512ae5f4c6f8184a391487406e3b44fb337..6084d583ed6aa5b5235f520f16a76ce39bc81188 100644 (file)
@@ -1,10 +1,10 @@
 #ifndef _INCLUDES_H
 #define _INCLUDES_H
 /* 
-   Unix SMB/Netbios implementation.
-   Version 1.9.
+   Unix SMB/CIFS implementation.
    Machine customisation and include handling
    Copyright (C) Andrew Tridgell 1994-1998
+   Copyright (C) 2002 by Martin Pool <mbp@samba.org>
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 #endif
 #endif
 
-/* use gcc attribute to check printf fns */
 #ifdef __GNUC__
+/** Use gcc attribute to check printf fns.  a1 is the 1-based index of
+ * the parameter containing the format, and a2 the index of the first
+ * argument.  **/
 #define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
 #else
 #define PRINTF_ATTRIBUTE(a1, a2)
 #endif
 
+#ifdef __GNUC__
+/** gcc attribute used on function parameters so that it does not emit
+ * warnings about them being unused. **/
+#  define UNUSED(param) param __attribute__ ((unused))
+#else
+#  define UNUSED(param) param
+/** Feel free to add definitions for other compilers here. */
+#endif
+
 #ifdef RELIANTUNIX
 /*
  * <unistd.h> has to be included before any other to get
 #include <sys/socket.h>
 #endif
 
-#ifdef HAVE_SYS_UN_H
+#ifdef HAVE_UNIXSOCKET
 #include <sys/un.h>
 #endif
 
 #include <sys/acl.h>
 #endif
 
-#ifdef HAVE_XFS_ACLS
-#include <acl/acl.h>
-#endif
-
 #ifdef HAVE_SYS_FS_S5PARAM_H 
 #include <sys/fs/s5param.h>
 #endif
 #endif
 
 #ifdef HAVE_SYS_CAPABILITY_H
+
+#if defined(BROKEN_REDHAT_7_SYSTEM_HEADERS) && !defined(_I386_STATFS_H)
+#define _I386_STATFS_H
+#define BROKEN_REDHAT_7_STATFS_WORKAROUND
+#endif
+
 #include <sys/capability.h>
+
+#ifdef BROKEN_REDHAT_7_STATFS_WORKAROUND
+#undef _I386_STATFS_H
+#undef BROKEN_REDHAT_7_STATFS_WORKAROUND
+#endif
+
 #endif
 
 #if defined(HAVE_RPC_RPC_H)
 #endif
 #endif /* HAVE_NETGROUP */
 
+#if defined(HAVE_SYS_IPC_H)
+#include <sys/ipc.h>
+#endif /* HAVE_SYS_IPC_H */
+
+#if defined(HAVE_SYS_SHM_H)
+#include <sys/shm.h>
+#endif /* HAVE_SYS_SHM_H */
+
+#ifdef HAVE_NATIVE_ICONV
+#include <iconv.h>
+#endif
+
+#if HAVE_KRB5_H
+#include <krb5.h>
+#else
+#undef HAVE_KRB5
+#endif
+
+#if HAVE_LBER_H
+#include <lber.h>
+#endif
+
+#if HAVE_LDAP_H
+#include <ldap.h>
+#else
+#undef HAVE_LDAP
+#endif
+
+#if HAVE_GSSAPI_GSSAPI_H
+#include <gssapi/gssapi.h>
+#else
+#undef HAVE_KRB5
+#endif
+
+#if HAVE_GSSAPI_GSSAPI_GENERIC_H
+#include <gssapi/gssapi_generic.h>
+#else
+#undef HAVE_KRB5
+#endif
+
+/* we support ADS if we have krb5 and ldap libs */
+#if defined(HAVE_KRB5) && defined(HAVE_LDAP) && defined(HAVE_GSSAPI)
+#define HAVE_ADS
+#endif
+
 /*
  * Define VOLATILE if needed.
  */
 #endif
 
 /*
- * Define SIG_ATOMIC_T if needed.
+ * Define additional missing types
  */
-
-#if defined(HAVE_SIG_ATOMIC_T_TYPE)
-#define SIG_ATOMIC_T sig_atomic_t
+#if defined(HAVE_SIG_ATOMIC_T_TYPE) && defined(AIX)
+typedef sig_atomic_t SIG_ATOMIC_T;
+#elif defined(HAVE_SIG_ATOMIC_T_TYPE) && !defined(AIX)
+typedef sig_atomic_t VOLATILE SIG_ATOMIC_T;
 #else
-#define SIG_ATOMIC_T int
+typedef int VOLATILE SIG_ATOMIC_T;
+#endif
+
+#ifndef HAVE_SOCKLEN_T_TYPE
+typedef int socklen_t;
 #endif
 
+
 #ifndef uchar
 #define uchar unsigned char
 #endif
 #define int32 long
 #elif (SIZEOF_SHORT == 4)
 #define int32 short
+#else
+/* uggh - no 32 bit type?? probably a CRAY. just hope this works ... */
+#define int32 int
 #endif
 #endif
 
 #define uint32 unsigned long
 #elif (SIZEOF_SHORT == 4)
 #define uint32 unsigned short
+#else
+/* uggh - no 32 bit type?? probably a CRAY. just hope this works ... */
+#define uint32 unsigned
 #endif
 #endif
 
  */
 
 #ifndef SMB_DEV_T
-#define SMB_DEV_T dev_t
+#  if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_DEV64_T)
+#    define SMB_DEV_T dev64_t
+#  else
+#    define SMB_DEV_T dev_t
+#  endif
 #endif
 
 /*
@@ -595,11 +675,6 @@ extern char *sys_errlist[];
 #define strerror(i) sys_errlist[i]
 #endif
 
-#ifndef HAVE_STRCHR
-# define strchr                 index
-# define strrchr                rindex
-#endif
-
 #ifndef HAVE_ERRNO_DECL
 extern int errno;
 #endif
@@ -614,20 +689,31 @@ extern int errno;
 #define NGROUPS_MAX 32 /* Guess... */
 #endif
 
+/* Our own pstrings and fstrings */
+#include "pstring.h"
+
 /* Lists, trees, caching, database... */
+#include "xfile.h"
+#include "intl.h"
 #include "ubi_sLinkList.h"
 #include "ubi_dLinkList.h"
 #include "dlinklist.h"
 #include "../tdb/tdb.h"
 #include "../tdb/spinlock.h"
+#include "../tdb/tdbutil.h"
 #include "talloc.h"
+#include "ads.h"
 #include "interfaces.h"
 #include "hash.h"
 #include "trans2.h"
 #include "nterr.h"
-#include "secrets.h"
+#include "ntioctl.h"
 #include "messages.h"
-#include "util_list.h"
+#include "charset.h"
+#include "dynconfig.h"
+#include "adt_tree.h"
+
+#include "util_getent.h"
 
 #ifndef UBI_BINTREE_H
 #include "ubi_Cache.h"
@@ -640,22 +726,34 @@ extern int errno;
 #include "smbw.h"
 #include "nameserv.h"
 
-#include "byteorder.h"
+#include "secrets.h"
 
-#include "kanji.h"
-#include "charset.h"
+#include "byteorder.h"
 
 #include "ntdomain.h"
 
 #include "msdfs.h"
 
-#include "profile.h"
+#include "smbprofile.h"
 
 #include "mapping.h"
 
-#ifndef MAXCODEPAGELINES
-#define MAXCODEPAGELINES 256
-#endif
+#include "rap.h"
+
+#include "md5.h"
+#include "hmacmd5.h"
+
+#include "auth.h"
+
+#include "passdb.h"
+
+#include "session.h"
+
+#include "asn_1.h"
+
+#include "popt.h"
+
+#include "mangle.h"
 
 /*
  * Type for wide character dirent structure.
@@ -680,6 +778,13 @@ typedef struct smb_wpasswd {
        wpstring       pw_shell;
 } SMB_STRUCT_WPASSWD;
 
+/* used in net.c */
+struct functable {
+       char *funcname;
+       int (*fn)(int argc, const char **argv);
+};
+
+
 /* Defines for wisXXX functions. */
 #define UNI_UPPER    0x1
 #define UNI_LOWER    0x2
@@ -687,19 +792,7 @@ typedef struct smb_wpasswd {
 #define UNI_XDIGIT   0x8
 #define UNI_SPACE    0x10
 
-#ifdef HAVE_NSS_H
-#include <nss.h>
-#else
-
-/* Minimal needed to compile.. */
-
-enum nss_status {
-       NSS_STATUS_SUCCESS,
-       NSS_STATUS_NOTFOUND,
-       NSS_STATUS_UNAVAIL
-};
-
-#endif
+#include "nsswitch/nss.h"
 
 /***** automatically generated prototypes *****/
 #include "proto.h"
@@ -722,7 +815,7 @@ enum nss_status {
 #endif
 
 #ifndef DEFAULT_PRINTING
-#ifdef HAVE_LIBCUPS
+#ifdef HAVE_CUPS
 #define DEFAULT_PRINTING PRINT_CUPS
 #define PRINTCAP_NAME "cups"
 #elif defined(SYSV)
@@ -746,7 +839,7 @@ enum nss_status {
 #define MAP_FILE 0
 #endif
 
-#if (!defined(WITH_NISPLUS) && !defined(WITH_LDAP) && !defined(WITH_TDBPWD))
+#if (!defined(WITH_NISPLUS) && !defined(WITH_LDAP) && !defined(WITH_TDB_SAM))
 #define USE_SMBPASS_DB 1
 #endif
 
@@ -840,10 +933,26 @@ int rename(const char *zfrom, const char *zto);
 time_t mktime(struct tm *t);
 #endif
 
+#ifndef HAVE_STRLCPY
+size_t strlcpy(char *d, const char *s, size_t bufsize);
+#endif
+
+#ifndef HAVE_STRLCAT
+size_t strlcat(char *d, const char *s, size_t bufsize);
+#endif
+
 #ifndef HAVE_FTRUNCATE
 int ftruncate(int f,long l);
 #endif
 
+#ifndef HAVE_STRNDUP
+char *strndup(const char *s, size_t n);
+#endif
+
+#ifndef HAVE_STRNLEN
+size_t strnlen(const char *s, size_t n);
+#endif
+
 #ifndef HAVE_STRTOUL
 unsigned long strtoul(const char *nptr, char **endptr, int base);
 #endif
@@ -855,6 +964,9 @@ int setresuid(uid_t ruid, uid_t euid, uid_t suid);
 #if (defined(USE_SETRESUID) && !defined(HAVE_SETRESGID_DECL))
 int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
 #endif
+#ifndef HAVE_VASPRINTF_DECL
+int vasprintf(char **ptr, const char *format, va_list ap);
+#endif
 
 #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
 #define bzero(a,b) memset((a),'\0',(b))
@@ -892,12 +1004,19 @@ int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
 #define DEFAULT_SOCKET_OPTIONS ""
 #endif
 
-/* Load header file for libdl stuff */
+/* Load header file for dynamic linking stuff */
 
-#ifdef HAVE_LIBDL
+#ifdef HAVE_DLFCN_H
 #include <dlfcn.h>
 #endif
 
+/* dmalloc -- free heap debugger (dmalloc.org).  This should be near
+ * the *bottom* of include files so as not to conflict. */
+#ifdef ENABLE_DMALLOC
+#  include <dmalloc.h>
+#endif
+
+
 /* Some POSIX definitions for those without */
  
 #ifndef S_IFDIR
@@ -943,23 +1062,46 @@ int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
 #define S_IXOTH 00001           /* execute permission: other */
 #endif
 
-/* NetBSD doesn't have these */
-#ifndef SHM_R
-#define SHM_R 0400
+/* For sys_adminlog(). */
+#ifndef LOG_EMERG
+#define LOG_EMERG       0       /* system is unusable */
 #endif
 
-#ifndef SHM_W
-#define SHM_W 0200
+#ifndef LOG_ALERT
+#define LOG_ALERT       1       /* action must be taken immediately */
+#endif
+
+#ifndef LOG_CRIT
+#define LOG_CRIT        2       /* critical conditions */
+#endif
+
+#ifndef LOG_ERR
+#define LOG_ERR         3       /* error conditions */
 #endif
 
+#ifndef LOG_WARNING
+#define LOG_WARNING     4       /* warning conditions */
+#endif
 
-/* Some systems (SCO) treat UNIX domain sockets as FIFOs */
+#ifndef LOG_NOTICE
+#define LOG_NOTICE      5       /* normal but significant condition */
+#endif
 
-#ifndef S_IFSOCK
-#define S_IFSOCK S_IFIFO
+#ifndef LOG_INFO
+#define LOG_INFO        6       /* informational */
 #endif
-#ifndef S_ISSOCK
-#define S_ISSOCK(mode)  ((mode & S_IFSOCK) == S_IFSOCK)
+
+#ifndef LOG_DEBUG
+#define LOG_DEBUG       7       /* debug-level messages */
+#endif
+
+/* NetBSD doesn't have these */
+#ifndef SHM_R
+#define SHM_R 0400
+#endif
+
+#ifndef SHM_W
+#define SHM_W 0200
 #endif
 
 #if HAVE_KERNEL_SHARE_MODES
@@ -988,6 +1130,7 @@ extern int DEBUGLEVEL;
 #define F_SETLKW 14
 #endif
 
+
 /* Needed for sys_dlopen/sys_dlsym/sys_dlclose */
 #ifndef RTLD_GLOBAL
 #define RTLD_GLOBAL 0
@@ -1001,13 +1144,21 @@ extern int DEBUGLEVEL;
 #define RTLD_NOW 0
 #endif
 
+/* needed for some systems without iconv. Doesn't really matter
+   what error code we use */
+#ifndef EILSEQ
+#define EILSEQ EIO
+#endif
+
 /* add varargs prototypes with printf checking */
-int fdprintf(int , char *, ...) PRINTF_ATTRIBUTE(2,3);
-#ifndef HAVE_SNPRINTF
+int fdprintf(int , const char *, ...) PRINTF_ATTRIBUTE(2,3);
+int d_printf(const char *, ...) PRINTF_ATTRIBUTE(1,2);
+int d_fprintf(FILE *f, const char *, ...) PRINTF_ATTRIBUTE(2,3);
+#ifndef HAVE_SNPRINTF_DECL
 int snprintf(char *,size_t ,const char *, ...) PRINTF_ATTRIBUTE(3,4);
 #endif
-#ifndef HAVE_ASPRINTF
-int asprintf(char **,char *, ...) PRINTF_ATTRIBUTE(2,3);
+#ifndef HAVE_ASPRINTF_DECL
+int asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3);
 #endif
 
 /* we used to use these fns, but now we have good replacements
@@ -1015,5 +1166,13 @@ int asprintf(char **,char *, ...) PRINTF_ATTRIBUTE(2,3);
 #define slprintf snprintf
 #define vslprintf vsnprintf
 
+
+/* we need to use __va_copy() on some platforms */
+#ifdef HAVE_VA_COPY
+#define VA_COPY(dest, src) __va_copy(dest, src)
+#else
+#define VA_COPY(dest, src) (dest) = (src)
+#endif
+
 #endif /* _INCLUDES_H */