2 Unix SMB/CIFS implementation.
3 Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 "Access to various registry formats and the Samba registry."
23 %module(docstring=DOCSTRING) registry
32 #include "param/param.h"
33 #include "events/events.h"
34 #include "scripting/python/modules.h"
36 typedef struct registry_context reg;
37 typedef struct hive_key hive_key;
39 %include "../../libcli/util/errors.i"
41 /* FIXME: This should be in another file */
42 %typemap(default,noblock=1) struct auth_session_info * {
47 %import "../../../lib/talloc/talloc.i"
48 %import "../../auth/credentials/credentials.i"
49 %import "../../param/param.i"
50 %import "../events/events.i"
52 /* Utility functions */
54 const char *reg_get_predef_name(uint32_t hkey);
55 const char *str_regtype(int type);
57 /* Registry contexts */
58 %typemap(in,noblock=1,numinputs=0) struct registry_context ** (struct registry_context *tmp) {
62 %typemap(argout,noblock=1) struct registry_context ** {
63 $result = SWIG_NewPointerObj(*$1, SWIGTYPE_p_registry_context, 0);
66 %typemap(in,noblock=1,numinputs=0) struct smb_iconv_convenience *ic {
67 $1 = py_iconv_convenience(NULL);
70 %typemap(freearg,noblock=1) struct smb_iconv_convenience *ic {
74 %rename(Registry) reg_open_local;
75 WERROR reg_open_local(TALLOC_CTX *parent_ctx, struct registry_context **ctx);
77 %typemap(in,noblock=1) const char ** {
78 /* Check if is a list */
79 if (PyList_Check($input)) {
80 int size = PyList_Size($input);
82 $1 = (char **) malloc((size+1)*sizeof(const char *));
83 for (i = 0; i < size; i++) {
84 PyObject *o = PyList_GetItem($input,i);
85 if (PyString_Check(o))
86 $1[i] = PyString_AsString(PyList_GetItem($input,i));
88 PyErr_SetString(PyExc_TypeError,"list must contain strings");
95 PyErr_SetString(PyExc_TypeError,"not a list");
100 %typemap(freearg,noblock=1) const char ** {
106 typedef struct registry_context {
109 %feature("docstring") get_predefined_key_by_name "S.get_predefined_key_by_name(name) -> key\n"
110 "Find a predefined key by name";
111 WERROR get_predefined_key_by_name(const char *name,
112 struct registry_key **key);
114 %feature("docstring") key_del_abs "S.key_del_abs(name) -> None\n"
115 "Delete a key by absolute path.";
116 WERROR key_del_abs(const char *path);
117 %feature("docstring") get_predefined_key "S.get_predefined_key(hkey_id) -> key\n"
118 "Find a predefined key by id";
119 WERROR get_predefined_key(uint32_t hkey_id, struct registry_key **key);
120 %feature("docstring") diff_apply "S.diff_apply(filename) -> None\n"
121 "Apply the diff from the specified file";
123 WERROR diff_apply(struct smb_iconv_convenience *ic, const char *filename);
124 WERROR generate_diff(struct registry_context *ctx2, const struct reg_diff_callbacks *callbacks,
125 void *callback_data);
127 WERROR mount_hive(struct hive_key *key, uint32_t hkey_id,
128 const char **elements=NULL);
130 struct registry_key *import_hive_key(struct hive_key *hive, uint32_t predef_key, const char **elements);
131 %feature("docstring") mount_hive "S.mount_hive(key, predef_name) -> None\n"
132 "Mount the specified key at the specified path.";
133 WERROR mount_hive(struct hive_key *key, const char *predef_name)
136 for (i = 0; reg_predefined_keys[i].name; i++) {
137 if (!strcasecmp(reg_predefined_keys[i].name, predef_name))
138 return reg_mount_hive($self, key,
139 reg_predefined_keys[i].handle, NULL);
141 return WERR_INVALID_NAME;
148 %typemap(in,noblock=1,numinputs=0) struct hive_key ** (struct hive_key *tmp) {
152 %typemap(argout,noblock=1) struct hive_key ** {
154 $result = SWIG_NewPointerObj(*$1, SWIGTYPE_p_hive_key, 0);
157 %feature("docstring") reg_open_hive "S.__init__(location, session_info=None, credentials=None, loadparm_context=None)";
158 %rename(hive_key) reg_open_hive;
159 WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
160 struct auth_session_info *session_info,
161 struct cli_credentials *credentials,
162 struct event_context *ev_ctx,
163 struct loadparm_context *lp_ctx,
164 struct hive_key **root);
166 %feature("docstring") reg_open_ldb_file "open_ldb(location, session_info=None, credentials=None, loadparm_context=None) -> key";
167 %rename(open_ldb) reg_open_ldb_file;
168 WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
169 struct auth_session_info *session_info,
170 struct cli_credentials *credentials,
171 struct event_context *ev_ctx,
172 struct loadparm_context *lp_ctx,
173 struct hive_key **k);
175 %feature("docstring") reg_create_directory "create_dir(location) -> key";
176 %rename(create_dir) reg_create_directory;
177 WERROR reg_create_directory(TALLOC_CTX *parent_ctx,
178 const char *location, struct hive_key **key);
180 %feature("docstring") reg_open_directory "open_dir(location) -> key";
181 %rename(open_dir) reg_open_directory;
182 WERROR reg_open_directory(TALLOC_CTX *parent_ctx,
183 const char *location, struct hive_key **key);
185 %talloctype(hive_key);
187 typedef struct hive_key {
189 %feature("docstring") del "S.del(name) -> None\n"
191 WERROR del(const char *name);
192 %feature("docstring") flush "S.flush() -> None\n"
193 "Flush this key to disk";
195 %feature("docstring") del_value "S.del_value(name) -> None\n"
197 WERROR del_value(const char *name);
198 %feature("docstring") set_value "S.set_value(name, type, data) -> None\n"
200 WERROR set_value(const char *name, uint32_t type, const DATA_BLOB data);
204 %rename(open_samba) reg_open_samba;
206 %feature("docstring") reg_open_samba "open_samba() -> reg";
207 WERROR reg_open_samba(TALLOC_CTX *mem_ctx,
208 struct registry_context **ctx,
209 struct event_context *ev_ctx,
210 struct loadparm_context *lp_ctx,
211 struct auth_session_info *session_info,
212 struct cli_credentials *credentials);
215 %constant uint32_t HKEY_CLASSES_ROOT = HKEY_CLASSES_ROOT;
216 %constant uint32_t HKEY_CURRENT_USER = HKEY_CURRENT_USER;
217 %constant uint32_t HKEY_LOCAL_MACHINE = HKEY_LOCAL_MACHINE;
218 %constant uint32_t HKEY_USERS = HKEY_USERS;
219 %constant uint32_t HKEY_PERFORMANCE_DATA = HKEY_PERFORMANCE_DATA;
220 %constant uint32_t HKEY_CURRENT_CONFIG = HKEY_CURRENT_CONFIG;
221 %constant uint32_t HKEY_DYN_DATA = HKEY_DYN_DATA;
222 %constant uint32_t HKEY_PERFORMANCE_TEXT = HKEY_PERFORMANCE_TEXT;
223 %constant uint32_t HKEY_PERFORMANCE_NLSTEXT = HKEY_PERFORMANCE_NLSTEXT;