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, write to the Free Software
24 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 %apply int { uint8_t };
28 %apply int { int8_t };
29 %apply unsigned int { uint16_t };
30 %apply int { int16_t };
31 %apply unsigned long long { uint64_t };
32 %apply long long { int64_t };
34 %typemap(in) uint32_t {
35 if (PyLong_Check($input))
36 $1 = PyLong_AsUnsignedLong($input);
37 else if (PyInt_Check($input))
38 $1 = PyInt_AsLong($input);
40 PyErr_SetString(PyExc_TypeError,"Expected a long or an int");
45 %typemap(out) uint32_t {
46 $result = PyLong_FromUnsignedLong($1);
49 %typemap(in) NTSTATUS {
50 if (PyLong_Check($input))
51 $1 = NT_STATUS(PyLong_AsUnsignedLong($input));
52 else if (PyInt_Check($input))
53 $1 = NT_STATUS(PyInt_AsLong($input));
55 PyErr_SetString(PyExc_TypeError, "Expected a long or an int");
60 %typemap(out) NTSTATUS {
61 $result = PyLong_FromUnsignedLong(NT_STATUS_V($1));
64 %typemap(in) struct cli_credentials * {
65 $1 = cli_credentials_init(arg1);
66 cli_credentials_set_conf($1);
67 if ($input == Py_None) {
68 cli_credentials_set_anonymous($1);
70 if (!PyTuple_Check($input) ||
71 PyTuple_Size($input) != 3) {
72 PyErr_SetString(PyExc_TypeError, "Expecting three element tuple");
75 if (!PyString_Check(PyTuple_GetItem($input, 0)) ||
76 !PyString_Check(PyTuple_GetItem($input, 1)) ||
77 !PyString_Check(PyTuple_GetItem($input, 2))) {
78 PyErr_SetString(PyExc_TypeError, "Expecting string elements");
81 cli_credentials_set_domain($1, PyString_AsString(PyTuple_GetItem($input, 0)), CRED_SPECIFIED);
82 cli_credentials_set_username($1, PyString_AsString(PyTuple_GetItem($input, 1)), CRED_SPECIFIED);
83 cli_credentials_set_password($1, PyString_AsString(PyTuple_GetItem($input, 2)), CRED_SPECIFIED);