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_from_python(PyObject *obj)
135 char *string_from_python(PyObject *obj)
137 return PyString_AsString(obj);
140 PyObject *string_to_python(char *obj)
142 return PyString_FromString(obj);
150 /* setup_logging("python", DEBUG_STDOUT); */
151 lp_load(dyn_CONFIGFILE, True, False, False);
153 ntstatus_exception = PyErr_NewException("dcerpc.NTSTATUS", NULL, NULL);
156 %typemap(in, numinputs=0) struct dcerpc_pipe **OUT (struct dcerpc_pipe *temp_dcerpc_pipe) {
157 $1 = &temp_dcerpc_pipe;
160 %typemap(in, numinputs=0) TALLOC_CTX * {
161 $1 = talloc_init("$symname");
164 %typemap(freearg) TALLOC_CTX * {
168 %typemap(argout) struct dcerpc_pipe ** {
169 long status = PyLong_AsLong(resultobj);
171 /* Throw exception if result was not OK */
174 set_ntstatus_exception(status);
178 /* Set REF_ALLOC flag so we don't have to do too much extra
179 mucking around with ref variables in ndr unmarshalling. */
181 (*$1)->flags |= DCERPC_NDR_REF_ALLOC;
183 /* Return swig handle on dcerpc_pipe */
185 resultobj = SWIG_NewPointerObj(*$1, SWIGTYPE_p_dcerpc_pipe, 0);
188 %types(struct dcerpc_pipe *);
190 %rename(pipe_connect) dcerpc_pipe_connect;
192 NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT,
194 const char *pipe_uuid,
197 const char *username,
198 const char *password);
200 %include "librpc/gen_ndr/samr.i"
201 %include "librpc/gen_ndr/lsa.i"