r26236: Remove more uses of global_loadparm or specify loadparm_context explicitly.
[ira/wip.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
29 typedef struct registry_context reg;
30 typedef struct hive_key hive;
31 %}
32
33 /* FIXME: This should be in another file */
34 %typemap(default) struct auth_session_info * {
35     $1 = NULL; 
36 }
37
38 %import "stdint.i"
39 %import "../../lib/talloc/talloc.i"
40 %import "../../auth/credentials/credentials.i"
41 %import "../../libcli/util/errors.i"
42
43 /* Utility functions */
44
45 const char *reg_get_predef_name(uint32_t hkey);
46 const char *str_regtype(int type);
47
48 /* Registry contexts */
49 %typemap(in,numinputs=0) struct registry_context ** (struct registry_context *tmp) {
50     $1 = &tmp; 
51 }
52
53 %typemap(argout) struct registry_context ** {
54     $result = SWIG_NewPointerObj(*$1, SWIGTYPE_p_registry_context, 0);
55 }
56
57 %rename(Registry) reg_open_local;
58 WERROR reg_open_local(TALLOC_CTX *parent_ctx, struct registry_context **ctx,
59                       struct auth_session_info *session_info,
60                       struct cli_credentials *credentials);
61
62 %typemap(in) 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) const char ** {
86   free((char **) $1);
87 }
88
89 typedef struct registry_context {
90     %extend {
91
92     ~reg() { talloc_free($self); }
93     WERROR get_predefined_key_by_name(const char *name, 
94                                       struct registry_key **key);
95
96     WERROR get_predefined_key(uint32_t hkey_id, struct registry_key **key);
97     WERROR apply_patchfile(const char *filename)
98     {
99         return reg_diff_apply(filename, $self);
100     }
101
102     WERROR mount_hive(struct hive_key *hive_key, uint32_t hkey_id,
103                       const char **elements=NULL);
104     }
105
106     %pythoncode {
107         def mount(self, path, hkey_id, elements=[]):
108             self.mount_hive(Hive(path), hkey_id, elements)
109     }
110 } reg;
111
112 /* Hives */
113 %typemap(in,numinputs=0) struct hive_key ** (struct hive_key *tmp) {
114     $1 = &tmp; 
115 }
116
117 %typemap(argout) struct hive_key ** {
118     Py_XDECREF($result);
119     $result = SWIG_NewPointerObj(*$1, SWIGTYPE_p_hive_key, 0);
120 }
121
122 %rename(Hive) reg_open_hive;
123 WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
124                      struct auth_session_info *session_info,
125                      struct cli_credentials *credentials,
126                      struct hive_key **root);
127
128 typedef struct hive_key {
129     %extend {
130         ~hive() { talloc_free($self); }
131     }
132 } hive;
133
134 %rename(open_samba) reg_open_samba;
135
136 WERROR reg_open_samba(TALLOC_CTX *mem_ctx,
137                       struct registry_context **ctx,
138                       struct loadparm_context *lp_ctx,
139                       struct auth_session_info *session_info,
140                       struct cli_credentials *credentials);
141
142 /* Constants */
143 %constant uint32_t HKEY_CLASSES_ROOT = HKEY_CLASSES_ROOT;
144 %constant uint32_t HKEY_CURRENT_USER = HKEY_CURRENT_USER;
145 %constant uint32_t HKEY_LOCAL_MACHINE = HKEY_LOCAL_MACHINE;
146 %constant uint32_t HKEY_USERS = HKEY_USERS;
147 %constant uint32_t HKEY_PERFORMANCE_DATA = HKEY_PERFORMANCE_DATA;
148 %constant uint32_t HKEY_CURRENT_CONFIG = HKEY_CURRENT_CONFIG;
149 %constant uint32_t HKEY_DYN_DATA = HKEY_DYN_DATA;
150 %constant uint32_t HKEY_PERFORMANCE_TEXT = HKEY_PERFORMANCE_TEXT;
151 %constant uint32_t HKEY_PERFORMANCE_NLSTEXT = HKEY_PERFORMANCE_NLSTEXT;