svn commit: samba r3009 - in branches/SAMBA_4_0/source: build/pidl scripting/swig/torture

tpot at samba.org tpot at samba.org
Sun Oct 17 00:27:40 GMT 2004


Author: tpot
Date: 2004-10-17 00:27:40 +0000 (Sun, 17 Oct 2004)
New Revision: 3009

WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_4_0/source&rev=3009&nolog=1

Log:
Fix up unmarshall functions to return Python dict instead of a NTSTATUS.
We can now unmarshall a single printer returned from an EnumPrinters.

Modified:
   branches/SAMBA_4_0/source/build/pidl/swig.pm
   branches/SAMBA_4_0/source/scripting/swig/torture/spoolss.py


Changeset:
Modified: branches/SAMBA_4_0/source/build/pidl/swig.pm
===================================================================
--- branches/SAMBA_4_0/source/build/pidl/swig.pm	2004-10-17 00:22:11 UTC (rev 3008)
+++ branches/SAMBA_4_0/source/build/pidl/swig.pm	2004-10-17 00:27:40 UTC (rev 3009)
@@ -468,7 +468,10 @@
 	$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 .= "\treturn ndr_pull_struct_blob(blob, mem_ctx, s, ndr_pull_$s->{NAME});\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";
     }
 
@@ -482,7 +485,7 @@
 
 	$result .= "%typemap(argout) struct $s->{NAME} * {\n";
 	$result .= "\tTALLOC_CTX *mem_ctx = talloc_init(\"typemap(argout) $s->{NAME}\");\n\n";
-	$result .= "\tresultobj = $s->{NAME}_ptr_to_python(mem_ctx, \$1);\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";
@@ -574,7 +577,7 @@
 	$result .= "\t\treturn;\n";
 	$result .= "\t}\n\n";
     }
-    $result .= "}\n";
+    $result .= "}\n\n";
 
     # Generate function to convert union pointer to Python dict
 
@@ -604,22 +607,8 @@
 
     $result .= "}\n\n";
 
-    # Generate function to convert DATA_BLOB to Python dict
+    $result .= "%}\n\n";    
 
-    if (util::has_property($u->{DATA}, "public")) {
-	$result .= "/* Convert a Python string to a struct $u->{NAME} python dict */\n\n";
-	$result .= "NTSTATUS unmarshall_$u->{NAME}(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, union $u->{NAME} *u)\n";
-	$result .= "{\n";
-	$result .= "\treturn NT_STATUS_OK;\n";
-	$result .= "}\n\n";
-    }
-
-    $result .= "\n%}\n\n";    
-
-    if (util::has_property($u->{DATA}, "public")) {
-	$result .= "NTSTATUS unmarshall_$u->{NAME}(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, union $u->{NAME} *EMPTY);\n\n";
-    }
-
     return $result;
 }
 

Modified: branches/SAMBA_4_0/source/scripting/swig/torture/spoolss.py
===================================================================
--- branches/SAMBA_4_0/source/scripting/swig/torture/spoolss.py	2004-10-17 00:22:11 UTC (rev 3008)
+++ branches/SAMBA_4_0/source/scripting/swig/torture/spoolss.py	2004-10-17 00:27:40 UTC (rev 3009)
@@ -6,11 +6,17 @@
     r['flags'] = 0x02
     r['server'] = None
     r['level'] = 1
-    r['buffer'] = 392 * '\x00'
-    r['buf_size'] = 392
+    r['buffer'] = None
+    r['buf_size'] = 0
 
     result = dcerpc.spoolss_EnumPrinters(pipe, r)
 
+    if result['result'] == dcerpc.WERR_INSUFFICIENT_BUFFER:
+        r['buffer'] = result['buf_size'] * '\x00'
+        r['buf_size'] = result['buf_size']
+
+        result = dcerpc.spoolss_EnumPrinters(pipe, r)
+
     print dcerpc.unmarshall_spoolss_PrinterInfo1(result['buffer'])
 
 def runtests(binding, domain, username, password):



More information about the samba-cvs mailing list