forked from nemequ/vala-extra-vapis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
libzmq.vapi
194 lines (174 loc) · 4.93 KB
/
libzmq.vapi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/* libzmq.vala
*
* Copyright (C) 2011 Lewis Gunsch <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author:
* Lewis Gunsch <[email protected]>
*/
[CCode (lower_case_cprefix = "zmq_", cheader_filename = "zmq.h")]
namespace ZMQ {
[Compact]
[CCode (cprefix = "zmq_", cname = "void", free_function = "zmq_term")]
public class Context {
[CCode (cname = "zmq_init")]
public Context (int io_threads);
}
[CCode (cprefix = "ZMQ_")]
namespace VERSION {
public const int MAJOR;
public const int MINOR;
public const int PATCH;
[CCode (cname = "ZMQ_VERSION")]
public const int VERSION;
}
public static void version (out int major, out int minor, out int patch);
/* ZMQ error numbers, in addition to POSIX error numbers. */
[CCode (cname = "EFSM")]
public const int EFSM;
[CCode (cname = "ENOCOMPATPROTO")]
public const int ENOCOMPATPROTO;
[CCode (cname = "ETERM")]
public const int ETERM;
[CCode (cname = "EMTHREAD")]
public const int EMTHREAD;
public int errno ();
public unowned string strerror (int errnum);
[CCode (cname = "ZMQ_MAX_VSM_SIZE")]
public const int MAX_VSM_SIZE;
[CCode (cname = "ZMQ_DELIMITER")]
public const int DELIMITER;
[CCode (cname = "ZMQ_VSM")]
public const int VSM;
[CCode (cname = "zmq_free_fn", type = "void (*)(void *, void *)")]
public delegate void free_fn (void *data);
[CCode (cprefix = "zmq_msg_", cname = "zmq_msg_t", destroy_function = "zmq_msg_close", copy_function = "NO_IMPLICIT_COPY")]
public struct Msg {
public const uchar MORE;
public const uchar SHARED;
[CCode (cname = "zmq_msg_init")]
public Msg ();
[CCode (cname = "zmq_msg_init_size")]
public Msg.with_size (size_t size);
[CCode (cname = "zmq_msg_init_data")]
public Msg.with_data (owned uint8[] data, free_fn? ffn = null);
[CCode (cname = "zmq_msg_copy", instance_pos = -1)]
private int _copy (ref Msg dest);
[CCode (cname = "zmq_msg_copy_wrapper")]
public Msg copy () {
Msg msg = Msg ();
this._copy (ref msg);
return msg;
}
public Msg clone () {
unowned uint8[] data = (uint8[]) GLib.Memory.dup((void*) this._data (), (uint) this.size ());
data.length = (int) this.size ();
Msg copy = Msg.with_data (data);
return copy;
}
[CCode (cname = "zmq_msg_data")]
private uint8 *_data ();
public size_t size ();
public uint8[] data {
get {
unowned uint8[] data = (uint8[]) this._data ();
data.length = (int) this.size ();
return data;
}
}
[CCode (instance_pos = -1)]
public int move (ref Msg dest);
}
[CCode (cname = "int", cprefix = "ZMQ_")]
public enum SocketType {
PAIR,
PUB,
SUB,
REQ,
REP,
DEALER,
ROUTER,
PULL,
PUSH,
XPUB,
XSUB
}
[CCode (cname = "int", cprefix = "ZMQ_")]
public enum SocketOption {
HWM,
SWAP,
AFFINITY,
IDENTITY,
SUBSCRIBE,
UNSUBSCRIBE,
RATE,
RECOVERY_IVL,
MCAST_LOOP,
SNDBUF,
RCVBUF,
RCVMORE,
FD,
EVENTS,
TYPE,
LINGER,
RECONNECT_IVL,
BACKLOG,
RECOVERY_IVL_MSEC,
RECONNECT_IVL_MAX
}
[CCode (cname = "int", cprefix = "ZMQ_")]
public enum SendRecvOption {
NOBLOCK,
SNDMORE
}
[Compact]
[CCode (cprefix = "zmq_", cname = "void", free_function = "zmq_close")]
public class Socket {
[CCode (cname = "zmq_socket")]
public static Socket? create(Context context, SocketType type);
[CCode (simple_generics = true)]
public int setsockopt < T > (SocketOption option, T optval, size_t optvallen);
[CCode (simple_generics = true)]
public int getsockopt < T > (SocketOption option, T optval, size_t optvallen);
public int bind (string addr);
public int connect (string addr);
public int send (ref Msg msg, SendRecvOption flags = 0);
public int recv (ref Msg msg, SendRecvOption flags = 0);
}
namespace POLL {
[CCode (cname = "ZMQ_POLLIN")]
public const short IN;
[CCode (cname = "ZMQ_POLLOUT")]
public const short OUT;
[CCode (cname = "ZMQ_POLLERR")]
public const short ERR;
[CCode (cname = "zmq_pollitem_t")]
public struct PollItem {
Socket *socket;
int fd;
short events;
short revents;
}
[CCode (cname = "zmq_poll")]
public int poll (PollItem[] items, long timeout);
}
[CCode (cname = "int", cprefix = "ZMQ_")]
public enum Device {
STREAMER,
FORWARDER,
QUEUE;
[CCode (cname = "zmq_device")]
public int device (Socket insocket, Socket outsocket);
}
}