From 44e1e23a738d98815911b500e275808b435fa7c6 Mon Sep 17 00:00:00 2001 From: "Robin Burchell w00t@inspircd.org" Date: Thu, 2 Oct 2008 15:17:08 +0000 Subject: Add overridden send_cmd() accepting a string source. git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1318 5417fbe8-f217-4b02-8779-1006273d7864 --- src/send.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src') diff --git a/src/send.c b/src/send.c index 79e8f5e68..d99b08dab 100644 --- a/src/send.c +++ b/src/send.c @@ -51,6 +51,36 @@ void send_cmd(const char *source, const char *fmt, ...) va_end(args); } + +/* + * Copypasta version that accepts std::string source. +void send_cmd(const std::string &source, const char *fmt, ...) +{ + va_list args; + static char buf[BUFSIZE]; + + va_start(args, fmt); + + vsnprintf(buf, BUFSIZE - 1, fmt, args); + + if (!source.empty()) + { + sockprintf(servsock, ":%s %s\r\n", source.c_str(), buf); + eventprintf(":%s %s", source, buf); + if (debug) + alog("debug: Sent: :%s %s", source.c_str(), buf); + } + else + { + sockprintf(servsock, "%s\r\n", buf); + eventprintf("%s", buf); + if (debug) + alog("debug: Sent: %s", buf); + } + + va_end(args); +} + /*************************************************************************/ /** -- cgit