2 Unix SMB/CIFS implementation.
4 Swig interface to librpc functions.
6 Copyright (C) Tim Potter 2004
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 /* This symbol is used in both includes.h and Python.h which causes an
28 annoying compiler warning. */
38 PyObject *ntstatus_exception;
40 /* Set up return of a dcerpc.NTSTATUS exception */
42 void set_ntstatus_exception(int status)
44 PyObject *obj = Py_BuildValue("(i,s)", status,
45 nt_errstr(NT_STATUS(status)));
47 PyErr_SetObject(ntstatus_exception, obj);
50 uint8 uint8_from_python(PyObject *obj)
52 return (uint8)PyInt_AsLong(obj);
55 PyObject *uint8_to_python(uint8 obj)
57 return PyInt_FromLong(obj);
60 uint16 uint16_from_python(PyObject *obj)
62 return (uint16)PyInt_AsLong(obj);
65 PyObject *uint16_to_python(uint16 obj)
67 return PyInt_FromLong(obj);
70 uint32 uint32_from_python(PyObject *obj)
72 return (uint32)PyInt_AsLong(obj);
75 PyObject *uint32_to_python(uint32 obj)
77 return PyInt_FromLong(obj);
80 int64 int64_from_python(PyObject *obj)
82 return (int64)PyLong_AsLong(obj);
85 PyObject *int64_to_python(int64 obj)
87 return PyLong_FromLong(obj);
90 uint64 uint64_from_python(PyObject *obj)
92 return (uint64)PyLong_AsLong(obj);
95 PyObject *uint64_to_python(uint64 obj)
97 return PyLong_FromLong(obj);
100 NTTIME NTTIME_from_python(PyObject *obj)
102 return (NTTIME)PyLong_AsLong(obj);
105 PyObject *NTTIME_to_python(NTTIME obj)
107 return PyLong_FromLong(obj);
110 HYPER_T HYPER_T_from_python(PyObject *obj)
112 return (HYPER_T)PyLong_AsLong(obj);
115 PyObject *HYPER_T_to_python(HYPER_T obj)
117 return PyLong_FromLong(obj);
120 struct policy_handle *policy_handle_from_python(PyObject *obj)
122 return (struct policy_handle *)PyString_AsString(obj);
125 PyObject *policy_handle_to_python(struct policy_handle *handle)
127 return PyString_FromStringAndSize((char *)handle, sizeof(*handle));
130 struct security_descriptor *security_descriptor_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj)
135 PyObject *security_descriptor_to_python(struct security_descriptor *obj)
140 struct dom_sid2 *dom_sid2_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj)
145 PyObject *dom_sid2_to_python(struct dom_sid2 *obj)
150 char *string_from_python(PyObject *obj)
155 return PyString_AsString(obj);
158 PyObject *string_to_python(char *obj)
163 return PyString_FromString(obj);
166 struct samr_Password *samr_Password_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj)
171 PyObject *samr_Password_to_python(struct samr_Password *obj)
181 /* setup_logging("python", DEBUG_STDOUT); */
182 lp_load(dyn_CONFIGFILE, True, False, False);
184 ntstatus_exception = PyErr_NewException("dcerpc.NTSTATUS", NULL, NULL);
187 %typemap(in, numinputs=0) struct dcerpc_pipe **OUT (struct dcerpc_pipe *temp_dcerpc_pipe) {
188 $1 = &temp_dcerpc_pipe;
191 %typemap(in, numinputs=0) TALLOC_CTX * {
192 $1 = talloc_init("$symname");
195 %typemap(freearg) TALLOC_CTX * {
199 %typemap(argout) struct dcerpc_pipe ** {
200 long status = PyLong_AsLong(resultobj);
202 /* Throw exception if result was not OK */
205 set_ntstatus_exception(status);
209 /* Set REF_ALLOC flag so we don't have to do too much extra
210 mucking around with ref variables in ndr unmarshalling. */
212 (*$1)->flags |= DCERPC_NDR_REF_ALLOC;
214 /* Return swig handle on dcerpc_pipe */
216 resultobj = SWIG_NewPointerObj(*$1, SWIGTYPE_p_dcerpc_pipe, 0);
219 %types(struct dcerpc_pipe *);
221 %rename(pipe_connect) dcerpc_pipe_connect;
223 NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT,
225 const char *pipe_uuid,
228 const char *username,
229 const char *password);
231 %include "librpc/gen_ndr/lsa.i"
232 %include "librpc/gen_ndr/samr.i"