diff options
Diffstat (limited to 'librabbitmq/amqp.h')
-rw-r--r-- | librabbitmq/amqp.h | 433 |
1 files changed, 286 insertions, 147 deletions
diff --git a/librabbitmq/amqp.h b/librabbitmq/amqp.h index 8b91cdc..c8d0127 100644 --- a/librabbitmq/amqp.h +++ b/librabbitmq/amqp.h @@ -1,6 +1,3 @@ -#ifndef librabbitmq_amqp_h -#define librabbitmq_amqp_h - /* * ***** BEGIN LICENSE BLOCK ***** * Version: MIT @@ -33,23 +30,96 @@ * ***** END LICENSE BLOCK ***** */ -#include <stdint.h> -#include <stddef.h> +#ifndef AMQP_H +#define AMQP_H #ifdef __cplusplus -extern "C" { -#endif - -#ifdef _WIN32 -#ifdef BUILDING_LIBRABBITMQ -#define RABBITMQ_EXPORT extern __declspec(dllexport) +#define AMQP_BEGIN_DECLS extern "C" { +#define AMQP_END_DECLS } #else -#define RABBITMQ_EXPORT extern __declspec(dllimport) +#define AMQP_BEGIN_DECLS +#define AMQP_END_DECLS #endif + +/** Important API Decorators + * AMQP_PUBLIC_FUNCTION - Declares an exportable function + * AMQP_PUBLIC_VARIABLE - Declares an exportable variable + * AMQP_CALL - Declares the calling convention + */ + +#if defined(_WIN32) && defined(_MSC_VER) +# if defined(AMQP_BUILD) && !defined(AMQP_STATIC) +# define AMQP_PUBLIC_FUNCTION __declspec(dllexport) +# define AMQP_PUBLIC_VARIABLE __declspec(dllexport) extern +# else +# define AMQP_PUBLIC_FUNCTION +# if !defined(AMQP_STATIC) +# define AMQP_PUBLIC_VARIABLE __declspec(dllimport) extern +# else +# define AMQP_PUBLIC_VARIABLE extern +# endif +# endif +# define AMQP_CALL __cdecl + +#elif defined(_WIN32) && defined(__BORLANDC__) +# if defined(AMQP_BUILD) && !defined(AMQP_STATIC) +# define AMQP_PUBLIC_FUNCTION __declspec(dllexport) +# define AMQP_PUBLIC_VARIABLE __declspec(dllexport) extern +# else +# define AMQP_PUBLIC_FUNCTION +# if !defined(AMQP_STATIC) +# define AMQP_PUBLIC_VARIABLE __declspec(dllimport) extern +# else +# define AMQP_PUBLIC_VARIABLE extern +# endif +# endif +# define AMQP_CALL __cdecl + +#elif defined(_WIN32) && defined(__MINGW32__) +# if defined(AMQP_BUILD) && !defined(AMQP_STATIC) +# define AMQP_PUBLIC_FUNCTION __declspec(dllexport) +# define AMQP_PUBLIC_VARIABLE __declspec(dllexport) +# else +# define AMQP_PUBLIC_FUNCTION +# if !defined(AMQP_STATIC) +# define AMQP_PUBLIC_VARIABLE __declspec(dllimport) extern +# else +# define AMQP_PUBLIC_VARIABLE extern +# endif +# endif +# define AMQP_CALL __cdecl + +#elif defined(_WIN32) && defined(__CYGWIN__) +# if defined(AMQP_BUILD) && !defined(AMQP_STATIC) +# define AMQP_PUBLIC_FUNCTION __declspec(dllexport) +# define AMQP_PUBLIC_VARIABLE __declspec(dllexport) +# else +# define AMQP_PUBLIC_FUNCTION +# if !defined(AMQP_STATIC) +# define AMQP_PUBLIC_VARIABLE __declspec(dllimport) extern +# else +# define AMQP_PUBLIC_VARIABLE extern +# endif +# endif +# define AMQP_CALL __cdecl + +#elif defined(__GNUC__) && __GNUC__ >= 4 +# define AMQP_PUBLIC_FUNCTION \ + __attribute__ ((visibility ("default"))) +# define AMQP_PUBLIC_VARIABLE \ + __attribute__ ((visibility ("default"))) extern +# define AMQP_CALL #else -#define RABBITMQ_EXPORT extern +# define AMQP_PUBLIC_FUNCTION +# define AMQP_PUBLIC_VARIABLE extern +# define AMQP_CALL #endif +#include <stddef.h> +#include <stdint.h> + +AMQP_BEGIN_DECLS + typedef int amqp_boolean_t; typedef uint32_t amqp_method_number_t; typedef uint32_t amqp_flags_t; @@ -223,12 +293,14 @@ typedef enum amqp_sasl_method_enum_ { /* Opaque struct. */ typedef struct amqp_connection_state_t_ *amqp_connection_state_t; -RABBITMQ_EXPORT char const *amqp_version(void); +AMQP_PUBLIC_FUNCTION +char const * +AMQP_CALL amqp_version(void); /* Exported empty data structures */ -RABBITMQ_EXPORT const amqp_bytes_t amqp_empty_bytes; -RABBITMQ_EXPORT const amqp_table_t amqp_empty_table; -RABBITMQ_EXPORT const amqp_array_t amqp_empty_array; +AMQP_PUBLIC_VARIABLE const amqp_bytes_t amqp_empty_bytes; +AMQP_PUBLIC_VARIABLE const amqp_table_t amqp_empty_table; +AMQP_PUBLIC_VARIABLE const amqp_array_t amqp_empty_array; /* Compatibility macros for the above, to avoid the need to update code written against earlier versions of librabbitmq. */ @@ -236,79 +308,141 @@ RABBITMQ_EXPORT const amqp_array_t amqp_empty_array; #define AMQP_EMPTY_TABLE amqp_empty_table #define AMQP_EMPTY_ARRAY amqp_empty_array -RABBITMQ_EXPORT void init_amqp_pool(amqp_pool_t *pool, size_t pagesize); -RABBITMQ_EXPORT void recycle_amqp_pool(amqp_pool_t *pool); -RABBITMQ_EXPORT void empty_amqp_pool(amqp_pool_t *pool); - -RABBITMQ_EXPORT void *amqp_pool_alloc(amqp_pool_t *pool, size_t amount); -RABBITMQ_EXPORT void amqp_pool_alloc_bytes(amqp_pool_t *pool, - size_t amount, amqp_bytes_t *output); - -RABBITMQ_EXPORT amqp_bytes_t amqp_cstring_bytes(char const *cstr); -RABBITMQ_EXPORT amqp_bytes_t amqp_bytes_malloc_dup(amqp_bytes_t src); -RABBITMQ_EXPORT amqp_bytes_t amqp_bytes_malloc(size_t amount); -RABBITMQ_EXPORT void amqp_bytes_free(amqp_bytes_t bytes); - -RABBITMQ_EXPORT amqp_connection_state_t amqp_new_connection(void); -RABBITMQ_EXPORT int amqp_get_sockfd(amqp_connection_state_t state); -RABBITMQ_EXPORT void amqp_set_sockfd(amqp_connection_state_t state, - int sockfd); -RABBITMQ_EXPORT int amqp_tune_connection(amqp_connection_state_t state, - int channel_max, - int frame_max, - int heartbeat); -RABBITMQ_EXPORT int amqp_get_channel_max(amqp_connection_state_t state); -RABBITMQ_EXPORT int amqp_destroy_connection(amqp_connection_state_t state); - -RABBITMQ_EXPORT int amqp_handle_input(amqp_connection_state_t state, - amqp_bytes_t received_data, - amqp_frame_t *decoded_frame); - -RABBITMQ_EXPORT amqp_boolean_t amqp_release_buffers_ok( - amqp_connection_state_t state); - -RABBITMQ_EXPORT void amqp_release_buffers(amqp_connection_state_t state); - -RABBITMQ_EXPORT void amqp_maybe_release_buffers(amqp_connection_state_t state); - -RABBITMQ_EXPORT int amqp_send_frame(amqp_connection_state_t state, - amqp_frame_t const *frame); - -RABBITMQ_EXPORT int amqp_table_entry_cmp(void const *entry1, - void const *entry2); - -RABBITMQ_EXPORT int amqp_open_socket(char const *hostname, - int portnumber); - -RABBITMQ_EXPORT int amqp_send_header(amqp_connection_state_t state); - -RABBITMQ_EXPORT amqp_boolean_t amqp_frames_enqueued( - amqp_connection_state_t state); - -RABBITMQ_EXPORT int amqp_simple_wait_frame(amqp_connection_state_t state, - amqp_frame_t *decoded_frame); - -RABBITMQ_EXPORT int amqp_simple_wait_method(amqp_connection_state_t state, - amqp_channel_t expected_channel, - amqp_method_number_t expected_method, - amqp_method_t *output); - -RABBITMQ_EXPORT int amqp_send_method(amqp_connection_state_t state, - amqp_channel_t channel, - amqp_method_number_t id, - void *decoded); - -RABBITMQ_EXPORT amqp_rpc_reply_t amqp_simple_rpc(amqp_connection_state_t state, - amqp_channel_t channel, - amqp_method_number_t request_id, - amqp_method_number_t *expected_reply_ids, - void *decoded_request_method); - -RABBITMQ_EXPORT void *amqp_simple_rpc_decoded(amqp_connection_state_t state, - amqp_channel_t channel, - amqp_method_number_t request_id, - amqp_method_number_t reply_id, - void *decoded_request_method); +AMQP_PUBLIC_FUNCTION +void +AMQP_CALL init_amqp_pool(amqp_pool_t *pool, size_t pagesize); + +AMQP_PUBLIC_FUNCTION +void +AMQP_CALL recycle_amqp_pool(amqp_pool_t *pool); + +AMQP_PUBLIC_FUNCTION +void +AMQP_CALL empty_amqp_pool(amqp_pool_t *pool); + +AMQP_PUBLIC_FUNCTION +void * +AMQP_CALL amqp_pool_alloc(amqp_pool_t *pool, size_t amount); + +AMQP_PUBLIC_FUNCTION +void +AMQP_CALL amqp_pool_alloc_bytes(amqp_pool_t *pool, size_t amount, amqp_bytes_t *output); + +AMQP_PUBLIC_FUNCTION +amqp_bytes_t +AMQP_CALL amqp_cstring_bytes(char const *cstr); + +AMQP_PUBLIC_FUNCTION +amqp_bytes_t +AMQP_CALL amqp_bytes_malloc_dup(amqp_bytes_t src); + +AMQP_PUBLIC_FUNCTION +amqp_bytes_t +AMQP_CALL amqp_bytes_malloc(size_t amount); + +AMQP_PUBLIC_FUNCTION +void +AMQP_CALL amqp_bytes_free(amqp_bytes_t bytes); + +AMQP_PUBLIC_FUNCTION +amqp_connection_state_t +AMQP_CALL amqp_new_connection(void); + +AMQP_PUBLIC_FUNCTION +int +AMQP_CALL amqp_get_sockfd(amqp_connection_state_t state); + +AMQP_PUBLIC_FUNCTION +void +AMQP_CALL amqp_set_sockfd(amqp_connection_state_t state, int sockfd); + +AMQP_PUBLIC_FUNCTION +int +AMQP_CALL amqp_tune_connection(amqp_connection_state_t state, + int channel_max, + int frame_max, + int heartbeat); + +AMQP_PUBLIC_FUNCTION +int +AMQP_CALL amqp_get_channel_max(amqp_connection_state_t state); + +AMQP_PUBLIC_FUNCTION +int +AMQP_CALL amqp_destroy_connection(amqp_connection_state_t state); + +AMQP_PUBLIC_FUNCTION +int +AMQP_CALL amqp_handle_input(amqp_connection_state_t state, + amqp_bytes_t received_data, + amqp_frame_t *decoded_frame); + +AMQP_PUBLIC_FUNCTION +amqp_boolean_t +AMQP_CALL amqp_release_buffers_ok(amqp_connection_state_t state); + +AMQP_PUBLIC_FUNCTION +void +AMQP_CALL amqp_release_buffers(amqp_connection_state_t state); + +AMQP_PUBLIC_FUNCTION +void +AMQP_CALL amqp_maybe_release_buffers(amqp_connection_state_t state); + +AMQP_PUBLIC_FUNCTION +int +AMQP_CALL amqp_send_frame(amqp_connection_state_t state, amqp_frame_t const *frame); + +AMQP_PUBLIC_FUNCTION +int +AMQP_CALL amqp_table_entry_cmp(void const *entry1, void const *entry2); + +AMQP_PUBLIC_FUNCTION +int +AMQP_CALL amqp_open_socket(char const *hostname, int portnumber); + +AMQP_PUBLIC_FUNCTION +int +AMQP_CALL amqp_send_header(amqp_connection_state_t state); + +AMQP_PUBLIC_FUNCTION +amqp_boolean_t +AMQP_CALL amqp_frames_enqueued(amqp_connection_state_t state); + +AMQP_PUBLIC_FUNCTION +int +AMQP_CALL amqp_simple_wait_frame(amqp_connection_state_t state, + amqp_frame_t *decoded_frame); + +AMQP_PUBLIC_FUNCTION +int +AMQP_CALL amqp_simple_wait_method(amqp_connection_state_t state, + amqp_channel_t expected_channel, + amqp_method_number_t expected_method, + amqp_method_t *output); + +AMQP_PUBLIC_FUNCTION +int +AMQP_CALL amqp_send_method(amqp_connection_state_t state, + amqp_channel_t channel, + amqp_method_number_t id, + void *decoded); + +AMQP_PUBLIC_FUNCTION +amqp_rpc_reply_t +AMQP_CALL amqp_simple_rpc(amqp_connection_state_t state, + amqp_channel_t channel, + amqp_method_number_t request_id, + amqp_method_number_t *expected_reply_ids, + void *decoded_request_method); + +AMQP_PUBLIC_FUNCTION +void * +AMQP_CALL amqp_simple_rpc_decoded(amqp_connection_state_t state, + amqp_channel_t channel, + amqp_method_number_t request_id, + amqp_method_number_t reply_id, + void *decoded_request_method); /* * The API methods corresponding to most synchronous AMQP methods @@ -323,48 +457,49 @@ RABBITMQ_EXPORT void *amqp_simple_rpc_decoded(amqp_connection_state_t state, * generally do NOT update this per-connection-global amqp_rpc_reply_t * instance. */ -RABBITMQ_EXPORT amqp_rpc_reply_t amqp_get_rpc_reply( - amqp_connection_state_t state); +AMQP_PUBLIC_FUNCTION +amqp_rpc_reply_t +AMQP_CALL amqp_get_rpc_reply(amqp_connection_state_t state); -RABBITMQ_EXPORT amqp_rpc_reply_t amqp_login(amqp_connection_state_t state, - char const *vhost, - int channel_max, - int frame_max, - int heartbeat, - amqp_sasl_method_enum sasl_method, ...); +AMQP_PUBLIC_FUNCTION +amqp_rpc_reply_t +AMQP_CALL amqp_login(amqp_connection_state_t state, char const *vhost, + int channel_max, int frame_max, int heartbeat, + amqp_sasl_method_enum sasl_method, ...); struct amqp_basic_properties_t_; -RABBITMQ_EXPORT int amqp_basic_publish(amqp_connection_state_t state, - amqp_channel_t channel, - amqp_bytes_t exchange, - amqp_bytes_t routing_key, - amqp_boolean_t mandatory, - amqp_boolean_t immediate, - struct amqp_basic_properties_t_ const *properties, - amqp_bytes_t body); - -RABBITMQ_EXPORT amqp_rpc_reply_t amqp_channel_close( - amqp_connection_state_t state, - amqp_channel_t channel, - int code); -RABBITMQ_EXPORT amqp_rpc_reply_t amqp_connection_close( - amqp_connection_state_t state, - int code); - -RABBITMQ_EXPORT int amqp_basic_ack(amqp_connection_state_t state, - amqp_channel_t channel, - uint64_t delivery_tag, - amqp_boolean_t multiple); - -RABBITMQ_EXPORT amqp_rpc_reply_t amqp_basic_get(amqp_connection_state_t state, - amqp_channel_t channel, - amqp_bytes_t queue, - amqp_boolean_t no_ack); - -RABBITMQ_EXPORT int amqp_basic_reject(amqp_connection_state_t state, - amqp_channel_t channel, - uint64_t delivery_tag, - amqp_boolean_t requeue); + +AMQP_PUBLIC_FUNCTION +int +AMQP_CALL amqp_basic_publish(amqp_connection_state_t state, amqp_channel_t channel, + amqp_bytes_t exchange, amqp_bytes_t routing_key, + amqp_boolean_t mandatory, amqp_boolean_t immediate, + struct amqp_basic_properties_t_ const *properties, + amqp_bytes_t body); + +AMQP_PUBLIC_FUNCTION +amqp_rpc_reply_t +AMQP_CALL amqp_channel_close(amqp_connection_state_t state, amqp_channel_t channel, + int code); + +AMQP_PUBLIC_FUNCTION +amqp_rpc_reply_t +AMQP_CALL amqp_connection_close(amqp_connection_state_t state, int code); + +AMQP_PUBLIC_FUNCTION +int +AMQP_CALL amqp_basic_ack(amqp_connection_state_t state, amqp_channel_t channel, + uint64_t delivery_tag, amqp_boolean_t multiple); + +AMQP_PUBLIC_FUNCTION +amqp_rpc_reply_t +AMQP_CALL amqp_basic_get(amqp_connection_state_t state, amqp_channel_t channel, + amqp_bytes_t queue, amqp_boolean_t no_ack); + +AMQP_PUBLIC_FUNCTION +int +AMQP_CALL amqp_basic_reject(amqp_connection_state_t state, amqp_channel_t channel, + uint64_t delivery_tag, amqp_boolean_t requeue); /* * Can be used to see if there is data still in the buffer, if so @@ -373,8 +508,9 @@ RABBITMQ_EXPORT int amqp_basic_reject(amqp_connection_state_t state, * * Possibly amqp_frames_enqueued should be used for this? */ -RABBITMQ_EXPORT amqp_boolean_t amqp_data_in_buffer( - amqp_connection_state_t state); +AMQP_PUBLIC_FUNCTION +amqp_boolean_t +AMQP_CALL amqp_data_in_buffer(amqp_connection_state_t state); /* * Get the error string for the given error code. @@ -382,16 +518,18 @@ RABBITMQ_EXPORT amqp_boolean_t amqp_data_in_buffer( * The returned string resides on the heap; the caller is responsible * for freeing it. */ -RABBITMQ_EXPORT char *amqp_error_string(int err); +AMQP_PUBLIC_FUNCTION +char * +AMQP_CALL amqp_error_string(int err); -RABBITMQ_EXPORT int amqp_decode_table(amqp_bytes_t encoded, - amqp_pool_t *pool, - amqp_table_t *output, - size_t *offset); +AMQP_PUBLIC_FUNCTION +int +AMQP_CALL amqp_decode_table(amqp_bytes_t encoded, amqp_pool_t *pool, + amqp_table_t *output, size_t *offset); -RABBITMQ_EXPORT int amqp_encode_table(amqp_bytes_t encoded, - amqp_table_t *input, - size_t *offset); +AMQP_PUBLIC_FUNCTION +int +AMQP_CALL amqp_encode_table(amqp_bytes_t encoded, amqp_table_t *input, size_t *offset); struct amqp_connection_info { char *user; @@ -401,15 +539,16 @@ struct amqp_connection_info { int port; }; -RABBITMQ_EXPORT void amqp_default_connection_info( - struct amqp_connection_info *parsed); -RABBITMQ_EXPORT int amqp_parse_url(char *url, - struct amqp_connection_info *parsed); +AMQP_PUBLIC_FUNCTION +void +AMQP_CALL amqp_default_connection_info(struct amqp_connection_info *parsed); -#ifdef __cplusplus -} -#endif +AMQP_PUBLIC_FUNCTION +int +AMQP_CALL amqp_parse_url(char *url, struct amqp_connection_info *parsed); + +AMQP_END_DECLS #include <amqp_framing.h> -#endif +#endif /* AMQP_H */ |