summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2004-10-31 11:33:40 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:05:06 -0500
commit751b412326e77ee4bea0c521906e6f83a8bedd07 (patch)
tree26a827aa52c31fd25c01c32f4bfd445584d11eda /source4/scripting
parent12fb5bc0cbc8b3180d8319a169611945ae42a242 (diff)
downloadsamba-751b412326e77ee4bea0c521906e6f83a8bedd07.tar.gz
samba-751b412326e77ee4bea0c521906e6f83a8bedd07.tar.bz2
samba-751b412326e77ee4bea0c521906e6f83a8bedd07.zip
r3410: Handle conversion of DATA_BLOBs and pointers to DATA_BLOBs from python.
(This used to be commit 12e037dbe3d497aff2415c0a22fab20a7932ab7a)
Diffstat (limited to 'source4/scripting')
-rw-r--r--source4/scripting/swig/dcerpc.i17
-rw-r--r--source4/scripting/swig/torture/spoolss.py27
2 files changed, 43 insertions, 1 deletions
diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i
index 796384d6e7..c7e2d79c12 100644
--- a/source4/scripting/swig/dcerpc.i
+++ b/source4/scripting/swig/dcerpc.i
@@ -254,6 +254,23 @@ 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
+void DATA_BLOB_from_python(TALLOC_CTX *mem_ctx, DATA_BLOB *s,
+ PyObject *obj, char name)
+{
+ 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;
+ }
+
+ s->length = PyString_Size(obj);
+ s->data = PyString_AsString(obj);
+}
+
void DATA_BLOB_ptr_from_python(TALLOC_CTX *mem_ctx, DATA_BLOB **s,
PyObject *obj, char *name)
{
diff --git a/source4/scripting/swig/torture/spoolss.py b/source4/scripting/swig/torture/spoolss.py
index 4779c278f2..ef8b3150e1 100644
--- a/source4/scripting/swig/torture/spoolss.py
+++ b/source4/scripting/swig/torture/spoolss.py
@@ -267,7 +267,31 @@ def test_EnumPrinterData(pipe, handle):
enum_index += 1
- sys.exit(1)
+def test_SetPrinterData(pipe, handle):
+
+ print 'testing spoolss_SetPrinterData'
+
+ valuename = '__printerdatatest__'
+ data = '12345'
+
+ r = {}
+ r['handle'] = handle
+ r['value_name'] = valuename
+ r['type'] = 3 # REG_BINARY
+ r['buffer'] = data
+ r['real_len'] = 5
+
+ dcerpc.spoolss_SetPrinterData(pipe, r)
+
+ s = {}
+ s['handle'] = handle
+ s['value_name'] = valuename
+
+ result = ResizeBufferCall(dcerpc.spoolss_GetPrinterData, pipe, r)
+
+ if result['buffer'] != data:
+ print 'SetPrinterData: mismatch'
+ sys.exit(1)
def test_EnumPrinters(pipe):
@@ -321,6 +345,7 @@ def test_EnumPrinters(pipe):
test_AddForm(pipe, handle)
test_EnumJobs(pipe, handle)
test_EnumPrinterData(pipe, handle)
+ test_SetPrinterData(pipe, handle)
test_ClosePrinter(pipe, handle)