diff options
author | Tony Garnock-Jones <tonyg@kcbbs.gen.nz> | 2009-04-27 00:44:59 +0100 |
---|---|---|
committer | Tony Garnock-Jones <tonyg@kcbbs.gen.nz> | 2009-04-27 00:44:59 +0100 |
commit | 3a51512706eb5dcebb6c8e2d4dcd571273f49899 (patch) | |
tree | 7cd5af04f901aba44f1ce43bccb6685b97ef33f6 /librabbitmq | |
parent | e954a0bf0d30c21b5563db2fd07e5d85d076edc2 (diff) | |
download | rabbitmq-c-github-ask-3a51512706eb5dcebb6c8e2d4dcd571273f49899.tar.gz |
More examples; clean shutdown
Diffstat (limited to 'librabbitmq')
-rw-r--r-- | librabbitmq/amqp.h | 4 | ||||
-rw-r--r-- | librabbitmq/amqp_mem.c | 7 | ||||
-rw-r--r-- | librabbitmq/amqp_socket.c | 30 |
3 files changed, 41 insertions, 0 deletions
diff --git a/librabbitmq/amqp.h b/librabbitmq/amqp.h index 18a7c76..03b682f 100644 --- a/librabbitmq/amqp.h +++ b/librabbitmq/amqp.h @@ -102,6 +102,7 @@ extern void *amqp_pool_alloc(amqp_pool_t *pool, size_t amount); extern void amqp_pool_alloc_bytes(amqp_pool_t *pool, size_t amount, amqp_bytes_t *output); extern amqp_bytes_t amqp_cstring_bytes(char const *cstr); +extern amqp_bytes_t amqp_bytes_malloc_dup(amqp_bytes_t src); extern amqp_connection_state_t amqp_new_connection(void); extern void amqp_set_sockfd(amqp_connection_state_t state, @@ -163,6 +164,9 @@ extern int amqp_basic_publish(amqp_connection_state_t state, struct amqp_basic_properties_t_ const *properties, amqp_bytes_t body); +extern amqp_rpc_reply_t amqp_channel_close(amqp_connection_state_t state, int code); +extern amqp_rpc_reply_t amqp_connection_close(amqp_connection_state_t state, int code); + #ifdef __cplusplus } #endif diff --git a/librabbitmq/amqp_mem.c b/librabbitmq/amqp_mem.c index e0795d2..79d7e08 100644 --- a/librabbitmq/amqp_mem.c +++ b/librabbitmq/amqp_mem.c @@ -113,3 +113,10 @@ amqp_bytes_t amqp_cstring_bytes(char const *cstr) { return result; } +amqp_bytes_t amqp_bytes_malloc_dup(amqp_bytes_t src) { + amqp_bytes_t result; + result.len = src.len; + result.bytes = malloc(src.len); + memcpy(result.bytes, src.bytes, src.len); + return result; +} diff --git a/librabbitmq/amqp_socket.c b/librabbitmq/amqp_socket.c index 20686c4..02e5728 100644 --- a/librabbitmq/amqp_socket.c +++ b/librabbitmq/amqp_socket.c @@ -418,3 +418,33 @@ int amqp_basic_publish(amqp_connection_state_t state, return 0; } + +amqp_rpc_reply_t amqp_channel_close(amqp_connection_state_t state, int code) { + amqp_channel_close_t s = + (amqp_channel_close_t) { + .reply_code = code, + .reply_text = {.len = 0, .bytes = NULL}, + .class_id = 0, + .method_id = 0 + }; + return amqp_simple_rpc(state, + 1, + AMQP_CHANNEL_CLOSE_METHOD, + AMQP_CHANNEL_CLOSE_OK_METHOD, + &s); +} + +amqp_rpc_reply_t amqp_connection_close(amqp_connection_state_t state, int code) { + amqp_connection_close_t s = + (amqp_connection_close_t) { + .reply_code = code, + .reply_text = {.len = 0, .bytes = NULL}, + .class_id = 0, + .method_id = 0 + }; + return amqp_simple_rpc(state, + 0, + AMQP_CONNECTION_CLOSE_METHOD, + AMQP_CONNECTION_CLOSE_OK_METHOD, + &s); +} |