summaryrefslogtreecommitdiff
path: root/tools/get.c
blob: 6efccd14bf2a57d408e19446fdba29dd724b2904 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "config.h"

#include <stdio.h>

#include <popt.h>

#include "common.h"
#include "common_consume.h"

static int do_get(amqp_connection_state_t conn)
{
	amqp_rpc_reply_t r
		= amqp_basic_get(conn, 1, setup_queue(conn), 1);
	die_rpc(r, "basic.get");
	
	if (r.reply.id == AMQP_BASIC_GET_EMPTY_METHOD)
		return 0;

	copy_body(conn, 1);
	return 1;
}

int main(int argc, const char **argv)
{
	amqp_connection_state_t conn;
	int got_something;

	struct poptOption options[] = {
		INCLUDE_OPTIONS(connect_options),
		INCLUDE_OPTIONS(consume_queue_options),
		POPT_AUTOHELP
		{ NULL, 0, 0, NULL, 0 }
	};
	
	process_all_options(argc, argv, options);
	
	conn = make_connection();
	got_something = do_get(conn);
	close_connection(conn);
	return got_something ? 0 : 2;
}