diff options
author | Tim Potter <tpot@samba.org> | 2004-10-14 07:33:09 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:59:52 -0500 |
commit | 1c4b87c78847542a14d88966f854aa1b38162b88 (patch) | |
tree | c99f5731c82d2101ac74d2b0151085f060daec48 /source4/scripting | |
parent | e3627c2c6eaf8b0ede0b014aacb3478d25faf1b8 (diff) | |
download | samba-1c4b87c78847542a14d88966f854aa1b38162b88.tar.gz samba-1c4b87c78847542a14d88966f854aa1b38162b88.tar.bz2 samba-1c4b87c78847542a14d88966f854aa1b38162b88.zip |
r2966: Handle conversion of DATA_BLOB fields from Python in a slightly nicer
manner. I'm hoping to get rid of DATA_BLOB's but for the moment they
make it easy to get some spoolss action happening quickly.
(This used to be commit 15f8f73f8bfec099973fb8bf167020ae50346cf6)
Diffstat (limited to 'source4/scripting')
-rw-r--r-- | source4/scripting/swig/dcerpc.i | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 606f236f35..918445d7e3 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -254,28 +254,28 @@ PyObject *string_ptr_to_python(TALLOC_CTX *mem_ctx, char *obj) #define dom_sid2_ptr_to_python dom_sid_ptr_to_python #define dom_sid2_ptr_from_python dom_sid_ptr_from_python -DATA_BLOB DATA_BLOB_from_python(PyObject *obj, char *name) +void DATA_BLOB_ptr_from_python(TALLOC_CTX *mem_ctx, DATA_BLOB **s, + PyObject *obj, char *name) { - DATA_BLOB ret; - - /* Because we treat DATA_BLOB as a scalar type (why?) there - doesn't seem to be a way to pass back when an error has - occured. */ - if (obj == NULL) { PyErr_Format(PyExc_ValueError, "Expecting key %s", name); return; } + if (obj == Py_None) { + *s = NULL; + return; + } + if (!PyString_Check(obj)) { PyErr_Format(PyExc_TypeError, "Expecting string value for key '%s'", name); return; } - ret.length = PyString_Size(obj); - ret.data = PyString_AsString(obj); + *s = talloc(mem_ctx, sizeof(DATA_BLOB)); - return ret; + (*s)->length = PyString_Size(obj); + (*s)->data = PyString_AsString(obj); } PyObject *DATA_BLOB_to_python(DATA_BLOB obj) |