summaryrefslogtreecommitdiff
path: root/source4/librpc/rpc
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-11-21 12:31:19 +0100
committerStefan Metzmacher <metze@samba.org>2007-12-21 05:45:53 +0100
commitf47bc82561707130be5d56c22300f11175401d66 (patch)
treefdeaa18953301c09e0811f104ba77cc6fa8fd98d /source4/librpc/rpc
parent328549a9ecc05ff2024094a0cdf76cac00a5ba00 (diff)
downloadsamba-f47bc82561707130be5d56c22300f11175401d66.tar.gz
samba-f47bc82561707130be5d56c22300f11175401d66.tar.bz2
samba-f47bc82561707130be5d56c22300f11175401d66.zip
r26071: Move DCE/RPC SWIG bindings closer to the code they're wrapping.
(This used to be commit 93eba0a3a984e9cd08ab2cf74b409938c991824a)
Diffstat (limited to 'source4/librpc/rpc')
-rw-r--r--source4/librpc/rpc/dcerpc.i120
1 files changed, 120 insertions, 0 deletions
diff --git a/source4/librpc/rpc/dcerpc.i b/source4/librpc/rpc/dcerpc.i
new file mode 100644
index 0000000000..6080a62777
--- /dev/null
+++ b/source4/librpc/rpc/dcerpc.i
@@ -0,0 +1,120 @@
+/* Tastes like -*- C -*- */
+
+/*
+ Unix SMB/CIFS implementation.
+
+ Swig interface to librpc functions.
+
+ Copyright (C) Tim Potter 2004
+ Copyright (C) Jelmer Vernooij 2007
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+%module dcerpc
+
+%{
+
+/* This symbol is used in both includes.h and Python.h which causes an
+ annoying compiler warning. */
+
+#ifdef HAVE_FSTAT
+#undef HAVE_FSTAT
+#endif
+
+#include "includes.h"
+#include "dynconfig.h"
+#include "librpc/rpc/dcerpc.h"
+
+#undef strcpy
+
+%}
+
+%include "samba.i"
+%include "../../lib/talloc/talloc.i"
+%include "../../auth/credentials/credentials.i"
+
+%typemap(in, numinputs=0) struct dcerpc_pipe **OUT (struct dcerpc_pipe *temp_dcerpc_pipe) {
+ $1 = &temp_dcerpc_pipe;
+}
+
+%typemap(argout) struct dcerpc_pipe ** {
+ /* Set REF_ALLOC flag so we don't have to do too much extra
+ mucking around with ref variables in ndr unmarshalling. */
+
+ (*$1)->conn->flags |= DCERPC_NDR_REF_ALLOC;
+
+ /* Return swig handle on dcerpc_pipe */
+
+ $result = SWIG_NewPointerObj(*$1, SWIGTYPE_p_dcerpc_pipe, 0);
+}
+
+%types(struct dcerpc_pipe *);
+
+%rename(pipe_connect) dcerpc_pipe_connect;
+
+NTSTATUS dcerpc_pipe_connect(TALLOC_CTX *parent_ctx,
+ struct dcerpc_pipe **OUT,
+ const char *binding,
+ const char *pipe_uuid,
+ uint32_t pipe_version,
+ struct cli_credentials *credentials);
+
+%typemap(in) DATA_BLOB * (DATA_BLOB temp_data_blob) {
+ temp_data_blob.data = PyString_AsString($input);
+ temp_data_blob.length = PyString_Size($input);
+ $1 = &temp_data_blob;
+}
+
+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);
+}
+
+%typemap(in) struct policy_handle * {
+
+ if ((SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor,
+ SWIG_POINTER_EXCEPTION)) == -1)
+ return NULL;
+
+ if ($1 == NULL) {
+ PyErr_SetString(PyExc_TypeError, "None is not a valid policy handle");
+ return NULL;
+ }
+}
+
+/* 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 * {
+ if ($1) {
+ 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);
+ } else {
+ Py_INCREF(Py_None);
+ $result = Py_None;
+ }
+}