From ca8996472c5e855087bacf947186d919b653ab7d Mon Sep 17 00:00:00 2001 From: "Robin Burchell w00t@inspircd.org" Date: Tue, 30 Sep 2008 18:45:10 +0000 Subject: [PATCH] Merge send_cmd() and vsend_cmd(). git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1205 5417fbe8-f217-4b02-8779-1006273d7864 --- include/extern.h | 2 -- src/send.c | 55 +++++++++++++++++------------------------------- 2 files changed, 19 insertions(+), 38 deletions(-) diff --git a/include/extern.h b/include/extern.h index d92c35a4c..4708457f7 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1013,8 +1013,6 @@ E void process(void); E void send_cmd(const char *source, const char *fmt, ...) FORMAT(printf,2,3); -E void vsend_cmd(const char *source, const char *fmt, va_list args) - FORMAT(printf,2,0); E void notice_server(char *source, Server * s, char *fmt, ...) FORMAT(printf,3,4); diff --git a/src/send.c b/src/send.c index e3c443e48..bd03cc4a6 100644 --- a/src/send.c +++ b/src/send.c @@ -26,46 +26,29 @@ */ void send_cmd(const char *source, const char *fmt, ...) { - va_list args; + va_list args; + static char buf[BUFSIZE]; - if (fmt) { - va_start(args, fmt); - vsend_cmd(source, fmt, args); - va_end(args); - } -} + va_start(args, fmt); -/*************************************************************************/ + vsnprintf(buf, BUFSIZE - 1, fmt, args); -/** - * actually Send a command to the server. - * @param source Orgin of the Message (some times NULL) - * @param fmt Format of the Message - * @param args List of the arguments - * @return void - */ -void vsend_cmd(const char *source, const char *fmt, va_list args) -{ - char buf[BUFSIZE]; - *buf = '\0'; + if (source) + { + sockprintf(servsock, ":%s %s\r\n", source, buf); + eventprintf(":%s %s", source, buf); + if (debug) + alog("debug: Sent: :%s %s", source, buf); + } + else + { + sockprintf(servsock, "%s\r\n", buf); + eventprintf("%s", buf); + if (debug) + alog("debug: Sent: %s", buf); + } - if (fmt) { - vsnprintf(buf, BUFSIZE - 1, fmt, args); - - if (source) { - sockprintf(servsock, ":%s %s\r\n", source, buf); - eventprintf(":%s %s", source, buf); - if (debug) { - alog("debug: Sent: :%s %s", source, buf); - } - } else { - sockprintf(servsock, "%s\r\n", buf); - eventprintf("%s", buf); - if (debug) { - alog("debug: Sent: %s", buf); - } - } - } + va_end(args); } /*************************************************************************/