diff options
Diffstat (limited to 'src/send.c')
-rw-r--r-- | src/send.c | 63 |
1 files changed, 23 insertions, 40 deletions
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; - - if (fmt) { - va_start(args, fmt); - vsend_cmd(source, fmt, args); - va_end(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 (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_list args; + static char buf[BUFSIZE]; + + va_start(args, 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); } /*************************************************************************/ |