r10028: More registry fixes.
[bbaumbach/samba-autobuild/.git] / source4 / lib / registry / registry.h
1 /* 
2    Unix SMB/CIFS implementation.
3    Registry interface
4    Copyright (C) Gerald Carter                        2002.
5    Copyright (C) Jelmer Vernooij                                          2003-2004.
6    
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.
11    
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.
16    
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.
20 */
21
22 #ifndef _REGISTRY_H /* _REGISTRY_H */
23 #define _REGISTRY_H 
24
25 /* Handles for the predefined keys */
26 #define HKEY_CLASSES_ROOT                0x80000000
27 #define HKEY_CURRENT_USER                0x80000001
28 #define HKEY_LOCAL_MACHINE               0x80000002
29 #define HKEY_USERS                               0x80000003
30 #define HKEY_PERFORMANCE_DATA    0x80000004
31 #define HKEY_CURRENT_CONFIG              0x80000005
32 #define HKEY_DYN_DATA                    0x80000006
33 #define HKEY_PERFORMANCE_TEXT    0x80000050
34 #define HKEY_PERFORMANCE_NLSTEXT 0x80000060
35
36 #define REG_DELETE                                                                 -1
37
38 /*
39  * The general idea here is that every backend provides a 'hive'. Combining
40  * various hives gives you a complete registry like windows has
41  */
42
43 #define REGISTRY_INTERFACE_VERSION 1
44
45 /* structure to store the registry handles */
46 struct registry_key {
47   char *name;         /* Name of the key                    */
48   const char *path;               /* Full path to the key */
49   char *class_name; /* Name of key class */
50   NTTIME last_mod; /* Time last modified                 */
51   struct registry_hive *hive;
52   void *backend_data;
53 };
54
55 struct registry_value {
56   char *name;
57   unsigned int data_type;
58   DATA_BLOB data;
59 };
60
61 /* FIXME */
62 typedef void (*key_notification_function) (void);
63 typedef void (*value_notification_function) (void);
64
65 /* 
66  * Container for function pointers to enumeration routines
67  * for virtual registry view 
68  *
69  * Backends can provide :
70  *  - just one hive (example: nt4, w95)
71  *  - several hives (example: rpc).
72  * 
73  * Backends should always do case-insensitive compares 
74  * (everything is case-insensitive but case-preserving, 
75  * just like the FS)
76  *
77  * There is no save function as all operations are expected to 
78  * be atomic.
79  */ 
80
81 struct hive_operations {
82         const char *name;
83
84         /* Implement this one */
85         WERROR (*open_hive) (struct registry_hive *, struct registry_key **);
86
87         /* Or this one */
88         WERROR (*open_key) (TALLOC_CTX *, struct registry_key *, const char *name, struct registry_key **);
89
90         WERROR (*num_subkeys) (struct registry_key *, uint32_t *count);
91         WERROR (*num_values) (struct registry_key *, uint32_t *count);
92         WERROR (*get_subkey_by_index) (TALLOC_CTX *, struct registry_key *, int idx, struct registry_key **);
93
94         /* Can not contain more then one level */
95         WERROR (*get_subkey_by_name) (TALLOC_CTX *, struct registry_key *, const char *name, struct registry_key **);
96         WERROR (*get_value_by_index) (TALLOC_CTX *, struct registry_key *, int idx, struct registry_value **);
97
98         /* Can not contain more then one level */
99         WERROR (*get_value_by_name) (TALLOC_CTX *, struct registry_key *, const char *name, struct registry_value **);
100
101         /* Security control */
102         WERROR (*key_get_sec_desc) (TALLOC_CTX *, struct registry_key *, struct security_descriptor **);
103         WERROR (*key_set_sec_desc) (struct registry_key *, struct security_descriptor *);
104
105         /* Notification */
106         WERROR (*request_key_change_notify) (struct registry_key *, key_notification_function);
107         WERROR (*request_value_change_notify) (struct registry_value *, value_notification_function);
108
109         /* Key management */
110         WERROR (*add_key)(TALLOC_CTX *, struct registry_key *, const char *name, uint32_t access_mask, struct security_descriptor *, struct registry_key **);
111         WERROR (*del_key)(struct registry_key *, const char *name);
112         WERROR (*flush_key) (struct registry_key *);
113
114         /* Value management */
115         WERROR (*set_value)(struct registry_key *, const char *name, uint32_t type, DATA_BLOB data); 
116         WERROR (*del_value)(struct registry_key *, const char *valname);
117 };
118
119 struct registry_hive {
120         const struct hive_operations *functions;
121         struct registry_key *root;
122         void *backend_data;
123         const char *location;
124 };
125
126 /* Handle to a full registry
127  * contains zero or more hives */
128 struct registry_context {
129     void *backend_data;
130         WERROR (*get_predefined_key) (struct registry_context *, uint32_t hkey, struct registry_key **);
131 };
132
133 struct reg_init_function_entry {
134         const struct hive_operations *hive_functions;
135         struct reg_init_function_entry *prev, *next;
136 };
137
138 #endif /* _REGISTRY_H */