From df0489220c991cfe106c88fbfaa2a14be0682779 Mon Sep 17 00:00:00 2001 From: danieldg Date: Wed, 2 Sep 2009 00:52:04 +0000 Subject: Make CHECK work remotely with optional second parameter git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11651 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules.cpp | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'src/modules.cpp') diff --git a/src/modules.cpp b/src/modules.cpp index ab2975d7c..bea9cad0f 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -768,20 +768,38 @@ void InspIRCd::SendMode(const std::vector& parameters, User *user) this->Modes->Process(parameters, user); } -void InspIRCd::DumpText(User* User, const std::string &LinePrefix, std::stringstream &TextStream) +void InspIRCd::DumpText(User* user, const std::string &text) { - std::string CompleteLine = LinePrefix; + if (IS_LOCAL(user)) + { + user->Write(text); + } + else + { + PI->PushToClient(user, ":" + text); + } +} + +void InspIRCd::DumpText(User* user, const std::string &LinePrefix, std::stringstream &TextStream) +{ + char line[MAXBUF]; + int start_pos = snprintf(line, MAXBUF, ":%s %s", Config->ServerName, LinePrefix.c_str()); + int pos = start_pos; std::string Word; while (TextStream >> Word) { - if (CompleteLine.length() + Word.length() + 3 > 500) + int len = Word.length(); + if (pos + len + 12 > MAXBUF) { - User->WriteServ(CompleteLine); - CompleteLine = LinePrefix; + line[pos] = '\0'; + DumpText(user, line); + pos = start_pos; } - CompleteLine = CompleteLine + Word + " "; + line[pos] = ' '; + memcpy(line + pos + 1, Word.data(), len); + pos += len + 1; } - User->WriteServ(CompleteLine); + DumpText(user, line); } bool InspIRCd::AddResolver(Resolver* r, bool cached) -- cgit v1.2.3