2 /* Python wrapper functions auto-generated by pidl */
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"
11 #include "librpc/gen_ndr/orpc.h"
12 staticforward PyTypeObject rot_InterfaceType;
14 void initrot(void);static PyTypeObject *MInterfacePointer_Type;
15 static PyTypeObject *ClientConnection_Type;
17 static bool pack_py_rot_add_args_in(PyObject *args, PyObject *kwargs, struct rot_add *r)
22 const char *kwnames[] = {
23 "flags", "unk", "moniker", NULL
26 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO:rot_add", discard_const_p(char *, kwnames), &py_flags, &py_unk, &py_moniker)) {
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) {
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) {
45 r->in.moniker = (struct MInterfacePointer *)pytalloc_get_ptr(py_moniker);
49 static PyObject *unpack_py_rot_add_args_out(struct rot_add *r)
53 py_rotid = PyInt_FromLong(*r->out.rotid);
55 if (!W_ERROR_IS_OK(r->out.result)) {
56 PyErr_SetWERROR(r->out.result);
63 static bool pack_py_rot_remove_args_in(PyObject *args, PyObject *kwargs, struct rot_remove *r)
66 const char *kwnames[] = {
70 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:rot_remove", discard_const_p(char *, kwnames), &py_rotid)) {
74 PY_CHECK_TYPE(&PyInt_Type, py_rotid, return false;);
75 r->in.rotid = PyInt_AsLong(py_rotid);
79 static PyObject *unpack_py_rot_remove_args_out(struct rot_remove *r)
84 if (!W_ERROR_IS_OK(r->out.result)) {
85 PyErr_SetWERROR(r->out.result);
92 static bool pack_py_rot_is_listed_args_in(PyObject *args, PyObject *kwargs, struct rot_is_listed *r)
95 const char *kwnames[] = {
99 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:rot_is_listed", discard_const_p(char *, kwnames), &py_moniker)) {
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) {
109 r->in.moniker = (struct MInterfacePointer *)pytalloc_get_ptr(py_moniker);
113 static PyObject *unpack_py_rot_is_listed_args_out(struct rot_is_listed *r)
118 if (!W_ERROR_IS_OK(r->out.result)) {
119 PyErr_SetWERROR(r->out.result);
126 static bool pack_py_rot_get_interface_pointer_args_in(PyObject *args, PyObject *kwargs, struct rot_get_interface_pointer *r)
128 PyObject *py_moniker;
129 const char *kwnames[] = {
133 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:rot_get_interface_pointer", discard_const_p(char *, kwnames), &py_moniker)) {
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) {
143 r->in.moniker = (struct MInterfacePointer *)pytalloc_get_ptr(py_moniker);
147 static PyObject *unpack_py_rot_get_interface_pointer_args_out(struct rot_get_interface_pointer *r)
151 py_ip = pytalloc_reference_ex(MInterfacePointer_Type, r->out.ip, r->out.ip);
153 if (!W_ERROR_IS_OK(r->out.result)) {
154 PyErr_SetWERROR(r->out.result);
161 static bool pack_py_rot_set_modification_time_args_in(PyObject *args, PyObject *kwargs, struct rot_set_modification_time *r)
165 const char *kwnames[] = {
169 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO:rot_set_modification_time", discard_const_p(char *, kwnames), &py_rotid, &py_t)) {
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);
181 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
182 PyInt_Type.tp_name, PyLong_Type.tp_name);
188 static PyObject *unpack_py_rot_set_modification_time_args_out(struct rot_set_modification_time *r)
193 if (!W_ERROR_IS_OK(r->out.result)) {
194 PyErr_SetWERROR(r->out.result);
201 static bool pack_py_rot_get_modification_time_args_in(PyObject *args, PyObject *kwargs, struct rot_get_modification_time *r)
203 PyObject *py_moniker;
204 const char *kwnames[] = {
208 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:rot_get_modification_time", discard_const_p(char *, kwnames), &py_moniker)) {
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) {
218 r->in.moniker = (struct MInterfacePointer *)pytalloc_get_ptr(py_moniker);
222 static PyObject *unpack_py_rot_get_modification_time_args_out(struct rot_get_modification_time *r)
226 py_t = PyLong_FromLongLong(*r->out.t);
228 if (!W_ERROR_IS_OK(r->out.result)) {
229 PyErr_SetWERROR(r->out.result);
236 static bool pack_py_rot_enum_args_in(PyObject *args, PyObject *kwargs, struct rot_enum *r)
238 const char *kwnames[] = {
242 if (!PyArg_ParseTupleAndKeywords(args, kwargs, ":rot_enum", discard_const_p(char *, kwnames))) {
249 static PyObject *unpack_py_rot_enum_args_out(struct rot_enum *r)
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);
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 },
274 static PyObject *interface_rot_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
276 return py_dcerpc_interface_init_helper(type, args, kwargs, &ndr_table_rot);
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"
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,
292 static PyMethodDef rot_methods[] = {
293 { NULL, NULL, 0, NULL }
299 PyObject *dep_samba_dcerpc_base;
300 PyObject *dep_samba_dcerpc_orpc;
302 dep_samba_dcerpc_base = PyImport_ImportModule("samba.dcerpc.base");
303 if (dep_samba_dcerpc_base == NULL)
306 dep_samba_dcerpc_orpc = PyImport_ImportModule("samba.dcerpc.orpc");
307 if (dep_samba_dcerpc_orpc == NULL)
310 MInterfacePointer_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_orpc, "MInterfacePointer");
311 if (MInterfacePointer_Type == NULL)
314 ClientConnection_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_base, "ClientConnection");
315 if (ClientConnection_Type == NULL)
318 rot_InterfaceType.tp_base = ClientConnection_Type;
320 if (PyType_Ready(&rot_InterfaceType) < 0)
322 if (!PyInterface_AddNdrRpcMethods(&rot_InterfaceType, py_ndr_rot_methods))
326 PY_ROT_PATCH(&rot_InterfaceType);
329 m = Py_InitModule3("rot", rot_methods, "rot DCE/RPC");
333 Py_INCREF((PyObject *)(void *)&rot_InterfaceType);
334 PyModule_AddObject(m, "rot", (PyObject *)(void *)&rot_InterfaceType);
335 #ifdef PY_MOD_ROT_PATCH