summaryrefslogtreecommitdiff
path: root/librabbitmq
diff options
context:
space:
mode:
Diffstat (limited to 'librabbitmq')
-rw-r--r--librabbitmq/CMakeLists.txt18
-rw-r--r--librabbitmq/Makefile.am35
-rw-r--r--librabbitmq/amqp.h433
-rw-r--r--librabbitmq/amqp_api.c21
-rw-r--r--librabbitmq/amqp_connection.c17
-rw-r--r--librabbitmq/amqp_mem.c14
-rw-r--r--librabbitmq/amqp_private.h28
-rw-r--r--librabbitmq/amqp_socket.c12
-rw-r--r--librabbitmq/amqp_table.c15
-rw-r--r--librabbitmq/amqp_url.c13
-rw-r--r--librabbitmq/codegen.py90
-rw-r--r--librabbitmq/unix/socket.c26
-rw-r--r--librabbitmq/unix/socket.h25
-rw-r--r--librabbitmq/win32/msinttypes/inttypes.h305
-rw-r--r--librabbitmq/win32/msinttypes/stdint.h247
-rw-r--r--librabbitmq/win32/socket.c (renamed from librabbitmq/windows/socket.c)35
-rw-r--r--librabbitmq/win32/socket.h (renamed from librabbitmq/windows/socket.h)39
17 files changed, 1052 insertions, 321 deletions
diff --git a/librabbitmq/CMakeLists.txt b/librabbitmq/CMakeLists.txt
index 7b1322d..140c4b9 100644
--- a/librabbitmq/CMakeLists.txt
+++ b/librabbitmq/CMakeLists.txt
@@ -33,25 +33,25 @@ add_custom_command(
VERBATIM)
-SET(CONFIG_CONTENTS "#define VERSION \"0.2\"
+SET(CONFIG_CONTENTS "#define VERSION \"${VERSION}\"
#ifndef __cplusplus
# define inline ${C_INLINE}
-#endif // __cplusplus
+#endif /* __cplusplus */
")
#prepare config.h
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/config.h" ${CONFIG_CONTENTS})
if(WIN32)
- set(SOCKET_IMPL "windows")
+ set(SOCKET_IMPL "win32")
else(WIN32)
set(SOCKET_IMPL "unix")
endif(WIN32)
if(MSVC)
if(MSVC_VERSION LESS 1600)
- set(MSINTTYPES_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/../msinttypes")
- set(STDINT_H_INSTALL_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../msinttypes/stdint.h")
+ set(MSINTTYPES_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/win32/msinttypes")
+ set(STDINT_H_INSTALL_FILE "${CMAKE_CURRENT_SOURCE_DIR}/win32/msinttypes/stdint.h")
endif(MSVC_VERSION LESS 1600)
endif(MSVC)
@@ -68,7 +68,7 @@ set(LIBRABBITMQ_INCLUDE_DIRS
${LIBRABBITMQ_INCLUDE_DIRS}
PARENT_SCOPE)
-add_definitions(-DBUILDING_LIBRABBITMQ)
+add_definitions(-DHAVE_CONFIG_H)
set(RABBITMQ_SOURCES
${CMAKE_CURRENT_BINARY_DIR}/amqp_framing.h
@@ -79,6 +79,12 @@ set(RABBITMQ_SOURCES
${SOCKET_IMPL}/socket.h ${SOCKET_IMPL}/socket.c
)
+add_definitions(-DAMQP_BUILD)
+
+if (NOT BUILD_SHARED_LIBS)
+ add_definitions(-DAMQP_STATIC)
+endif()
+
add_library(rabbitmq ${RABBITMQ_SOURCES})
if(WIN32)
diff --git a/librabbitmq/Makefile.am b/librabbitmq/Makefile.am
deleted file mode 100644
index f5908c3..0000000
--- a/librabbitmq/Makefile.am
+++ /dev/null
@@ -1,35 +0,0 @@
-lib_LTLIBRARIES = librabbitmq.la
-
-AM_CFLAGS = -I$(srcdir)/$(PLATFORM_DIR) -DBUILDING_LIBRABBITMQ
-
-if GCC
-# Because we want to build under Microsoft's C compiler (for which
-# there is apparently no demand for C99 support), it's a good idea
-# to have gcc tell us when we stray from the old standard.
-AM_CFLAGS += -ansi -pedantic
-endif
-
-if USE_MSINTTYPES
-AM_CFLAGS += -I$(top_srcdir)/msinttypes
-endif
-
-librabbitmq_la_SOURCES = amqp_mem.c amqp_table.c amqp_connection.c amqp_socket.c amqp_api.c amqp_url.c $(PLATFORM_DIR)/socket.c
-librabbitmq_la_LDFLAGS = -no-undefined
-librabbitmq_la_LIBADD = $(EXTRA_LIBS)
-nodist_librabbitmq_la_SOURCES = amqp_framing.c
-include_HEADERS = amqp_framing.h amqp.h
-noinst_HEADERS = amqp_private.h $(PLATFORM_DIR)/socket.h
-BUILT_SOURCES = amqp_framing.h amqp_framing.c
-CLEANFILES = amqp_framing.h amqp_framing.c
-EXTRA_DIST = \
- codegen.py \
- unix/socket.c unix/socket.h \
- windows/socket.c windows/socket.h
-
-CODEGEN_PY=$(srcdir)/codegen.py
-
-amqp_framing.h: $(top_srcdir)/$(AMQP_SPEC_JSON_PATH) $(CODEGEN_PY)
- PYTHONPATH=$(top_srcdir)/$(AMQP_CODEGEN_DIR) $(PYTHON) $(CODEGEN_PY) header $< $@
-
-amqp_framing.c: $(top_srcdir)/$(AMQP_SPEC_JSON_PATH) $(CODEGEN_PY)
- PYTHONPATH=$(top_srcdir)/$(AMQP_CODEGEN_DIR) $(PYTHON) $(CODEGEN_PY) body $< $@
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 */
diff --git a/librabbitmq/amqp_api.c b/librabbitmq/amqp_api.c
index 621e71b..f011354 100644
--- a/librabbitmq/amqp_api.c
+++ b/librabbitmq/amqp_api.c
@@ -30,19 +30,17 @@
* ***** END LICENSE BLOCK *****
*/
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#endif
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-#include <stdarg.h>
-
-#include "amqp.h"
-#include "amqp_framing.h"
#include "amqp_private.h"
-
#include <assert.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
static const char *client_error_strings[ERROR_MAX] = {
"could not allocate memory", /* ERROR_NO_MEMORY */
@@ -141,9 +139,8 @@ int amqp_basic_publish(amqp_connection_state_t state,
return res;
body_offset = 0;
- while (1) {
- int remaining = body.len - body_offset;
- assert(remaining >= 0);
+ while (body_offset < body.len) {
+ size_t remaining = body.len - body_offset;
if (remaining == 0)
break;
diff --git a/librabbitmq/amqp_connection.c b/librabbitmq/amqp_connection.c
index fc99862..561d496 100644
--- a/librabbitmq/amqp_connection.c
+++ b/librabbitmq/amqp_connection.c
@@ -30,15 +30,16 @@
* ***** END LICENSE BLOCK *****
*/
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-#include <assert.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
-#include "amqp.h"
-#include "amqp_framing.h"
#include "amqp_private.h"
+#include <assert.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#define INITIAL_FRAME_POOL_PAGE_SIZE 65536
#define INITIAL_DECODING_POOL_PAGE_SIZE 131072
@@ -47,7 +48,7 @@
#define ENFORCE_STATE(statevec, statenum) \
{ \
amqp_connection_state_t _check_state = (statevec); \
- int _wanted_state = (statenum); \
+ size_t _wanted_state = (statenum); \
if (_check_state->state != _wanted_state) \
amqp_abort("Programming error: invalid AMQP connection state: expected %d, got %d", \
_wanted_state, \
diff --git a/librabbitmq/amqp_mem.c b/librabbitmq/amqp_mem.c
index 429d423..d1cf2ad 100644
--- a/librabbitmq/amqp_mem.c
+++ b/librabbitmq/amqp_mem.c
@@ -30,15 +30,17 @@
* ***** END LICENSE BLOCK *****
*/
-#include <stdlib.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "amqp_private.h"
+#include <assert.h>
+#include <stdint.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
-#include <stdint.h>
#include <sys/types.h>
-#include <assert.h>
-
-#include "amqp.h"
-#include "config.h"
char const *amqp_version(void) {
return VERSION; /* defined in config.h */
diff --git a/librabbitmq/amqp_private.h b/librabbitmq/amqp_private.h
index 90ff6d3..bbee792 100644
--- a/librabbitmq/amqp_private.h
+++ b/librabbitmq/amqp_private.h
@@ -33,7 +33,13 @@
* ***** END LICENSE BLOCK *****
*/
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#endif
+
+#include "amqp.h"
+#include "amqp_framing.h"
+#include <string.h>
/* Error numbering: Because of differences in error numbering on
* different platforms, we want to keep error numbers opaque for
@@ -57,7 +63,23 @@
#define ERROR_BAD_AMQP_URL 8
#define ERROR_MAX 8
-extern char *amqp_os_error_string(int err);
+/* GCC attributes */
+#if __GNUC__ > 2 | (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
+#define AMQP_NORETURN \
+ __attribute__ ((__noreturn__))
+#else
+#define AMQP_NORETURN
+#endif
+
+#if __GNUC__ >= 4
+#define AMQP_PRIVATE \
+ __attribute__ ((visibility ("hidden")))
+#else
+#define AMQP_PRIVATE
+#endif
+
+char *
+amqp_os_error_string(int err);
#include "socket.h"
@@ -255,6 +277,8 @@ static inline int amqp_decode_bytes(amqp_bytes_t encoded, size_t *offset,
}
}
-extern void amqp_abort(const char *fmt, ...);
+AMQP_NORETURN
+void
+amqp_abort(const char *fmt, ...);
#endif
diff --git a/librabbitmq/amqp_socket.c b/librabbitmq/amqp_socket.c
index d7c523e..6b9486c 100644
--- a/librabbitmq/amqp_socket.c
+++ b/librabbitmq/amqp_socket.c
@@ -30,6 +30,11 @@
* ***** END LICENSE BLOCK *****
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "amqp_private.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -37,11 +42,6 @@
#include <stdarg.h>
#include <assert.h>
-#include "amqp.h"
-#include "amqp_framing.h"
-#include "amqp_private.h"
-
-
int amqp_open_socket(char const *hostname,
int portnumber)
{
@@ -368,7 +368,7 @@ static int amqp_login_inner(amqp_connection_state_t state,
{
int res;
amqp_method_t method;
- uint32_t server_frame_max;
+ int server_frame_max;
uint16_t server_channel_max;
uint16_t server_heartbeat;
diff --git a/librabbitmq/amqp_table.c b/librabbitmq/amqp_table.c
index 3f78a5b..4e0de12 100644
--- a/librabbitmq/amqp_table.c
+++ b/librabbitmq/amqp_table.c
@@ -30,15 +30,16 @@
* ***** END LICENSE BLOCK *****
*/
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
-#include "amqp.h"
#include "amqp_private.h"
-
#include <assert.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#define INITIAL_ARRAY_SIZE 16
#define INITIAL_TABLE_SIZE 16
@@ -409,7 +410,7 @@ int amqp_table_entry_cmp(void const *entry1, void const *entry2) {
amqp_table_entry_t const *p2 = (amqp_table_entry_t const *) entry2;
int d;
- int minlen;
+ size_t minlen;
minlen = p1->key.len;
if (p2->key.len < minlen) minlen = p2->key.len;
diff --git a/librabbitmq/amqp_url.c b/librabbitmq/amqp_url.c
index 476d5dc..eb29ca8 100644
--- a/librabbitmq/amqp_url.c
+++ b/librabbitmq/amqp_url.c
@@ -30,14 +30,15 @@
* ***** END LICENSE BLOCK *****
*/
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
-#include "amqp.h"
-#include "amqp_framing.h"
#include "amqp_private.h"
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
void amqp_default_connection_info(struct amqp_connection_info *ci)
{
diff --git a/librabbitmq/codegen.py b/librabbitmq/codegen.py
index 67255a6..42d039d 100644
--- a/librabbitmq/codegen.py
+++ b/librabbitmq/codegen.py
@@ -250,7 +250,7 @@ def methodApiPrototype(m):
args.append(" ")
args.append(n)
- return "%s_ok_t *%s(amqp_connection_state_t state, amqp_channel_t channel%s)" % (fn, fn, ''.join(args))
+ return "AMQP_PUBLIC_FUNCTION %s_ok_t * AMQP_CALL %s(amqp_connection_state_t state, amqp_channel_t channel%s)" % (fn, fn, ''.join(args))
AmqpMethod.apiPrototype = methodApiPrototype
@@ -366,15 +366,16 @@ def genErl(spec):
* ***** END LICENSE BLOCK *****
*/
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdio.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
-#include "amqp.h"
-#include "amqp_framing.h"
#include "amqp_private.h"
#include "socket.h"
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
"""
print """
@@ -551,14 +552,12 @@ def genHrl(spec):
methods = spec.allMethods()
print """/* Autogenerated code. Do not edit. */
-#ifndef librabbitmq_amqp_framing_h
-#define librabbitmq_amqp_framing_h
+#ifndef AMQP_FRAMING_H
+#define AMQP_FRAMING_H
#include <amqp.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+AMQP_BEGIN_DECLS
"""
print "#define AMQP_PROTOCOL_VERSION_MAJOR %d" % (spec.major)
print "#define AMQP_PROTOCOL_VERSION_MINOR %d" % (spec.minor)
@@ -571,24 +570,47 @@ extern "C" {
print """/* Function prototypes. */
-extern char const *amqp_constant_name(int constantNumber);
-extern amqp_boolean_t amqp_constant_is_hard_error(int constantNumber);
-RABBITMQ_EXPORT char const *amqp_method_name(amqp_method_number_t methodNumber);
-extern amqp_boolean_t amqp_method_has_content(amqp_method_number_t methodNumber);
-extern int amqp_decode_method(amqp_method_number_t methodNumber,
- amqp_pool_t *pool,
- amqp_bytes_t encoded,
- void **decoded);
-extern int amqp_decode_properties(uint16_t class_id,
- amqp_pool_t *pool,
- amqp_bytes_t encoded,
- void **decoded);
-extern int amqp_encode_method(amqp_method_number_t methodNumber,
- void *decoded,
- amqp_bytes_t encoded);
-extern int amqp_encode_properties(uint16_t class_id,
- void *decoded,
- amqp_bytes_t encoded);
+AMQP_PUBLIC_FUNCTION
+char const *
+AMQP_CALL amqp_constant_name(int constantNumber);
+
+AMQP_PUBLIC_FUNCTION
+amqp_boolean_t
+AMQP_CALL amqp_constant_is_hard_error(int constantNumber);
+
+AMQP_PUBLIC_FUNCTION
+char const *
+AMQP_CALL amqp_method_name(amqp_method_number_t methodNumber);
+
+AMQP_PUBLIC_FUNCTION
+amqp_boolean_t
+AMQP_CALL amqp_method_has_content(amqp_method_number_t methodNumber);
+
+AMQP_PUBLIC_FUNCTION
+int
+AMQP_CALL amqp_decode_method(amqp_method_number_t methodNumber,
+ amqp_pool_t *pool,
+ amqp_bytes_t encoded,
+ void **decoded);
+
+AMQP_PUBLIC_FUNCTION
+int
+AMQP_CALL amqp_decode_properties(uint16_t class_id,
+ amqp_pool_t *pool,
+ amqp_bytes_t encoded,
+ void **decoded);
+
+AMQP_PUBLIC_FUNCTION
+int
+AMQP_CALL amqp_encode_method(amqp_method_number_t methodNumber,
+ void *decoded,
+ amqp_bytes_t encoded);
+
+AMQP_PUBLIC_FUNCTION
+int
+AMQP_CALL amqp_encode_properties(uint16_t class_id,
+ void *decoded,
+ amqp_bytes_t encoded);
"""
print "/* Method field records. */\n"
@@ -625,14 +647,12 @@ extern int amqp_encode_properties(uint16_t class_id,
for m in methods:
if m.isSynchronous and apiMethodInfo.get(m.fullName()) is not False:
- print "RABBITMQ_EXPORT %s;" % (m.apiPrototype(),)
+ print "%s;" % (m.apiPrototype(),)
print """
-#ifdef __cplusplus
-}
-#endif
+AMQP_END_DECLS
-#endif"""
+#endif /* AMQP_FRAMING_H */"""
def generateErl(specPath):
genErl(AmqpSpec(specPath))
diff --git a/librabbitmq/unix/socket.c b/librabbitmq/unix/socket.c
index 5d339e6..cb8a2b9 100644
--- a/librabbitmq/unix/socket.c
+++ b/librabbitmq/unix/socket.c
@@ -30,19 +30,31 @@
* ***** END LICENSE BLOCK *****
*/
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#endif
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <unistd.h>
+#include "amqp_private.h"
+#include "socket.h"
#include <fcntl.h>
#include <stdint.h>
-#include <string.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <unistd.h>
-#include "amqp.h"
-#include "amqp_private.h"
-#include "socket.h"
+int
+amqp_socket_init(void)
+{
+ return 0;
+}
+
+int
+amqp_socket_error(void)
+{
+ return errno | ERROR_CATEGORY_OS;
+}
int amqp_socket_socket(int domain, int type, int proto)
{
diff --git a/librabbitmq/unix/socket.h b/librabbitmq/unix/socket.h
index af86ffb..ff6fa73 100644
--- a/librabbitmq/unix/socket.h
+++ b/librabbitmq/unix/socket.h
@@ -34,28 +34,25 @@
*/
#include <errno.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <sys/uio.h>
-#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <unistd.h>
-static inline int amqp_socket_init(void)
-{
- return 0;
-}
+int
+amqp_socket_init(void);
-extern int amqp_socket_socket(int domain, int type, int proto);
+int
+amqp_socket_socket(int domain, int type, int proto);
+
+int
+amqp_socket_error(void);
#define amqp_socket_setsockopt setsockopt
#define amqp_socket_close close
#define amqp_socket_writev writev
-static inline int amqp_socket_error()
-{
- return errno | ERROR_CATEGORY_OS;
-}
-
#endif
diff --git a/librabbitmq/win32/msinttypes/inttypes.h b/librabbitmq/win32/msinttypes/inttypes.h
new file mode 100644
index 0000000..4b3828a
--- /dev/null
+++ b/librabbitmq/win32/msinttypes/inttypes.h
@@ -0,0 +1,305 @@
+// ISO C9x compliant inttypes.h for Microsoft Visual Studio
+// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
+//
+// Copyright (c) 2006 Alexander Chemeris
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// 3. The name of the author may be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _MSC_VER // [
+#error "Use this header only with Microsoft Visual C++ compilers!"
+#endif // _MSC_VER ]
+
+#ifndef _MSC_INTTYPES_H_ // [
+#define _MSC_INTTYPES_H_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif
+
+#include "stdint.h"
+
+// 7.8 Format conversion of integer types
+
+typedef struct {
+ intmax_t quot;
+ intmax_t rem;
+} imaxdiv_t;
+
+// 7.8.1 Macros for format specifiers
+
+#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198
+
+// The fprintf macros for signed integers are:
+#define PRId8 "d"
+#define PRIi8 "i"
+#define PRIdLEAST8 "d"
+#define PRIiLEAST8 "i"
+#define PRIdFAST8 "d"
+#define PRIiFAST8 "i"
+
+#define PRId16 "hd"
+#define PRIi16 "hi"
+#define PRIdLEAST16 "hd"
+#define PRIiLEAST16 "hi"
+#define PRIdFAST16 "hd"
+#define PRIiFAST16 "hi"
+
+#define PRId32 "I32d"
+#define PRIi32 "I32i"
+#define PRIdLEAST32 "I32d"
+#define PRIiLEAST32 "I32i"
+#define PRIdFAST32 "I32d"
+#define PRIiFAST32 "I32i"
+
+#define PRId64 "I64d"
+#define PRIi64 "I64i"
+#define PRIdLEAST64 "I64d"
+#define PRIiLEAST64 "I64i"
+#define PRIdFAST64 "I64d"
+#define PRIiFAST64 "I64i"
+
+#define PRIdMAX "I64d"
+#define PRIiMAX "I64i"
+
+#define PRIdPTR "Id"
+#define PRIiPTR "Ii"
+
+// The fprintf macros for unsigned integers are:
+#define PRIo8 "o"
+#define PRIu8 "u"
+#define PRIx8 "x"
+#define PRIX8 "X"
+#define PRIoLEAST8 "o"
+#define PRIuLEAST8 "u"
+#define PRIxLEAST8 "x"
+#define PRIXLEAST8 "X"
+#define PRIoFAST8 "o"
+#define PRIuFAST8 "u"
+#define PRIxFAST8 "x"
+#define PRIXFAST8 "X"
+
+#define PRIo16 "ho"
+#define PRIu16 "hu"
+#define PRIx16 "hx"
+#define PRIX16 "hX"
+#define PRIoLEAST16 "ho"
+#define PRIuLEAST16 "hu"
+#define PRIxLEAST16 "hx"
+#define PRIXLEAST16 "hX"
+#define PRIoFAST16 "ho"
+#define PRIuFAST16 "hu"
+#define PRIxFAST16 "hx"
+#define PRIXFAST16 "hX"
+
+#define PRIo32 "I32o"
+#define PRIu32 "I32u"
+#define PRIx32 "I32x"
+#define PRIX32 "I32X"
+#define PRIoLEAST32 "I32o"
+#define PRIuLEAST32 "I32u"
+#define PRIxLEAST32 "I32x"
+#define PRIXLEAST32 "I32X"
+#define PRIoFAST32 "I32o"
+#define PRIuFAST32 "I32u"
+#define PRIxFAST32 "I32x"
+#define PRIXFAST32 "I32X"
+
+#define PRIo64 "I64o"
+#define PRIu64 "I64u"
+#define PRIx64 "I64x"
+#define PRIX64 "I64X"
+#define PRIoLEAST64 "I64o"
+#define PRIuLEAST64 "I64u"
+#define PRIxLEAST64 "I64x"
+#define PRIXLEAST64 "I64X"
+#define PRIoFAST64 "I64o"
+#define PRIuFAST64 "I64u"
+#define PRIxFAST64 "I64x"
+#define PRIXFAST64 "I64X"
+
+#define PRIoMAX "I64o"
+#define PRIuMAX "I64u"
+#define PRIxMAX "I64x"
+#define PRIXMAX "I64X"
+
+#define PRIoPTR "Io"
+#define PRIuPTR "Iu"
+#define PRIxPTR "Ix"
+#define PRIXPTR "IX"
+
+// The fscanf macros for signed integers are:
+#define SCNd8 "d"
+#define SCNi8 "i"
+#define SCNdLEAST8 "d"
+#define SCNiLEAST8 "i"
+#define SCNdFAST8 "d"
+#define SCNiFAST8 "i"
+
+#define SCNd16 "hd"
+#define SCNi16 "hi"
+#define SCNdLEAST16 "hd"
+#define SCNiLEAST16 "hi"
+#define SCNdFAST16 "hd"
+#define SCNiFAST16 "hi"
+
+#define SCNd32 "ld"
+#define SCNi32 "li"
+#define SCNdLEAST32 "ld"
+#define SCNiLEAST32 "li"
+#define SCNdFAST32 "ld"
+#define SCNiFAST32 "li"
+
+#define SCNd64 "I64d"
+#define SCNi64 "I64i"
+#define SCNdLEAST64 "I64d"
+#define SCNiLEAST64 "I64i"
+#define SCNdFAST64 "I64d"
+#define SCNiFAST64 "I64i"
+
+#define SCNdMAX "I64d"
+#define SCNiMAX "I64i"
+
+#ifdef _WIN64 // [
+# define SCNdPTR "I64d"
+# define SCNiPTR "I64i"
+#else // _WIN64 ][
+# define SCNdPTR "ld"
+# define SCNiPTR "li"
+#endif // _WIN64 ]
+
+// The fscanf macros for unsigned integers are:
+#define SCNo8 "o"
+#define SCNu8 "u"
+#define SCNx8 "x"
+#define SCNX8 "X"
+#define SCNoLEAST8 "o"
+#define SCNuLEAST8 "u"
+#define SCNxLEAST8 "x"
+#define SCNXLEAST8 "X"
+#define SCNoFAST8 "o"
+#define SCNuFAST8 "u"
+#define SCNxFAST8 "x"
+#define SCNXFAST8 "X"
+
+#define SCNo16 "ho"
+#define SCNu16 "hu"
+#define SCNx16 "hx"
+#define SCNX16 "hX"
+#define SCNoLEAST16 "ho"
+#define SCNuLEAST16 "hu"
+#define SCNxLEAST16 "hx"
+#define SCNXLEAST16 "hX"
+#define SCNoFAST16 "ho"
+#define SCNuFAST16 "hu"
+#define SCNxFAST16 "hx"
+#define SCNXFAST16 "hX"
+
+#define SCNo32 "lo"
+#define SCNu32 "lu"
+#define SCNx32 "lx"
+#define SCNX32 "lX"
+#define SCNoLEAST32 "lo"
+#define SCNuLEAST32 "lu"
+#define SCNxLEAST32 "lx"
+#define SCNXLEAST32 "lX"
+#define SCNoFAST32 "lo"
+#define SCNuFAST32 "lu"
+#define SCNxFAST32 "lx"
+#define SCNXFAST32 "lX"
+
+#define SCNo64 "I64o"
+#define SCNu64 "I64u"
+#define SCNx64 "I64x"
+#define SCNX64 "I64X"
+#define SCNoLEAST64 "I64o"
+#define SCNuLEAST64 "I64u"
+#define SCNxLEAST64 "I64x"
+#define SCNXLEAST64 "I64X"
+#define SCNoFAST64 "I64o"
+#define SCNuFAST64 "I64u"
+#define SCNxFAST64 "I64x"
+#define SCNXFAST64 "I64X"
+
+#define SCNoMAX "I64o"
+#define SCNuMAX "I64u"
+#define SCNxMAX "I64x"
+#define SCNXMAX "I64X"
+
+#ifdef _WIN64 // [
+# define SCNoPTR "I64o"
+# define SCNuPTR "I64u"
+# define SCNxPTR "I64x"
+# define SCNXPTR "I64X"
+#else // _WIN64 ][
+# define SCNoPTR "lo"
+# define SCNuPTR "lu"
+# define SCNxPTR "lx"
+# define SCNXPTR "lX"
+#endif // _WIN64 ]
+
+#endif // __STDC_FORMAT_MACROS ]
+
+// 7.8.2 Functions for greatest-width integer types
+
+// 7.8.2.1 The imaxabs function
+#define imaxabs _abs64
+
+// 7.8.2.2 The imaxdiv function
+
+// This is modified version of div() function from Microsoft's div.c found
+// in %MSVC.NET%\crt\src\div.c
+#ifdef STATIC_IMAXDIV // [
+static
+#else // STATIC_IMAXDIV ][
+_inline
+#endif // STATIC_IMAXDIV ]
+imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)
+{
+ imaxdiv_t result;
+
+ result.quot = numer / denom;
+ result.rem = numer % denom;
+
+ if (numer < 0 && result.rem > 0) {
+ // did division wrong; must fix up
+ ++result.quot;
+ result.rem -= denom;
+ }
+
+ return result;
+}
+
+// 7.8.2.3 The strtoimax and strtoumax functions
+#define strtoimax _strtoi64
+#define strtoumax _strtoui64
+
+// 7.8.2.4 The wcstoimax and wcstoumax functions
+#define wcstoimax _wcstoi64
+#define wcstoumax _wcstoui64
+
+
+#endif // _MSC_INTTYPES_H_ ]
diff --git a/librabbitmq/win32/msinttypes/stdint.h b/librabbitmq/win32/msinttypes/stdint.h
new file mode 100644
index 0000000..d02608a
--- /dev/null
+++ b/librabbitmq/win32/msinttypes/stdint.h
@@ -0,0 +1,247 @@
+// ISO C9x compliant stdint.h for Microsoft Visual Studio
+// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
+//
+// Copyright (c) 2006-2008 Alexander Chemeris
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// 3. The name of the author may be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _MSC_VER // [
+#error "Use this header only with Microsoft Visual C++ compilers!"
+#endif // _MSC_VER ]
+
+#ifndef _MSC_STDINT_H_ // [
+#define _MSC_STDINT_H_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif
+
+#include <limits.h>
+
+// For Visual Studio 6 in C++ mode and for many Visual Studio versions when
+// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
+// or compiler give many errors like this:
+// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
+#ifdef __cplusplus
+extern "C" {
+#endif
+# include <wchar.h>
+#ifdef __cplusplus
+}
+#endif
+
+// Define _W64 macros to mark types changing their size, like intptr_t.
+#ifndef _W64
+# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
+# define _W64 __w64
+# else
+# define _W64
+# endif
+#endif
+
+
+// 7.18.1 Integer types
+
+// 7.18.1.1 Exact-width integer types
+
+// Visual Studio 6 and Embedded Visual C++ 4 doesn't
+// realize that, e.g. char has the same size as __int8
+// so we give up on __intX for them.
+#if (_MSC_VER < 1300)
+ typedef signed char int8_t;
+ typedef signed short int16_t;
+ typedef signed int int32_t;
+ typedef unsigned char uint8_t;
+ typedef unsigned short uint16_t;
+ typedef unsigned int uint32_t;
+#else
+ typedef signed __int8 int8_t;
+ typedef signed __int16 int16_t;
+ typedef signed __int32 int32_t;
+ typedef unsigned __int8 uint8_t;
+ typedef unsigned __int16 uint16_t;
+ typedef unsigned __int32 uint32_t;
+#endif
+typedef signed __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+
+
+// 7.18.1.2 Minimum-width integer types
+typedef int8_t int_least8_t;
+typedef int16_t int_least16_t;
+typedef int32_t int_least32_t;
+typedef int64_t int_least64_t;
+typedef uint8_t uint_least8_t;
+typedef uint16_t uint_least16_t;
+typedef uint32_t uint_least32_t;
+typedef uint64_t uint_least64_t;
+
+// 7.18.1.3 Fastest minimum-width integer types
+typedef int8_t int_fast8_t;
+typedef int16_t int_fast16_t;
+typedef int32_t int_fast32_t;
+typedef int64_t int_fast64_t;
+typedef uint8_t uint_fast8_t;
+typedef uint16_t uint_fast16_t;
+typedef uint32_t uint_fast32_t;
+typedef uint64_t uint_fast64_t;
+
+// 7.18.1.4 Integer types capable of holding object pointers
+#ifdef _WIN64 // [
+ typedef signed __int64 intptr_t;
+ typedef unsigned __int64 uintptr_t;
+#else // _WIN64 ][
+ typedef _W64 signed int intptr_t;
+ typedef _W64 unsigned int uintptr_t;
+#endif // _WIN64 ]
+
+// 7.18.1.5 Greatest-width integer types
+typedef int64_t intmax_t;
+typedef uint64_t uintmax_t;
+
+
+// 7.18.2 Limits of specified-width integer types
+
+#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
+
+// 7.18.2.1 Limits of exact-width integer types
+#define INT8_MIN ((int8_t)_I8_MIN)
+#define INT8_MAX _I8_MAX
+#define INT16_MIN ((int16_t)_I16_MIN)
+#define INT16_MAX _I16_MAX
+#define INT32_MIN ((int32_t)_I32_MIN)
+#define INT32_MAX _I32_MAX
+#define INT64_MIN ((int64_t)_I64_MIN)
+#define INT64_MAX _I64_MAX
+#define UINT8_MAX _UI8_MAX
+#define UINT16_MAX _UI16_MAX
+#define UINT32_MAX _UI32_MAX
+#define UINT64_MAX _UI64_MAX
+
+// 7.18.2.2 Limits of minimum-width integer types
+#define INT_LEAST8_MIN INT8_MIN
+#define INT_LEAST8_MAX INT8_MAX
+#define INT_LEAST16_MIN INT16_MIN
+#define INT_LEAST16_MAX INT16_MAX
+#define INT_LEAST32_MIN INT32_MIN
+#define INT_LEAST32_MAX INT32_MAX
+#define INT_LEAST64_MIN INT64_MIN
+#define INT_LEAST64_MAX INT64_MAX
+#define UINT_LEAST8_MAX UINT8_MAX
+#define UINT_LEAST16_MAX UINT16_MAX
+#define UINT_LEAST32_MAX UINT32_MAX
+#define UINT_LEAST64_MAX UINT64_MAX
+
+// 7.18.2.3 Limits of fastest minimum-width integer types
+#define INT_FAST8_MIN INT8_MIN
+#define INT_FAST8_MAX INT8_MAX
+#define INT_FAST16_MIN INT16_MIN
+#define INT_FAST16_MAX INT16_MAX
+#define INT_FAST32_MIN INT32_MIN
+#define INT_FAST32_MAX INT32_MAX
+#define INT_FAST64_MIN INT64_MIN
+#define INT_FAST64_MAX INT64_MAX
+#define UINT_FAST8_MAX UINT8_MAX
+#define UINT_FAST16_MAX UINT16_MAX
+#define UINT_FAST32_MAX UINT32_MAX
+#define UINT_FAST64_MAX UINT64_MAX
+
+// 7.18.2.4 Limits of integer types capable of holding object pointers
+#ifdef _WIN64 // [
+# define INTPTR_MIN INT64_MIN
+# define INTPTR_MAX INT64_MAX
+# define UINTPTR_MAX UINT64_MAX
+#else // _WIN64 ][
+# define INTPTR_MIN INT32_MIN
+# define INTPTR_MAX INT32_MAX
+# define UINTPTR_MAX UINT32_MAX
+#endif // _WIN64 ]
+
+// 7.18.2.5 Limits of greatest-width integer types
+#define INTMAX_MIN INT64_MIN
+#define INTMAX_MAX INT64_MAX
+#define UINTMAX_MAX UINT64_MAX
+
+// 7.18.3 Limits of other integer types
+
+#ifdef _WIN64 // [
+# define PTRDIFF_MIN _I64_MIN
+# define PTRDIFF_MAX _I64_MAX
+#else // _WIN64 ][
+# define PTRDIFF_MIN _I32_MIN
+# define PTRDIFF_MAX _I32_MAX
+#endif // _WIN64 ]
+
+#define SIG_ATOMIC_MIN INT_MIN
+#define SIG_ATOMIC_MAX INT_MAX
+
+#ifndef SIZE_MAX // [
+# ifdef _WIN64 // [
+# define SIZE_MAX _UI64_MAX
+# else // _WIN64 ][
+# define SIZE_MAX _UI32_MAX
+# endif // _WIN64 ]
+#endif // SIZE_MAX ]
+
+// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
+#ifndef WCHAR_MIN // [
+# define WCHAR_MIN 0
+#endif // WCHAR_MIN ]
+#ifndef WCHAR_MAX // [
+# define WCHAR_MAX _UI16_MAX
+#endif // WCHAR_MAX ]
+
+#define WINT_MIN 0
+#define WINT_MAX _UI16_MAX
+
+#endif // __STDC_LIMIT_MACROS ]
+
+
+// 7.18.4 Limits of other integer types
+
+#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
+
+// 7.18.4.1 Macros for minimum-width integer constants
+
+#define INT8_C(val) val##i8
+#define INT16_C(val) val##i16
+#define INT32_C(val) val##i32
+#define INT64_C(val) val##i64
+
+#define UINT8_C(val) val##ui8
+#define UINT16_C(val) val##ui16
+#define UINT32_C(val) val##ui32
+#define UINT64_C(val) val##ui64
+
+// 7.18.4.2 Macros for greatest-width integer constants
+#define INTMAX_C INT64_C
+#define UINTMAX_C UINT64_C
+
+#endif // __STDC_CONSTANT_MACROS ]
+
+
+#endif // _MSC_STDINT_H_ ]
diff --git a/librabbitmq/windows/socket.c b/librabbitmq/win32/socket.c
index faf6819..43b919b 100644
--- a/librabbitmq/windows/socket.c
+++ b/librabbitmq/win32/socket.c
@@ -33,15 +33,15 @@
/* See http://msdn.microsoft.com/en-us/library/ms737629%28VS.85%29.aspx */
#define WIN32_LEAN_AND_MEAN
+#ifdef HAVE_CONFIG_H
#include "config.h"
+#endif
-#include <windows.h>
-#include <stdint.h>
-#include <stdlib.h>
-
-#include "amqp.h"
#include "amqp_private.h"
#include "socket.h"
+#include <stdint.h>
+#include <stdlib.h>
+#include <windows.h>
static int called_wsastartup;
@@ -74,3 +74,28 @@ char *amqp_os_error_string(int err)
LocalFree(msg);
return copy;
}
+
+int
+amqp_socket_setsockopt(int sock, int level, int optname,
+ const void *optval, size_t optlen)
+{
+ /* the winsock setsockopt function has its 4th argument as a
+ const char * */
+ return setsockopt(sock, level, optname, (const char *)optval, optlen);
+}
+
+int
+amqp_socket_writev(int sock, struct iovec *iov, int nvecs)
+{
+ DWORD ret;
+ if (WSASend(sock, (LPWSABUF)iov, nvecs, &ret, 0, NULL, NULL) == 0)
+ return ret;
+ else
+ return -1;
+}
+
+int
+amqp_socket_error(void)
+{
+ return WSAGetLastError() | ERROR_CATEGORY_OS;
+}
diff --git a/librabbitmq/windows/socket.h b/librabbitmq/win32/socket.h
index 0665b3a..4572410 100644
--- a/librabbitmq/windows/socket.h
+++ b/librabbitmq/win32/socket.h
@@ -35,37 +35,26 @@
#include <winsock2.h>
-extern int amqp_socket_init(void);
-
-#define amqp_socket_socket socket
-#define amqp_socket_close closesocket
-
-static inline int amqp_socket_setsockopt(int sock, int level, int optname,
- const void *optval, size_t optlen)
-{
- /* the winsock setsockopt function has its 4th argument as a
- const char * */
- return setsockopt(sock, level, optname, (const char *)optval, optlen);
-}
-
/* same as WSABUF */
struct iovec {
u_long iov_len;
void *iov_base;
};
-static inline int amqp_socket_writev(int sock, struct iovec *iov, int nvecs)
-{
- DWORD ret;
- if (WSASend(sock, (LPWSABUF)iov, nvecs, &ret, 0, NULL, NULL) == 0)
- return ret;
- else
- return -1;
-}
+int
+amqp_socket_init(void);
+
+#define amqp_socket_socket socket
+#define amqp_socket_close closesocket
+
+int
+amqp_socket_setsockopt(int sock, int level, int optname, const void *optval,
+ size_t optlen);
+
+int
+amqp_socket_writev(int sock, struct iovec *iov, int nvecs);
-static inline int amqp_socket_error()
-{
- return WSAGetLastError() | ERROR_CATEGORY_OS;
-}
+int
+amqp_socket_error(void);
#endif