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