printing: rework nt_printer_guid_store to return errors
[Samba.git] / source3 / registry / reg_import.h
blob70db4acd1bdeb9e5aab13673bff64caaf7a794fd
1 /*
2 * Samba Unix/Linux SMB client library
4 * Copyright (C) Gregor Beck 2010
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 /**
21 * @brief Adapter to use reg_parse with the registry api
22 * @file reg_import.h
23 * @author Gregor Beck <gb@sernet.de>
24 * @date Jun 2010
28 #ifndef REG_IMPORT_H
29 #define REG_IMPORT_H
31 #include "reg_parse.h"
33 struct registry_value;
34 struct regval_blob;
36 /**
37 * Protoype for function called to open a key.
39 * @param private_data
40 * @param[in] parent the parent of the key to open, may be NULL
41 * @param[in] name the name of the key relative to parent.
42 * @param[out] key the opened key
44 * @return WERR_OK on success
46 typedef WERROR (*reg_import_callback_openkey_t) (void* private_data,
47 void* parent,
48 const char* name,
49 void** key);
51 /**
52 * Protoype for function called to close a key.
54 * @param private_data
55 * @param key the key to close
57 * @return WERR_OK on success
59 typedef WERROR (*reg_import_callback_closekey_t) (void* private_data,
60 void* key);
62 /**
63 * Protoype for function called to create (or open an existing) key.
65 * @param private_data
66 * @param[in] parent the parent of the key to create, may be NULL
67 * @param[in] name the name of the key relative to parent.
68 * @param[out] key the opened key
69 * @param[out] existing whether we opened an existing key
71 * @return WERR_OK on success
73 typedef WERROR (*reg_import_callback_createkey_t)(void* private_data,
74 void* parent,
75 const char* name,
76 void** key,
77 bool* existing);
79 /**
80 * Protoype for function called to delete a key.
82 * @param private_data
83 * @param parent the parent of the key to delete, may be NULL
84 * @param[in] name the name of the key relative to parent.
86 * @return WERR_OK on success
88 typedef WERROR (*reg_import_callback_deletekey_t)(void* private_data,
89 void* parent,
90 const char* name);
92 /**
93 * Protoype for function called to delete a value.
95 * @param private_data
96 * @param parent the key of the value to delete
97 * @param[in] name the name of the value to delete.
99 * @return WERR_OK on success
101 typedef WERROR (*reg_import_callback_deleteval_t)(void* private_data,
102 void* parent,
103 const char* name);
106 * Protoype for function called to set a value.
108 * @param private_data
109 * @param parent the key of the value to set
110 * @param name the name of the value
111 * @param type the type of the value
112 * @param data the value of the value
113 * @param size the number of bytes of data
115 * @return WERR_OK on success
117 typedef WERROR (*reg_import_callback_setval_blob_t)(void* private_data,
118 void* parent,
119 const char* name,
120 uint32_t type,
121 const uint8_t* data,
122 uint32_t size);
125 * Protoype for function called to set a value given as struct registry_value.
127 * @param private_data
128 * @param parent the key of the value to set
129 * @param name the name of the value
130 * @param val the value of the value
132 * @return WERR_OK on success
134 typedef WERROR (*reg_import_callback_setval_registry_value_t) (
135 void* private_data,
136 void* parent,
137 const char* name,
138 const struct registry_value* val);
141 * Protoype for function called to set a value given as struct struct regval_blob.
143 * @param private_data
144 * @param parent the key of the value to set
145 * @param val the value
147 * @return WERR_OK on success
149 typedef WERROR (*reg_import_callback_setval_regval_blob_t)(
150 void* private_data,
151 void* parent,
152 const struct regval_blob* val);
155 * Type handling the output of a reg_import object.
156 * It containes the functions to call and an opaque data pointer.
158 struct reg_import_callback {
159 /** Function called to open key */
160 reg_import_callback_openkey_t openkey;
161 /** Function called to close key */
162 reg_import_callback_closekey_t closekey;
163 /** Function called to create or open key */
164 reg_import_callback_createkey_t createkey;
165 /** Function called to delete key */
166 reg_import_callback_deletekey_t deletekey;
167 /** Function called to delete value */
168 reg_import_callback_deleteval_t deleteval;
170 /** Function called to set value */
171 union {
172 reg_import_callback_setval_blob_t blob;
173 reg_import_callback_setval_registry_value_t registry_value;
174 reg_import_callback_setval_regval_blob_t regval_blob;
175 } setval;
176 /** Which function is called to set a value */
177 enum {
178 NONE=0, /**< no setval function used */
179 BLOB, /**< @ref reg_import_callback_setval_blob_t blob */
180 REGISTRY_VALUE, /**< @ref reg_import_callback_setval_registry_value_t registry_value */
181 REGVAL_BLOB, /**< @ref reg_import_callback_setval_regval_blob_t regval_blob */
182 } setval_type;
183 void* data; /**< Private data passed to callback function */
188 * Create a new reg_import object.
189 * Because its only purpose is to act as an reg_parse_callback the return type
190 * is accordingly.
192 * @param talloc_ctx the talloc parent
193 * @param cb the output handler
195 * @return a talloc'ed reg_import object, NULL on error
197 struct reg_parse_callback* reg_import_adapter(TALLOC_CTX *talloc_ctx,
198 struct reg_import_callback cb);
199 #endif