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"
35 typedef struct registry_context reg
;
36 typedef struct hive_key hive_key
;
38 %include
"../../libcli/util/errors.i"
40 /* FIXME
: This should be in another file
*/
41 %typemap
(default
,noblock
=1) struct auth_session_info
* {
46 %import
"../../../lib/talloc/talloc.i"
47 %import
"../../auth/credentials/credentials.i"
48 %import
"../../param/param.i"
49 %import
"../events/events.i"
51 /* Utility functions
*/
53 const char
*reg_get_predef_name
(uint32_t hkey
);
54 const char
*str_regtype
(int type
);
56 /* Registry contexts
*/
57 %typemap
(in
,noblock
=1,numinputs
=0) struct registry_context
** (struct registry_context
*tmp
) {
61 %typemap
(argout
,noblock
=1) struct registry_context
** {
62 $result
= SWIG_NewPointerObj
(*$
1, SWIGTYPE_p_registry_context
, 0);
65 %rename
(Registry
) reg_open_local
;
66 WERROR reg_open_local
(TALLOC_CTX
*parent_ctx
, struct registry_context
**ctx
);
68 %typemap
(in
,noblock
=1) const char
** {
69 /* Check if is a list
*/
70 if
(PyList_Check
($input
)) {
71 int size
= PyList_Size
($input
);
73 $
1 = (char
**) malloc
((size
+1)*sizeof
(const char
*));
74 for
(i
= 0; i
< size
; i
++) {
75 PyObject
*o
= PyList_GetItem
($input
,i
);
76 if
(PyString_Check
(o
))
77 $
1[i
] = PyString_AsString
(PyList_GetItem
($input
,i
));
79 PyErr_SetString
(PyExc_TypeError
,"list must contain strings");
86 PyErr_SetString
(PyExc_TypeError
,"not a list");
91 %typemap
(freearg
,noblock
=1) const char
** {
97 typedef struct registry_context
{
100 %feature
("docstring") get_predefined_key_by_name
"S.get_predefined_key_by_name(name) -> key\n"
101 "Find a predefined key by name";
102 WERROR get_predefined_key_by_name
(const char
*name
,
103 struct registry_key
**key
);
105 %feature
("docstring") key_del_abs
"S.key_del_abs(name) -> None\n"
106 "Delete a key by absolute path.";
107 WERROR key_del_abs
(const char
*path
);
108 %feature
("docstring") get_predefined_key
"S.get_predefined_key(hkey_id) -> key\n"
109 "Find a predefined key by id";
110 WERROR get_predefined_key
(uint32_t hkey_id
, struct registry_key
**key
);
111 %feature
("docstring") diff_apply
"S.diff_apply(filename) -> None\n"
112 "Apply the diff from the specified file";
114 WERROR diff_apply
(const char
*filename
);
115 WERROR generate_diff
(struct registry_context
*ctx2
, const struct reg_diff_callbacks
*callbacks
,
116 void
*callback_data
);
118 WERROR mount_hive
(struct hive_key
*key
, uint32_t hkey_id
,
119 const char
**elements
=NULL);
121 struct registry_key
*import_hive_key
(struct hive_key
*hive
, uint32_t predef_key
, const char
**elements
);
122 %feature
("docstring") mount_hive
"S.mount_hive(key, predef_name) -> None\n"
123 "Mount the specified key at the specified path.";
124 WERROR mount_hive
(struct hive_key
*key
, const char
*predef_name
)
127 for
(i
= 0; reg_predefined_keys
[i
].name
; i
++) {
128 if
(!strcasecmp
(reg_predefined_keys
[i
].name
, predef_name
))
129 return reg_mount_hive
($self
, key
,
130 reg_predefined_keys
[i
].handle
, NULL);
132 return WERR_INVALID_NAME
;
139 %typemap
(in
,noblock
=1,numinputs
=0) struct hive_key
** (struct hive_key
*tmp
) {
143 %typemap
(argout
,noblock
=1) struct hive_key
** {
145 $result
= SWIG_NewPointerObj
(*$
1, SWIGTYPE_p_hive_key
, 0);
148 %feature
("docstring") reg_open_hive
"S.__init__(location, session_info=None, credentials=None, loadparm_context=None)";
149 %rename
(hive_key
) reg_open_hive
;
150 WERROR reg_open_hive
(TALLOC_CTX
*parent_ctx
, const char
*location
,
151 struct auth_session_info
*session_info
,
152 struct cli_credentials
*credentials
,
153 struct event_context
*ev_ctx
,
154 struct loadparm_context
*lp_ctx
,
155 struct hive_key
**root
);
157 %feature
("docstring") reg_open_ldb_file
"open_ldb(location, session_info=None, credentials=None, loadparm_context=None) -> key";
158 %rename
(open_ldb
) reg_open_ldb_file
;
159 WERROR reg_open_ldb_file
(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
**k
);
166 %feature
("docstring") reg_create_directory
"create_dir(location) -> key";
167 %rename
(create_dir
) reg_create_directory
;
168 WERROR reg_create_directory
(TALLOC_CTX
*parent_ctx
,
169 const char
*location
, struct hive_key
**key
);
171 %feature
("docstring") reg_open_directory
"open_dir(location) -> key";
172 %rename
(open_dir
) reg_open_directory
;
173 WERROR reg_open_directory
(TALLOC_CTX
*parent_ctx
,
174 const char
*location
, struct hive_key
**key
);
176 %talloctype
(hive_key
);
178 typedef struct hive_key
{
180 %feature
("docstring") del
"S.del(name) -> None\n"
182 WERROR del
(const char
*name
);
183 %feature
("docstring") flush
"S.flush() -> None\n"
184 "Flush this key to disk";
186 %feature
("docstring") del_value
"S.del_value(name) -> None\n"
188 WERROR del_value
(const char
*name
);
189 %feature
("docstring") set_value
"S.set_value(name, type, data) -> None\n"
191 WERROR set_value
(const char
*name
, uint32_t type
, const DATA_BLOB data
);
195 %rename
(open_samba
) reg_open_samba
;
197 %feature
("docstring") reg_open_samba
"open_samba() -> reg";
198 WERROR reg_open_samba
(TALLOC_CTX
*mem_ctx
,
199 struct registry_context
**ctx
,
200 struct event_context
*ev_ctx
,
201 struct loadparm_context
*lp_ctx
,
202 struct auth_session_info
*session_info
,
203 struct cli_credentials
*credentials
);
206 %constant uint32_t HKEY_CLASSES_ROOT
= HKEY_CLASSES_ROOT
;
207 %constant uint32_t HKEY_CURRENT_USER
= HKEY_CURRENT_USER
;
208 %constant uint32_t HKEY_LOCAL_MACHINE
= HKEY_LOCAL_MACHINE
;
209 %constant uint32_t HKEY_USERS
= HKEY_USERS
;
210 %constant uint32_t HKEY_PERFORMANCE_DATA
= HKEY_PERFORMANCE_DATA
;
211 %constant uint32_t HKEY_CURRENT_CONFIG
= HKEY_CURRENT_CONFIG
;
212 %constant uint32_t HKEY_DYN_DATA
= HKEY_DYN_DATA
;
213 %constant uint32_t HKEY_PERFORMANCE_TEXT
= HKEY_PERFORMANCE_TEXT
;
214 %constant uint32_t HKEY_PERFORMANCE_NLSTEXT
= HKEY_PERFORMANCE_NLSTEXT
;