From 63574fda0e43c18e5379654ee53e62ff7657de66 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 8 Dec 2010 15:07:32 +0100 Subject: s4:python: add PyString_FromStringOrNULL() to pyrpc_util metze --- source4/librpc/rpc/pyrpc_util.c | 8 ++++++++ source4/librpc/rpc/pyrpc_util.h | 2 ++ 2 files changed, 10 insertions(+) (limited to 'source4') diff --git a/source4/librpc/rpc/pyrpc_util.c b/source4/librpc/rpc/pyrpc_util.c index 33bce387af..5ad8d2f9e8 100644 --- a/source4/librpc/rpc/pyrpc_util.c +++ b/source4/librpc/rpc/pyrpc_util.c @@ -300,3 +300,11 @@ PyObject *py_return_ndr_struct(const char *module_name, const char *type_name, return py_talloc_reference_ex(py_type, r_ctx, r); } + +PyObject *PyString_FromStringOrNULL(const char *str) +{ + if (str == NULL) { + Py_RETURN_NONE; + } + return PyString_FromString(str); +} diff --git a/source4/librpc/rpc/pyrpc_util.h b/source4/librpc/rpc/pyrpc_util.h index f102014147..445138b9b5 100644 --- a/source4/librpc/rpc/pyrpc_util.h +++ b/source4/librpc/rpc/pyrpc_util.h @@ -53,4 +53,6 @@ PyObject *py_dcerpc_interface_init_helper(PyTypeObject *type, PyObject *args, Py PyObject *py_return_ndr_struct(const char *module_name, const char *type_name, TALLOC_CTX *r_ctx, void *r); +PyObject *PyString_FromStringOrNULL(const char *str); + #endif /* __PYRPC_UTIL_H__ */ -- cgit