summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2004-10-25 07:31:59 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:04:40 -0500
commit266e36aa54dc82a48655d6c64cb8cd3fbfdf4fa9 (patch)
tree82ae4c37c71243668ac86f37aab5e0a56465f285 /source4
parentd200f9385f1088240eb588deb94550291796ca10 (diff)
downloadsamba-266e36aa54dc82a48655d6c64cb8cd3fbfdf4fa9.tar.gz
samba-266e36aa54dc82a48655d6c64cb8cd3fbfdf4fa9.tar.bz2
samba-266e36aa54dc82a48655d6c64cb8cd3fbfdf4fa9.zip
r3204: Got unpacking of an array of PrinterInfo union elements working. Phew.
(This used to be commit f490cd719cc02589e73e26fa983aff90708d1926)
Diffstat (limited to 'source4')
-rw-r--r--source4/build/pidl/swig.pm97
-rw-r--r--source4/scripting/swig/torture/spoolss.py2
2 files changed, 45 insertions, 54 deletions
diff --git a/source4/build/pidl/swig.pm b/source4/build/pidl/swig.pm
index 31a726e32d..0ba654538d 100644
--- a/source4/build/pidl/swig.pm
+++ b/source4/build/pidl/swig.pm
@@ -462,61 +462,8 @@ sub ParseStruct($)
$result .= "\treturn obj;\n";
$result .= "}\n\n";
- # Generate function to convert DATA_BLOB to Python dict and an array
- # of Python dicts.
-
- if (util::has_property($s->{DATA}, "public")) {
-
- $result .= "/* Convert a Python string to a struct $s->{NAME} python dict */\n\n";
- $result .= "NTSTATUS unmarshall_$s->{NAME}(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, struct $s->{NAME} *s)\n";
- $result .= "{\n";
- $result .= "\tstruct ndr_pull *ndr = ndr_pull_init_blob(blob, mem_ctx);\n";
- $result .= "\tNTSTATUS result;\n\n";
- $result .= "\tresult = ndr_pull_struct_blob(blob, mem_ctx, s, ndr_pull_$s->{NAME});\n";
- $result .= "\treturn result;\n";
- $result .= "}\n\n";
-
- $result .= "/* Convert a Python string to an array of struct $s->{NAME} python dicts */\n\n";
- $result .= "NTSTATUS unmarshall_$s->{NAME}_array(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, uint32 count, struct $s->{NAME} **s)\n";
- $result .= "{\n";
- $result .= "\tstruct ndr_pull *ndr = ndr_pull_init_blob(blob, mem_ctx);\n";
- $result .= "\tNTSTATUS result;\n\n";
- $result .= "\t*s = talloc(mem_ctx, sizeof(struct $s->{NAME}) * count);\n\n";
- $result .= "\tresult = ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, *s, sizeof(struct $s->{NAME}), count, ndr_pull_$s->{NAME});\n\n";
- $result .= "\treturn result;\n";
- $result .= "}\n\n";
- }
-
$result .= "%}\n\n";
- if (util::has_property($s->{DATA}, "public")) {
-
- $result .= "%typemap(in, numinputs=0) struct $s->{NAME} *EMPTY (struct $s->{NAME} temp_$s->{NAME}) {\n";
- $result .= "\t\$1 = &temp_$s->{NAME};\n";
- $result .= "}\n\n";
-
- $result .= "%typemap(argout) struct $s->{NAME} *EMPTY {\n";
- $result .= "\tTALLOC_CTX *mem_ctx = talloc_init(\"typemap(argout) $s->{NAME} *\");\n\n";
- $result .= "\t\$result = $s->{NAME}_ptr_to_python(mem_ctx, \$1);\n";
- $result .= "}\n\n";
-
- $result .= "NTSTATUS unmarshall_$s->{NAME}(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, struct $s->{NAME} *EMPTY);\n\n";
-
- $result .= "%typemap(in, numinputs=0) struct $s->{NAME} **ARRAY (struct $s->{NAME} *temp_$s->{NAME}) {\n";
- $result .= "\t\$1 = &temp_$s->{NAME};\n";
- $result .= "}\n\n";
-
- $result .= "%typemap(argout) (uint32 count, struct $s->{NAME} **ARRAY) {\n";
- $result .= "\tTALLOC_CTX *mem_ctx = talloc_init(\"typemap(argout) $s->{NAME} **\");\n";
- $result .= "\tuint32 i;\n\n";
- $result .= "\t\$result = PyList_New(\$1);\n\n";
- $result .= "\tfor (i = 0; i < \$1; i++)\n";
- $result .= "\t\tPyList_SetItem(\$result, i, spoolss_PrinterInfo1_ptr_to_python(mem_ctx, \$2[i]));\n";
- $result .= "}\n\n";
-
- $result .= "NTSTATUS unmarshall_$s->{NAME}_array(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, uint32 count, struct $s->{NAME} **ARRAY);\n\n";
- }
-
return $result;
}
@@ -633,8 +580,52 @@ sub ParseUnion($)
$result .= "}\n\n";
+ if (util::has_property($u->{DATA}, "public")) {
+
+ # Generate function to unmarshall an array of structures.
+ # Used exclusively (?) in the spoolss pipe.
+
+ $result .= "/* Unmarshall an array of structures from a Python string */\n\n";
+
+ $result .= "NTSTATUS unmarshall_$u->{NAME}_array(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, uint32 level, uint32 count, union $u->{NAME} **info)\n";
+ $result .= "{\n";
+ $result .= "\tint i;\n";
+ $result .= "\tstruct ndr_pull *ndr;\n";
+ $result .= "\tndr = ndr_pull_init_blob(blob, mem_ctx);\n";
+ $result .= "\tif (!ndr) {\n";
+ $result .= "\t\treturn NT_STATUS_NO_MEMORY;\n";
+ $result .= "\t}\n";
+ $result .= "\tNDR_ALLOC_N(ndr, (*info), count);\n";
+ $result .= "\tfor (i=0;i<count;i++) {\n";
+ $result .= "\t\tndr->data += ndr->offset;\n";
+ $result .= "\t\tndr->offset = 0;\n";
+ $result .= "\t\tNDR_CHECK(ndr_pull_spoolss_PrinterInfo(ndr, NDR_SCALARS|NDR_BUFFERS, level, &(*info)[i]));\n";
+ $result .= "\t}\n\n";
+ $result .= "\treturn NT_STATUS_OK;\n";
+ $result .= "\t}\n";
+ }
+
$result .= "%}\n\n";
+ if (util::has_property($u->{DATA}, "public")) {
+
+ $result .= "%typemap(in, numinputs=0) union $u->{NAME} **EMPTY (union $u->{NAME} *temp_$u->{NAME}) {\n";
+ $result .= "\t\$1 = &temp_$u->{NAME};\n";
+ $result .= "}\n\n";
+
+ $result .= "%typemap(argout) (uint32 level, uint32 count, union $u->{NAME} **EMPTY) {\n";
+ $result .= "\tTALLOC_CTX *mem_ctx = talloc_init(\"unmarshall_$u->{NAME}_array\");\n";
+ $result .= "\tint i;\n\n";
+ $result .= "\t\$result = PyList_New(\$2);\n\n";
+ $result .= "\tfor (i = 0; i < \$2; i++) {\n";
+ $result .= "\t\tPyList_SetItem(\$result, i, $u->{NAME}_ptr_to_python(mem_ctx, &(*\$3)[i], \$1));\n";
+ $result .= "\t}\n\n";
+ $result .= "\ttalloc_free(mem_ctx);\n";
+ $result .= "}\n\n";
+
+ $result .= "NTSTATUS unmarshall_$u->{NAME}_array(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, uint32 level, uint32 count, union $u->{NAME} **EMPTY);\n\n";
+ }
+
return $result;
}
diff --git a/source4/scripting/swig/torture/spoolss.py b/source4/scripting/swig/torture/spoolss.py
index d7a16917f9..8336a027df 100644
--- a/source4/scripting/swig/torture/spoolss.py
+++ b/source4/scripting/swig/torture/spoolss.py
@@ -17,7 +17,7 @@ def test_EnumPrinters(pipe):
result = dcerpc.spoolss_EnumPrinters(pipe, r)
- print dcerpc.unmarshall_spoolss_PrinterInfo1(result['buffer'])
+ print dcerpc.unmarshall_spoolss_PrinterInfo_array(result['buffer'], r['level'], result['count'])
def runtests(binding, domain, username, password):