summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-07 18:26:38 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-07 18:26:38 +0000
commitdba88edc767697f9c2a9de3c4c2fbaea6cc35f3e (patch)
tree74122d2f9666219c8b4bd047604711f5a2772fa5 /src
parentdaff96bf568a51de4e4ec460240e093c43b11ff3 (diff)
Experimental improved string handling in server links
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3127 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/command_parse.cpp23
-rw-r--r--src/inspircd_io.cpp10
-rw-r--r--src/modules.cpp22
-rw-r--r--src/modules/m_spanningtree.cpp15
-rw-r--r--src/users.cpp5
5 files changed, 34 insertions, 41 deletions
diff --git a/src/command_parse.cpp b/src/command_parse.cpp
index 9835c6961..311def7d2 100644
--- a/src/command_parse.cpp
+++ b/src/command_parse.cpp
@@ -475,9 +475,9 @@ void CommandParser::ProcessCommand(userrec *user, char* cmd)
}
else
{
- for (unsigned int i = 0; i <= strlen(cmd); i++)
+ for (char* i = cmd; *i; i++)
{
- cmd[i] = toupper(cmd[i]);
+ *i = toupper(*i);
}
}
@@ -541,17 +541,16 @@ void CommandParser::ProcessCommand(userrec *user, char* cmd)
if (cm != cmdlist.end())
{
-
- if (user)
+ if (user)
+ {
+ /* activity resets the ping pending timer */
+ user->nping = TIME + user->pingmax;
+ if ((items) < cm->second->min_params)
{
- /* activity resets the ping pending timer */
- user->nping = TIME + user->pingmax;
- if ((items) < cm->second->min_params)
- {
- log(DEBUG,"not enough parameters: %s %s",user->nick,command);
- WriteServ(user->fd,"461 %s %s :Not enough parameters",user->nick,command);
- return;
- }
+ log(DEBUG,"not enough parameters: %s %s",user->nick,command);
+ WriteServ(user->fd,"461 %s %s :Not enough parameters",user->nick,command);
+ return;
+ }
if ((!strchr(user->modes,cm->second->flags_needed)) && (cm->second->flags_needed))
{
log(DEBUG,"permission denied: %s %s",user->nick,command);
diff --git a/src/inspircd_io.cpp b/src/inspircd_io.cpp
index 3788055a4..95f88e357 100644
--- a/src/inspircd_io.cpp
+++ b/src/inspircd_io.cpp
@@ -603,11 +603,11 @@ std::string ServerConfig::ConfProcess(char* buffer, long linenumber, std::string
return "";
}
// firstly clean up the line by stripping spaces from the start and end and converting tabs to spaces
- for (unsigned int d = 0; d < strlen(buffer); d++)
- if ((buffer[d]) == 9)
- buffer[d] = ' ';
- while ((buffer[0] == ' ') && (strlen(buffer)>0)) buffer++;
- while ((buffer[strlen(buffer)-1] == ' ') && (strlen(buffer)>0)) buffer[strlen(buffer)-1] = '\0';
+ for (char* d = buffer; *d; d++)
+ if (*d == 9)
+ *d = ' ';
+ while (*buffer == ' ') buffer++;
+ while ((buffer[strlen(buffer)-1] == ' ') && (*buffer)) buffer[strlen(buffer)-1] = '\0';
// empty lines are syntactically valid, as are comments
if (!(*buffer) || buffer[0] == '#')
diff --git a/src/modules.cpp b/src/modules.cpp
index 38b84c2bd..b1ac75f8f 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -778,26 +778,26 @@ long Server::CalcDuration(std::string delta)
bool Server::IsValidMask(std::string mask)
{
- const char* dest = mask.c_str();
+ char* dest = (char*)mask.c_str();
if (strchr(dest,'!')==0)
return false;
if (strchr(dest,'@')==0)
return false;
- for (unsigned int i = 0; i < strlen(dest); i++)
- if (dest[i] < 32)
+ for (char* i = dest; *i; i++)
+ if (*i < 32)
return false;
- for (unsigned int i = 0; i < strlen(dest); i++)
- if (dest[i] > 126)
+ for (char* i = dest; *i; i++)
+ if (*i > 126)
return false;
unsigned int c = 0;
- for (unsigned int i = 0; i < strlen(dest); i++)
- if (dest[i] == '!')
+ for (char* i = dest; *i; i++)
+ if (*i == '!')
c++;
if (c>1)
return false;
c = 0;
- for (unsigned int i = 0; i < strlen(dest); i++)
- if (dest[i] == '@')
+ for (char* i = dest; *i; i++)
+ if (*i == '@')
c++;
if (c>1)
return false;
@@ -893,9 +893,9 @@ long ConfigReader::ReadInteger(std::string tag, std::string name, int index, boo
this->error = CONF_VALUE_NOT_FOUND;
return 0;
}
- for (unsigned int i = 0; i < strlen(val); i++)
+ for (char* i = val; *i; i++)
{
- if (!isdigit(val[i]))
+ if (!isdigit(*i))
{
this->error = CONF_NOT_A_NUMBER;
return 0;
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index 10a3191f7..0710b9b0a 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -1306,17 +1306,10 @@ class TreeSocket : public InspSocket
*/
while (in_buffer.find("\n") != std::string::npos)
{
- char* line = (char*)in_buffer.c_str();
- std::string ret = "";
- while ((*line != '\n') && (*line))
- {
- if ((*line != '\r') && (*line != '\n'))
- ret = ret + *line;
- line++;
- }
- if ((*line == '\n') || (*line == '\r'))
- line++;
- in_buffer = line;
+ std::string ret = in_buffer.substr(0,in_buffer.find("\n")-1);
+ in_buffer = in_buffer.substr(in_buffer.find("\n")+1,in_buffer.length()-in_buffer.find("\n"));
+ if (ret.find("\r") != std::string::npos)
+ ret = in_buffer.substr(0,in_buffer.find("\r")-1);
/* Process this one, abort if it
* didnt return true.
*/
diff --git a/src/users.cpp b/src/users.cpp
index 7513fa273..8c3ad4969 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -276,7 +276,8 @@ bool userrec::AddBuffer(std::string a)
bool userrec::BufferIsReady()
{
- for (unsigned int i = 0; i < recvq.length(); i++)
+ unsigned int t = recvq.length();
+ for (unsigned int i = 0; i < t; i++)
if (recvq[i] == '\n')
return true;
return false;
@@ -293,7 +294,7 @@ std::string userrec::GetBuffer()
return "";
char* line = (char*)recvq.c_str();
std::string ret = "";
- while ((*line != '\n') && (strlen(line)))
+ while ((*line != '\n') && (*line))
{
ret = ret + *line;
line++;