From ae02bf6f068d49478f159be726e628fa6287907a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 27 Mar 2014 14:54:29 +0100 Subject: [PATCH] s4:pyrpc: add py_dcerpc_syntax_init_helper() Signed-off-by: Stefan Metzmacher Reviewed-by: Andrew Bartlett --- source4/librpc/rpc/pyrpc_util.c | 22 ++++++++++++++++++++++ source4/librpc/rpc/pyrpc_util.h | 4 ++++ 2 files changed, 26 insertions(+) diff --git a/source4/librpc/rpc/pyrpc_util.c b/source4/librpc/rpc/pyrpc_util.c index cec8574319e..314ad2cc8d7 100644 --- a/source4/librpc/rpc/pyrpc_util.c +++ b/source4/librpc/rpc/pyrpc_util.c @@ -304,6 +304,28 @@ bool PyInterface_AddNdrRpcMethods(PyTypeObject *ifacetype, const struct PyNdrRpc return true; } +PyObject *py_dcerpc_syntax_init_helper(PyTypeObject *type, PyObject *args, PyObject *kwargs, + const struct ndr_syntax_id *syntax) +{ + PyObject *ret; + struct ndr_syntax_id *obj; + const char *kwnames[] = { NULL }; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, ":abstract_syntax", discard_const_p(char *, kwnames))) { + return NULL; + } + + ret = pytalloc_new(struct ndr_syntax_id, type); + if (ret == NULL) { + return NULL; + } + + obj = (struct ndr_syntax_id *)pytalloc_get_ptr(ret); + *obj = *syntax; + + return ret; +} + void PyErr_SetDCERPCStatus(struct dcerpc_pipe *p, NTSTATUS status) { if (p && NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { diff --git a/source4/librpc/rpc/pyrpc_util.h b/source4/librpc/rpc/pyrpc_util.h index 837a33be169..21454cae15b 100644 --- a/source4/librpc/rpc/pyrpc_util.h +++ b/source4/librpc/rpc/pyrpc_util.h @@ -50,6 +50,10 @@ bool py_check_dcerpc_type(PyObject *obj, const char *module, const char *type_na bool PyInterface_AddNdrRpcMethods(PyTypeObject *object, const struct PyNdrRpcMethodDef *mds); PyObject *py_dcerpc_interface_init_helper(PyTypeObject *type, PyObject *args, PyObject *kwargs, const struct ndr_interface_table *table); +struct ndr_syntax_id; +PyObject *py_dcerpc_syntax_init_helper(PyTypeObject *type, PyObject *args, PyObject *kwargs, + const struct ndr_syntax_id *syntax); + PyObject *py_return_ndr_struct(const char *module_name, const char *type_name, TALLOC_CTX *r_ctx, void *r);