56d6d4206e2634bac94cc3f49b3f8e6dccba4e4c
[metze/samba/wip.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 %import "stdint.i"
43 %import "../../lib/talloc/talloc.i"
44
45 %typemap(in) NTSTATUS {
46         if (PyLong_Check($input))
47                 $1 = NT_STATUS(PyLong_AsUnsignedLong($input));
48         else if (PyInt_Check($input))
49                 $1 = NT_STATUS(PyInt_AsLong($input));
50         else {
51                 PyErr_SetString(PyExc_TypeError, "Expected a long or an int");
52                 return NULL;
53         }
54 }
55
56 %typemap(out) NTSTATUS {
57         $result = PyLong_FromUnsignedLong(NT_STATUS_V($1));
58 }
59
60 /* Function prototypes */
61
62 struct event_context *event_context_init(TALLOC_CTX *mem_ctx);
63
64 struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx, 
65                                              struct event_context *event_ctx);
66
67 enum nbt_name_type {
68         NBT_NAME_CLIENT=0x00,
69         NBT_NAME_MS=0x01,
70         NBT_NAME_USER=0x03,
71         NBT_NAME_SERVER=0x20,
72         NBT_NAME_PDC=0x1B,
73         NBT_NAME_LOGON=0x1C,
74         NBT_NAME_MASTER=0x1D,
75         NBT_NAME_BROWSER=0x1E
76 };
77
78 struct nbt_name {
79         const char *name;
80         const char *scope;
81         enum nbt_name_type type;
82 };
83
84 %rename(data_in) in;
85 %rename(data_out) out;
86
87 struct nbt_name_query {
88         struct {
89                 struct nbt_name name;
90                 const char *dest_addr;
91                 bool broadcast;
92                 bool wins_lookup;
93                 int timeout; /* in seconds */
94                 int retries;
95         } in;
96         struct {
97                 const char *reply_from;
98                 struct nbt_name name;
99                 int16_t num_addrs;
100                 const char **reply_addrs;
101         } out;
102 };
103
104 %include "carrays.i"
105 %array_functions(char *, char_ptr_array);
106
107 NTSTATUS do_nbt_name_query(struct nbt_name_socket *nbtsock, 
108                            TALLOC_CTX *mem_ctx, struct nbt_name_query *io);
109
110 %{
111 NTSTATUS do_nbt_name_query(struct nbt_name_socket *nbtsock, 
112                            TALLOC_CTX *mem_ctx, struct nbt_name_query *io)
113 {
114         return nbt_name_query(nbtsock, mem_ctx, io);
115 }
116 %}