r26570: - Trim size of the swig-generated Python bindings by removing a bunch of...
[Samba.git] / source4 / librpc / rpc / dcerpc.i
blob3b860c4fa46aefcc26d8a9e5de4af3d818449777
1 /* Tastes like -*- C -*- */
3 /*
4 Unix SMB/CIFS implementation.
6 Swig interface to librpc functions.
8 Copyright (C) Tim Potter 2004
9 Copyright (C) Jelmer Vernooij 2007
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 %module dcerpc
29 /* This symbol is used in both includes.h and Python.h which causes an
30 annoying compiler warning. */
32 #ifdef HAVE_FSTAT
33 #undef HAVE_FSTAT
34 #endif
36 #include "includes.h"
37 #include "dynconfig.h"
38 #include "librpc/rpc/dcerpc.h"
40 #undef strcpy
44 %include "../../lib/talloc/talloc.i"
45 %include "../../auth/credentials/credentials.i"
47 %typemap(in,noblock=1, numinputs=0) struct dcerpc_pipe **OUT (struct dcerpc_pipe *temp_dcerpc_pipe) {
48 $1 = &temp_dcerpc_pipe;
51 %typemap(argout,noblock=1) struct dcerpc_pipe ** {
52 /* Set REF_ALLOC flag so we don't have to do too much extra
53 mucking around with ref variables in ndr unmarshalling. */
55 (*$1)->conn->flags |= DCERPC_NDR_REF_ALLOC;
57 /* Return swig handle on dcerpc_pipe */
59 $result = SWIG_NewPointerObj(*$1, SWIGTYPE_p_dcerpc_pipe, 0);
62 %types(struct dcerpc_pipe *);
64 %rename(pipe_connect) dcerpc_pipe_connect;
66 NTSTATUS dcerpc_pipe_connect(TALLOC_CTX *parent_ctx,
67 struct dcerpc_pipe **OUT,
68 const char *binding,
69 const char *pipe_uuid,
70 uint32_t pipe_version,
71 struct cli_credentials *credentials,
72 struct loadparm_context *lp_ctx);
74 %typemap(in,noblock=1) DATA_BLOB * (DATA_BLOB temp_data_blob) {
75 temp_data_blob.data = PyString_AsString($input);
76 temp_data_blob.length = PyString_Size($input);
77 $1 = &temp_data_blob;
80 const char *dcerpc_server_name(struct dcerpc_pipe *p);
82 /* Some typemaps for easier access to resume handles. Really this can
83 also be done using the uint32 carray functions, but it's a bit of a
84 hassle. TODO: Fix memory leak here. */
86 %typemap(in,noblock=1) uint32_t *resume_handle {
87 $1 = malloc(sizeof(*$1));
88 *$1 = PyLong_AsLong($input);
91 %typemap(out,noblock=1) uint32_t *resume_handle {
92 $result = PyLong_FromLong(*$1);
95 %typemap(in,noblock=1) struct policy_handle * {
97 if ((SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor,
98 SWIG_POINTER_EXCEPTION)) == -1)
99 return NULL;
101 if ($1 == NULL) {
102 PyErr_SetString(PyExc_TypeError, "None is not a valid policy handle");
103 return NULL;
107 /* When returning a policy handle to Python we need to make a copy of
108 as the talloc context it is created under is destroyed after the
109 wrapper function returns. TODO: Fix memory leak created here. */
111 %typemap(out,noblock=1) struct policy_handle * {
112 if ($1) {
113 struct policy_handle *temp = (struct policy_handle *)malloc(sizeof(struct policy_handle));
114 memcpy(temp, $1, sizeof(struct policy_handle));
115 $result = SWIG_NewPointerObj(temp, SWIGTYPE_p_policy_handle, 0);
116 } else {
117 Py_INCREF(Py_None);
118 $result = Py_None;