]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/command_parse.cpp
Remove the craqy self-restarting loop in trunk, and use proper safe iterators to...
[user/henk/code/inspircd.git] / src / command_parse.cpp
index d8e59e0c047f2fad1dd2814caf2b8923db24fb31..9e54a63d9b84bfeaccdaf2ebd524b7d7f1e20ef0 100644 (file)
@@ -292,7 +292,7 @@ bool CommandParser::ProcessCommand(User *user, std::string &cmd)
        {
                if (user->registered == REG_ALL)
                {
-                       user->WriteServ("421 %s %s :Unknown command",user->nick,command.c_str());
+                       user->WriteNumeric(421, "%s %s :Unknown command",user->nick,command.c_str());
                }
                ServerInstance->stats->statsUnknown++;
                return true;
@@ -316,33 +316,33 @@ bool CommandParser::ProcessCommand(User *user, std::string &cmd)
        {
                if (!user->IsModeSet(cm->second->flags_needed))
                {
-                       user->WriteServ("481 %s :Permission Denied - You do not have the required operator privileges",user->nick);
+                       user->WriteNumeric(481, "%s :Permission Denied - You do not have the required operator privileges",user->nick);
                        return do_more;
                }
                if (!user->HasPermission(command))
                {
-                       user->WriteServ("481 %s :Permission Denied - Oper type %s does not have access to command %s",user->nick,user->oper,command.c_str());
+                       user->WriteNumeric(481, "%s :Permission Denied - Oper type %s does not have access to command %s",user->nick,user->oper,command.c_str());
                        return do_more;
                }
        }
        if ((user->registered == REG_ALL) && (!IS_OPER(user)) && (cm->second->IsDisabled()))
        {
                /* command is disabled! */
-               user->WriteServ("421 %s %s :This command has been disabled.",user->nick,command.c_str());
+               user->WriteNumeric(421, "%s %s :This command has been disabled.",user->nick,command.c_str());
                ServerInstance->SNO->WriteToSnoMask('d', "%s denied for %s (%s@%s)",
                                command.c_str(), user->nick, user->ident, user->host);
                return do_more;
        }
        if (items < cm->second->min_params)
        {
-               user->WriteServ("461 %s %s :Not enough parameters.", user->nick, command.c_str());
+               user->WriteNumeric(461, "%s %s :Not enough parameters.", user->nick, command.c_str());
                if ((ServerInstance->Config->SyntaxHints) && (user->registered == REG_ALL) && (cm->second->syntax.length()))
-                       user->WriteServ("304 %s :SYNTAX %s %s", user->nick, cm->second->command.c_str(), cm->second->syntax.c_str());
+                       user->WriteNumeric(304, "%s :SYNTAX %s %s", user->nick, cm->second->command.c_str(), cm->second->syntax.c_str());
                return do_more;
        }
        if ((user->registered != REG_ALL) && (!cm->second->WorksBeforeReg()))
        {
-               user->WriteServ("451 %s :You have not registered",command.c_str());
+               user->WriteNumeric(451, "%s :You have not registered",command.c_str());
                return do_more;
        }
        else
@@ -367,24 +367,15 @@ bool CommandParser::ProcessCommand(User *user, std::string &cmd)
        }
 }
 
-bool CommandParser::RemoveCommands(const char* source)
+void CommandParser::RemoveCommands(const char* source)
 {
        Commandable::iterator i,safei;
-       for (i = cmdlist.begin(); i != cmdlist.end(); i++)
+       for (i = cmdlist.begin(); i != cmdlist.end();)
        {
                safei = i;
-               safei++;
-               if (safei != cmdlist.end())
-               {
-                       RemoveCommand(safei, source);
-               }
-       }
-       safei = cmdlist.begin();
-       if (safei != cmdlist.end())
-       {
+               i++;
                RemoveCommand(safei, source);
        }
-       return true;
 }
 
 void CommandParser::RemoveCommand(Commandable::iterator safei, const char* source)
@@ -559,7 +550,7 @@ void CommandParser::SetupCommandTable(User* user)
        if (library)
        {
                dirent* entry = NULL;
-               while ((entry = readdir(library)))
+               while (0 != (entry = readdir(library)))
                {
                        if (match(entry->d_name, "cmd_*.so"))
                        {
@@ -663,3 +654,4 @@ int CommandParser::TranslateUIDs(TranslateType to, const std::string &source, st
        return translations;
 }
 
+