From be9fbe56f96dddb09af5b256f4529f1d8d563743 Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 8 Aug 2006 21:58:21 +0000 Subject: Improve Write functions, and change some stuff from char* to const char* git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4803 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/users.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/users.cpp') diff --git a/src/users.cpp b/src/users.cpp index 31320581d..a47ff60e8 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -1281,19 +1281,17 @@ const char* userrec::GetIPString(char* buf) void userrec::Write(const std::string &text) { - char tb[MAXBUF]; - int bytes; - if ((this->fd < 0) || (this->fd > MAX_DESCRIPTORS)) return; - bytes = snprintf(tb,MAXBUF,"%s\r\n",text.c_str()); + static std::string crlf = text; + crlf.append("\r\n"); if (Config->GetIOHook(this->GetPort())) { try { - Config->GetIOHook(this->GetPort())->OnRawSocketWrite(this->fd,tb,bytes); + Config->GetIOHook(this->GetPort())->OnRawSocketWrite(this->fd, crlf.data(), crlf.length()); } catch (ModuleException& modexcept) { @@ -1302,9 +1300,9 @@ void userrec::Write(const std::string &text) } else { - this->AddWriteBuf(tb); + this->AddWriteBuf(crlf); } - ServerInstance->stats->statsSent += bytes; + ServerInstance->stats->statsSent += crlf.length(); } /** Write() -- cgit v1.3.1-10-gc9f91