summaryrefslogtreecommitdiffstats
path: root/source3/registry/reg_import.h
blob: 70db4acd1bdeb9e5aab13673bff64caaf7a794fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/*
 * Samba Unix/Linux SMB client library
 *
 * Copyright (C) Gregor Beck 2010
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * @brief  Adapter to use reg_parse with the registry api
 * @file   reg_import.h
 * @author Gregor Beck <gb@sernet.de>
 * @date   Jun 2010
 */


#ifndef REG_IMPORT_H
#define REG_IMPORT_H

#include "reg_parse.h"

struct registry_value;
struct regval_blob;

/**
 * Protoype for function called to open a key.
 *
 * @param private_data
 * @param[in] parent    the parent of the key to open, may be NULL
 * @param[in] name      the name of the key relative to parent.
 * @param[out] key      the opened key
 *
 * @return WERR_OK on success
 */
typedef	WERROR (*reg_import_callback_openkey_t) (void* private_data,
						void* parent,
						const char* name,
						void** key);

/**
 * Protoype for function called to close a key.
 *
 * @param private_data
 * @param key the key to close
 *
 * @return WERR_OK on success
 */
typedef	WERROR (*reg_import_callback_closekey_t) (void* private_data,
						  void* key);

/**
 * Protoype for function called to create (or open an existing) key.
 *
 * @param private_data
 * @param[in] parent    the parent of the key to create, may be NULL
 * @param[in] name      the name of the key relative to parent.
 * @param[out] key      the opened key
 * @param[out] existing whether we opened an existing key
 *
 * @return WERR_OK on success
 */
typedef	WERROR (*reg_import_callback_createkey_t)(void* private_data,
						void* parent,
						const char* name,
						void** key,
						bool* existing);

/**
 * Protoype for function called to delete a key.
 *
 * @param private_data
 * @param parent    the parent of the key to delete, may be NULL
 * @param[in] name  the name of the key relative to parent.
 *
 * @return WERR_OK on success
 */
typedef	WERROR (*reg_import_callback_deletekey_t)(void* private_data,
						  void* parent,
						  const char* name);

/**
 * Protoype for function called to delete a value.
 *
 * @param private_data
 * @param parent    the key of the value to delete
 * @param[in] name  the name of the value to delete.
 *
 * @return WERR_OK on success
 */
typedef	WERROR (*reg_import_callback_deleteval_t)(void* private_data,
						void* parent,
						const char* name);

/**
 * Protoype for function called to set a value.
 *
 * @param private_data
 * @param parent the key of the value to set
 * @param name   the name of the value
 * @param type   the type of the value
 * @param data   the value of the value
 * @param size   the number of bytes of data
 *
 * @return WERR_OK on success
 */
typedef	WERROR (*reg_import_callback_setval_blob_t)(void* private_data,
						  void* parent,
						  const char* name,
						  uint32_t type,
						  const uint8_t* data,
						  uint32_t size);

/**
 * Protoype for function called to set a value given as struct registry_value.
 *
 * @param private_data
 * @param parent the key of the value to set
 * @param name   the name of the value
 * @param val    the value of the value
 *
 * @return WERR_OK on success
 */
typedef	WERROR (*reg_import_callback_setval_registry_value_t) (
	void* private_data,
	void* parent,
	const char* name,
	const struct registry_value* val);

/**
 * Protoype for function called to set a value given as struct struct regval_blob.
 *
 * @param private_data
 * @param parent the key of the value to set
 * @param val    the value
 *
 * @return WERR_OK on success
 */
typedef	WERROR (*reg_import_callback_setval_regval_blob_t)(
	void* private_data,
	void* parent,
	const struct regval_blob* val);

/**
 * Type handling the output of a reg_import object.
 * It containes the functions to call and an opaque data pointer.
 */
struct reg_import_callback {
	/** Function called to open key */
	reg_import_callback_openkey_t   openkey;
	/** Function called to close key */
	reg_import_callback_closekey_t  closekey;
	/** Function called to create or open key */
	reg_import_callback_createkey_t createkey;
	/** Function called to delete key */
	reg_import_callback_deletekey_t deletekey;
	/** Function called to delete value */
	reg_import_callback_deleteval_t deleteval;

	/** Function called to set value */
	union {
		reg_import_callback_setval_blob_t           blob;
		reg_import_callback_setval_registry_value_t registry_value;
		reg_import_callback_setval_regval_blob_t    regval_blob;
	} setval;
	/** Which function is called to set a value */
	enum {
		NONE=0,         /**< no setval function used */
		BLOB,           /**< @ref reg_import_callback_setval_blob_t blob */
		REGISTRY_VALUE, /**< @ref reg_import_callback_setval_registry_value_t registry_value */
		REGVAL_BLOB,    /**< @ref reg_import_callback_setval_regval_blob_t regval_blob */
	} setval_type;
	void* data; /**< Private data passed to callback function */
};


/**
 * Create a new reg_import object.
 * Because its only purpose is to act as an reg_parse_callback the return type
 * is accordingly.
 *
 * @param talloc_ctx the talloc parent
 * @param cb         the output handler
 *
 * @return a talloc'ed reg_import object, NULL on error
 */
struct reg_parse_callback* reg_import_adapter(TALLOC_CTX *talloc_ctx,
					      struct reg_import_callback cb);
#endif