svn commit: samba r5224 - in branches/SAMBA_4_0/source/scripting/swig: .

tpot at samba.org tpot at samba.org
Fri Feb 4 06:35:45 GMT 2005


Author: tpot
Date: 2005-02-04 06:35:45 +0000 (Fri, 04 Feb 2005)
New Revision: 5224

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5224

Log:
Add in/out typemaps for resume handles.  This saves us having to much
around with pointers to just one uint32.

Add an output typemap to copy a policy handle as the talloc context is 
destroyed before the wrapper function returns.  More work here needed 
to avoid memory leaks.

Use the swig carrays.i file to create accessor and setter functions
for fixed width integer types.  Also add functions for struct samr_SamEntry
as it's returned by the LookupDomain RPC.  This really needs to be
done by pidl so I don't have to go through and find all the structures
that are returned in arrays.

Include security.i to give us SIDs and security descriptors.

Modified:
   branches/SAMBA_4_0/source/scripting/swig/dcerpc.i


Changeset:
Modified: branches/SAMBA_4_0/source/scripting/swig/dcerpc.i
===================================================================
--- branches/SAMBA_4_0/source/scripting/swig/dcerpc.i	2005-02-04 06:28:50 UTC (rev 5223)
+++ branches/SAMBA_4_0/source/scripting/swig/dcerpc.i	2005-02-04 06:35:45 UTC (rev 5224)
@@ -169,10 +169,49 @@
 
 const char *dcerpc_server_name(struct dcerpc_pipe *p);
 
+/* Some typemaps for easier access to resume handles.  Really this can
+   also be done using the uint32 carray functions, but it's a bit of a
+   hassle.  TODO: Fix memory leak here. */
+
+%typemap(in) uint32_t *resume_handle {
+	$1 = malloc(sizeof(*$1));
+	*$1 = PyLong_AsLong($input);
+}
+
+%typemap(out) uint32_t *resume_handle {
+	$result = PyLong_FromLong(*$1);
+}
+
+/* When returning a policy handle to Python we need to make a copy of
+   as the talloc context it is created under is destroyed after the
+   wrapper function returns.  TODO: Fix memory leak created here. */
+
+%typemap(out) struct policy_handle * {
+	struct policy_handle *temp = (struct policy_handle *)malloc(sizeof(struct policy_handle));
+	memcpy(temp, $1, sizeof(struct policy_handle));
+	$result = SWIG_NewPointerObj(temp, SWIGTYPE_p_policy_handle, 0);
+}
+
 %{
 #include "librpc/gen_ndr/ndr_misc.h"
+#include "librpc/gen_ndr/ndr_security.h"
 #include "librpc/gen_ndr/ndr_samr.h"
 %}
 
+%include "carrays.i"
+
+/* Some functions for accessing arrays of fixed-width integers. */
+
+%array_functions(uint8_t, uint8_array);
+%array_functions(uint16_t, uint16_array);
+%array_functions(uint32_t, uint32_array);
+
+/* Functions for handling arrays of structures.  It would be nice for 
+   pidl to automatically generating these instead of having to find
+   them all by hand. */
+
+%array_functions(struct samr_SamEntry, samr_SamEntry_array);
+
 %include "librpc/gen_ndr/misc.i"
+%include "librpc/gen_ndr/security.i"
 %include "librpc/gen_ndr/samr.i"



More information about the samba-cvs mailing list