]> git.samba.org - samba.git/blob - source4/lib/registry/registry.i
Specify event_context to ldb_wrap_connect explicitly.
[samba.git] / source4 / lib / registry / registry.i
1 /* 
2    Unix SMB/CIFS implementation.
3    Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
4    
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.
9    
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.
14    
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/>.
17 */
18
19 %module registry
20
21 %{
22 /* Include headers */
23 #include <stdint.h>
24 #include <stdbool.h>
25
26 #include "includes.h"
27 #include "registry.h"
28 #include "param/param.h"
29 #include "events/events.h"
30
31 typedef struct registry_context reg;
32 typedef struct hive_key hive_key;
33 %}
34
35 /* FIXME: This should be in another file */
36 %typemap(default,noblock=1) struct auth_session_info * {
37     $1 = NULL; 
38 }
39
40 %import "stdint.i"
41 %import "../../lib/talloc/talloc.i"
42 %import "../../auth/credentials/credentials.i"
43 %import "../../libcli/util/errors.i"
44 %import "../../param/param.i"
45 %import "../events/events.i"
46
47 /* Utility functions */
48
49 const char *reg_get_predef_name(uint32_t hkey);
50 const char *str_regtype(int type);
51
52 /* Registry contexts */
53 %typemap(in,noblock=1,numinputs=0) struct registry_context ** (struct registry_context *tmp) {
54     $1 = &tmp; 
55 }
56
57 %typemap(argout,noblock=1) struct registry_context ** {
58     $result = SWIG_NewPointerObj(*$1, SWIGTYPE_p_registry_context, 0);
59 }
60
61 %rename(Registry) reg_open_local;
62 WERROR reg_open_local(TALLOC_CTX *parent_ctx, struct registry_context **ctx);
63
64 %typemap(in,noblock=1) const char ** {
65   /* Check if is a list */
66   if (PyList_Check($input)) {
67     int size = PyList_Size($input);
68     int i = 0;
69     $1 = (char **) malloc((size+1)*sizeof(const char *));
70     for (i = 0; i < size; i++) {
71       PyObject *o = PyList_GetItem($input,i);
72       if (PyString_Check(o))
73     $1[i] = PyString_AsString(PyList_GetItem($input,i));
74       else {
75     PyErr_SetString(PyExc_TypeError,"list must contain strings");
76     free($1);
77     return NULL;
78       }
79     }
80     $1[i] = 0;
81   } else {
82     PyErr_SetString(PyExc_TypeError,"not a list");
83     return NULL;
84   }
85 }
86
87 %typemap(freearg,noblock=1) const char ** {
88   free((char **) $1);
89 }
90
91 %talloctype(reg);
92
93 typedef struct registry_context {
94     %extend {
95
96     WERROR get_predefined_key_by_name(const char *name, 
97                                       struct registry_key **key);
98
99     WERROR key_del_abs(const char *path);
100     WERROR get_predefined_key(uint32_t hkey_id, struct registry_key **key);
101     WERROR diff_apply(const char *filename);
102     WERROR generate_diff(struct registry_context *ctx2, const struct reg_diff_callbacks *callbacks,
103                          void *callback_data);
104
105     WERROR mount_hive(struct hive_key *key, uint32_t hkey_id,
106                       const char **elements=NULL);
107
108     struct registry_key *import_hive_key(struct hive_key *hive, uint32_t predef_key, const char **elements);
109     WERROR mount_hive(struct hive_key *key, const char *predef_name)
110     {
111         int i;
112         for (i = 0; reg_predefined_keys[i].name; i++) {
113             if (!strcasecmp(reg_predefined_keys[i].name, predef_name))
114                 return reg_mount_hive($self, key, 
115                                       reg_predefined_keys[i].handle, NULL);
116         }
117         return WERR_INVALID_NAME;
118     }
119
120     }
121 } reg;
122
123 /* Hives */
124 %typemap(in,noblock=1,numinputs=0) struct hive_key ** (struct hive_key *tmp) {
125     $1 = &tmp; 
126 }
127
128 %typemap(argout,noblock=1) struct hive_key ** {
129     Py_XDECREF($result);
130     $result = SWIG_NewPointerObj(*$1, SWIGTYPE_p_hive_key, 0);
131 }
132
133 %rename(hive_key) reg_open_hive;
134 WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
135                      struct auth_session_info *session_info,
136                      struct cli_credentials *credentials,
137                      struct event_context *ev_ctx,
138                      struct loadparm_context *lp_ctx,
139                      struct hive_key **root);
140
141 %rename(open_ldb) reg_open_ldb_file;
142 WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
143              struct auth_session_info *session_info,
144              struct cli_credentials *credentials,
145              struct event_context *ev_ctx,
146              struct loadparm_context *lp_ctx,
147              struct hive_key **k);
148
149 %rename(create_dir) reg_create_directory;
150 WERROR reg_create_directory(TALLOC_CTX *parent_ctx,
151                 const char *location, struct hive_key **key);
152
153 %rename(open_dir) reg_open_directory;
154 WERROR reg_open_directory(TALLOC_CTX *parent_ctx,
155              const char *location, struct hive_key **key);
156
157 %talloctype(hive_key);
158
159 typedef struct hive_key {
160     %extend {
161         WERROR del(const char *name);
162         WERROR flush(void);
163         WERROR del_value(const char *name);
164         WERROR set_value(const char *name, uint32_t type, const DATA_BLOB data);
165     }
166 } hive_key;
167
168 %rename(open_samba) reg_open_samba;
169
170 WERROR reg_open_samba(TALLOC_CTX *mem_ctx,
171                       struct registry_context **ctx,
172                       struct event_context *ev_ctx,
173                       struct loadparm_context *lp_ctx,
174                       struct auth_session_info *session_info,
175                       struct cli_credentials *credentials);
176
177 /* Constants */
178 %constant uint32_t HKEY_CLASSES_ROOT = HKEY_CLASSES_ROOT;
179 %constant uint32_t HKEY_CURRENT_USER = HKEY_CURRENT_USER;
180 %constant uint32_t HKEY_LOCAL_MACHINE = HKEY_LOCAL_MACHINE;
181 %constant uint32_t HKEY_USERS = HKEY_USERS;
182 %constant uint32_t HKEY_PERFORMANCE_DATA = HKEY_PERFORMANCE_DATA;
183 %constant uint32_t HKEY_CURRENT_CONFIG = HKEY_CURRENT_CONFIG;
184 %constant uint32_t HKEY_DYN_DATA = HKEY_DYN_DATA;
185 %constant uint32_t HKEY_PERFORMANCE_TEXT = HKEY_PERFORMANCE_TEXT;
186 %constant uint32_t HKEY_PERFORMANCE_NLSTEXT = HKEY_PERFORMANCE_NLSTEXT;