From 50ecf259b61eb389559dc24a7c4af718c225ec8d Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Tue, 18 Jun 2013 21:25:43 +0200 Subject: [PATCH] Remove dead code from the InspIRCd and CommandParser classes and typedefs.h Removed functions: InspIRCd: - Restart() - unused - DoSocketTimeouts() - no implementation exists - AddCommand() - useless wrapper around ModuleManager::AddService() CommandParser: - IsValidCommand() - unused - ProcessParameters() - no implementation exists --- include/command_parse.h | 17 ----------------- include/inspircd.h | 22 ---------------------- include/typedefs.h | 6 ------ src/command_parse.cpp | 24 ------------------------ src/inspircd.cpp | 29 ----------------------------- src/modmanager_static.cpp | 2 +- 6 files changed, 1 insertion(+), 99 deletions(-) diff --git a/include/command_parse.h b/include/command_parse.h index 480151612..b39bf31c0 100644 --- a/include/command_parse.h +++ b/include/command_parse.h @@ -30,13 +30,6 @@ class CoreExport CommandParser { private: - /** Process a parameter string into a list of items - * @param command_p The output list of items - * @param parameters The input string - * @return The number of parameters parsed into command_p - */ - int ProcessParameters(std::vector& command_p, char* parameters); - /** Process a command from a user. * @param user The user to parse the command for * @param cmd The command string to process @@ -70,16 +63,6 @@ class CoreExport CommandParser */ Command* GetHandler(const std::string &commandname); - /** This function returns true if a command is valid with the given number of parameters and user. - * @param commandname The command name to check - * @param pcnt The parameter count - * @param user The user to check against - * @return If the user given has permission to execute the command, and the parameter count is - * equal to or greater than the minimum number of parameters to the given command, then this - * function will return true, otherwise it will return false. - */ - bool IsValidCommand(const std::string &commandname, unsigned int pcnt, User * user); - /** LoopCall is used to call a command handler repeatedly based on the contents of a comma seperated list. * There are two ways to call this method, either with one potential list or with two potential lists. * We need to handle two potential lists for JOIN, because a JOIN may contain two lists of items at once: diff --git a/include/inspircd.h b/include/inspircd.h index 4845a777e..a25466647 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -265,11 +265,6 @@ class CoreExport InspIRCd */ bool DaemonSeed(); - /** Iterate the list of BufferedSocket objects, removing ones which have timed out - * @param TIME the current time - */ - void DoSocketTimeouts(time_t TIME); - /** The current time, updated in the mainloop */ struct timespec TIME; @@ -544,15 +539,6 @@ class CoreExport InspIRCd */ caller1 IsIdent; - /** Add a command to this server's command parser - * @param f A Command command handler object to add - * @throw ModuleException Will throw ModuleExcption if the command already exists - */ - inline void AddCommand(Command *f) - { - Modules->AddService(*f); - } - /** Match two strings using pattern matching, optionally, with a map * to check case against (may be NULL). If map is null, match will be case insensitive. * @param str The literal string to match against @@ -694,14 +680,6 @@ class CoreExport InspIRCd */ caller3 OnCheckExemption; - /** Restart the server. - * This function will not return. If an error occurs, - * it will throw an instance of CoreException. - * @param reason The restart reason to show to all clients - * @throw CoreException An instance of CoreException indicating the error from execv(). - */ - void Restart(const std::string &reason); - /** Prepare the ircd for restart or shutdown. * This function unloads all modules which can be unloaded, * closes all open sockets, and closes the logfile. diff --git a/include/typedefs.h b/include/typedefs.h index 404175ddb..c38f89d4d 100644 --- a/include/typedefs.h +++ b/include/typedefs.h @@ -22,11 +22,9 @@ #pragma once class BanCacheManager; -class BanItem; class BufferedSocket; class Channel; class Command; -class ConfigReader; class ConfigTag; class Extensible; class FakeUser; @@ -77,10 +75,6 @@ typedef std::set UserChanList; */ typedef UserChanList::iterator UCListIter; -/** Holds a complete ban list - */ -typedef std::vector BanList; - /** A list of custom modes parameters on a channel */ typedef std::map CustomModeList; diff --git a/src/command_parse.cpp b/src/command_parse.cpp index 31e61d161..457934d2b 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -108,30 +108,6 @@ bool CommandParser::LoopCall(User* user, Command* handler, const std::vector= n->second->min_params)) - { - if (IS_LOCAL(user) && n->second->flags_needed) - { - if (user->IsModeSet(n->second->flags_needed)) - { - return (user->HasPermission(commandname)); - } - } - else - { - return true; - } - } - } - return false; -} - Command* CommandParser::GetHandler(const std::string &commandname) { Commandtable::iterator n = cmdlist.find(commandname); diff --git a/src/inspircd.cpp b/src/inspircd.cpp index a469de640..29156973c 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -140,35 +140,6 @@ void InspIRCd::Cleanup() DeleteZero(this->Logs); } -void InspIRCd::Restart(const std::string &reason) -{ - /* SendError flushes each client's queue, - * regardless of writeability state - */ - this->SendError(reason); - - /* Figure out our filename (if theyve renamed it, we're boned) */ - std::string me; - - char** argv = Config->cmdline.argv; - -#ifdef _WIN32 - char module[MAX_PATH]; - if (GetModuleFileNameA(NULL, module, MAX_PATH)) - me = module; -#else - me = argv[0]; -#endif - - this->Cleanup(); - - if (execv(me.c_str(), argv) == -1) - { - /* Will raise a SIGABRT if not trapped */ - throw CoreException(std::string("Failed to execv()! error: ") + strerror(errno)); - } -} - void InspIRCd::SetSignals() { #ifndef _WIN32 diff --git a/src/modmanager_static.cpp b/src/modmanager_static.cpp index c82ee3f7a..44c36919b 100644 --- a/src/modmanager_static.cpp +++ b/src/modmanager_static.cpp @@ -58,7 +58,7 @@ class AllModule : public Module { Command* c = (*i)(this); cmds.push_back(c); - ServerInstance->AddCommand(c); + ServerInstance->Modules->AddService(*c); } } catch (...) -- 2.39.5