// calls a handler function for a command
-bool CommandParser::CallHandler(const std::string &commandname,const char** parameters, int pcnt, userrec *user)
+CmdResult CommandParser::CallHandler(const std::string &commandname,const char** parameters, int pcnt, userrec *user)
{
nspace::hash_map<std::string,command_t*>::iterator n = cmdlist.find(commandname);
{
if ((user->HasPermission(commandname)) || (!IS_LOCAL(user)))
{
- n->second->Handle(parameters,pcnt,user);
- return true;
+ return n->second->Handle(parameters,pcnt,user);
}
}
else
{
- n->second->Handle(parameters,pcnt,user);
- return true;
+ return n->second->Handle(parameters,pcnt,user);
}
}
}
}
- return false;
+ return CMD_INVALID;
}
void CommandParser::ProcessCommand(userrec *user, std::string &cmd)
{
const char *command_p[127];
int items = 0;
- std::string para[127];
irc::tokenstream tokens(cmd);
std::string command = tokens.GetToken();
while (((para[items] = tokens.GetToken()) != "") && (items < 127))
- command_p[items] = para[items++].c_str();
+ {
+ command_p[items] = para[items].c_str();
+ items++;
+ }
std::transform(command.begin(), command.end(), command.begin(), ::toupper);
* command handler call, as the handler
* may free the user structure!
*/
+ CmdResult result = cm->second->Handle(command_p,items,user);
- cm->second->Handle(command_p,items,user);
+ if (result != CMD_USER_DELETED)
+ {
+ FOREACH_MOD(I_OnPostCommand,OnPostCommand(command, command_p, items, user, result));
+ }
return;
}
else
CommandParser::CommandParser(InspIRCd* Instance) : ServerInstance(Instance)
{
+ para.resize(128);
this->SetupCommandTable();
}