Rely on standard {u,}int{8,16,32,64}_t types provided by system or
[abartlet/samba.git/.git] / source3 / include / includes.h
index 14ef2258e6f4e2cd76843f6857443ded696f0c41..0df4ef9ec766180a03eb8929be350b0ae0cc350c 100644 (file)
@@ -25,7 +25,7 @@
 #undef SIZEOF_LONG
 #endif
 
-#include "lib/replace/replace.h"
+#include "../replace/replace.h"
 
 /* make sure we have included the correct config.h */
 #ifndef NO_CONFIG_H /* for some tests */
@@ -250,6 +250,10 @@ typedef int ber_int_t;
 #include <langinfo.h>
 #endif
 
+#if HAVE_NETGROUP_H
+#include <netgroup.h>
+#endif
+
 #if defined(HAVE_AIO_H) && defined(WITH_AIO)
 #include <aio.h>
 #endif
@@ -281,37 +285,21 @@ typedef int ber_int_t;
 #define HAVE_ADS
 #endif
 
-/*
- * Define VOLATILE if needed.
- */
-
-#if defined(HAVE_VOLATILE)
-#define VOLATILE volatile
-#else
-#define VOLATILE
-#endif
-
 /*
  * Define additional missing types
  */
 #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;
+typedef sig_atomic_t volatile SIG_ATOMIC_T;
 #else
-typedef int VOLATILE SIG_ATOMIC_T;
+typedef int volatile SIG_ATOMIC_T;
 #endif
 
 #ifndef uchar
 #define uchar unsigned char
 #endif
 
-#ifdef HAVE_UNSIGNED_CHAR
-#define schar signed char
-#else
-#define schar char
-#endif
-
 /*
    Samba needs type definitions for int16, int32, uint16 and uint32.
 
@@ -322,15 +310,11 @@ typedef int VOLATILE SIG_ATOMIC_T;
 */
 
 #ifndef uint8
-#define uint8 unsigned char
+#define uint8 uint8_t
 #endif
 
 #if !defined(int16) && !defined(HAVE_INT16_FROM_RPC_RPC_H)
-#  if (SIZEOF_SHORT == 4)
-#    define int16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
-#  else /* SIZEOF_SHORT != 4 */
-#    define int16 short
-#  endif /* SIZEOF_SHORT != 4 */
+#  define int16 int16_t
    /* needed to work around compile issue on HP-UX 11.x */
 #  define _INT16       1
 #endif
@@ -340,25 +324,13 @@ typedef int VOLATILE SIG_ATOMIC_T;
  * case as int16 may be a typedef from rpc/rpc.h
  */
 
+
 #if !defined(uint16) && !defined(HAVE_UINT16_FROM_RPC_RPC_H)
-#if (SIZEOF_SHORT == 4)
-#define uint16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
-#else /* SIZEOF_SHORT != 4 */
-#define uint16 unsigned short
-#endif /* SIZEOF_SHORT != 4 */
+#  define uint16 uint16_t
 #endif
 
 #if !defined(int32) && !defined(HAVE_INT32_FROM_RPC_RPC_H)
-#  if (SIZEOF_INT == 4)
-#    define int32 int
-#  elif (SIZEOF_LONG == 4)
-#    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
+#  define int32 int32_t
    /* needed to work around compile issue on HP-UX 11.x */
 #  define _INT32       1
 #endif
@@ -369,16 +341,7 @@ typedef int VOLATILE SIG_ATOMIC_T;
  */
 
 #if !defined(uint32) && !defined(HAVE_UINT32_FROM_RPC_RPC_H)
-#if (SIZEOF_INT == 4)
-#define uint32 unsigned int
-#elif (SIZEOF_LONG == 4)
-#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
+#  define uint32 uint32_t
 #endif
 
 /*
@@ -386,19 +349,11 @@ typedef int VOLATILE SIG_ATOMIC_T;
  */
 
 #if !defined(uint64)
-#if (SIZEOF_LONG == 8)
-#define uint64 unsigned long
-#elif (SIZEOF_LONG_LONG == 8)
-#define uint64 unsigned long long
-#endif /* don't lie.  If we don't have it, then don't use it */
+#  define uint64 uint64_t
 #endif
 
 #if !defined(int64)
-#if (SIZEOF_LONG == 8)
-#define int64 long
-#elif (SIZEOF_LONG_LONG == 8)
-#define int64 long long
-#endif /* don't lie.  If we don't have it, then don't use it */
+#  define int64 int64_t
 #endif
 
 
@@ -422,7 +377,7 @@ typedef int VOLATILE SIG_ATOMIC_T;
 
 #ifdef LARGE_SMB_DEV_T
 #define SDEV_T_VAL(p, ofs, v) (SIVAL((p),(ofs),(v)&0xFFFFFFFF), SIVAL((p),(ofs)+4,(v)>>32))
-#define DEV_T_VAL(p, ofs) ((SMB_DEV_T)(((SMB_BIG_UINT)(IVAL((p),(ofs))))| (((SMB_BIG_UINT)(IVAL((p),(ofs)+4))) << 32)))
+#define DEV_T_VAL(p, ofs) ((SMB_DEV_T)(((uint64_t)(IVAL((p),(ofs))))| (((uint64_t)(IVAL((p),(ofs)+4))) << 32)))
 #else 
 #define SDEV_T_VAL(p, ofs, v) (SIVAL((p),(ofs),v),SIVAL((p),(ofs)+4,0))
 #define DEV_T_VAL(p, ofs) ((SMB_DEV_T)(IVAL((p),(ofs))))
@@ -448,7 +403,7 @@ typedef int VOLATILE SIG_ATOMIC_T;
 
 #ifdef LARGE_SMB_INO_T
 #define SINO_T_VAL(p, ofs, v) (SIVAL((p),(ofs),(v)&0xFFFFFFFF), SIVAL((p),(ofs)+4,(v)>>32))
-#define INO_T_VAL(p, ofs) ((SMB_INO_T)(((SMB_BIG_UINT)(IVAL(p,ofs)))| (((SMB_BIG_UINT)(IVAL(p,(ofs)+4))) << 32)))
+#define INO_T_VAL(p, ofs) ((SMB_INO_T)(((uint64_t)(IVAL(p,ofs)))| (((uint64_t)(IVAL(p,(ofs)+4))) << 32)))
 #else 
 #define SINO_T_VAL(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
 #define INO_T_VAL(p, ofs) ((SMB_INO_T)(IVAL((p),(ofs))))
@@ -462,20 +417,13 @@ typedef int VOLATILE SIG_ATOMIC_T;
 #  endif
 #endif
 
-#if defined(HAVE_LONGLONG)
-#define SMB_BIG_UINT unsigned long long
-#define SMB_BIG_INT long long
 #define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
-#else
-#define SMB_BIG_UINT unsigned long
-#define SMB_BIG_INT long
-#define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
-#endif
+#define IVAL2_TO_SMB_BIG_UINT(buf,off) ( (((uint64_t)(IVAL((buf),(off)))) & ((uint64_t)0xFFFFFFFF)) | \
+               (( ((uint64_t)(IVAL((buf),(off+4)))) & ((uint64_t)0xFFFFFFFF) ) << 32 ) )
 
-#define SMB_BIG_UINT_BITS (sizeof(SMB_BIG_UINT)*8)
 
 /* this should really be a 64 bit type if possible */
-#define br_off SMB_BIG_UINT
+typedef uint64_t br_off;
 
 #define SMB_OFF_T_BITS (sizeof(SMB_OFF_T)*8)
 
@@ -493,15 +441,11 @@ typedef int VOLATILE SIG_ATOMIC_T;
 #ifdef LARGE_SMB_OFF_T
 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
 #define SOFF_T_R(p, ofs, v) (SIVAL(p,(ofs)+4,(v)&0xFFFFFFFF), SIVAL(p,ofs,(v)>>32))
-#define IVAL_TO_SMB_OFF_T(buf,off) ((SMB_OFF_T)(( ((SMB_BIG_UINT)(IVAL((buf),(off)))) & ((SMB_BIG_UINT)0xFFFFFFFF) )))
-#define IVAL2_TO_SMB_BIG_UINT(buf,off) ( (((SMB_BIG_UINT)(IVAL((buf),(off)))) & ((SMB_BIG_UINT)0xFFFFFFFF)) | \
-               (( ((SMB_BIG_UINT)(IVAL((buf),(off+4)))) & ((SMB_BIG_UINT)0xFFFFFFFF) ) << 32 ) )
+#define IVAL_TO_SMB_OFF_T(buf,off) ((SMB_OFF_T)(( ((uint64_t)(IVAL((buf),(off)))) & ((uint64_t)0xFFFFFFFF) )))
 #else 
 #define SOFF_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
 #define SOFF_T_R(p, ofs, v) (SIVAL(p,(ofs)+4,v),SIVAL(p,ofs,0))
 #define IVAL_TO_SMB_OFF_T(buf,off) ((SMB_OFF_T)(( ((uint32)(IVAL((buf),(off)))) & 0xFFFFFFFF )))
-#define IVAL2_TO_SMB_BIG_UINT(buf,off) ( (((SMB_BIG_UINT)(IVAL((buf),(off)))) & ((SMB_BIG_UINT)0xFFFFFFFF)) | \
-                               (( ((SMB_BIG_UINT)(IVAL((buf),(off+4)))) & ((SMB_BIG_UINT)0xFFFFFFFF) ) << 32 ) )
 #endif
 
 /*
@@ -642,13 +586,16 @@ typedef char fstring[FSTRING_LEN];
 #endif
 
 /* Lists, trees, caching, database... */
-#include "xfile.h"
+#include "../lib/util/xfile.h"
 #include "intl.h"
-#include "dlinklist.h"
+#include "../lib/util/dlinklist.h"
 #include "tdb.h"
 #include "util_tdb.h"
 
-#include "lib/talloc/talloc.h"
+#include "../talloc/talloc.h"
+
+#include "../lib/util/data_blob.h"
+#include "../lib/util/time.h"
 /* And a little extension. Abort on type mismatch */
 #define talloc_get_type_abort(ptr, type) \
        (type *)talloc_check_name_abort(ptr, #type)
@@ -669,10 +616,9 @@ typedef char fstring[FSTRING_LEN];
 #include "messages.h"
 #include "locking.h"
 #include "smb.h"
-#include "ads_cldap.h"
 #include "nameserv.h"
 #include "secrets.h"
-#include "byteorder.h"
+#include "../lib/util/byteorder.h"
 #include "privileges.h"
 #include "rpc_misc.h"
 #include "rpc_dce.h"
@@ -683,25 +629,27 @@ typedef char fstring[FSTRING_LEN];
 #include "authdata.h"
 #include "msdfs.h"
 #include "rap.h"
-#include "md5.h"
-#include "hmacmd5.h"
+#include "../lib/crypto/md5.h"
+#include "../lib/crypto/arcfour.h"
+#include "../lib/crypto/crc32.h"
+#include "../lib/crypto/hmacmd5.h"
 #include "ntlmssp.h"
 #include "auth.h"
 #include "ntdomain.h"
 #include "rpc_svcctl.h"
 #include "rpc_ntsvcs.h"
 #include "rpc_lsa.h"
-#include "rpc_netlogon.h"
 #include "reg_objects.h"
 #include "reg_db.h"
-#include "rpc_samr.h"
-#include "rpc_srvsvc.h"
 #include "rpc_spoolss.h"
 #include "rpc_eventlog.h"
-#include "rpc_ds.h"
 #include "rpc_perfcount.h"
 #include "rpc_perfcount_defs.h"
 #include "librpc/gen_ndr/notify.h"
+#include "librpc/gen_ndr/xattr.h"
+#include "librpc/gen_ndr/messaging.h"
+#include "librpc/gen_ndr/ndr_nbt.h"
+#include "librpc/rpc/dcerpc.h"
 #include "nt_printing.h"
 #include "idmap.h"
 #include "client.h"
@@ -720,18 +668,11 @@ typedef char fstring[FSTRING_LEN];
 #include "ctdbd_conn.h"
 #include "talloc_stack.h"
 #include "memcache.h"
+#include "async_req.h"
+#include "async_smb.h"
+#include "async_sock.h"
 
-/* used in net.c */
-struct functable {
-       const char *funcname;
-       int (*fn)(int argc, const char **argv);
-};
-
-struct functable2 {
-       const char *funcname;
-       int (*fn)(int argc, const char **argv);
-       const char *helptext;
-};
+#include "lib/smbconf/smbconf.h"
 
 /* Defines for wisXXX functions. */
 #define UNI_UPPER    0x1
@@ -784,6 +725,7 @@ enum flush_reason_enum {
     NUM_FLUSH_REASONS};
 
 #include "nss_info.h"
+#include "modules/nfs4_acls.h"
 #include "nsswitch/libwbclient/wbclient.h"
 
 /* generated rpc server implementation functions */
@@ -799,6 +741,26 @@ enum flush_reason_enum {
 #include "proto.h"
 #endif
 
+#if defined(HAVE_POSIX_ACLS)
+#include "modules/vfs_posixacl.h"
+#endif
+
+#if defined(HAVE_TRU64_ACLS)
+#include "modules/vfs_tru64acl.h"
+#endif
+
+#if defined(HAVE_SOLARIS_ACLS) || defined(HAVE_UNIXWARE_ACLS)
+#include "modules/vfs_solarisacl.h"
+#endif
+
+#if defined(HAVE_HPUX_ACLS)
+#include "modules/vfs_hpuxacl.h"
+#endif
+
+#if defined(HAVE_IRIX_ACLS)
+#include "modules/vfs_irixacl.h"
+#endif
+
 #ifdef HAVE_LDAP
 #include "ads_protos.h"
 #endif
@@ -811,6 +773,9 @@ enum flush_reason_enum {
 #include "srvstr.h"
 #include "safe_string.h"
 
+/* prototypes from lib/util_transfer_file.c */
+#include "transfer_file.h"
+
 #ifdef __COMPAR_FN_T
 #define QSORT_CAST (__compar_fn_t)
 #endif
@@ -900,14 +865,6 @@ int setresuid(uid_t ruid, uid_t euid, uid_t suid);
 int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
 #endif
 
-/*
- * Some older systems seem not to have MAXHOSTNAMELEN
- * defined.
- */
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 255
-#endif
-
 /* yuck, I'd like a better way of doing this */
 #define DIRP_SIZE (256 + 32)
 
@@ -1104,6 +1061,14 @@ char *talloc_asprintf_strupper_m(TALLOC_CTX *t, const char *fmt, ...) PRINTF_ATT
 #define VXFS_QUOTA
 #endif
 
+#ifndef XATTR_CREATE
+#define XATTR_CREATE  0x1       /* set value, fail if attr already exists */
+#endif
+
+#ifndef XATTR_REPLACE
+#define XATTR_REPLACE 0x2       /* set value, fail if attr does not exist */
+#endif
+
 #if defined(HAVE_KRB5)
 
 krb5_error_code smb_krb5_parse_name(krb5_context context,
@@ -1138,8 +1103,7 @@ void krb5_free_unparsed_name(krb5_context ctx, char *val);
 
 /* Samba wrapper function for krb5 functionality. */
 bool setup_kaddr( krb5_address *pkaddr, struct sockaddr_storage *paddr);
-int create_kerberos_key_from_string(krb5_context context, krb5_principal host_princ, krb5_data *password, krb5_keyblock *key, krb5_enctype enctype);
-int create_kerberos_key_from_string_direct(krb5_context context, krb5_principal host_princ, krb5_data *password, krb5_keyblock *key, krb5_enctype enctype);
+int create_kerberos_key_from_string(krb5_context context, krb5_principal host_princ, krb5_data *password, krb5_keyblock *key, krb5_enctype enctype, bool no_salt);
 bool get_auth_data_from_tkt(TALLOC_CTX *mem_ctx, DATA_BLOB *auth_data, krb5_ticket *tkt);
 krb5_const_principal get_principal_from_tkt(krb5_ticket *tkt);
 krb5_error_code smb_krb5_locate_kdc(krb5_context ctx, const krb5_data *realm, struct sockaddr **addr_pp, int *naddrs, int get_masters);
@@ -1155,15 +1119,15 @@ bool kerberos_compatible_enctypes(krb5_context context, krb5_enctype enctype1, k
 void kerberos_free_data_contents(krb5_context context, krb5_data *pdata);
 NTSTATUS decode_pac_data(TALLOC_CTX *mem_ctx,
                         DATA_BLOB *pac_data_blob,
-                        krb5_context context, 
+                        krb5_context context,
                         krb5_keyblock *service_keyblock,
                         krb5_const_principal client_principal,
                         time_t tgs_authtime,
-                        PAC_DATA **pac_data);
+                        struct PAC_DATA **pac_data_out);
 void smb_krb5_checksum_from_pac_sig(krb5_checksum *cksum, 
-                                   PAC_SIGNATURE_DATA *sig);
+                                   struct PAC_SIGNATURE_DATA *sig);
 krb5_error_code smb_krb5_verify_checksum(krb5_context context,
-                                        krb5_keyblock *keyblock,
+                                        const krb5_keyblock *keyblock,
                                         krb5_keyusage usage,
                                         krb5_checksum *cksum,
                                         uint8 *data,
@@ -1191,7 +1155,6 @@ bool smb_krb5_principal_compare_any_realm(krb5_context context,
                                          krb5_const_principal princ2);
 int cli_krb5_get_ticket(const char *principal, time_t time_offset, 
                        DATA_BLOB *ticket, DATA_BLOB *session_key_krb5, uint32 extra_ap_opts, const char *ccname, time_t *tgs_expire);
-PAC_LOGON_INFO *get_logon_info_from_pac(PAC_DATA *pac_data);
 krb5_error_code smb_krb5_renew_ticket(const char *ccache_string, const char *client_string, const char *service_string, time_t *expire_time);
 krb5_error_code kpasswd_err_to_krb5_err(krb5_error_code res_code);
 krb5_error_code smb_krb5_gen_netbios_krb5_address(smb_krb5_addresses **kerb_addr);
@@ -1210,7 +1173,7 @@ krb5_error_code smb_krb5_mk_error(krb5_context context,
                                        krb5_error_code error_code,
                                        const krb5_principal server,
                                        krb5_data *reply);
-krb5_enctype smb_get_enctype_from_kt_entry(const krb5_keytab_entry *kt_entry);
+krb5_enctype smb_get_enctype_from_kt_entry(krb5_keytab_entry *kt_entry);
 krb5_error_code smb_krb5_enctype_to_string(krb5_context context, 
                                            krb5_enctype enctype, 
                                            char **etype_s);
@@ -1218,6 +1181,19 @@ krb5_error_code smb_krb5_open_keytab(krb5_context context,
                                      const char *keytab_name, 
                                      bool write_access, 
                                      krb5_keytab *keytab);
+krb5_error_code smb_krb5_keytab_name(TALLOC_CTX *mem_ctx,
+                                    krb5_context context,
+                                    krb5_keytab keytab,
+                                    const char **keytab_name);
+int smb_krb5_kt_add_entry_ext(krb5_context context,
+                             krb5_keytab keytab,
+                             krb5_kvno kvno,
+                             const char *princ_s,
+                             krb5_enctype *enctypes,
+                             krb5_data password,
+                             bool no_salt,
+                             bool keep_old_entries);
+
 #endif /* HAVE_KRB5 */
 
 
@@ -1274,4 +1250,9 @@ void exit_server_fault(void) NORETURN_ATTRIBUTE ;
 #include "libnscd.h"
 #endif
 
+#if defined(HAVE_IPV6)
+void in6_addr_to_sockaddr_storage(struct sockaddr_storage *ss,
+                                 struct in6_addr ip);
+#endif
+
 #endif /* _INCLUDES_H */