git add -f bin/default/librpc/gen_ndr/*.[ch] bin/default/source*/librpc/gen_ndr/...
[metze/samba/wip.git] / bin.gen_ndr / default / librpc / gen_ndr / py_rot.c
1
2 /* Python wrapper functions auto-generated by pidl */
3 #include <Python.h>
4 #include "includes.h"
5 #include <pytalloc.h>
6 #include "librpc/rpc/pyrpc.h"
7 #include "librpc/rpc/pyrpc_util.h"
8 #include "bin/default/librpc/gen_ndr/ndr_rot.h"
9 #include "bin/default/librpc/gen_ndr/ndr_rot_c.h"
10
11 #include "librpc/gen_ndr/orpc.h"
12 staticforward PyTypeObject rot_InterfaceType;
13
14 void initrot(void);static PyTypeObject *MInterfacePointer_Type;
15 static PyTypeObject *ClientConnection_Type;
16
17 static bool pack_py_rot_add_args_in(PyObject *args, PyObject *kwargs, struct rot_add *r)
18 {
19         PyObject *py_flags;
20         PyObject *py_unk;
21         PyObject *py_moniker;
22         const char *kwnames[] = {
23                 "flags", "unk", "moniker", NULL
24         };
25
26         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO:rot_add", discard_const_p(char *, kwnames), &py_flags, &py_unk, &py_moniker)) {
27                 return false;
28         }
29
30         PY_CHECK_TYPE(&PyInt_Type, py_flags, return false;);
31         r->in.flags = PyInt_AsLong(py_flags);
32         r->in.unk = talloc_ptrtype(r, r->in.unk);
33         PY_CHECK_TYPE(MInterfacePointer_Type, py_unk, return false;);
34         if (talloc_reference(r, pytalloc_get_mem_ctx(py_unk)) == NULL) {
35                 PyErr_NoMemory();
36                 return false;
37         }
38         r->in.unk = (struct MInterfacePointer *)pytalloc_get_ptr(py_unk);
39         r->in.moniker = talloc_ptrtype(r, r->in.moniker);
40         PY_CHECK_TYPE(MInterfacePointer_Type, py_moniker, return false;);
41         if (talloc_reference(r, pytalloc_get_mem_ctx(py_moniker)) == NULL) {
42                 PyErr_NoMemory();
43                 return false;
44         }
45         r->in.moniker = (struct MInterfacePointer *)pytalloc_get_ptr(py_moniker);
46         return true;
47 }
48
49 static PyObject *unpack_py_rot_add_args_out(struct rot_add *r)
50 {
51         PyObject *result;
52         PyObject *py_rotid;
53         py_rotid = PyInt_FromLong(*r->out.rotid);
54         result = py_rotid;
55         if (!W_ERROR_IS_OK(r->out.result)) {
56                 PyErr_SetWERROR(r->out.result);
57                 return NULL;
58         }
59
60         return result;
61 }
62
63 static bool pack_py_rot_remove_args_in(PyObject *args, PyObject *kwargs, struct rot_remove *r)
64 {
65         PyObject *py_rotid;
66         const char *kwnames[] = {
67                 "rotid", NULL
68         };
69
70         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:rot_remove", discard_const_p(char *, kwnames), &py_rotid)) {
71                 return false;
72         }
73
74         PY_CHECK_TYPE(&PyInt_Type, py_rotid, return false;);
75         r->in.rotid = PyInt_AsLong(py_rotid);
76         return true;
77 }
78
79 static PyObject *unpack_py_rot_remove_args_out(struct rot_remove *r)
80 {
81         PyObject *result;
82         result = Py_None;
83         Py_INCREF(result);
84         if (!W_ERROR_IS_OK(r->out.result)) {
85                 PyErr_SetWERROR(r->out.result);
86                 return NULL;
87         }
88
89         return result;
90 }
91
92 static bool pack_py_rot_is_listed_args_in(PyObject *args, PyObject *kwargs, struct rot_is_listed *r)
93 {
94         PyObject *py_moniker;
95         const char *kwnames[] = {
96                 "moniker", NULL
97         };
98
99         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:rot_is_listed", discard_const_p(char *, kwnames), &py_moniker)) {
100                 return false;
101         }
102
103         r->in.moniker = talloc_ptrtype(r, r->in.moniker);
104         PY_CHECK_TYPE(MInterfacePointer_Type, py_moniker, return false;);
105         if (talloc_reference(r, pytalloc_get_mem_ctx(py_moniker)) == NULL) {
106                 PyErr_NoMemory();
107                 return false;
108         }
109         r->in.moniker = (struct MInterfacePointer *)pytalloc_get_ptr(py_moniker);
110         return true;
111 }
112
113 static PyObject *unpack_py_rot_is_listed_args_out(struct rot_is_listed *r)
114 {
115         PyObject *result;
116         result = Py_None;
117         Py_INCREF(result);
118         if (!W_ERROR_IS_OK(r->out.result)) {
119                 PyErr_SetWERROR(r->out.result);
120                 return NULL;
121         }
122
123         return result;
124 }
125
126 static bool pack_py_rot_get_interface_pointer_args_in(PyObject *args, PyObject *kwargs, struct rot_get_interface_pointer *r)
127 {
128         PyObject *py_moniker;
129         const char *kwnames[] = {
130                 "moniker", NULL
131         };
132
133         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:rot_get_interface_pointer", discard_const_p(char *, kwnames), &py_moniker)) {
134                 return false;
135         }
136
137         r->in.moniker = talloc_ptrtype(r, r->in.moniker);
138         PY_CHECK_TYPE(MInterfacePointer_Type, py_moniker, return false;);
139         if (talloc_reference(r, pytalloc_get_mem_ctx(py_moniker)) == NULL) {
140                 PyErr_NoMemory();
141                 return false;
142         }
143         r->in.moniker = (struct MInterfacePointer *)pytalloc_get_ptr(py_moniker);
144         return true;
145 }
146
147 static PyObject *unpack_py_rot_get_interface_pointer_args_out(struct rot_get_interface_pointer *r)
148 {
149         PyObject *result;
150         PyObject *py_ip;
151         py_ip = pytalloc_reference_ex(MInterfacePointer_Type, r->out.ip, r->out.ip);
152         result = py_ip;
153         if (!W_ERROR_IS_OK(r->out.result)) {
154                 PyErr_SetWERROR(r->out.result);
155                 return NULL;
156         }
157
158         return result;
159 }
160
161 static bool pack_py_rot_set_modification_time_args_in(PyObject *args, PyObject *kwargs, struct rot_set_modification_time *r)
162 {
163         PyObject *py_rotid;
164         PyObject *py_t;
165         const char *kwnames[] = {
166                 "rotid", "t", NULL
167         };
168
169         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO:rot_set_modification_time", discard_const_p(char *, kwnames), &py_rotid, &py_t)) {
170                 return false;
171         }
172
173         PY_CHECK_TYPE(&PyInt_Type, py_rotid, return false;);
174         r->in.rotid = PyInt_AsLong(py_rotid);
175         r->in.t = talloc_ptrtype(r, r->in.t);
176         if (PyLong_Check(py_t)) {
177                 *r->in.t = PyLong_AsLongLong(py_t);
178         } else if (PyInt_Check(py_t)) {
179                 *r->in.t = PyInt_AsLong(py_t);
180         } else {
181                 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
182                   PyInt_Type.tp_name, PyLong_Type.tp_name);
183                 return false;
184         }
185         return true;
186 }
187
188 static PyObject *unpack_py_rot_set_modification_time_args_out(struct rot_set_modification_time *r)
189 {
190         PyObject *result;
191         result = Py_None;
192         Py_INCREF(result);
193         if (!W_ERROR_IS_OK(r->out.result)) {
194                 PyErr_SetWERROR(r->out.result);
195                 return NULL;
196         }
197
198         return result;
199 }
200
201 static bool pack_py_rot_get_modification_time_args_in(PyObject *args, PyObject *kwargs, struct rot_get_modification_time *r)
202 {
203         PyObject *py_moniker;
204         const char *kwnames[] = {
205                 "moniker", NULL
206         };
207
208         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:rot_get_modification_time", discard_const_p(char *, kwnames), &py_moniker)) {
209                 return false;
210         }
211
212         r->in.moniker = talloc_ptrtype(r, r->in.moniker);
213         PY_CHECK_TYPE(MInterfacePointer_Type, py_moniker, return false;);
214         if (talloc_reference(r, pytalloc_get_mem_ctx(py_moniker)) == NULL) {
215                 PyErr_NoMemory();
216                 return false;
217         }
218         r->in.moniker = (struct MInterfacePointer *)pytalloc_get_ptr(py_moniker);
219         return true;
220 }
221
222 static PyObject *unpack_py_rot_get_modification_time_args_out(struct rot_get_modification_time *r)
223 {
224         PyObject *result;
225         PyObject *py_t;
226         py_t = PyLong_FromLongLong(*r->out.t);
227         result = py_t;
228         if (!W_ERROR_IS_OK(r->out.result)) {
229                 PyErr_SetWERROR(r->out.result);
230                 return NULL;
231         }
232
233         return result;
234 }
235
236 static bool pack_py_rot_enum_args_in(PyObject *args, PyObject *kwargs, struct rot_enum *r)
237 {
238         const char *kwnames[] = {
239                 NULL
240         };
241
242         if (!PyArg_ParseTupleAndKeywords(args, kwargs, ":rot_enum", discard_const_p(char *, kwnames))) {
243                 return false;
244         }
245
246         return true;
247 }
248
249 static PyObject *unpack_py_rot_enum_args_out(struct rot_enum *r)
250 {
251         PyObject *result;
252         PyObject *py_EnumMoniker;
253         py_EnumMoniker = pytalloc_reference_ex(MInterfacePointer_Type, r->out.EnumMoniker, r->out.EnumMoniker);
254         result = py_EnumMoniker;
255         if (!W_ERROR_IS_OK(r->out.result)) {
256                 PyErr_SetWERROR(r->out.result);
257                 return NULL;
258         }
259
260         return result;
261 }
262
263 const struct PyNdrRpcMethodDef py_ndr_rot_methods[] = {
264         { "add", "S.add(flags, unk, moniker) -> rotid", (py_dcerpc_call_fn)dcerpc_rot_add_r, (py_data_pack_fn)pack_py_rot_add_args_in, (py_data_unpack_fn)unpack_py_rot_add_args_out, 0, &ndr_table_rot },
265         { "remove", "S.remove(rotid) -> None", (py_dcerpc_call_fn)dcerpc_rot_remove_r, (py_data_pack_fn)pack_py_rot_remove_args_in, (py_data_unpack_fn)unpack_py_rot_remove_args_out, 1, &ndr_table_rot },
266         { "is_listed", "S.is_listed(moniker) -> None", (py_dcerpc_call_fn)dcerpc_rot_is_listed_r, (py_data_pack_fn)pack_py_rot_is_listed_args_in, (py_data_unpack_fn)unpack_py_rot_is_listed_args_out, 2, &ndr_table_rot },
267         { "get_interface_pointer", "S.get_interface_pointer(moniker) -> ip", (py_dcerpc_call_fn)dcerpc_rot_get_interface_pointer_r, (py_data_pack_fn)pack_py_rot_get_interface_pointer_args_in, (py_data_unpack_fn)unpack_py_rot_get_interface_pointer_args_out, 3, &ndr_table_rot },
268         { "set_modification_time", "S.set_modification_time(rotid, t) -> None", (py_dcerpc_call_fn)dcerpc_rot_set_modification_time_r, (py_data_pack_fn)pack_py_rot_set_modification_time_args_in, (py_data_unpack_fn)unpack_py_rot_set_modification_time_args_out, 4, &ndr_table_rot },
269         { "get_modification_time", "S.get_modification_time(moniker) -> t", (py_dcerpc_call_fn)dcerpc_rot_get_modification_time_r, (py_data_pack_fn)pack_py_rot_get_modification_time_args_in, (py_data_unpack_fn)unpack_py_rot_get_modification_time_args_out, 5, &ndr_table_rot },
270         { "enum", "S.enum() -> EnumMoniker", (py_dcerpc_call_fn)dcerpc_rot_enum_r, (py_data_pack_fn)pack_py_rot_enum_args_in, (py_data_unpack_fn)unpack_py_rot_enum_args_out, 6, &ndr_table_rot },
271         { NULL }
272 };
273
274 static PyObject *interface_rot_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
275 {
276         return py_dcerpc_interface_init_helper(type, args, kwargs, &ndr_table_rot);
277 }
278
279 static PyTypeObject rot_InterfaceType = {
280         PyObject_HEAD_INIT(NULL) 0,
281         .tp_name = "rot.rot",
282         .tp_basicsize = sizeof(dcerpc_InterfaceObject),
283         .tp_doc = "rot(binding, lp_ctx=None, credentials=None) -> connection\n"
284 "\n"
285 "binding should be a DCE/RPC binding string (for example: ncacn_ip_tcp:127.0.0.1)\n"
286 "lp_ctx should be a path to a smb.conf file or a param.LoadParm object\n"
287 "credentials should be a credentials.Credentials object.\n\n",
288         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
289         .tp_new = interface_rot_new,
290 };
291
292 static PyMethodDef rot_methods[] = {
293         { NULL, NULL, 0, NULL }
294 };
295
296 void initrot(void)
297 {
298         PyObject *m;
299         PyObject *dep_samba_dcerpc_base;
300         PyObject *dep_samba_dcerpc_orpc;
301
302         dep_samba_dcerpc_base = PyImport_ImportModule("samba.dcerpc.base");
303         if (dep_samba_dcerpc_base == NULL)
304                 return;
305
306         dep_samba_dcerpc_orpc = PyImport_ImportModule("samba.dcerpc.orpc");
307         if (dep_samba_dcerpc_orpc == NULL)
308                 return;
309
310         MInterfacePointer_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_orpc, "MInterfacePointer");
311         if (MInterfacePointer_Type == NULL)
312                 return;
313
314         ClientConnection_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_base, "ClientConnection");
315         if (ClientConnection_Type == NULL)
316                 return;
317
318         rot_InterfaceType.tp_base = ClientConnection_Type;
319
320         if (PyType_Ready(&rot_InterfaceType) < 0)
321                 return;
322         if (!PyInterface_AddNdrRpcMethods(&rot_InterfaceType, py_ndr_rot_methods))
323                 return;
324
325 #ifdef PY_ROT_PATCH
326         PY_ROT_PATCH(&rot_InterfaceType);
327 #endif
328
329         m = Py_InitModule3("rot", rot_methods, "rot DCE/RPC");
330         if (m == NULL)
331                 return;
332
333         Py_INCREF((PyObject *)(void *)&rot_InterfaceType);
334         PyModule_AddObject(m, "rot", (PyObject *)(void *)&rot_InterfaceType);
335 #ifdef PY_MOD_ROT_PATCH
336         PY_MOD_ROT_PATCH(m);
337 #endif
338
339 }