diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-12-21 21:31:20 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-12-21 21:31:20 +0000 |
commit | 984ae685724f26dad0865ad43773364c8b5128ff (patch) | |
tree | 84addc4437b175f9ed39332678f7435f30cfb9f3 /src | |
parent | 48411d8c6b214282174519d5e31e8a4144c135cc (diff) |
Updated m_alias to fix bug #92, updated configs
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2603 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/command_parse.cpp | 78 | ||||
-rw-r--r-- | src/modules/m_alias.cpp | 31 |
2 files changed, 58 insertions, 51 deletions
diff --git a/src/command_parse.cpp b/src/command_parse.cpp index 7c26ffe61..1f17e4735 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -377,9 +377,10 @@ void CommandParser::ProcessCommand(userrec *user, char* cmd) } int total_params = 0; - if (strlen(cmd)>2) + unsigned int xl = strlen(cmd); + if (xl > 2) { - for (unsigned int q = 0; q < strlen(cmd)-1; q++) + for (unsigned int q = 0; q < xl - 1; q++) { if ((cmd[q] == ' ') && (cmd[q+1] == ':')) { @@ -426,7 +427,8 @@ void CommandParser::ProcessCommand(userrec *user, char* cmd) items = 0; command_p[0] = NULL; parameters = NULL; - for (unsigned int i = 0; i <= strlen(cmd); i++) + unsigned int tl = strlen(cmd); + for (unsigned int i = 0; i <= tl; i++) { cmd[i] = toupper(cmd[i]); } @@ -434,10 +436,12 @@ void CommandParser::ProcessCommand(userrec *user, char* cmd) } else { - strcpy(cmd,""); + *cmd = 0; j = 0; + + unsigned int vl = strlen(temp); /* strip out extraneous linefeeds through mirc's crappy pasting (thanks Craig) */ - for (unsigned int i = 0; i < strlen(temp); i++) + for (unsigned int i = 0; i < vl; i++) { if ((temp[i] != 10) && (temp[i] != 13) && (temp[i] != 0) && (temp[i] != 7)) { @@ -447,11 +451,14 @@ void CommandParser::ProcessCommand(userrec *user, char* cmd) } /* split the full string into a command plus parameters */ parameters = p; - strcpy(p," "); + p[0] = ' '; + p[1] = 0; + command = cmd; if (strchr(cmd,' ')) { - for (unsigned int i = 0; i <= strlen(cmd); i++) + unsigned int cl = strlen(cmd); + for (unsigned int i = 0; i <= cl; i++) { /* capitalise the command ONLY, leave params intact */ cmd[i] = toupper(cmd[i]); @@ -482,13 +489,13 @@ void CommandParser::ProcessCommand(userrec *user, char* cmd) return; } - for (unsigned int x = 0; x < strlen(command); x++) + for (char* x = command; *x; x++) { - if (((command[x] < 'A') || (command[x] > 'Z')) && (command[x] != '.')) + if (((*x < 'A') || (*x > 'Z')) && (*x != '.')) { - if (((command[x] < '0') || (command[x]> '9')) && (command[x] != '-')) + if (((*x < '0') || (*x> '9')) && (*x != '-')) { - if (strchr("@!\"$%^&*(){}[]_=+;:'#~,<>/?\\|`",command[x])) + if (strchr("@!\"$%^&*(){}[]_=+;:'#~,<>/?\\|`",*x)) { ServerInstance->stats->statsUnknown++; WriteServ(user->fd,"421 %s %s :Unknown command",user->nick,command); @@ -499,37 +506,40 @@ void CommandParser::ProcessCommand(userrec *user, char* cmd) } std::string xcommand = command; + + /* Tweak by brain - why was this INSIDE the mainloop? */ + if (parameters) + { + if (parameters[0]) + { + items = this->ProcessParameters(command_p,parameters); + } + else + { + items = 0; + command_p[0] = NULL; + } + } + else + { + items = 0; + command_p[0] = NULL; + } + + int MOD_RESULT = 0; + FOREACH_RESULT(OnPreCommand(command,command_p,items,user,false)); + if (MOD_RESULT == 1) { + return; + } + for (unsigned int i = 0; i != cmdlist.size(); i++) { if ((xcommand.length() >= cmdlist[i]->command.length()) && (xcommand == cmdlist[i]->command)) { - if (parameters) - { - if (parameters[0]) - { - items = this->ProcessParameters(command_p,parameters); - } - else - { - items = 0; - command_p[0] = NULL; - } - } - else - { - items = 0; - command_p[0] = NULL; - } - if (user) { /* activity resets the ping pending timer */ user->nping = TIME + user->pingmax; - int MOD_RESULT = 0; - FOREACH_RESULT(OnPreCommand(command,command_p,items,user,false)); - if (MOD_RESULT == 1) { - return; - } if ((items) < cmdlist[i]->min_params) { log(DEBUG,"not enough parameters: %s %s",user->nick,command); diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index a0d361e78..59492c828 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -95,7 +95,6 @@ class ModuleAlias : public Module for (unsigned int i = 0; i < Aliases.size(); i++) { - log(DEBUG,"Check against alias %s: %s",Aliases[i].text.c_str(),c.c_str()); if (Aliases[i].text == c) { if (Aliases[i].requires != "") @@ -118,28 +117,26 @@ class ModuleAlias : public Module } } - std::stringstream stuff(Aliases[i].replace_with); - for (int j = 1; j < pcnt; j++) + std::string n = ""; + for (int j = 0; j < pcnt; j++) { if (j) - stuff << " "; - stuff << parameters[j]; - } - - std::vector<std::string> items; - while (!stuff.eof()) - { - std::string data; - stuff >> data; - items.push_back(data); + n = n + " "; + n = n + parameters[j]; } + /* Final param now in n as one string */ + std::stringstream stuff(Aliases[i].replace_with); - char* para[127]; + std::string cmd = ""; + std::string target = ""; + stuff >> cmd; + stuff >> target; - for (unsigned int j = 1; j < items.size(); j++) - para[j-1] = (char*)items[j].c_str(); + char* para[2]; + para[0] = (char*)target.c_str(); + para[1] = (char*)n.c_str(); - Srv->CallCommandHandler(items[0],para,items.size()-1,user); + Srv->CallCommandHandler(cmd,para,2,user); return 1; } } |