From 6e574a2021ec1662229c2362761271f436be260c Mon Sep 17 00:00:00 2001 From: Leonid Evdokimov Date: Sat, 27 Nov 2010 23:30:58 +0200 Subject: [PATCH] Another source code cleanup. --- redsocks.c | 9 ++------- utils.h | 9 +++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/redsocks.c b/redsocks.c index 19b73c6..befc4e6 100644 --- a/redsocks.c +++ b/redsocks.c @@ -373,14 +373,9 @@ static void redsocks_event_error(struct bufferevent *buffev, short what, void *_ } else { errno = redsocks_socket_geterrno(client, buffev); - redsocks_log_errno(client, LOG_NOTICE, "%s error, code %s|%s|%s|%s|%s == %X", + redsocks_log_errno(client, LOG_NOTICE, "%s error, code " event_fmt_str, buffev == client->relay ? "relay" : "client", - what & EVBUFFER_READ ? "EVBUFFER_READ" : "0", - what & EVBUFFER_WRITE ? "EVBUFFER_WRITE" : "0", - what & EVBUFFER_EOF ? "EVBUFFER_EOF" : "0", - what & EVBUFFER_ERROR ? "EVBUFFER_ERROR" : "0", - what & EVBUFFER_TIMEOUT ? "EVBUFFER_TIMEOUT" : "0", - what); + event_fmt(what)); redsocks_drop_client(client); } } diff --git a/utils.h b/utils.h index d7ae73b..e87fd6e 100644 --- a/utils.h +++ b/utils.h @@ -30,6 +30,15 @@ int red_is_socket_connected_ok(struct bufferevent *buffev); int fcntl_nonblock(int fd); +#define event_fmt_str "%s|%s|%s|%s|%s|0x%x" +#define event_fmt(what) \ + (what) & EVBUFFER_READ ? "EVBUFFER_READ" : "0", \ + (what) & EVBUFFER_WRITE ? "EVBUFFER_WRITE" : "0", \ + (what) & EVBUFFER_EOF ? "EVBUFFER_EOF" : "0", \ + (what) & EVBUFFER_ERROR ? "EVBUFFER_ERROR" : "0", \ + (what) & EVBUFFER_TIMEOUT ? "EVBUFFER_TIMEOUT" : "0", \ + (what) & ~(EVBUFFER_READ|EVBUFFER_WRITE|EVBUFFER_EOF|EVBUFFER_ERROR|EVBUFFER_TIMEOUT) + /* vim:set tabstop=4 softtabstop=4 shiftwidth=4: */ /* vim:set foldmethod=marker foldlevel=32 foldmarker={,}: */ #endif /* UTILS_H_SAT_FEB__2_02_24_05_2008 */