From d7d01bdc5c667a1fafd95241282b58e03b4caa5b Mon Sep 17 00:00:00 2001 From: rburchell Date: Mon, 9 Feb 2009 21:01:05 +0000 Subject: Squashed commit: merge next (1.9.1) back to trunk. SVN users, NOTE: THIS WILL NOT BUILD, NOR SHOULD YOU RUN IT YET. git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1953 5417fbe8-f217-4b02-8779-1006273d7864 --- src/core/os_quit.c | 64 +++++++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 29 deletions(-) (limited to 'src/core/os_quit.c') diff --git a/src/core/os_quit.c b/src/core/os_quit.c index f295c173b..60e045d3e 100644 --- a/src/core/os_quit.c +++ b/src/core/os_quit.c @@ -15,22 +15,49 @@ #include "module.h" -int do_os_quit(User * u); -void myOperServHelp(User * u); +void myOperServHelp(User *u); + +class CommandOSQuit : public Command +{ + public: + CommandOSQuit() : Command("QUIT", 0, 0) + { + } + + CommandResult Execute(User *u, std::vector ¶ms) + { + quitmsg = new char[28 + strlen(u->nick)]; + if (!quitmsg) + quitmsg = "QUIT command received, but out of memory!"; + else + sprintf(const_cast(quitmsg), "QUIT command received from %s", u->nick); // XXX we know this is safe, but.. + + if (GlobalOnCycle) + oper_global(NULL, "%s", GlobalOnCycleMessage); + quitting = 1; + return MOD_CONT; + } + + bool OnHelp(User *u, const std::string &subcommand) + { + if (!is_services_root(u)) + return false; + + notice_lang(s_OperServ, u, OPER_HELP_QUIT); + return true; + } +}; class OSQuit : public Module { public: OSQuit(const std::string &modname, const std::string &creator) : Module(modname, creator) { - Command *c; - this->SetAuthor("Anope"); this->SetVersion("$Id$"); this->SetType(CORE); - c = createCommand("QUIT", do_os_quit, is_services_root, OPER_HELP_QUIT, -1, -1, -1, -1); - this->AddCommand(OPERSERV, c, MOD_UNIQUE); + this->AddCommand(OPERSERV, new CommandOSQuit(), MOD_UNIQUE); this->SetOperHelp(myOperServHelp); } @@ -41,31 +68,10 @@ class OSQuit : public Module * Add the help response to anopes /os help output. * @param u The user who is requesting help **/ -void myOperServHelp(User * u) +void myOperServHelp(User *u) { - if (is_services_root(u)) { + if (is_services_root(u)) notice_lang(s_OperServ, u, OPER_HELP_CMD_QUIT); - } -} - -/** - * The /os quit command. - * @param u The user who issued the command - * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. - **/ -int do_os_quit(User * u) -{ - quitmsg = new char[28 + strlen(u->nick)]; - if (!quitmsg) - quitmsg = "QUIT command received, but out of memory!"; - else - sprintf(const_cast(quitmsg), "QUIT command received from %s", u->nick); // XXX we know this is safe, but.. - - if (GlobalOnCycle) { - oper_global(NULL, "%s", GlobalOnCycleMessage); - } - quitting = 1; - return MOD_CONT; } MODULE_INIT("os_quit", OSQuit) -- cgit