X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fhelperfuncs.cpp;h=2626da6bbd6132518866946809e73fd181503909;hb=e950f568d0f571e9475aa38177486468714de4d3;hp=cc760c535dfff52d2f96fc819b311f676f8d2e00;hpb=b36ce84c7da93f680fc397bcb4c877abe063eaaa;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index cc760c535..2626da6bb 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -22,8 +22,6 @@ */ -/* $Core */ - #ifdef _WIN32 #define _CRT_RAND_S #include @@ -38,7 +36,7 @@ std::string InspIRCd::GetServerDescription(const std::string& servername) { std::string description; - FOREACH_MOD(I_OnGetServerDescription,OnGetServerDescription(servername,description)); + FOREACH_MOD(OnGetServerDescription, (servername,description)); if (!description.empty()) { @@ -116,12 +114,6 @@ void InspIRCd::SendError(const std::string &s) } } -/* return channel count */ -long InspIRCd::ChannelCount() -{ - return chanlist->size(); -} - bool InspIRCd::IsValidMask(const std::string &mask) { const char* dest = mask.c_str(); @@ -401,10 +393,22 @@ unsigned long InspIRCd::Duration(const std::string &str) const char* InspIRCd::Format(va_list &vaList, const char* formatString) { static std::vector formatBuffer(1024); - int vsnret = 0; - while ((vsnret = vsnprintf(&formatBuffer[0], formatBuffer.size(), formatString, vaList)) < 0 || static_cast(vsnret) >= formatBuffer.size()) + + while (true) + { + va_list dst; + va_copy(dst, vaList); + + int vsnret = vsnprintf(&formatBuffer[0], formatBuffer.size(), formatString, dst); + if (vsnret > 0 && static_cast(vsnret) < formatBuffer.size()) + { + return &formatBuffer[0]; + } + formatBuffer.resize(formatBuffer.size() * 2); - return &formatBuffer[0]; + } + + throw CoreException(); } const char* InspIRCd::Format(const char* formatString, ...)