2
* ***** BEGIN LICENSE BLOCK *****
5
* Portions created by VMware are Copyright (c) 2007-2012 VMware, Inc.
8
* Portions created by Tony Garnock-Jones are Copyright (c) 2009-2010
9
* VMware, Inc. and Tony Garnock-Jones. All Rights Reserved.
11
* Permission is hereby granted, free of charge, to any person
12
* obtaining a copy of this software and associated documentation
13
* files (the "Software"), to deal in the Software without
14
* restriction, including without limitation the rights to use, copy,
15
* modify, merge, publish, distribute, sublicense, and/or sell copies
16
* of the Software, and to permit persons to whom the Software is
17
* furnished to do so, subject to the following conditions:
19
* The above copyright notice and this permission notice shall be
20
* included in all copies or substantial portions of the Software.
22
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
26
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
28
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
* ***** END LICENSE BLOCK *****
37
#define AMQP_BEGIN_DECLS extern "C" {
38
#define AMQP_END_DECLS }
40
#define AMQP_BEGIN_DECLS
41
#define AMQP_END_DECLS
44
/** Important API Decorators
45
* AMQP_PUBLIC_FUNCTION - Declares an exportable function
46
* AMQP_PUBLIC_VARIABLE - Declares an exportable variable
47
* AMQP_CALL - Declares the calling convention
50
#if defined(_WIN32) && defined(_MSC_VER)
51
# if defined(AMQP_BUILD) && !defined(AMQP_STATIC)
52
# define AMQP_PUBLIC_FUNCTION __declspec(dllexport)
53
# define AMQP_PUBLIC_VARIABLE __declspec(dllexport) extern
55
# define AMQP_PUBLIC_FUNCTION
56
# if !defined(AMQP_STATIC)
57
# define AMQP_PUBLIC_VARIABLE __declspec(dllimport) extern
59
# define AMQP_PUBLIC_VARIABLE extern
62
# define AMQP_CALL __cdecl
64
#elif defined(_WIN32) && defined(__BORLANDC__)
65
# if defined(AMQP_BUILD) && !defined(AMQP_STATIC)
66
# define AMQP_PUBLIC_FUNCTION __declspec(dllexport)
67
# define AMQP_PUBLIC_VARIABLE __declspec(dllexport) extern
69
# define AMQP_PUBLIC_FUNCTION
70
# if !defined(AMQP_STATIC)
71
# define AMQP_PUBLIC_VARIABLE __declspec(dllimport) extern
73
# define AMQP_PUBLIC_VARIABLE extern
76
# define AMQP_CALL __cdecl
78
#elif defined(_WIN32) && defined(__MINGW32__)
79
# if defined(AMQP_BUILD) && !defined(AMQP_STATIC)
80
# define AMQP_PUBLIC_FUNCTION __declspec(dllexport)
81
# define AMQP_PUBLIC_VARIABLE __declspec(dllexport)
83
# define AMQP_PUBLIC_FUNCTION
84
# if !defined(AMQP_STATIC)
85
# define AMQP_PUBLIC_VARIABLE __declspec(dllimport) extern
87
# define AMQP_PUBLIC_VARIABLE extern
90
# define AMQP_CALL __cdecl
92
#elif defined(_WIN32) && defined(__CYGWIN__)
93
# if defined(AMQP_BUILD) && !defined(AMQP_STATIC)
94
# define AMQP_PUBLIC_FUNCTION __declspec(dllexport)
95
# define AMQP_PUBLIC_VARIABLE __declspec(dllexport)
97
# define AMQP_PUBLIC_FUNCTION
98
# if !defined(AMQP_STATIC)
99
# define AMQP_PUBLIC_VARIABLE __declspec(dllimport) extern
101
# define AMQP_PUBLIC_VARIABLE extern
104
# define AMQP_CALL __cdecl
106
#elif defined(__GNUC__) && __GNUC__ >= 4
107
# define AMQP_PUBLIC_FUNCTION \
108
__attribute__ ((visibility ("default")))
109
# define AMQP_PUBLIC_VARIABLE \
110
__attribute__ ((visibility ("default"))) extern
113
# define AMQP_PUBLIC_FUNCTION
114
# define AMQP_PUBLIC_VARIABLE extern
123
typedef int amqp_boolean_t;
124
typedef uint32_t amqp_method_number_t;
125
typedef uint32_t amqp_flags_t;
126
typedef uint16_t amqp_channel_t;
128
typedef struct amqp_bytes_t_ {
133
typedef struct amqp_decimal_t_ {
138
typedef struct amqp_table_t_ {
140
struct amqp_table_entry_t_ *entries;
143
typedef struct amqp_array_t_ {
145
struct amqp_field_value_t_ *entries;
149
0-9 0-9-1 Qpid/Rabbit Type Remarks
150
---------------------------------------------------------------------------
154
U s Signed 16-bit (A1)
158
L l Signed 64-bit (B)
166
T T T Timestamp (u64)
173
A1, A2: Notice how the types **CONFLICT** here. In Qpid and Rabbit,
174
's' means a signed 16-bit integer; in 0-9-1, it means a
177
B: Notice how the signednesses **CONFLICT** here. In Qpid and Rabbit,
178
'l' means a signed 64-bit integer; in 0-9-1, it means an unsigned
181
I'm going with the Qpid/Rabbit types, where there's a conflict, and
182
the 0-9-1 types otherwise. 0-8 is a subset of 0-9, which is a subset
183
of the other two, so this will work for both 0-8 and 0-9-1 branches of
187
typedef struct amqp_field_value_t_ {
190
amqp_boolean_t boolean;
201
amqp_decimal_t decimal;
206
} amqp_field_value_t;
208
typedef struct amqp_table_entry_t_ {
210
amqp_field_value_t value;
211
} amqp_table_entry_t;
214
AMQP_FIELD_KIND_BOOLEAN = 't',
215
AMQP_FIELD_KIND_I8 = 'b',
216
AMQP_FIELD_KIND_U8 = 'B',
217
AMQP_FIELD_KIND_I16 = 's',
218
AMQP_FIELD_KIND_U16 = 'u',
219
AMQP_FIELD_KIND_I32 = 'I',
220
AMQP_FIELD_KIND_U32 = 'i',
221
AMQP_FIELD_KIND_I64 = 'l',
222
AMQP_FIELD_KIND_U64 = 'L',
223
AMQP_FIELD_KIND_F32 = 'f',
224
AMQP_FIELD_KIND_F64 = 'd',
225
AMQP_FIELD_KIND_DECIMAL = 'D',
226
AMQP_FIELD_KIND_UTF8 = 'S',
227
AMQP_FIELD_KIND_ARRAY = 'A',
228
AMQP_FIELD_KIND_TIMESTAMP = 'T',
229
AMQP_FIELD_KIND_TABLE = 'F',
230
AMQP_FIELD_KIND_VOID = 'V',
231
AMQP_FIELD_KIND_BYTES = 'x'
232
} amqp_field_value_kind_t;
234
typedef struct amqp_pool_blocklist_t_ {
237
} amqp_pool_blocklist_t;
239
typedef struct amqp_pool_t_ {
242
amqp_pool_blocklist_t pages;
243
amqp_pool_blocklist_t large_blocks;
250
typedef struct amqp_method_t_ {
251
amqp_method_number_t id;
255
typedef struct amqp_frame_t_ {
256
uint8_t frame_type; /* 0 means no event */
257
amqp_channel_t channel;
259
amqp_method_t method;
266
amqp_bytes_t body_fragment;
268
uint8_t transport_high;
269
uint8_t transport_low;
270
uint8_t protocol_version_major;
271
uint8_t protocol_version_minor;
276
typedef enum amqp_response_type_enum_ {
277
AMQP_RESPONSE_NONE = 0,
278
AMQP_RESPONSE_NORMAL,
279
AMQP_RESPONSE_LIBRARY_EXCEPTION,
280
AMQP_RESPONSE_SERVER_EXCEPTION
281
} amqp_response_type_enum;
283
typedef struct amqp_rpc_reply_t_ {
284
amqp_response_type_enum reply_type;
286
int library_error; /* if AMQP_RESPONSE_LIBRARY_EXCEPTION, then 0 here means socket EOF */
289
typedef enum amqp_sasl_method_enum_ {
290
AMQP_SASL_METHOD_PLAIN = 0
291
} amqp_sasl_method_enum;
294
typedef struct amqp_connection_state_t_ *amqp_connection_state_t;
298
AMQP_CALL amqp_version(void);
300
/* Exported empty data structures */
301
AMQP_PUBLIC_VARIABLE const amqp_bytes_t amqp_empty_bytes;
302
AMQP_PUBLIC_VARIABLE const amqp_table_t amqp_empty_table;
303
AMQP_PUBLIC_VARIABLE const amqp_array_t amqp_empty_array;
305
/* Compatibility macros for the above, to avoid the need to update
306
code written against earlier versions of librabbitmq. */
307
#define AMQP_EMPTY_BYTES amqp_empty_bytes
308
#define AMQP_EMPTY_TABLE amqp_empty_table
309
#define AMQP_EMPTY_ARRAY amqp_empty_array
313
AMQP_CALL init_amqp_pool(amqp_pool_t *pool, size_t pagesize);
317
AMQP_CALL recycle_amqp_pool(amqp_pool_t *pool);
321
AMQP_CALL empty_amqp_pool(amqp_pool_t *pool);
325
AMQP_CALL amqp_pool_alloc(amqp_pool_t *pool, size_t amount);
329
AMQP_CALL amqp_pool_alloc_bytes(amqp_pool_t *pool, size_t amount, amqp_bytes_t *output);
333
AMQP_CALL amqp_cstring_bytes(char const *cstr);
337
AMQP_CALL amqp_bytes_malloc_dup(amqp_bytes_t src);
341
AMQP_CALL amqp_bytes_malloc(size_t amount);
345
AMQP_CALL amqp_bytes_free(amqp_bytes_t bytes);
348
amqp_connection_state_t
349
AMQP_CALL amqp_new_connection(void);
353
AMQP_CALL amqp_get_sockfd(amqp_connection_state_t state);
357
AMQP_CALL amqp_set_sockfd(amqp_connection_state_t state, int sockfd);
361
AMQP_CALL amqp_tune_connection(amqp_connection_state_t state,
368
AMQP_CALL amqp_get_channel_max(amqp_connection_state_t state);
372
AMQP_CALL amqp_destroy_connection(amqp_connection_state_t state);
376
AMQP_CALL amqp_handle_input(amqp_connection_state_t state,
377
amqp_bytes_t received_data,
378
amqp_frame_t *decoded_frame);
382
AMQP_CALL amqp_release_buffers_ok(amqp_connection_state_t state);
386
AMQP_CALL amqp_release_buffers(amqp_connection_state_t state);
390
AMQP_CALL amqp_maybe_release_buffers(amqp_connection_state_t state);
394
AMQP_CALL amqp_send_frame(amqp_connection_state_t state, amqp_frame_t const *frame);
398
AMQP_CALL amqp_table_entry_cmp(void const *entry1, void const *entry2);
402
AMQP_CALL amqp_open_socket(char const *hostname, int portnumber);
406
AMQP_CALL amqp_send_header(amqp_connection_state_t state);
410
AMQP_CALL amqp_frames_enqueued(amqp_connection_state_t state);
414
AMQP_CALL amqp_simple_wait_frame(amqp_connection_state_t state,
415
amqp_frame_t *decoded_frame);
419
AMQP_CALL amqp_simple_wait_method(amqp_connection_state_t state,
420
amqp_channel_t expected_channel,
421
amqp_method_number_t expected_method,
422
amqp_method_t *output);
426
AMQP_CALL amqp_send_method(amqp_connection_state_t state,
427
amqp_channel_t channel,
428
amqp_method_number_t id,
433
AMQP_CALL amqp_simple_rpc(amqp_connection_state_t state,
434
amqp_channel_t channel,
435
amqp_method_number_t request_id,
436
amqp_method_number_t *expected_reply_ids,
437
void *decoded_request_method);
441
AMQP_CALL amqp_simple_rpc_decoded(amqp_connection_state_t state,
442
amqp_channel_t channel,
443
amqp_method_number_t request_id,
444
amqp_method_number_t reply_id,
445
void *decoded_request_method);
448
* The API methods corresponding to most synchronous AMQP methods
449
* return a pointer to the decoded method result. Upon error, they
450
* return NULL, and we need some way of discovering what, if anything,
451
* went wrong. amqp_get_rpc_reply() returns the most recent
452
* amqp_rpc_reply_t instance corresponding to such an API operation
453
* for the given connection.
455
* Only use it for operations that do not themselves return
456
* amqp_rpc_reply_t; operations that do return amqp_rpc_reply_t
457
* generally do NOT update this per-connection-global amqp_rpc_reply_t
462
AMQP_CALL amqp_get_rpc_reply(amqp_connection_state_t state);
466
AMQP_CALL amqp_login(amqp_connection_state_t state, char const *vhost,
467
int channel_max, int frame_max, int heartbeat,
468
amqp_sasl_method_enum sasl_method, ...);
470
struct amqp_basic_properties_t_;
474
AMQP_CALL amqp_basic_publish(amqp_connection_state_t state, amqp_channel_t channel,
475
amqp_bytes_t exchange, amqp_bytes_t routing_key,
476
amqp_boolean_t mandatory, amqp_boolean_t immediate,
477
struct amqp_basic_properties_t_ const *properties,
482
AMQP_CALL amqp_channel_close(amqp_connection_state_t state, amqp_channel_t channel,
487
AMQP_CALL amqp_connection_close(amqp_connection_state_t state, int code);
491
AMQP_CALL amqp_basic_ack(amqp_connection_state_t state, amqp_channel_t channel,
492
uint64_t delivery_tag, amqp_boolean_t multiple);
496
AMQP_CALL amqp_basic_get(amqp_connection_state_t state, amqp_channel_t channel,
497
amqp_bytes_t queue, amqp_boolean_t no_ack);
501
AMQP_CALL amqp_basic_reject(amqp_connection_state_t state, amqp_channel_t channel,
502
uint64_t delivery_tag, amqp_boolean_t requeue);
505
* Can be used to see if there is data still in the buffer, if so
506
* calling amqp_simple_wait_frame will not immediately enter a
509
* Possibly amqp_frames_enqueued should be used for this?
513
AMQP_CALL amqp_data_in_buffer(amqp_connection_state_t state);
516
* Get the error string for the given error code.
518
* The returned string resides on the heap; the caller is responsible
523
AMQP_CALL amqp_error_string(int err);
527
AMQP_CALL amqp_decode_table(amqp_bytes_t encoded, amqp_pool_t *pool,
528
amqp_table_t *output, size_t *offset);
532
AMQP_CALL amqp_encode_table(amqp_bytes_t encoded, amqp_table_t *input, size_t *offset);
534
struct amqp_connection_info {
544
AMQP_CALL amqp_default_connection_info(struct amqp_connection_info *parsed);
548
AMQP_CALL amqp_parse_url(char *url, struct amqp_connection_info *parsed);
552
#include <amqp_framing.h>