diff options
Diffstat (limited to 'tools/declare_queue.c')
-rw-r--r-- | tools/declare_queue.c | 69 |
1 files changed, 37 insertions, 32 deletions
diff --git a/tools/declare_queue.c b/tools/declare_queue.c index 26c3a68..25a94b1 100644 --- a/tools/declare_queue.c +++ b/tools/declare_queue.c @@ -44,41 +44,46 @@ int main(int argc, const char **argv) { - amqp_connection_state_t conn; - char *queue = NULL; - int durable = 0; + amqp_connection_state_t conn; + char *queue = NULL; + int durable = 0; - struct poptOption options[] = { - INCLUDE_OPTIONS(connect_options), - {"queue", 'q', POPT_ARG_STRING, &queue, 0, - "the queue name to declare, or the empty string", "queue"}, - {"durable", 'd', POPT_ARG_VAL, &durable, 1, - "declare a durable queue", NULL}, - POPT_AUTOHELP - { NULL, '\0', 0, NULL, 0, NULL, NULL } - }; + struct poptOption options[] = { + INCLUDE_OPTIONS(connect_options), + { + "queue", 'q', POPT_ARG_STRING, &queue, 0, + "the queue name to declare, or the empty string", "queue" + }, + { + "durable", 'd', POPT_ARG_VAL, &durable, 1, + "declare a durable queue", NULL + }, + POPT_AUTOHELP + { NULL, '\0', 0, NULL, 0, NULL, NULL } + }; - process_all_options(argc, argv, options); + process_all_options(argc, argv, options); - if (queue == NULL) { - fprintf(stderr, "queue name not specified\n"); - return 1; - } + if (queue == NULL) { + fprintf(stderr, "queue name not specified\n"); + return 1; + } - conn = make_connection(); - { - amqp_queue_declare_ok_t *reply = amqp_queue_declare(conn, 1, - cstring_bytes(queue), - 0, - durable, - 0, - 0, - amqp_empty_table); - if (reply == NULL) - die_rpc(amqp_get_rpc_reply(conn), "queue.declare"); + conn = make_connection(); + { + amqp_queue_declare_ok_t *reply = amqp_queue_declare(conn, 1, + cstring_bytes(queue), + 0, + durable, + 0, + 0, + amqp_empty_table); + if (reply == NULL) { + die_rpc(amqp_get_rpc_reply(conn), "queue.declare"); + } - printf("%.*s\n", (int)reply->queue.len, (char *)reply->queue.bytes); - } - close_connection(conn); - return 0; + printf("%.*s\n", (int)reply->queue.len, (char *)reply->queue.bytes); + } + close_connection(conn); + return 0; } |