X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcommand_parse.cpp;h=4a375f3654189cfe598b3c349a02c140ed84d5c1;hb=eb28eaea35d9d109a0b7b890de9d957d562da675;hp=08c082383e1e7774a6a2d60d74632c7ee80a5648;hpb=e00b5b82db1fdffd97704ea1b43bf921476adfa1;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/command_parse.cpp b/src/command_parse.cpp index 08c082383..4a375f365 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "users.h" #include "globals.h" #include "modules.h" @@ -52,22 +53,12 @@ extern InspIRCd* ServerInstance; extern std::vector modules; extern std::vector factory; -extern std::vector module_sockets; -extern std::vector local_users; extern int MODCOUNT; -extern InspSocket* socket_ref[MAX_DESCRIPTORS]; extern time_t TIME; -// This table references users by file descriptor. -// its an array to make it VERY fast, as all lookups are referenced -// by an integer, meaning there is no need for a scan/search operation. -extern userrec* fd_ref_table[MAX_DESCRIPTORS]; - extern Server* MyServer; -extern ServerConfig *Config; -extern user_hash clientlist; extern chan_hash chanlist; /* Special commands which may occur without registration of the user */ @@ -84,7 +75,7 @@ cmd_pass* command_pass; * Therefore, we need to deal with both lists concurrently. The first instance of this method does that by creating * two instances of irc::commasepstream and reading them both together until the first runs out of tokens. * The second version is much simpler and just has the one stream to read, and is used in NAMES, WHOIS, PRIVMSG etc. - * Both will only parse until they reach Config->MaxTargets number of targets, to stop abuse via spam. + * Both will only parse until they reach ServerInstance->Config->MaxTargets number of targets, to stop abuse via spam. */ int CommandParser::LoopCall(userrec* user, command_t* CommandObj, const char** parameters, int pcnt, unsigned int splithere, unsigned int extra) { @@ -105,7 +96,7 @@ int CommandParser::LoopCall(userrec* user, command_t* CommandObj, const char** p * which called us, for every parameter pair until there are * no more left to parse. */ - while (((item = items1.GetToken()) != "") && (max++ < Config->MaxTargets)) + while (((item = items1.GetToken()) != "") && (max++ < ServerInstance->Config->MaxTargets)) { std::string extrastuff = items2.GetToken(); parameters[splithere] = item.c_str(); @@ -132,7 +123,7 @@ int CommandParser::LoopCall(userrec* user, command_t* CommandObj, const char** p * Each token we parse out, call the command handler that called us * with it */ - while (((item = items1.GetToken()) != "") && (max++ < Config->MaxTargets)) + while (((item = items1.GetToken()) != "") && (max++ < ServerInstance->Config->MaxTargets)) { parameters[splithere] = item.c_str(); CommandObj->Handle(parameters,pcnt,user); @@ -207,8 +198,7 @@ void CommandParser::ProcessCommand(userrec *user, std::string &cmd) while (((para[items] = tokens.GetToken()) != "") && (items < 127)) command_p[items] = para[items++].c_str(); - for (std::string::iterator makeupper = command.begin(); makeupper != command.end(); makeupper++) - *makeupper = toupper(*makeupper); + std::transform(command.begin(), command.end(), command.begin(), ::toupper); int MOD_RESULT = 0; FOREACH_RESULT(I_OnPreCommand,OnPreCommand(command,command_p,items,user,false)); @@ -228,27 +218,27 @@ void CommandParser::ProcessCommand(userrec *user, std::string &cmd) { if (!user->IsModeSet(cm->second->flags_needed)) { - WriteServ(user->fd,"481 %s :Permission Denied- You do not have the required operator privilages",user->nick); + user->WriteServ("481 %s :Permission Denied- You do not have the required operator privilages",user->nick); return; } if (!user->HasPermission(command)) { - WriteServ(user->fd,"481 %s :Permission Denied- Oper type %s does not have access to command %s",user->nick,user->oper,command.c_str()); + user->WriteServ("481 %s :Permission Denied- Oper type %s does not have access to command %s",user->nick,user->oper,command.c_str()); return; } } if ((user->registered == REG_ALL) && (!*user->oper) && (cm->second->IsDisabled())) { /* command is disabled! */ - WriteServ(user->fd,"421 %s %s :This command has been disabled.",user->nick,command.c_str()); + user->WriteServ("421 %s %s :This command has been disabled.",user->nick,command.c_str()); return; } if (items < cm->second->min_params) { - WriteServ(user->fd,"461 %s %s :Not enough parameters.", user->nick, command.c_str()); + user->WriteServ("461 %s %s :Not enough parameters.", user->nick, command.c_str()); /* If syntax is given, display this as the 461 reply */ - if ((Config->SyntaxHints) && (cm->second->syntax.length())) - WriteServ(user->fd,"304 %s :SYNTAX %s %s", user->nick, cm->second->command.c_str(), cm->second->syntax.c_str()); + if ((ServerInstance->Config->SyntaxHints) && (cm->second->syntax.length())) + user->WriteServ("304 %s :SYNTAX %s %s", user->nick, cm->second->command.c_str(), cm->second->syntax.c_str()); return; } if ((user->registered == REG_ALL) || (cm->second == command_user) || (cm->second == command_nick) || (cm->second == command_pass)) @@ -273,7 +263,7 @@ void CommandParser::ProcessCommand(userrec *user, std::string &cmd) } else { - WriteServ(user->fd,"451 %s :You have not registered",command.c_str()); + user->WriteServ("451 %s :You have not registered",command.c_str()); return; } } @@ -281,7 +271,7 @@ void CommandParser::ProcessCommand(userrec *user, std::string &cmd) else if (user) { ServerInstance->stats->statsUnknown++; - WriteServ(user->fd,"421 %s %s :Unknown command",user->nick,command.c_str()); + user->WriteServ("421 %s %s :Unknown command",user->nick,command.c_str()); } }