forked from nemequ/vala-extra-vapis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
librabbitmq.vapi
333 lines (296 loc) · 11.2 KB
/
librabbitmq.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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
/* librabbitmq Vala Bindings
* Copyright 2012 Evan Nemerson <evan@coeus-group.com>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
[CCode (cprefix = "amqp_", lower_case_cprefix = "amqp_", cheader_filename = "stdint.h,amqp.h")]
namespace AMQP {
[SimpleType, CCode (cname = "amqp_method_number_t")]
public struct MethodNumber : uint32 { }
[SimpleType, CCode (cname = "amqp_flags_t")]
public struct Flags : uint32 { }
[SimpleType, CCode (cname = "amqp_channel_t")]
public struct Channel : uint32 { }
[SimpleType, CCode (cname = "amqp_bytes_t", copy_function = "amqp_bytes_malloc_dup", destroy_function = "amqp_bytes_free")]
public struct Bytes {
[CCode (cname = "amqp_bytes_malloc")]
public Bytes (size_t amount);
//[CCode (cname = "amqp_cstring_bytes")]
//public Bytes.from_string (string cstr);
public static AMQP.Bytes from_string (string cstr) {
AMQP.Bytes bytes = AMQP.Bytes (cstr.length);
GLib.Memory.copy (bytes.bytes, cstr, bytes.bytes.length);
return bytes;
}
[CCode (array_length_cname = "len", array_length_type = "size_t")]
public uint8[] bytes;
[CCode (cname = "amqp_empty_bytes")]
public static const AMQP.Bytes EMPTY;
}
[SimpleType, CCode (cname = "amqp_decimal_t")]
public struct Decimal {
public uint8 decimals;
public uint32 value;
}
[CCode (cname = "amqp_table_t")]
public struct Table {
[CCode (array_length_cname = "num_entries")]
public AMQP.TableEntry[] entries;
[CCode (instance_pos = 2.9, cname = "amqp_decode_table")]
public Table.decode (AMQP.Bytes encoded, AMQP.Pool pool, ref size_t offset);
[CCode (cname = "amqp_encode_table", instance_pos = 1.9)]
public int encode (AMQP.Bytes encoded, ref size_t offset);
[CCode (cname = "amqp_empty_table")]
public static const AMQP.Table EMPTY;
}
[CCode (cname = "amqp_array_t")]
public struct Array {
[CCode (array_length_cname = "num_entries")]
public AMQP.FieldValue[] entries;
[CCode (cname = "amqp_empty_array")]
public static const AMQP.Array EMPTY;
}
[CCode (cname = "amqp_field_value_t")]
public class FieldValue {
public uint8 kind;
[CCode (cname = "value.boolean")]
public bool value_boolean;
[CCode (cname = "value.i8")]
public int8 value_i8;
[CCode (cname = "value.u8")]
public uint8 value_u8;
[CCode (cname = "value.i16")]
public int16 value_i16;
[CCode (cname = "value.u16")]
public uint16 value_u16;
[CCode (cname = "value.i32")]
public int32 value_i32;
[CCode (cname = "value.u32")]
public uint32 value_u32;
[CCode (cname = "value.i64")]
public int64 value_i64;
[CCode (cname = "value.u64")]
public uint64 value_u64;
[CCode (cname = "value.f32")]
public float value_f32;
[CCode (cname = "value.f64")]
public double value_f64;
[CCode (cname = "value.decimal")]
public AMQP.Decimal value_decimal;
[CCode (cname = "value.bytes")]
public AMQP.Bytes value_bytes;
[CCode (cname = "value.table")]
public AMQP.Table value_table;
[CCode (cname = "value.array")]
public AMQP.Array value_array;
}
[CCode (cname = "amqp_table_entry_t")]
public struct TableEntry {
public AMQP.Bytes key;
public AMQP.FieldValue value;
public static int compare ([CCode (type = "void const *")] AMQP.TableEntry entry1, [CCode (type = "void const *")] AMQP.TableEntry entry2);
}
[CCode (cname = "amqp_field_value_kind_t", cprefix = "AMQP_FIELD_KIND_")]
public enum ValueKind {
BOOLEAN,
I8,
U8,
I16,
U16,
I32,
U32,
I64,
U64,
F32,
F64,
DECIMAL,
UTF8,
ARRAY,
TIMESTAMP,
TABLE,
VOID,
BYTES
}
[CCode (cname = "amqp_pool_blocklist_t")]
public struct PoolBlocklist {
[CCode (array_length_cname = "num_blocks")]
public void*[] blocklist;
}
[CCode (cname = "amqp_pool_t")]
public struct Pool {
public size_t pagesize;
public AMQP.PoolBlocklist pages;
public AMQP.PoolBlocklist large_blocks;
public int next_page;
public char* alloc_block;
public size_t alloc_used;
[CCode (cname = "init_amqp_pool")]
public Pool ();
[CCode (cname = "recycle_amqp_pool")]
public void recycle ();
[CCode (cname = "empty_amqp_pool")]
public void empty ();
public void* alloc (size_t amount);
public void alloc_bytes (size_t amount, out AMQP.Bytes output);
}
[CCode (cname = "amqp_method_t")]
public struct Method {
public AMQP.MethodNumber id;
public void* decoded;
}
[CCode (cname = "amqp_frame_t")]
public struct Frame {
public uint8 frame_type;
public AMQP.Channel channel;
[CCode (cname = "payload.method")]
public AMQP.Method payload_method;
[CCode (cname = "payload.properties.class_id")]
public uint16 payload_properties_class_id;
[CCode (cname = "payload.properties.body_size")]
public uint64 payload_properties_body_size;
[CCode (cname = "payload.properties.decoded")]
public void* payload_properties_decoded;
[CCode (cname = "payload.properties.raw")]
public AMQP.Bytes payload_properties_raw;
[CCode (cname = "payload.body_fragment")]
public AMQP.Bytes payload_body_fragment;
[CCode (cname = "payload.protocol_header.high")]
public uint8 payload_protocol_header_high;
[CCode (cname = "payload.protocol_header.low")]
public uint8 payload_protocol_header_low;
[CCode (cname = "payload.protocol_header.protocol_version_major")]
public uint8 payload_protocol_header_protocol_version_major;
[CCode (cname = "payload.protocol_header.protocol_version_minor")]
public uint8 payload_protocol_header_protocol_version_minor;
}
[CCode (cname = "amqp_response_type_enum", cprefix = "AMQP_RESPONSE_")]
public enum ResponseType {
NONE,
NORMAL,
LIBRARY_EXCEPTION,
SERVER_EXCEPTION
}
[SimpleType, CCode (cname = "amqp_rpc_reply_t")]
public struct RPCReply {
public AMQP.ResponseType reply_type;
public AMQP.Method reply;
public int library_error;
}
[CCode (cname = "amqp_sasl_method_enum")]
public enum SASLMethod {
PLAIN
}
[CCode (lower_case_cprefix = "amqp_", cheader_filename = "amqp_framing.h")]
namespace Response {
[Compact, CCode (cname = "void", free_function = "")]
public class Method { }
[Compact, CCode (cname = "amqp_channel_open_ok_t")]
public class ChannelOpen : Method {
public AMQP.Bytes channel_id;
}
}
[Compact, CCode (cname = "struct amqp_connection_state_t_", lower_case_cprefix = "amqp_", free_function = "amqp_destroy_connection")]
public class Connection {
[CCode (cname = "amqp_new_connection")]
public Connection ();
public int get_sockfd ();
public void set_sockfd (int sockfd);
[CCode (cname = "amqp_tune_connection")]
public int tune (int channel_max, int frame_max, int heartbeat);
public int get_channel_max ();
public int handle_input (AMQP.Bytes received_data, AMQP.Frame decoded_frame);
public bool buffers_ok;
public void release_buffers ();
public void maybe_release_buffers ();
public int send_frame (AMQP.Frame frame);
public int send_header ();
public bool frames_enqeued ();
public int simple_wait_frame (AMQP.Frame decoded_frame);
public int simple_wait_method (AMQP.Channel expected_channel, AMQP.Method expected_method, out AMQP.Method output);
public int send_method (AMQP.Channel channel, AMQP.MethodNumber id, void* decoded);
public AMQP.RPCReply simple_rpc (AMQP.Channel channel, AMQP.MethodNumber request_id, out AMQP.MethodNumber expected_reply_ids, void* decoded_request_method);
public void* simple_rpc_decoded (AMQP.Channel channel, AMQP.MethodNumber request_id, AMQP.MethodNumber reply_id, void* decoded_request_method);
public AMQP.RPCReply get_rpc_reply ();
public AMQP.RPCReply login (string vhost, int channel_max, int frame_max, int heartbeat, AMQP.SASLMethod sasl_method, ...);
public int basic_publish (AMQP.Channel channel, AMQP.Bytes exchange, AMQP.Bytes routing_key, bool mandatory, bool immediate, AMQP.BasicProperties? properties, AMQP.Bytes body);
public AMQP.RPCReply channel_close (AMQP.Channel channel, int code);
public AMQP.RPCReply close (int code);
public AMQP.RPCReply basic_get (AMQP.Channel channel, AMQP.Bytes queue, bool no_ack);
public int basic_reject (AMQP.Channel channel, uint64 delivery_tag, bool requeue);
public bool data_in_buffer ();
public unowned Response.ChannelOpen channel_open (AMQP.Channel channel);
}
[Flags, CCode (cname = "amqp_flags_t")]
public enum BasicType {
[CCode (cname = "AMQP_BASIC_CLASS")]
CLASS,
[CCode (cname = "AMQP_BASIC_CONTENT_TYPE_FLAG")]
CONTENT_TYPE,
[CCode (cname = "AMQP_BASIC_CONTENT_ENCODING_FLAG")]
CONTENT_ENCODING,
[CCode (cname = "AMQP_BASIC_HEADERS_FLAG")]
HEADERS,
[CCode (cname = "AMQP_BASIC_DELIVERY_MODE_FLAG")]
DELIVERY_MODE,
[CCode (cname = "AMQP_BASIC_PRIORITY_FLAG")]
PRIORITY,
[CCode (cname = "AMQP_BASIC_CORRELATION_ID_FLAG")]
CORRELATION_ID,
[CCode (cname = "AMQP_BASIC_REPLY_TO_FLAG")]
REPLY_TO,
[CCode (cname = "AMQP_BASIC_EXPIRATION_FLAG")]
EXPIRATION,
[CCode (cname = "AMQP_BASIC_MESSAGE_ID_FLAG")]
MESSAGE_ID,
[CCode (cname = "AMQP_BASIC_TIMESTAMP_FLAG")]
TIMESTAMP,
[CCode (cname = "AMQP_BASIC_TYPE_FLAG")]
TYPE,
[CCode (cname = "AMQP_BASIC_USER_ID_FLAG")]
USER_ID,
[CCode (cname = "AMQP_BASIC_APP_ID_FLAG")]
APP_ID,
[CCode (cname = "AMQP_BASIC_CLUSTER_ID_FLAG")]
CLUSTER_ID
}
[CCode (cname = "amqp_basic_properties_t", cheader_filename = "amqp_framing.h", destroy_function = "")]
public struct BasicProperties {
[CCode (cname = "_flags")]
public AMQP.BasicType flags;
public AMQP.Bytes content_type;
public AMQP.Bytes content_encoding;
public AMQP.Table headers;
public uint8 delivery_mode;
public uint8 priority;
public AMQP.Bytes correlation_id;
public AMQP.Bytes reply_to;
public AMQP.Bytes expiration;
public AMQP.Bytes message_id;
public uint64 timestamp;
public AMQP.Bytes type;
public AMQP.Bytes user_id;
public AMQP.Bytes app_id;
public AMQP.Bytes cluster_id;
}
public static int version ();
public string error_string (int err);
public int open_socket(string hostname, int portnumber);
}