Rename cache.[ch] to memcache.[ch]
[samba.git] / source3 / include / includes.h
index ede93e5865d92943f62ca019d9590ddc5418114d..fdeff346e540b64119971d089614dd7e529a9adb 100644 (file)
@@ -8,7 +8,7 @@
    
    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
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -17,8 +17,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 /* work around broken krb5.h on sles9 */
 #undef SIZEOF_LONG
 #endif
 
-#ifndef NO_CONFIG_H /* for some tests */
 #include "lib/replace/replace.h"
+
+/* make sure we have included the correct config.h */
+#ifndef NO_CONFIG_H /* for some tests */
+#ifndef CONFIG_H_IS_FROM_SAMBA
+#error "make sure you have removed all config.h files from standalone builds!"
+#error "the included config.h isn't from samba!"
 #endif
+#endif /* NO_CONFIG_H */
 
 /* only do the C++ reserved word check when we compile
    to include --with-developer since too many systems
 #endif
 #endif
 
-#ifndef NORETURN_ATTRIBUTE
-#if (__GNUC__ >= 3)
-#define NORETURN_ATTRIBUTE __attribute__ ((noreturn))
-#else
-#define NORETURN_ATTRIBUTE
-#endif
-#endif
-
 #if defined(__GNUC__) && !defined(__cplusplus)
 /** gcc attribute used on function parameters so that it does not emit
  * warnings about them being unused. **/
 #include "system/locale.h"
 #include "system/network.h"
 #include "system/passwd.h"
-#include "system/printing.h"
 #include "system/readline.h"
 #include "system/select.h"
 #include "system/shmem.h"
 #include "system/time.h"
 #include "system/wait.h"
 
-#ifdef HAVE_STROPTS_H
-#include <stropts.h>
-#endif
-
-#ifdef HAVE_POLL_H
-#include <poll.h>
-#endif
-
 #if defined(HAVE_RPC_RPC_H)
 /*
  * Check for AUTH_ERROR define conflict with rpc/rpc.h in prot.h.
 
 #if HAVE_LBER_H
 #include <lber.h>
+#if defined(HPUX) && !defined(_LBER_TYPES_H)
+/* Define ber_tag_t and ber_int_t for using
+ * HP LDAP-UX Integration products' LDAP libraries.
+*/
+#ifndef ber_tag_t
+typedef unsigned long ber_tag_t;
+typedef int ber_int_t;
+#endif
+#endif /* defined(HPUX) && !defined(_LBER_TYPES_H) */
 #ifndef LBER_USE_DER
 #define LBER_USE_DER 0x01
 #endif
 #include <sys/attributes.h>
 #endif
 
+#ifndef ENOATTR
+#define ENOATTR ENODATA
+#endif
+
 /* mutually exclusive (SuSE 8.2) */
 #if HAVE_ATTR_XATTR_H
 #include <attr/xattr.h>
@@ -301,12 +302,6 @@ typedef sig_atomic_t VOLATILE SIG_ATOMIC_T;
 typedef int VOLATILE SIG_ATOMIC_T;
 #endif
 
-#ifndef HAVE_SOCKLEN_T_TYPE
-#define HAVE_SOCKLEN_T_TYPE
-typedef int socklen_t;
-#endif
-
-
 #ifndef uchar
 #define uchar unsigned char
 #endif
@@ -612,11 +607,6 @@ struct timespec {
 #define MAX(a,b) ((a)>(b)?(a):(b))
 #endif
 
-#ifndef _UPPER_BOOL
-typedef int BOOL;
-#define _UPPER_BOOL
-#endif
-
 #ifdef HAVE_BROKEN_GETGROUPS
 #define GID_T int
 #else
@@ -627,16 +617,36 @@ typedef int BOOL;
 #define NGROUPS_MAX 32 /* Guess... */
 #endif
 
-/* Our own pstrings and fstrings */
-#include "pstring.h"
+/* Our own fstrings */
+
+/*
+                  --------------
+                 /              \
+                /      REST      \
+               /        IN        \
+              /       PEACE        \
+             /                      \
+             | The infamous pstring |
+             |                      |
+             |                      |
+             |      7 December      |
+             |                      |
+             |         2007         |
+            *|     *  *  *          | *
+   _________)/\\_//(\/(/\)/\//\/\///|_)_______
+*/
+
+#ifndef FSTRING_LEN
+#define FSTRING_LEN 256
+typedef char fstring[FSTRING_LEN];
+#endif
 
 /* Lists, trees, caching, database... */
 #include "xfile.h"
 #include "intl.h"
 #include "dlinklist.h"
 #include "tdb.h"
-#include "tdbutil.h"
-#include "tdbback.h"
+#include "util_tdb.h"
 
 #include "lib/talloc/talloc.h"
 /* And a little extension. Abort on type mismatch */
@@ -650,13 +660,13 @@ typedef int BOOL;
 #include "trans2.h"
 #include "nterr.h"
 #include "ntioctl.h"
-#include "messages.h"
 #include "charset.h"
 #include "dynconfig.h"
 #include "util_getent.h"
 #include "debugparse.h"
 #include "version.h"
 #include "privileges.h"
+#include "messages.h"
 #include "locking.h"
 #include "smb.h"
 #include "ads_cldap.h"
@@ -669,6 +679,7 @@ typedef int BOOL;
 #include "mapping.h"
 #include "passdb.h"
 #include "rpc_secdes.h"
+#include "gpo.h"
 #include "authdata.h"
 #include "msdfs.h"
 #include "rap.h"
@@ -682,25 +693,19 @@ typedef int BOOL;
 #include "rpc_lsa.h"
 #include "rpc_netlogon.h"
 #include "reg_objects.h"
-#include "rpc_reg.h"
+#include "reg_db.h"
 #include "rpc_samr.h"
-#include "rpc_wkssvc.h"
+#include "rpc_srvsvc.h"
 #include "rpc_spoolss.h"
 #include "rpc_eventlog.h"
 #include "rpc_ds.h"
-#include "rpc_shutdown.h"
 #include "rpc_perfcount.h"
 #include "rpc_perfcount_defs.h"
-#include "librpc/gen_ndr/srvsvc.h"
-#include "librpc/gen_ndr/echo.h"
+#include "librpc/gen_ndr/notify.h"
 #include "nt_printing.h"
 #include "idmap.h"
 #include "client.h"
 
-#ifdef WITH_SMBWRAPPER
-#include "smbw.h"
-#endif
-
 #include "session.h"
 #include "asn_1.h"
 #include "popt.h"
@@ -710,29 +715,11 @@ typedef int BOOL;
 #include "spnego.h"
 #include "rpc_client.h"
 #include "event.h"
-
-/*
- * Type for wide character dirent structure.
- * Only d_name is defined by POSIX.
- */
-
-typedef struct smb_wdirent {
-       wpstring        d_name;
-} SMB_STRUCT_WDIRENT;
-
-/*
- * Type for wide character passwd structure.
- */
-
-typedef struct smb_wpasswd {
-       wfstring       pw_name;
-       char           *pw_passwd;
-       uid_t          pw_uid;
-       gid_t          pw_gid;
-       wpstring       pw_gecos;
-       wpstring       pw_dir;
-       wpstring       pw_shell;
-} SMB_STRUCT_WPASSWD;
+#include "dbwrap.h"
+#include "packet.h"
+#include "ctdbd_conn.h"
+#include "talloc_stack.h"
+#include "memcache.h"
 
 /* used in net.c */
 struct functable {
@@ -760,14 +747,26 @@ struct functable2 {
 
 struct printjob;
 
-struct smb_ldap_privates;
-
 /* forward declarations from smbldap.c */
 
 #include "smbldap.h"
 
 #include "smb_ldap.h"
 
+struct dns_reg_state;
+
+void dns_register_smbd(struct dns_reg_state ** dns_state_ptr,
+               unsigned port,
+               int *maxfd,
+               fd_set *listen_set,
+               struct timeval *timeout);
+
+void dns_register_close(struct dns_reg_state ** dns_state_ptr);
+
+
+bool dns_register_smbd_reply(struct dns_reg_state *dns_state,
+               fd_set *lfds, struct timeval *timeout);
+
 /*
  * Reasons for cache flush.
  */
@@ -784,6 +783,16 @@ enum flush_reason_enum {
     /* NUM_FLUSH_REASONS must remain the last value in the enumeration. */
     NUM_FLUSH_REASONS};
 
+#include "nss_info.h"
+
+/* generated rpc server implementation functions */
+#include "librpc/gen_ndr/srv_echo.h"
+#include "librpc/gen_ndr/srv_svcctl.h"
+#include "librpc/gen_ndr/srv_lsa.h"
+#include "librpc/gen_ndr/srv_eventlog.h"
+#include "librpc/gen_ndr/srv_winreg.h"
+#include "librpc/gen_ndr/srv_initshutdown.h"
+
 /***** automatically generated prototypes *****/
 #ifndef NO_PROTO_H
 #include "proto.h"
@@ -895,7 +904,7 @@ int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
  * defined.
  */
 #ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 254
+#define MAXHOSTNAMELEN 255
 #endif
 
 /* yuck, I'd like a better way of doing this */
@@ -918,12 +927,6 @@ int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
 #define DEFAULT_SOCKET_OPTIONS ""
 #endif
 
-/* Load header file for dynamic linking stuff */
-
-#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
@@ -1066,8 +1069,6 @@ int d_fprintf(FILE *f, const char *, ...) PRINTF_ATTRIBUTE(2,3);
 /* PRINTFLIKE2 */
 void sys_adminlog(int priority, const char *format_str, ...) PRINTF_ATTRIBUTE(2,3);
 
-/* PRINTFLIKE2 */
-int pstr_sprintf(pstring s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
 /* PRINTFLIKE2 */
 int fstr_sprintf(fstring s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
 
@@ -1075,6 +1076,9 @@ int d_vfprintf(FILE *f, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0);
 
 int smb_xvasprintf(char **ptr, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0);
 
+int asprintf_strupper_m(char **strp, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
+char *talloc_asprintf_strupper_m(TALLOC_CTX *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
+
 /* we used to use these fns, but now we have good replacements
    for snprintf and vsnprintf */
 #define slprintf snprintf
@@ -1113,9 +1117,7 @@ krb5_error_code smb_krb5_unparse_name(krb5_context context,
 krb5_error_code krb5_set_real_time(krb5_context context, int32_t seconds, int32_t microseconds);
 #endif
 
-#ifndef HAVE_KRB5_SET_DEFAULT_TGS_KTYPES
 krb5_error_code krb5_set_default_tgs_ktypes(krb5_context ctx, const krb5_enctype *enc);
-#endif
 
 #if defined(HAVE_KRB5_AUTH_CON_SETKEY) && !defined(HAVE_KRB5_AUTH_CON_SETUSERUSERKEY)
 krb5_error_code krb5_auth_con_setuseruserkey(krb5_context context, krb5_auth_context auth_context, krb5_keyblock *keyblock);
@@ -1125,20 +1127,30 @@ krb5_error_code krb5_auth_con_setuseruserkey(krb5_context context, krb5_auth_con
 void krb5_free_unparsed_name(krb5_context ctx, char *val);
 #endif
 
+/* Stub out initialize_krb5_error_table since it is not present in all
+ * Kerberos implementations. If it's not present, it's not necessary to
+ * call it.
+ */
+#ifndef HAVE_INITIALIZE_KRB5_ERROR_TABLE
+#define initialize_krb5_error_table()
+#endif
+
 /* Samba wrapper function for krb5 functionality. */
-void setup_kaddr( krb5_address *pkaddr, struct sockaddr *paddr);
+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);
-BOOL get_auth_data_from_tkt(TALLOC_CTX *mem_ctx, DATA_BLOB *auth_data, krb5_ticket *tkt);
+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);
+#if defined(HAVE_KRB5_LOCATE_KDC)
 krb5_error_code krb5_locate_kdc(krb5_context ctx, const krb5_data *realm, struct sockaddr **addr_pp, int *naddrs, int get_masters);
+#endif
 krb5_error_code get_kerberos_allowed_etypes(krb5_context context, krb5_enctype **enctypes);
-void free_kerberos_etypes(krb5_context context, krb5_enctype *enctypes);
-BOOL get_krb5_smb_session_key(krb5_context context, krb5_auth_context auth_context, DATA_BLOB *session_key, BOOL remote);
+bool get_krb5_smb_session_key(krb5_context context, krb5_auth_context auth_context, DATA_BLOB *session_key, bool remote);
 krb5_error_code smb_krb5_kt_free_entry(krb5_context context, krb5_keytab_entry *kt_entry);
 krb5_principal kerberos_fetch_salt_princ_for_host_princ(krb5_context context, krb5_principal host_princ, int enctype);
 void kerberos_set_creds_enctype(krb5_creds *pcreds, int enctype);
-BOOL kerberos_compatible_enctypes(krb5_context context, krb5_enctype enctype1, krb5_enctype enctype2);
+bool kerberos_compatible_enctypes(krb5_context context, krb5_enctype enctype1, krb5_enctype enctype2);
 void kerberos_free_data_contents(krb5_context context, krb5_data *pdata);
 NTSTATUS decode_pac_data(TALLOC_CTX *mem_ctx,
                         DATA_BLOB *pac_data_blob,
@@ -1173,13 +1185,13 @@ krb5_error_code krb5_rd_req_return_keyblock_from_keytab(krb5_context context,
 krb5_error_code smb_krb5_parse_name_norealm(krb5_context context, 
                                            const char *name, 
                                            krb5_principal *principal);
-BOOL smb_krb5_principal_compare_any_realm(krb5_context context, 
+bool smb_krb5_principal_compare_any_realm(krb5_context context, 
                                          krb5_const_principal princ1, 
                                          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);
+                       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 *new_start_time);
+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);
 krb5_error_code smb_krb5_free_addresses(krb5_context context, smb_krb5_addresses *addr);
@@ -1188,6 +1200,23 @@ krb5_error_code nt_status_to_krb5(NTSTATUS nt_status);
 void smb_krb5_free_error(krb5_context context, krb5_error *krberror);
 krb5_error_code handle_krberror_packet(krb5_context context,
                                          krb5_data *packet);
+
+void smb_krb5_get_init_creds_opt_free(krb5_context context,
+                                   krb5_get_init_creds_opt *opt);
+krb5_error_code smb_krb5_get_init_creds_opt_alloc(krb5_context context,
+                                   krb5_get_init_creds_opt **opt);
+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_error_code smb_krb5_enctype_to_string(krb5_context context, 
+                                           krb5_enctype enctype, 
+                                           char **etype_s);
+krb5_error_code smb_krb5_open_keytab(krb5_context context, 
+                                     const char *keytab_name, 
+                                     bool write_access, 
+                                     krb5_keytab *keytab);
 #endif /* HAVE_KRB5 */
 
 
@@ -1198,6 +1227,9 @@ LDAP *ldap_open_with_timeout(const char *server, int port, unsigned int to);
 
 #endif /* HAVE_LDAP */
 
+#if defined(HAVE_LINUX_READAHEAD) && ! defined(HAVE_READAHEAD_DECL)
+ssize_t readahead(int fd, off64_t offset, size_t count);
+#endif
 
 /* TRUE and FALSE are part of the C99 standard and gcc, but
    unfortunately many vendor compilers don't support them.  Use True