aboutsummaryrefslogtreecommitdiffstats
path: root/src/helperfuncs.cpp
diff options
context:
space:
mode:
authorGravatar Daniel Vassdal2013-05-12 10:54:07 -0700
committerGravatar attilamolnar2013-05-16 21:34:45 +0200
commit6153822a2de1867b7b90b95e8ed9bc1a8c792c84 (patch)
tree4ed80311ecdd5f530997ed0443d318a0ecfdee52 /src/helperfuncs.cpp
parentFix padding bug in GenerateSID(), spotted by @ShutterQuick (diff)
Added a function to replace all the ugly sprintf-ing everywhere
Diffstat (limited to 'src/helperfuncs.cpp')
-rw-r--r--src/helperfuncs.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index c7287e661..8a74a64e4 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -424,6 +424,19 @@ unsigned long InspIRCd::Duration(const std::string &str)
return total + subtotal;
}
+const char* InspIRCd::Format(const char* formatString, ...)
+{
+ static std::vector<char> formatBuffer(1024);
+ int vsnret = 0;
+
+ va_list vaList;
+ va_start(vaList, formatString);
+ while ((vsnret = vsnprintf(&formatBuffer[0], formatBuffer.size(), formatString, vaList)) < 0 || static_cast<unsigned int>(vsnret) >= formatBuffer.size())
+ formatBuffer.resize(formatBuffer.size() * 2);
+ va_end(vaList);
+ return &formatBuffer[0];
+}
+
bool InspIRCd::ULine(const std::string& sserver)
{
if (sserver.empty())