2 Unix SMB/CIFS implementation.
4 Copyright (C) Gerald Carter 2002.
5 Copyright (C) Jelmer Vernooij 2003-2004.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #ifndef _REGISTRY_H /* _REGISTRY_H */
25 /* Handles for the predefined keys */
26 enum reg_predefined_key {
27 HKEY_CLASSES_ROOT = 0x80000000,
28 HKEY_CURRENT_USER = 0x80000001,
29 HKEY_LOCAL_MACHINE = 0x80000002,
30 HKEY_USERS = 0x80000003,
31 HKEY_PERFORMANCE_DATA = 0x80000004,
32 HKEY_CURRENT_CONFIG = 0x80000005,
33 HKEY_DYN_DATA = 0x80000006,
34 HKEY_PERFORMANCE_TEXT = 0x80000050,
35 HKEY_PERFORMANCE_NLSTEXT= 0x80000060
38 /* Registry data types */
43 #define REG_EXPAND_SZ 2
45 #define REG_DWORD_LE 4
46 #define REG_DWORD REG_DWORD_LE
47 #define REG_DWORD_BE 5
49 #define REG_MULTI_SZ 7
50 #define REG_RESOURCE_LIST 8
51 #define REG_FULL_RESOURCE_DESCRIPTOR 9
52 #define REG_RESOURCE_REQUIREMENTS_LIST 10
53 #define REG_QWORD_LE 11
54 #define REG_QWORD REQ_QWORD_LE
58 typedef struct ace_struct_s {
60 uint_t perms; /* Perhaps a better def is in order */
66 * The general idea here is that every backend provides a 'hive'. Combining
67 * various hives gives you a complete registry like windows has
70 #define REGISTRY_INTERFACE_VERSION 1
72 /* structure to store the registry handles */
74 char *name; /* Name of the key */
75 const char *path; /* Full path to the key */
76 char *class_name; /* Name of key class */
77 NTTIME last_mod; /* Time last modified */
78 struct registry_hive *hive;
82 struct registry_value {
84 unsigned int data_type;
86 void *data_blk; /* Might want a separate block */
90 typedef void (*key_notification_function) (void);
91 typedef void (*value_notification_function) (void);
94 * Container for function pointers to enumeration routines
95 * for virtual registry view
97 * Backends can provide :
98 * - just one hive (example: nt4, w95)
99 * - several hives (example: rpc).
103 struct hive_operations {
106 /* Implement this one */
107 WERROR (*open_hive) (struct registry_hive *, struct registry_key **);
110 WERROR (*open_key) (TALLOC_CTX *, struct registry_key *, const char *name, struct registry_key **);
112 /* Either implement these */
113 WERROR (*num_subkeys) (struct registry_key *, int *count);
114 WERROR (*num_values) (struct registry_key *, int *count);
115 WERROR (*get_subkey_by_index) (TALLOC_CTX *, struct registry_key *, int idx, struct registry_key **);
117 /* Can not contain more then one level */
118 WERROR (*get_subkey_by_name) (TALLOC_CTX *, struct registry_key *, const char *name, struct registry_key **);
119 WERROR (*get_value_by_index) (TALLOC_CTX *, struct registry_key *, int idx, struct registry_value **);
121 /* Can not contain more then one level */
122 WERROR (*get_value_by_name) (TALLOC_CTX *, struct registry_key *, const char *name, struct registry_value **);
124 /* Security control */
125 WERROR (*key_get_sec_desc) (TALLOC_CTX *, struct registry_key *, SEC_DESC **);
126 WERROR (*key_set_sec_desc) (struct registry_key *, SEC_DESC *);
129 WERROR (*request_key_change_notify) (struct registry_key *, key_notification_function);
130 WERROR (*request_value_change_notify) (struct registry_value *, value_notification_function);
133 WERROR (*add_key)(TALLOC_CTX *, struct registry_key *, const char *name, uint32_t access_mask, SEC_DESC *, struct registry_key **);
134 WERROR (*del_key)(struct registry_key *);
135 WERROR (*flush_key) (struct registry_key *);
137 /* Value management */
138 WERROR (*set_value)(struct registry_key *, const char *name, int type, void *data, int len);
139 WERROR (*del_value)(struct registry_key *, const char *valname);
142 struct registry_hive {
143 const struct hive_operations *functions;
144 struct registry_key *root;
146 const char *location;
149 /* Handle to a full registry
150 * contains zero or more hives */
151 struct registry_context {
153 WERROR (*get_predefined_key) (struct registry_context *, uint32 hkey, struct registry_key **);
156 struct reg_init_function_entry {
157 /* Function to create a member of the pdb_methods list */
158 const struct hive_operations *hive_functions;
159 struct reg_init_function_entry *prev, *next;
162 /* Used internally */
163 #define SMB_REG_ASSERT(a) { if(!(a)) { DEBUG(0,("%s failed! (%s:%d)", #a, __FILE__, __LINE__)); }}
165 #endif /* _REGISTRY_H */