common.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * ***** BEGIN LICENSE BLOCK *****
  3. * Version: MIT
  4. *
  5. * Portions created by Alan Antonuk are Copyright (c) 2012-2013
  6. * Alan Antonuk. All Rights Reserved.
  7. *
  8. * Portions created by VMware are Copyright (c) 2007-2012 VMware, Inc.
  9. * All Rights Reserved.
  10. *
  11. * Portions created by Tony Garnock-Jones are Copyright (c) 2009-2010
  12. * VMware, Inc. and Tony Garnock-Jones. All Rights Reserved.
  13. *
  14. * Permission is hereby granted, free of charge, to any person
  15. * obtaining a copy of this software and associated documentation
  16. * files (the "Software"), to deal in the Software without
  17. * restriction, including without limitation the rights to use, copy,
  18. * modify, merge, publish, distribute, sublicense, and/or sell copies
  19. * of the Software, and to permit persons to whom the Software is
  20. * furnished to do so, subject to the following conditions:
  21. *
  22. * The above copyright notice and this permission notice shall be
  23. * included in all copies or substantial portions of the Software.
  24. *
  25. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  26. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  27. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  28. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  29. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  30. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  31. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  32. * SOFTWARE.
  33. * ***** END LICENSE BLOCK *****
  34. */
  35. #include <stdint.h>
  36. #include <popt.h>
  37. #include <amqp.h>
  38. #include <amqp_framing.h>
  39. extern const char *amqp_server_exception_string(amqp_rpc_reply_t r);
  40. extern const char *amqp_rpc_reply_string(amqp_rpc_reply_t r);
  41. extern void die(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
  42. extern void die_errno(int err, const char *fmt, ...)
  43. __attribute__((format(printf, 2, 3)));
  44. extern void die_amqp_error(int err, const char *fmt, ...)
  45. __attribute__((format(printf, 2, 3)));
  46. extern void die_rpc(amqp_rpc_reply_t r, const char *fmt, ...)
  47. __attribute__((format(printf, 2, 3)));
  48. extern const char *connect_options_title;
  49. extern struct poptOption connect_options[];
  50. extern amqp_connection_state_t make_connection(void);
  51. extern void close_connection(amqp_connection_state_t conn);
  52. extern amqp_bytes_t read_all(int fd);
  53. extern void write_all(int fd, amqp_bytes_t data);
  54. extern void copy_body(amqp_connection_state_t conn, int fd);
  55. #define INCLUDE_OPTIONS(options) \
  56. { NULL, 0, POPT_ARG_INCLUDE_TABLE, options, 0, options##_title, NULL }
  57. extern poptContext process_options(int argc, const char **argv,
  58. struct poptOption *options,
  59. const char *help);
  60. extern void process_all_options(int argc, const char **argv,
  61. struct poptOption *options);
  62. extern amqp_bytes_t cstring_bytes(const char *str);