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).
101 * Backends should always do case-insensitive compares
102 * (everything is case-insensitive but case-preserving,
106 struct hive_operations {
109 /* Implement this one */
110 WERROR (*open_hive) (struct registry_hive *, struct registry_key **);
113 WERROR (*open_key) (TALLOC_CTX *, struct registry_key *, const char *name, struct registry_key **);
115 /* Either implement these */
116 WERROR (*num_subkeys) (struct registry_key *, int *count);
117 WERROR (*num_values) (struct registry_key *, int *count);
118 WERROR (*get_subkey_by_index) (TALLOC_CTX *, struct registry_key *, int idx, struct registry_key **);
120 /* Can not contain more then one level */
121 WERROR (*get_subkey_by_name) (TALLOC_CTX *, struct registry_key *, const char *name, struct registry_key **);
122 WERROR (*get_value_by_index) (TALLOC_CTX *, struct registry_key *, int idx, struct registry_value **);
124 /* Can not contain more then one level */
125 WERROR (*get_value_by_name) (TALLOC_CTX *, struct registry_key *, const char *name, struct registry_value **);
127 /* Security control */
128 WERROR (*key_get_sec_desc) (TALLOC_CTX *, struct registry_key *, struct security_descriptor **);
129 WERROR (*key_set_sec_desc) (struct registry_key *, struct security_descriptor *);
132 WERROR (*request_key_change_notify) (struct registry_key *, key_notification_function);
133 WERROR (*request_value_change_notify) (struct registry_value *, value_notification_function);
136 WERROR (*add_key)(TALLOC_CTX *, struct registry_key *, const char *name, uint32_t access_mask, struct security_descriptor *, struct registry_key **);
137 WERROR (*del_key)(struct registry_key *, const char *name);
138 WERROR (*flush_key) (struct registry_key *);
140 /* Value management */
141 WERROR (*set_value)(struct registry_key *, const char *name, uint32_t type, void *data, int len);
142 WERROR (*del_value)(struct registry_key *, const char *valname);
145 struct registry_hive {
146 const struct hive_operations *functions;
147 struct registry_key *root;
149 const char *location;
152 /* Handle to a full registry
153 * contains zero or more hives */
154 struct registry_context {
156 WERROR (*get_predefined_key) (struct registry_context *, uint32_t hkey, struct registry_key **);
159 struct reg_init_function_entry {
160 /* Function to create a member of the pdb_methods list */
161 const struct hive_operations *hive_functions;
162 struct reg_init_function_entry *prev, *next;
165 /* Used internally */
166 #define SMB_REG_ASSERT(a) { if(!(a)) { DEBUG(0,("%s failed! (%s:%d)", #a, __FILE__, __LINE__)); }}
168 #endif /* _REGISTRY_H */