diff options
author | Tim Potter <tpot@samba.org> | 2004-10-02 11:22:20 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:59:32 -0500 |
commit | 7cef5fd077cb99343df3fff0c9145e15bce563d7 (patch) | |
tree | 0d36d3f15f02f1a1a8a08bc7fa14f37b1774828b /source4 | |
parent | 91346236c2b88e05154de33bf15544a75bb4e154 (diff) | |
download | samba-7cef5fd077cb99343df3fff0c9145e15bce563d7.tar.gz samba-7cef5fd077cb99343df3fff0c9145e15bce563d7.tar.bz2 samba-7cef5fd077cb99343df3fff0c9145e15bce563d7.zip |
r2780: Add conversion routines for DATA_BLOB. I'm not convinced that DATA_BLOB's
should be treated as scalar types though.
(This used to be commit c9e96038f821783c30b5cf509334176f982403d9)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/scripting/swig/dcerpc.i | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 6be0b639f0..5c3ce0ceec 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -246,6 +246,35 @@ 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) +{ + 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 (!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); + + return ret; +} + +PyObject *DATA_BLOB_to_python(DATA_BLOB obj) +{ + return PyString_FromStringAndSize(obj.data, obj.length); +} + %} %include "samba.i" |