diff options
author | Michael Steinert <mike.steinert@gmail.com> | 2012-06-08 15:38:22 -0600 |
---|---|---|
committer | Alan Antonuk <alan.antonuk@gmail.com> | 2013-04-09 15:48:03 -0700 |
commit | 0f022fce389543404f86824ed6c5720d2502cd09 (patch) | |
tree | 6e39adb0a9268d32e6873a48723f3d84c1316e87 /examples/utils.c | |
parent | 7240f48af34aea8412473f29e93f6443f79230db (diff) | |
download | rabbitmq-c-github-ask-0f022fce389543404f86824ed6c5720d2502cd09.tar.gz |
Propose new socket API
The general idea is to have a non-instantiable socket base class.
Connection-specific sub-classes provide a constructor and methods for
modifying connection parameters. `amqp_socket_close()` is the
destructor.
Signed-off-by: Michael Steinert <mike.steinert@gmail.com>
Diffstat (limited to 'examples/utils.c')
-rw-r--r-- | examples/utils.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/examples/utils.c b/examples/utils.c index 609c354..0830738 100644 --- a/examples/utils.c +++ b/examples/utils.c @@ -34,6 +34,7 @@ * ***** END LICENSE BLOCK ***** */ +#include <stdarg.h> #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -45,8 +46,17 @@ #include "utils.h" -void die_on_error(int x, char const *context) +void die(const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + fprintf(stderr, "\n"); + exit(1); +} + +void die_on_error(int x, char const *context) { if (x < 0) { char *errstr = amqp_error_string(-x); fprintf(stderr, "%s: %s\n", context, errstr); |