2 Unix SMB/CIFS implementation.
4 Common swig definitions
6 Copyright (C) 2004 Tim Potter <tpot@samba.org>
8 ** NOTE! The following LGPL license applies to the swig
9 ** definitions. This does NOT imply that all of Samba is released
12 This library is free software; you can redistribute it and/or
13 modify it under the terms of the GNU Lesser General Public
14 License as published by the Free Software Foundation; either
15 version 3 of the License, or (at your option) any later version.
17 This library is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Lesser General Public License for more details.
22 You should have received a copy of the GNU Lesser General Public
23 License along with this library; if not, see <http://www.gnu.org/licenses/>.
26 %apply int { uint8_t };
27 %apply int { int8_t };
28 %apply unsigned int { uint16_t };
29 %apply int { int16_t };
30 %apply unsigned long long { uint64_t };
31 %apply long long { int64_t };
33 %typemap(in) uint32_t {
34 if (PyLong_Check($input))
35 $1 = PyLong_AsUnsignedLong($input);
36 else if (PyInt_Check($input))
37 $1 = PyInt_AsLong($input);
39 PyErr_SetString(PyExc_TypeError,"Expected a long or an int");
44 %typemap(out) uint32_t {
45 $result = PyLong_FromUnsignedLong($1);
48 %typemap(in) NTSTATUS {
49 if (PyLong_Check($input))
50 $1 = NT_STATUS(PyLong_AsUnsignedLong($input));
51 else if (PyInt_Check($input))
52 $1 = NT_STATUS(PyInt_AsLong($input));
54 PyErr_SetString(PyExc_TypeError, "Expected a long or an int");
59 %typemap(out) NTSTATUS {
60 $result = PyLong_FromUnsignedLong(NT_STATUS_V($1));
63 %typemap(in) struct cli_credentials * {
64 $1 = cli_credentials_init(arg1);
65 cli_credentials_set_conf($1);
66 if ($input == Py_None) {
67 cli_credentials_set_anonymous($1);
69 if (!PyTuple_Check($input) ||
70 PyTuple_Size($input) != 3) {
71 PyErr_SetString(PyExc_TypeError, "Expecting three element tuple");
74 if (!PyString_Check(PyTuple_GetItem($input, 0)) ||
75 !PyString_Check(PyTuple_GetItem($input, 1)) ||
76 !PyString_Check(PyTuple_GetItem($input, 2))) {
77 PyErr_SetString(PyExc_TypeError, "Expecting string elements");
80 cli_credentials_set_domain($1, PyString_AsString(PyTuple_GetItem($input, 0)), CRED_SPECIFIED);
81 cli_credentials_set_username($1, PyString_AsString(PyTuple_GetItem($input, 1)), CRED_SPECIFIED);
82 cli_credentials_set_password($1, PyString_AsString(PyTuple_GetItem($input, 2)), CRED_SPECIFIED);