summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-08 21:58:21 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-08 21:58:21 +0000
commitbe9fbe56f96dddb09af5b256f4529f1d8d563743 (patch)
treecc3b0524d5335250710f9de85ce325820bc65a50
parent21deb54715b6937ac9d4de5e2c4c46fb1b38aa3a (diff)
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
-rw-r--r--include/modules.h2
-rw-r--r--src/modules.cpp2
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp2
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp2
-rw-r--r--src/users.cpp12
5 files changed, 9 insertions, 11 deletions
diff --git a/include/modules.h b/include/modules.h
index f086188d0..392047a35 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -1192,7 +1192,7 @@ class Module : public Extensible
* @param Number of characters to write
* @return Number of characters actually written or 0 if you didn't handle the operation
*/
- virtual int OnRawSocketWrite(int fd, char* buffer, int count);
+ virtual int OnRawSocketWrite(int fd, const char* buffer, int count);
/** Called immediately before any socket is closed. When this event is called, shutdown()
* has not yet been called on the socket.
diff --git a/src/modules.cpp b/src/modules.cpp
index 84502d374..d8557fc2e 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -197,7 +197,7 @@ void Module::OnGlobalConnect(userrec* user) { };
int Module::OnAddBan(userrec* source, chanrec* channel,const std::string &banmask) { return 0; };
int Module::OnDelBan(userrec* source, chanrec* channel,const std::string &banmask) { return 0; };
void Module::OnRawSocketAccept(int fd, const std::string &ip, int localport) { };
-int Module::OnRawSocketWrite(int fd, char* buffer, int count) { return 0; };
+int Module::OnRawSocketWrite(int fd, const char* buffer, int count) { return 0; };
void Module::OnRawSocketClose(int fd) { };
int Module::OnRawSocketRead(int fd, char* buffer, unsigned int count, int &readresult) { return 0; };
void Module::OnUserMessage(userrec* user, void* dest, int target_type, const std::string &text, char status) { };
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index 216c69c25..d9ee49bd0 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -382,7 +382,7 @@ class ModuleSSLGnuTLS : public Module
return 1;
}
- virtual int OnRawSocketWrite(int fd, char* buffer, int count)
+ virtual int OnRawSocketWrite(int fd, const char* buffer, int count)
{
issl_session* session = &sessions[fd];
const char* sendbuffer = buffer;
diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp
index 29b97ba9a..b2883c0f0 100644
--- a/src/modules/extra/m_ssl_openssl.cpp
+++ b/src/modules/extra/m_ssl_openssl.cpp
@@ -381,7 +381,7 @@ class ModuleSSLOpenSSL : public Module
return -1;
}
- virtual int OnRawSocketWrite(int fd, char* buffer, int count)
+ virtual int OnRawSocketWrite(int fd, const char* buffer, int count)
{
issl_session* session = &sessions[fd];
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()