r19598: Ahead of a merge to current lorikeet-heimdal:
[Samba.git] / source / lib / registry / registry.h
blob4c1eb8f39ed87bdf1e818af87bde5240acd2dfeb
1 /*
2 Unix SMB/CIFS implementation.
3 Registry interface
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 */
23 #define _REGISTRY_H
25 #include "librpc/gen_ndr/security.h"
27 /* Handles for the predefined keys */
28 #define HKEY_CLASSES_ROOT 0x80000000
29 #define HKEY_CURRENT_USER 0x80000001
30 #define HKEY_LOCAL_MACHINE 0x80000002
31 #define HKEY_USERS 0x80000003
32 #define HKEY_PERFORMANCE_DATA 0x80000004
33 #define HKEY_CURRENT_CONFIG 0x80000005
34 #define HKEY_DYN_DATA 0x80000006
35 #define HKEY_PERFORMANCE_TEXT 0x80000050
36 #define HKEY_PERFORMANCE_NLSTEXT 0x80000060
38 struct reg_predefined_key {
39 uint32_t handle;
40 const char *name;
43 extern const struct reg_predefined_key reg_predefined_keys[];
45 #define REG_DELETE -1
48 * The general idea here is that every backend provides a 'hive'. Combining
49 * various hives gives you a complete registry like windows has
52 #define REGISTRY_INTERFACE_VERSION 1
54 /* structure to store the registry handles */
55 struct registry_key
57 const char *name;
58 const char *path;
59 const char *class_name;
60 NTTIME last_mod;
61 struct registry_hive *hive;
62 void *backend_data;
65 struct registry_value
67 const char *name;
68 unsigned int data_type;
69 DATA_BLOB data;
72 /* FIXME */
73 typedef void (*reg_key_notification_function) (void);
74 typedef void (*reg_value_notification_function) (void);
76 /*
77 * Container for function pointers to enumeration routines
78 * for virtual registry view
80 * Backends can provide :
81 * - just one hive (example: nt4, w95)
82 * - several hives (example: rpc).
84 * Backends should always do case-insensitive compares
85 * (everything is case-insensitive but case-preserving,
86 * just like the FS)
88 * There is no save function as all operations are expected to
89 * be atomic.
90 */
92 struct hive_operations {
93 const char *name;
95 /* Implement this one */
96 WERROR (*open_hive) (struct registry_hive *, struct registry_key **);
98 /* Or this one */
99 WERROR (*open_key) (TALLOC_CTX *, const struct registry_key *, const char *name, struct registry_key **);
101 WERROR (*num_subkeys) (const struct registry_key *, uint32_t *count);
102 WERROR (*num_values) (const struct registry_key *, uint32_t *count);
103 WERROR (*get_subkey_by_index) (TALLOC_CTX *, const struct registry_key *, int idx, struct registry_key **);
105 /* Can not contain more than one level */
106 WERROR (*get_subkey_by_name) (TALLOC_CTX *, const struct registry_key *, const char *name, struct registry_key **);
107 WERROR (*get_value_by_index) (TALLOC_CTX *, const struct registry_key *, int idx, struct registry_value **);
109 /* Can not contain more than one level */
110 WERROR (*get_value_by_name) (TALLOC_CTX *, const struct registry_key *, const char *name, struct registry_value **);
112 /* Security control */
113 WERROR (*key_get_sec_desc) (TALLOC_CTX *, const struct registry_key *, struct security_descriptor **);
114 WERROR (*key_set_sec_desc) (const struct registry_key *, const struct security_descriptor *);
116 /* Notification */
117 WERROR (*request_key_change_notify) (const struct registry_key *, reg_key_notification_function);
118 WERROR (*request_value_change_notify) (const struct registry_value *, reg_value_notification_function);
120 /* Key management */
121 WERROR (*add_key)(TALLOC_CTX *, const struct registry_key *, const char *name, uint32_t access_mask, struct security_descriptor *, struct registry_key **);
122 WERROR (*del_key)(const struct registry_key *, const char *name);
123 WERROR (*flush_key) (const struct registry_key *);
125 /* Value management */
126 WERROR (*set_value)(const struct registry_key *, const char *name, uint32_t type, const DATA_BLOB data);
127 WERROR (*del_value)(const struct registry_key *, const char *valname);
130 struct cli_credentials;
132 struct registry_hive
134 const struct hive_operations *functions;
135 struct registry_key *root;
136 struct auth_session_info *session_info;
137 struct cli_credentials *credentials;
138 void *backend_data;
139 const char *location;
142 /* Handle to a full registry
143 * contains zero or more hives */
144 struct registry_context {
145 void *backend_data;
146 struct cli_credentials *credentials;
147 struct auth_session_info *session_info;
148 WERROR (*get_predefined_key) (struct registry_context *, uint32_t hkey, struct registry_key **);
151 struct reg_init_function_entry {
152 const struct hive_operations *hive_functions;
153 struct reg_init_function_entry *prev, *next;
156 /* Representing differences between registry files */
158 struct reg_diff_value
160 const char *name;
161 enum { REG_DIFF_DEL_VAL, REG_DIFF_SET_VAL } changetype;
162 uint32_t type;
163 DATA_BLOB data;
166 struct reg_diff_key
168 const char *name;
169 enum { REG_DIFF_CHANGE_KEY, REG_DIFF_DEL_KEY } changetype;
170 uint32_t numvalues;
171 struct reg_diff_value *values;
174 struct reg_diff
176 const char *format;
177 uint32_t numkeys;
178 struct reg_diff_key *keys;
181 struct auth_session_info;
182 struct event_context;
184 #include "lib/registry/registry_proto.h"
186 #endif /* _REGISTRY_H */