diff options
| author | 2005-04-29 05:46:17 +0000 | |
|---|---|---|
| committer | 2005-04-29 05:46:17 +0000 | |
| commit | 80015fe115f37243e7b75a48312edb5a029fa229 (patch) | |
| tree | e009d2b26ab159520715ef6c0166074aea3bd26b /src/users.cpp | |
| parent | Added 901 numeric - end of modules list (diff) | |
| download | inspircd++-80015fe115f37243e7b75a48312edb5a029fa229.tar.gz inspircd++-80015fe115f37243e7b75a48312edb5a029fa229.tar.bz2 inspircd++-80015fe115f37243e7b75a48312edb5a029fa229.zip | |
Updated buffering, faster and more sensible (old code sucks)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1256 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/users.cpp')
| -rw-r--r-- | src/users.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/users.cpp b/src/users.cpp index c0332dbe4..40589b234 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -44,6 +44,7 @@ userrec::userrec() flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0; haspassed = false; dns_done = false; + recvq = ""; strcpy(result,""); for (int i = 0; i < MAXCHANS; i++) { @@ -163,3 +164,43 @@ bool userrec::HasPermission(char* command) } +void userrec::AddBuffer(std::string a) +{ + std::string b = ""; + for (int i = 0; i < a.length(); i++) + if ((a[i] != '\r') && (a[i] != '\0') && (a[i] != 7)) + b = b + a[i]; + std::stringstream stream(recvq); + stream << b; + recvq = stream.str(); +} + +bool userrec::BufferIsReady() +{ + for (int i = 0; i < recvq.length(); i++) + if (recvq[i] == '\n') + return true; + return false; +} + +void userrec::ClearBuffer() +{ + recvq = ""; +} + +std::string userrec::GetBuffer() +{ + log(DEBUG,"GetBuffer\n%s\n",recvq.c_str()); + char* line = (char*)recvq.c_str(); + std::string ret = ""; + while ((*line != '\n') && (strlen(line))) + { + ret = ret + *line; + line++; + } + if ((*line == '\n') || (*line == '\r')) + line++; + recvq = line; + return ret; +} + |
