~ubuntu-cloud-archive/ubuntu/precise/librabbitmq/precise-icehouse

« back to all changes in this revision

Viewing changes to tools/declare_queue.c

  • Committer: Package Import Robot
  • Author(s): Michael Fladischer
  • Date: 2013-11-04 20:15:55 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20131104201555-wdjlgotdjansj1j9
Tags: 0.4.1-1
* Imported Upstream version 0.4.1
* Add libssl-dev to Build-Depends.
* Update librabbitmq1.symbols.
* Switch buildsystem to cmake.
  + Add cmake_multiarch.patch to fix multiarch installation paths for shared
    library files in cmake.
  * Add cmake to Build-Depends.
  * Drop dh-autoreconf from Build-Depends.
* Format packaging files with wrap-and-sort.
* Update d/watch file to use github releases instead of tags.
* Bump Standards version to 3.9.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */
1
2
/*
2
3
 * ***** BEGIN LICENSE BLOCK *****
3
4
 * Version: MIT
4
5
 *
 
6
 * Portions created by Alan Antonuk are Copyright (c) 2012-2013
 
7
 * Alan Antonuk. All Rights Reserved.
 
8
 *
5
9
 * Portions created by VMware are Copyright (c) 2007-2012 VMware, Inc.
6
10
 * All Rights Reserved.
7
11
 *
43
47
 
44
48
int main(int argc, const char **argv)
45
49
{
46
 
        amqp_connection_state_t conn;
47
 
        char *queue = NULL;
48
 
        int durable = 0;
49
 
 
50
 
        struct poptOption options[] = {
51
 
                INCLUDE_OPTIONS(connect_options),
52
 
                {"queue", 'q', POPT_ARG_STRING, &queue, 0,
53
 
                 "the queue name to declare, or the empty string", "queue"},
54
 
                {"durable", 'd', POPT_ARG_VAL, &durable, 1,
55
 
                 "declare a durable queue", NULL},
56
 
                POPT_AUTOHELP
57
 
                { NULL, '\0', 0, NULL, 0, NULL, NULL }
58
 
        };
59
 
 
60
 
        process_all_options(argc, argv, options);
61
 
 
62
 
        if (queue == NULL) {
63
 
          fprintf(stderr, "queue name not specified\n");
64
 
          return 1;
65
 
        }
66
 
 
67
 
        conn = make_connection();
68
 
        {
69
 
          amqp_queue_declare_ok_t *reply = amqp_queue_declare(conn, 1,
70
 
                                                              cstring_bytes(queue),
71
 
                                                              0,
72
 
                                                              durable,
73
 
                                                              0,
74
 
                                                              0,
75
 
                                                              amqp_empty_table);
76
 
          if (reply == NULL)
77
 
            die_rpc(amqp_get_rpc_reply(conn), "queue.declare");
78
 
 
79
 
          printf("%.*s\n", (int)reply->queue.len, (char *)reply->queue.bytes);
80
 
        }
81
 
        close_connection(conn);
82
 
        return 0;
 
50
  amqp_connection_state_t conn;
 
51
  char *queue = NULL;
 
52
  int durable = 0;
 
53
 
 
54
  struct poptOption options[] = {
 
55
    INCLUDE_OPTIONS(connect_options),
 
56
    {
 
57
      "queue", 'q', POPT_ARG_STRING, &queue, 0,
 
58
      "the queue name to declare, or the empty string", "queue"
 
59
    },
 
60
    {
 
61
      "durable", 'd', POPT_ARG_VAL, &durable, 1,
 
62
      "declare a durable queue", NULL
 
63
    },
 
64
    POPT_AUTOHELP
 
65
    { NULL, '\0', 0, NULL, 0, NULL, NULL }
 
66
  };
 
67
 
 
68
  process_all_options(argc, argv, options);
 
69
 
 
70
  if (queue == NULL) {
 
71
    fprintf(stderr, "queue name not specified\n");
 
72
    return 1;
 
73
  }
 
74
 
 
75
  conn = make_connection();
 
76
  {
 
77
    amqp_queue_declare_ok_t *reply = amqp_queue_declare(conn, 1,
 
78
                                     cstring_bytes(queue),
 
79
                                     0,
 
80
                                     durable,
 
81
                                     0,
 
82
                                     0,
 
83
                                     amqp_empty_table);
 
84
    if (reply == NULL) {
 
85
      die_rpc(amqp_get_rpc_reply(conn), "queue.declare");
 
86
    }
 
87
 
 
88
    printf("%.*s\n", (int)reply->queue.len, (char *)reply->queue.bytes);
 
89
  }
 
90
  close_connection(conn);
 
91
  return 0;
83
92
}