Debian Codegraph @

tools/declare_queue.c

raw symbols SCIP
1 // Copyright 2007 - 2021, Alan Antonuk and the rabbitmq-c contributors.
2 // SPDX-License-Identifier: mit
3
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include <unistd.h>
8
9 #include "common.h"
10
11 int main(int argc, const char **argv) {
12 amqp_connection_state_t conn;
13 static char *queue = NULL;
14 static int durable = 0;
15
16 struct poptOption options[] = {
17 INCLUDE_OPTIONS(connect_options),
18 {"queue", 'q', POPT_ARG_STRING, &queue, 0,
19 "the queue name to declare, or the empty string", "queue"},
20 {"durable", 'd', POPT_ARG_VAL, &durable, 1, "declare a durable queue",
21 NULL},
22 POPT_AUTOHELP{NULL, '\0', 0, NULL, 0, NULL, NULL}};
23
24 process_all_options(argc, argv, options);
25
26 if (queue == NULL) {
27 fprintf(stderr, "queue name not specified\n");
28 return 1;
29 }
30
31 conn = make_connection();
32 {
33 amqp_queue_declare_ok_t *reply = amqp_queue_declare(
34 conn, 1, cstring_bytes(queue), 0, durable, 0, 0, amqp_empty_table);
35 if (reply == NULL) {
36 die_rpc(amqp_get_rpc_reply(conn), "queue.declare");
37 }
38
39 printf("%.*s\n", (int)reply->queue.len, (char *)reply->queue.bytes);
40 }
41 close_connection(conn);
42 return 0;
43 }