r25578: BOOL -> bool
[samba.git] / source4 / libcli / swig / libcli_nbt.i
1 /* 
2    Unix SMB/CIFS implementation.
3
4    Swig interface to libcli_nbt library.
5
6    Copyright (C) 2006 Tim Potter <tpot@samba.org>
7
8      ** NOTE! The following LGPL license applies to the tdb
9      ** library. This does NOT imply that all of Samba is released
10      ** under the LGPL
11    
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.
16
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.
21
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/>.
24 */
25
26 %module libcli_nbt
27
28 %{
29
30 #include "includes.h"
31 #include "lib/talloc/talloc.h"
32 #include "lib/events/events.h"
33 #include "libcli/nbt/libnbt.h"
34 #include "param/param.h"
35
36 /* Undo strcpy safety macro as it's used by swig )-: */
37
38 #undef strcpy
39
40 %}
41
42 %apply bool { bool };
43 %apply int { uint8_t };
44 %apply int { int8_t };
45 %apply unsigned int { uint16_t };
46 %apply int { int16_t };
47
48 %typemap(in) uint32_t {
49         if (PyLong_Check($input))
50                 $1 = PyLong_AsUnsignedLong($input);
51         else if (PyInt_Check($input))
52                 $1 = PyInt_AsLong($input);
53         else {
54                 PyErr_SetString(PyExc_TypeError,"Expected a long or an int");
55                 return NULL;
56         }
57 }
58
59 %typemap(out) uint32_t {
60         $result = PyLong_FromUnsignedLong($1);
61 }
62
63 %apply unsigned long long { uint64_t };
64 %apply long long { int64_t };
65
66 %typemap(in) NTSTATUS {
67         if (PyLong_Check($input))
68                 $1 = NT_STATUS(PyLong_AsUnsignedLong($input));
69         else if (PyInt_Check($input))
70                 $1 = NT_STATUS(PyInt_AsLong($input));
71         else {
72                 PyErr_SetString(PyExc_TypeError, "Expected a long or an int");
73                 return NULL;
74         }
75 }
76
77 %typemap(out) NTSTATUS {
78         $result = PyLong_FromUnsignedLong(NT_STATUS_V($1));
79 }
80
81 TALLOC_CTX *talloc_init(char *name);
82 int talloc_free(TALLOC_CTX *ptr);
83
84 /* Function prototypes */
85
86 struct event_context *event_context_init(TALLOC_CTX *mem_ctx);
87
88 struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx, 
89                                              struct event_context *event_ctx);
90
91 enum nbt_name_type {
92         NBT_NAME_CLIENT=0x00,
93         NBT_NAME_MS=0x01,
94         NBT_NAME_USER=0x03,
95         NBT_NAME_SERVER=0x20,
96         NBT_NAME_PDC=0x1B,
97         NBT_NAME_LOGON=0x1C,
98         NBT_NAME_MASTER=0x1D,
99         NBT_NAME_BROWSER=0x1E
100 };
101
102 struct nbt_name {
103         const char *name;
104         const char *scope;
105         enum nbt_name_type type;
106 };
107
108 %rename(data_in) in;
109 %rename(data_out) out;
110
111 struct nbt_name_query {
112         struct {
113                 struct nbt_name name;
114                 const char *dest_addr;
115                 bool broadcast;
116                 bool wins_lookup;
117                 int timeout; /* in seconds */
118                 int retries;
119         } in;
120         struct {
121                 const char *reply_from;
122                 struct nbt_name name;
123                 int16_t num_addrs;
124                 const char **reply_addrs;
125         } out;
126 };
127
128 %include "carrays.i"
129 %array_functions(char *, char_ptr_array);
130
131 NTSTATUS do_nbt_name_query(struct nbt_name_socket *nbtsock, 
132                            TALLOC_CTX *mem_ctx, struct nbt_name_query *io);
133
134 %{
135 NTSTATUS do_nbt_name_query(struct nbt_name_socket *nbtsock, 
136                            TALLOC_CTX *mem_ctx, struct nbt_name_query *io)
137 {
138         return nbt_name_query(nbtsock, mem_ctx, io);
139 }
140 %}
141
142 %init %{
143       lp_load();
144 %}