diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-09-03 02:30:12 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-09-03 02:30:12 +0000 |
commit | f4472dd6dcdfbb5d4a2a50ddc615644c3b2c8145 (patch) | |
tree | df27c8b3070c1fe4f285259f925de9fabe31b8a5 /src/commands | |
parent | c29175d8064b3428685da1155704b6c54c116b94 (diff) |
Change cmd_*.so to use the Module object API
Create Module* objects for each command, and load them like modules.
This unifies the external API for modules.
Library directory is now deprecated: all modules are located in a
single module directory.
Header files for each command are no longer needed; remove.
This also fixes two potential segfaults in m_spanningtree.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11668 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/commands')
53 files changed, 1710 insertions, 592 deletions
diff --git a/src/commands/cmd_admin.cpp b/src/commands/cmd_admin.cpp index 95170e069..a0d99ea09 100644 --- a/src/commands/cmd_admin.cpp +++ b/src/commands/cmd_admin.cpp @@ -12,13 +12,36 @@ */ #include "inspircd.h" -#include "commands/cmd_admin.h" +#ifndef __CMD_ADMIN_H__ +#define __CMD_ADMIN_H__ -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#include "users.h" +#include "channels.h" + +/** Handle /ADMIN. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandAdmin : public Command { - return new CommandAdmin(Instance); -} + public: + /** Constructor for admin. + */ + CommandAdmin (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"ADMIN",0,0) { syntax = "[<servername>]"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + + /** Handle /ADMIN */ @@ -31,3 +54,5 @@ CmdResult CommandAdmin::Handle (const std::vector<std::string>& parameters, User user->WriteNumeric(RPL_ADMINEMAIL, "%s :E-Mail - %s",user->nick.c_str(),ServerInstance->Config->AdminEmail); return CMD_SUCCESS; } + +COMMAND_INIT(CommandAdmin) diff --git a/src/commands/cmd_away.cpp b/src/commands/cmd_away.cpp index 261bdd38c..fa91342e0 100644 --- a/src/commands/cmd_away.cpp +++ b/src/commands/cmd_away.cpp @@ -12,12 +12,37 @@ */ #include "inspircd.h" -#include "commands/cmd_away.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_AWAY_H__ +#define __CMD_AWAY_H__ + +// include the common header files + +#include "users.h" +#include "channels.h" + +/** Handle /AWAY. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandAway : public Command { - return new CommandAway(Instance); -} + public: + /** Constructor for away. + */ + CommandAway (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"AWAY",0,0) { syntax = "[<message>]"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + /** Handle /AWAY */ @@ -50,3 +75,5 @@ CmdResult CommandAway::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } + +COMMAND_INIT(CommandAway) diff --git a/src/commands/cmd_clearcache.cpp b/src/commands/cmd_clearcache.cpp index 151587f12..6303fa528 100644 --- a/src/commands/cmd_clearcache.cpp +++ b/src/commands/cmd_clearcache.cpp @@ -12,12 +12,36 @@ */ #include "inspircd.h" -#include "commands/cmd_clearcache.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_ADMIN_H__ +#define __CMD_ADMIN_H__ + +#include "users.h" +#include "channels.h" +#include "ctables.h" + +/** Handle /ADMIN. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandClearcache : public Command { - return new CommandClearcache(Instance); -} + public: + /** Constructor for clearcache. + */ + CommandClearcache (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"CLEARCACHE","o",0) { } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + /** Handle /CLEARCACHE */ @@ -27,3 +51,5 @@ CmdResult CommandClearcache::Handle (const std::vector<std::string>& parameters, user->WriteServ("NOTICE %s :*** Cleared DNS cache of %d items.", user->nick.c_str(), n); return CMD_SUCCESS; } + +COMMAND_INIT(CommandClearcache) diff --git a/src/commands/cmd_commands.cpp b/src/commands/cmd_commands.cpp index 2683f0619..5fa041b8f 100644 --- a/src/commands/cmd_commands.cpp +++ b/src/commands/cmd_commands.cpp @@ -12,15 +12,40 @@ */ #include "inspircd.h" -#include "commands/cmd_commands.h" -/** Handle /COMMANDS +#ifndef __CMD_COMMANDS_H__ +#define __CMD_COMMANDS_H__ + +// include the common header files + +#include "users.h" +#include "channels.h" + +/** Handle /COMMANDS. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. */ -extern "C" DllExport Command* init_command(InspIRCd* Instance) +class CommandCommands : public Command { - return new CommandCommands(Instance); -} + public: + /** Constructor for commands. + */ + CommandCommands (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"COMMANDS",0,0) { } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; +#endif + + +/** Handle /COMMANDS + */ CmdResult CommandCommands::Handle (const std::vector<std::string>&, User *user) { for (Commandtable::iterator i = ServerInstance->Parser->cmdlist.begin(); i != ServerInstance->Parser->cmdlist.end(); i++) @@ -36,3 +61,5 @@ CmdResult CommandCommands::Handle (const std::vector<std::string>&, User *user) user->WriteNumeric(RPL_COMMANDSEND, "%s :End of COMMANDS list",user->nick.c_str()); return CMD_SUCCESS; } + +COMMAND_INIT(CommandCommands) diff --git a/src/commands/cmd_connect.cpp b/src/commands/cmd_connect.cpp index 073993f8c..7a391592d 100644 --- a/src/commands/cmd_connect.cpp +++ b/src/commands/cmd_connect.cpp @@ -12,17 +12,42 @@ */ #include "inspircd.h" -#include "commands/cmd_connect.h" + +#ifndef __CMD_CONNECT_H__ +#define __CMD_CONNECT_H__ + +#include "users.h" +#include "channels.h" +#include "ctables.h" +#include "modules.h" + +/** Handle /CONNECT. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandConnect : public Command +{ + public: + /** Constructor for connect. + */ + CommandConnect (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"CONNECT","o",1,false,0) { syntax = "<servername> [<remote-server>]"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + /* * This is handled by the server linking module, if necessary. Do not remove this stub. */ -extern "C" DllExport Command* init_command(InspIRCd* Instance) -{ - return new CommandConnect(Instance); -} - /** Handle /CONNECT */ CmdResult CommandConnect::Handle (const std::vector<std::string>&, User *user) @@ -30,3 +55,5 @@ CmdResult CommandConnect::Handle (const std::vector<std::string>&, User *user) user->WriteServ( "NOTICE %s :Look into loading a linking module (like m_spanningtree) if you want this to do anything useful.", user->nick.c_str()); return CMD_SUCCESS; } + +COMMAND_INIT(CommandConnect) diff --git a/src/commands/cmd_die.cpp b/src/commands/cmd_die.cpp index b85323afc..6eb9e0336 100644 --- a/src/commands/cmd_die.cpp +++ b/src/commands/cmd_die.cpp @@ -12,13 +12,38 @@ */ #include "inspircd.h" -#include "commands/cmd_die.h" -#include "exitcodes.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_DIE_H__ +#define __CMD_DIE_H__ + +// include the common header files + +#include "users.h" +#include "channels.h" + +/** Handle /DIE. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandDie : public Command { - return new CommandDie(Instance); -} + public: + /** Constructor for die. + */ + CommandDie (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"DIE","o",1,false,0) { syntax = "<password>"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + +#include "exitcodes.h" /** Handle /DIE */ @@ -45,3 +70,5 @@ CmdResult CommandDie::Handle (const std::vector<std::string>& parameters, User * } return CMD_SUCCESS; } + +COMMAND_INIT(CommandDie) diff --git a/src/commands/cmd_eline.cpp b/src/commands/cmd_eline.cpp index d28f4c8ee..0591b9163 100644 --- a/src/commands/cmd_eline.cpp +++ b/src/commands/cmd_eline.cpp @@ -13,12 +13,49 @@ #include "inspircd.h" #include "xline.h" -#include "commands/cmd_eline.h" +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * See: http://wiki.inspircd.org/Credits + * + * This program is free but copyrighted software; see + * the file COPYING for details. + * + * --------------------------------------------------- + */ + +#ifndef __CMD_ELINE_H__ +#define __CMD_ELINE_H__ + +// include the common header files -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#include "users.h" +#include "channels.h" + +/** Handle /ELINE. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandEline : public Command { - return new CommandEline(Instance); -} + public: + /** Constructor for eline. + */ + CommandEline (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"ELINE","o",1,3,false,0) { syntax = "<ident@host> [<duration> :<reason>]"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + /** Handle /ELINE */ @@ -84,3 +121,5 @@ CmdResult CommandEline::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } + +COMMAND_INIT(CommandEline) diff --git a/src/commands/cmd_gline.cpp b/src/commands/cmd_gline.cpp index 346ca98f6..9da5f7071 100644 --- a/src/commands/cmd_gline.cpp +++ b/src/commands/cmd_gline.cpp @@ -13,12 +13,49 @@ #include "inspircd.h" #include "xline.h" -#include "commands/cmd_gline.h" +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * See: http://wiki.inspircd.org/Credits + * + * This program is free but copyrighted software; see + * the file COPYING for details. + * + * --------------------------------------------------- + */ + +#ifndef __CMD_GLINE_H__ +#define __CMD_GLINE_H__ + +// include the common header file -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#include "users.h" +#include "channels.h" + +/** Handle /GLINE. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandGline : public Command { - return new CommandGline(Instance); -} + public: + /** Constructor for gline. + */ + CommandGline (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"GLINE","o",1,3,false,0) { syntax = "<ident@host> [<duration> :<reason>]"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + /** Handle /GLINE */ @@ -92,3 +129,5 @@ CmdResult CommandGline::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } + +COMMAND_INIT(CommandGline) diff --git a/src/commands/cmd_info.cpp b/src/commands/cmd_info.cpp index 286e64f61..43f8286f2 100644 --- a/src/commands/cmd_info.cpp +++ b/src/commands/cmd_info.cpp @@ -12,12 +12,37 @@ */ #include "inspircd.h" -#include "commands/cmd_info.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_INFO_H__ +#define __CMD_INFO_H__ + +// include the common header files + +#include "users.h" +#include "channels.h" + +/** Handle /INFO. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandInfo : public Command { - return new CommandInfo(Instance); -} + public: + /** Constructor for info. + */ + CommandInfo (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"INFO",0,0) { syntax = "[<servermask>]"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + /** Handle /INFO */ @@ -62,3 +87,5 @@ CmdResult CommandInfo::Handle (const std::vector<std::string>&, User *user) user->WriteNumeric(RPL_ENDOFINFO, "%s :End of /INFO list", user->nick.c_str()); return CMD_SUCCESS; } + +COMMAND_INIT(CommandInfo) diff --git a/src/commands/cmd_invite.cpp b/src/commands/cmd_invite.cpp index 31c6f459c..73b7068e5 100644 --- a/src/commands/cmd_invite.cpp +++ b/src/commands/cmd_invite.cpp @@ -12,12 +12,37 @@ */ #include "inspircd.h" -#include "commands/cmd_invite.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_INVITE_H__ +#define __CMD_INVITE_H__ + +// include the common header files + +#include "users.h" +#include "channels.h" + +/** Handle /INVITE. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandInvite : public Command { - return new CommandInvite(Instance); -} + public: + /** Constructor for invite. + */ + CommandInvite (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"INVITE", 0, 0, false, 4) { syntax = "[<nick> <channel>]"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + /** Handle /INVITE */ @@ -111,3 +136,5 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use return CMD_SUCCESS; } + +COMMAND_INIT(CommandInvite) diff --git a/src/commands/cmd_ison.cpp b/src/commands/cmd_ison.cpp index 52fbcde4b..2f64547e6 100644 --- a/src/commands/cmd_ison.cpp +++ b/src/commands/cmd_ison.cpp @@ -12,12 +12,37 @@ */ #include "inspircd.h" -#include "commands/cmd_ison.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_ISON_H__ +#define __CMD_ISON_H__ + +// include the common header files + +#include "users.h" +#include "channels.h" + +/** Handle /ISON. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandIson : public Command { - return new CommandIson(Instance); -} + public: + /** Constructor for ison. + */ + CommandIson (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"ISON",0,0) { syntax = "<nick> {nick}"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + /** Handle /ISON */ @@ -79,3 +104,5 @@ CmdResult CommandIson::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } + +COMMAND_INIT(CommandIson) diff --git a/src/commands/cmd_join.cpp b/src/commands/cmd_join.cpp index c8d731ef5..d86516aaa 100644 --- a/src/commands/cmd_join.cpp +++ b/src/commands/cmd_join.cpp @@ -12,12 +12,37 @@ */ #include "inspircd.h" -#include "commands/cmd_join.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_JOIN_H__ +#define __CMD_JOIN_H__ + +// include the common header files + +#include "users.h" +#include "channels.h" + +/** Handle /JOIN. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandJoin : public Command { - return new CommandJoin(Instance); -} + public: + /** Constructor for join. + */ + CommandJoin (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"JOIN", 0, 1, false, 2) { syntax = "<channel>{,<channel>} {<key>{,<key>}}"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + /** Handle /JOIN */ @@ -49,3 +74,5 @@ CmdResult CommandJoin::Handle (const std::vector<std::string>& parameters, User user->WriteNumeric(ERR_NOSUCHCHANNEL, "%s %s :Invalid channel name",user->nick.c_str(), parameters[0].c_str()); return CMD_FAILURE; } + +COMMAND_INIT(CommandJoin) diff --git a/src/commands/cmd_kick.cpp b/src/commands/cmd_kick.cpp index e26ec8653..54a5bd888 100644 --- a/src/commands/cmd_kick.cpp +++ b/src/commands/cmd_kick.cpp @@ -12,12 +12,37 @@ */ #include "inspircd.h" -#include "commands/cmd_kick.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_KICK_H__ +#define __CMD_KICK_H__ + +// include the common header files + +#include "users.h" +#include "channels.h" + +/** Handle /KICK. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandKick : public Command { - return new CommandKick(Instance); -} + public: + /** Constructor for kick. + */ + CommandKick (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"KICK",0,2) { syntax = "<channel> <nick>{,<nick>} [<reason>]"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + /** Handle /KICK */ @@ -57,3 +82,5 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } + +COMMAND_INIT(CommandKick) diff --git a/src/commands/cmd_kill.cpp b/src/commands/cmd_kill.cpp index 2f1a4783e..15cf58f47 100644 --- a/src/commands/cmd_kill.cpp +++ b/src/commands/cmd_kill.cpp @@ -12,12 +12,37 @@ */ #include "inspircd.h" -#include "commands/cmd_kill.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_KILL_H__ +#define __CMD_KILL_H__ + +// include the common header files + +#include "users.h" +#include "channels.h" + +/** Handle /KILL. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandKill : public Command { - return new CommandKill(Instance); -} + public: + /** Constructor for kill. + */ + CommandKill (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"KILL","o",2,false,0) { syntax = "<nickname> <reason>"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + /** Handle /KILL */ @@ -113,3 +138,5 @@ CmdResult CommandKill::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } + +COMMAND_INIT(CommandKill) diff --git a/src/commands/cmd_kline.cpp b/src/commands/cmd_kline.cpp index 0a3e7c930..79e2e7292 100644 --- a/src/commands/cmd_kline.cpp +++ b/src/commands/cmd_kline.cpp @@ -13,12 +13,49 @@ #include "inspircd.h" #include "xline.h" -#include "commands/cmd_kline.h" +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * See: http://wiki.inspircd.org/Credits + * + * This program is free but copyrighted software; see + * the file COPYING for details. + * + * --------------------------------------------------- + */ + +#ifndef __CMD_KLINE_H__ +#define __CMD_KLINE_H__ + +// include the common header files -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#include "users.h" +#include "channels.h" + +/** Handle /KLINE. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandKline : public Command { - return new CommandKline(Instance); -} + public: + /** Constructor for kline. + */ + CommandKline (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"KLINE","o",1,3,false,0) { syntax = "<ident@host> [<duration> :<reason>]"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + /** Handle /KLINE */ @@ -91,3 +128,5 @@ CmdResult CommandKline::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } + +COMMAND_INIT(CommandKline) diff --git a/src/commands/cmd_links.cpp b/src/commands/cmd_links.cpp index 943577cd6..5de58e90f 100644 --- a/src/commands/cmd_links.cpp +++ b/src/commands/cmd_links.cpp @@ -12,12 +12,37 @@ */ #include "inspircd.h" -#include "commands/cmd_links.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_LINKS_H__ +#define __CMD_LINKS_H__ + +// include the common header files + +#include "users.h" +#include "channels.h" + +/** Handle /LINKS. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandLinks : public Command { - return new CommandLinks(Instance); -} + public: + /** Constructor for links. + */ + CommandLinks (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"LINKS",0,0) { } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + /** Handle /LINKS */ @@ -27,3 +52,5 @@ CmdResult CommandLinks::Handle (const std::vector<std::string>&, User *user) user->WriteNumeric(365, "%s * :End of /LINKS list.",user->nick.c_str()); return CMD_SUCCESS; } + +COMMAND_INIT(CommandLinks) diff --git a/src/commands/cmd_list.cpp b/src/commands/cmd_list.cpp index 9d65b4165..1560487c5 100644 --- a/src/commands/cmd_list.cpp +++ b/src/commands/cmd_list.cpp @@ -12,15 +12,40 @@ */ #include "inspircd.h" -#include "commands/cmd_list.h" -/** Handle /LIST +#ifndef __CMD_LIST_H__ +#define __CMD_LIST_H__ + +// include the common header files + +#include "users.h" +#include "channels.h" + +/** Handle /LIST. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. */ -extern "C" DllExport Command* init_command(InspIRCd* Instance) +class CommandList : public Command { - return new CommandList(Instance); -} + public: + /** Constructor for list. + */ + CommandList (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"LIST", 0, 0, false, 5) { } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; +#endif + + +/** Handle /LIST + */ CmdResult CommandList::Handle (const std::vector<std::string>& parameters, User *user) { int minusers = 0, maxusers = 0; @@ -79,3 +104,5 @@ CmdResult CommandList::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } + +COMMAND_INIT(CommandList) diff --git a/src/commands/cmd_loadmodule.cpp b/src/commands/cmd_loadmodule.cpp index c6dbd8069..d6456d7d2 100644 --- a/src/commands/cmd_loadmodule.cpp +++ b/src/commands/cmd_loadmodule.cpp @@ -12,12 +12,37 @@ */ #include "inspircd.h" -#include "commands/cmd_loadmodule.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_LOADMODULE_H__ +#define __CMD_LOADMODULE_H__ + +// include the common header files + +#include "users.h" +#include "channels.h" + +/** Handle /LOADMODULE. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandLoadmodule : public Command { - return new CommandLoadmodule(Instance); -} + public: + /** Constructor for loadmodule. + */ + CommandLoadmodule (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"LOADMODULE","o",1) { syntax = "<modulename>"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + /** Handle /LOADMODULE */ @@ -35,3 +60,5 @@ CmdResult CommandLoadmodule::Handle (const std::vector<std::string>& parameters, return CMD_FAILURE; } } + +COMMAND_INIT(CommandLoadmodule) diff --git a/src/commands/cmd_lusers.cpp b/src/commands/cmd_lusers.cpp index fb4b197c0..ea278a406 100644 --- a/src/commands/cmd_lusers.cpp +++ b/src/commands/cmd_lusers.cpp @@ -12,12 +12,37 @@ */ #include "inspircd.h" -#include "commands/cmd_lusers.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_LUSERS_H__ +#define __CMD_LUSERS_H__ + +// include the common header files + +#include "users.h" +#include "channels.h" + +/** Handle /LUSERS. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandLusers : public Command { - return new CommandLusers(Instance); -} + public: + /** Constructor for lusers. + */ + CommandLusers (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"LUSERS",0,0) { } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + /** Handle /LUSERS */ @@ -38,3 +63,5 @@ CmdResult CommandLusers::Handle (const std::vector<std::string>&, User *user) return CMD_SUCCESS; } + +COMMAND_INIT(CommandLusers) diff --git a/src/commands/cmd_map.cpp b/src/commands/cmd_map.cpp index 3c49ca0c0..780caf081 100644 --- a/src/commands/cmd_map.cpp +++ b/src/commands/cmd_map.cpp @@ -12,12 +12,37 @@ */ #include "inspircd.h" -#include "commands/cmd_map.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_MAP_H__ +#define __CMD_MAP_H__ + +// include the common header files + +#include "users.h" +#include "channels.h" + +/** Handle /MAP. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandMap : public Command { - return new CommandMap(Instance); -} + public: + /** Constructor for map. + */ + CommandMap (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"MAP",0,0,false,2) { } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + /** Handle /MAP */ @@ -31,3 +56,5 @@ CmdResult CommandMap::Handle (const std::vector<std::string>&, User *user) return CMD_SUCCESS; } + +COMMAND_INIT(CommandMap) diff --git a/src/commands/cmd_mode.cpp b/src/commands/cmd_mode.cpp index 267b78326..9b80b77a4 100644 --- a/src/commands/cmd_mode.cpp +++ b/src/commands/cmd_mode.cpp @@ -12,12 +12,36 @@ */ #include "inspircd.h" -#include "commands/cmd_mode.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_ADMIN_H__ +#define __CMD_ADMIN_H__ + +#include "users.h" +#include "channels.h" +#include "ctables.h" + +/** Handle /MODE. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandMode : public Command { - return new CommandMode(Instance); -} + public: + /** Constructor for mode. + */ + CommandMode (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"MODE",0,1) { syntax = "<target> <modes> {<mode-parameters>}"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + /** Handle /MODE */ @@ -27,3 +51,5 @@ CmdResult CommandMode::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } + +COMMAND_INIT(CommandMode) diff --git a/src/commands/cmd_modules.cpp b/src/commands/cmd_modules.cpp index 36e2e9109..619cf1cb6 100644 --- a/src/commands/cmd_modules.cpp +++ b/src/commands/cmd_modules.cpp @@ -12,12 +12,37 @@ */ #include "inspircd.h" -#include "commands/cmd_modules.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_MODULES_H__ +#define __CMD_MODULES_H__ + +// include the common header files + +#include "users.h" +#include "channels.h" + +/** Handle /MODULES. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandModules : public Command { - return new CommandModules(Instance); -} + public: + /** Constructor for modules. + */ + CommandModules (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"MODULES",0,0) { syntax = "[debug]"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + /** Handle /MODULES */ @@ -49,3 +74,5 @@ CmdResult CommandModules::Handle (const std::vector<std::string>&, User *user) return CMD_SUCCESS; } + +COMMAND_INIT(CommandModules) diff --git a/src/commands/cmd_motd.cpp b/src/commands/cmd_motd.cpp index 2db6139b1..36306603c 100644 --- a/src/commands/cmd_motd.cpp +++ b/src/commands/cmd_motd.cpp @@ -12,12 +12,40 @@ */ #include "inspircd.h" -#include "commands/cmd_motd.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_MOTD_H__ +#define __CMD_MOTD_H__ + +// include the common header files + +#include <string> +#include <vector> +#include "inspircd.h" +#include "users.h" +#include "channels.h" + +/** Handle /MOTD. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandMotd : public Command { - return new CommandMotd(Instance); -} + public: + /** Constructor for motd. + */ + CommandMotd (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"MOTD",0,0) { syntax = "[<servername>]"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + /** Handle /MOTD */ @@ -26,3 +54,5 @@ CmdResult CommandMotd::Handle (const std::vector<std::string>&, User *user) user->ShowMOTD(); return CMD_SUCCESS; } + +COMMAND_INIT(CommandMotd) diff --git a/src/commands/cmd_names.cpp b/src/commands/cmd_names.cpp index e6df558a6..642fafb5d 100644 --- a/src/commands/cmd_names.cpp +++ b/src/commands/cmd_names.cpp @@ -12,12 +12,37 @@ */ #include "inspircd.h" -#include "commands/cmd_names.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_NAMES_H__ +#define __CMD_NAMES_H__ + +// include the common header files + +#include "users.h" +#include "channels.h" + +/** Handle /NAMES. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandNames : public Command { - return new CommandNames(Instance); -} + public: + /** Constructor for names. + */ + CommandNames (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"NAMES",0,0) { syntax = "{<channel>{,<channel>}}"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + /** Handle /NAMES */ @@ -51,3 +76,5 @@ CmdResult CommandNames::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } + +COMMAND_INIT(CommandNames) diff --git a/src/commands/cmd_nick.cpp b/src/commands/cmd_nick.cpp index 33e0e8081..ecc254f17 100644 --- a/src/commands/cmd_nick.cpp +++ b/src/commands/cmd_nick.cpp @@ -13,12 +13,57 @@ #include "inspircd.h" #include "xline.h" -#include "commands/cmd_nick.h" +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * See: http://wiki.inspircd.org/Credits + * + * This program is free but copyrighted software; see + * the file COPYING for details. + * + * --------------------------------------------------- + */ + +#ifndef __CMD_NICK_H__ +#define __CMD_NICK_H__ + +// include the common header files -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#include "users.h" +#include "channels.h" + +/** Handle /NICK. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandNick : public Command { - return new CommandNick(Instance); -} + bool allowinvalid; + public: + /** Constructor for nick. + */ + CommandNick (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"NICK", 0, 1, true, 3), allowinvalid(false) { syntax = "<newnick>"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); + + /** Handle internal command + * @param id Used to indicate if invalid nick changes are allowed. + * Set to 1 to allow invalid nicks and 0 to deny them. + * @param parameters Currently unused + */ + CmdResult HandleInternal(const unsigned int id, const std::deque<classbase*> ¶meters); +}; + +#endif + /** Handle nick changes from users. * NOTE: If you are used to ircds based on ircd2.8, and are looking @@ -212,3 +257,5 @@ CmdResult CommandNick::HandleInternal(const unsigned int id, const std::deque<cl return CMD_SUCCESS; } + +COMMAND_INIT(CommandNick) diff --git a/src/commands/cmd_notice.cpp b/src/commands/cmd_notice.cpp index e9049d7ab..c94dbc87a 100644 --- a/src/commands/cmd_notice.cpp +++ b/src/commands/cmd_notice.cpp @@ -12,12 +12,37 @@ */ #include "inspircd.h" -#include "commands/cmd_notice.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_NOTICE_H__ +#define __CMD_NOTICE_H__ + +// include the common header files + +#include "users.h" +#include "channels.h" + +/** Handle /NOTICE. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandNotice : public Command { - return new CommandNotice(Instance); -} + public: + /** Constructor for notice. + */ + CommandNotice (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"NOTICE",0,2) { syntax = "<target>{,<target>} <message>"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, User *user) { @@ -185,3 +210,5 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use return CMD_SUCCESS; } + +COMMAND_INIT(CommandNotice) diff --git a/src/commands/cmd_oper.cpp b/src/commands/cmd_oper.cpp index 85af2da18..3efafca5b 100644 --- a/src/commands/cmd_oper.cpp +++ b/src/commands/cmd_oper.cpp @@ -12,7 +12,39 @@ */ #include "inspircd.h" -#include "commands/cmd_oper.h" + +#ifndef __CMD_OPER_H__ +#define __CMD_OPER_H__ + +// include the common header files + +#include "users.h" +#include "channels.h" + +bool OneOfMatches(const char* host, const char* ip, const char* hostlist); + +/** Handle /OPER. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandOper : public Command +{ + public: + /** Constructor for oper. + */ + CommandOper (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"OPER",0,2,false,2) { syntax = "<username> <password>"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + #include "hashcomp.h" bool OneOfMatches(const char* host, const char* ip, const char* hostlist) @@ -29,11 +61,6 @@ bool OneOfMatches(const char* host, const char* ip, const char* hostlist) return false; } -extern "C" DllExport Command* init_command(InspIRCd* Instance) -{ - return new CommandOper(Instance); -} - CmdResult CommandOper::Handle (const std::vector<std::string>& parameters, User *user) { char LoginName[MAXBUF]; @@ -150,3 +177,5 @@ CmdResult CommandOper::Handle (const std::vector<std::string>& parameters, User } return CMD_SUCCESS; } + +COMMAND_INIT(CommandOper) diff --git a/src/commands/cmd_part.cpp b/src/commands/cmd_part.cpp index 834ee2b28..e9753c456 100644 --- a/src/commands/cmd_part.cpp +++ b/src/commands/cmd_part.cpp @@ -12,12 +12,37 @@ */ #include "inspircd.h" -#include "commands/cmd_part.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_PART_H__ +#define __CMD_PART_H__ + +// include the common header files + +#include "users.h" +#include "channels.h" + +/** Handle /PART. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandPart : public Command { - return new CommandPart(Instance); -} + public: + /** Constructor for part. + */ + CommandPart (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"PART", 0, 1, false, 5) { syntax = "<channel>{,<channel>} [<reason>]"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + CmdResult CommandPart::Handle (const std::vector<std::string>& parameters, User *user) { @@ -59,3 +84,5 @@ CmdResult CommandPart::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } + +COMMAND_INIT(CommandPart) diff --git a/src/commands/cmd_pass.cpp b/src/commands/cmd_pass.cpp index e4bbf59c2..8429a494f 100644 --- a/src/commands/cmd_pass.cpp +++ b/src/commands/cmd_pass.cpp @@ -12,12 +12,40 @@ */ #include "inspircd.h" -#include "commands/cmd_pass.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_PASS_H__ +#define __CMD_PASS_H__ + +// include the common header files + +#include <string> +#include <vector> +#include "inspircd.h" +#include "users.h" +#include "channels.h" + +/** Handle /PASS. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandPass : public Command { - return new CommandPass(Instance); -} + public: + /** Constructor for pass. + */ + CommandPass (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"PASS",0,1,true,0) { syntax = "<password>"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + CmdResult CommandPass::Handle (const std::vector<std::string>& parameters, User *user) { @@ -37,3 +65,5 @@ CmdResult CommandPass::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } + +COMMAND_INIT(CommandPass) diff --git a/src/commands/cmd_ping.cpp b/src/commands/cmd_ping.cpp index 11e975624..feea84f59 100644 --- a/src/commands/cmd_ping.cpp +++ b/src/commands/cmd_ping.cpp @@ -12,15 +12,42 @@ */ #include "inspircd.h" -#include "commands/cmd_ping.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_PING_H__ +#define __CMD_PING_H__ + +// include the common header files + +#include "users.h" +#include "channels.h" + +/** Handle /PING. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandPing : public Command { - return new CommandPing(Instance); -} + public: + /** Constructor for ping. + */ + CommandPing (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"PING", 0, 1, false, 0) { syntax = "<servername> [:<servername>]"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + CmdResult CommandPing::Handle (const std::vector<std::string>& parameters, User *user) { user->WriteServ("PONG %s :%s", ServerInstance->Config->ServerName, parameters[0].c_str()); return CMD_SUCCESS; } + +COMMAND_INIT(CommandPing) diff --git a/src/commands/cmd_pong.cpp b/src/commands/cmd_pong.cpp index 6ceb11e93..5ca5b4cfc 100644 --- a/src/commands/cmd_pong.cpp +++ b/src/commands/cmd_pong.cpp @@ -12,12 +12,38 @@ */ #include "inspircd.h" -#include "commands/cmd_pong.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_PONG_H__ +#define __CMD_PONG_H__ + +// include the common header files + +#include "inspircd.h" +#include "users.h" +#include "channels.h" + +/** Handle /PONG. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandPong : public Command { - return new CommandPong(Instance); -} + public: + /** Constructor for pong. + */ + CommandPong (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"PONG", 0, 1, false, 0) { syntax = "<ping-text>"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + CmdResult CommandPong::Handle (const std::vector<std::string>&, User *user) { @@ -25,3 +51,5 @@ CmdResult CommandPong::Handle (const std::vector<std::string>&, User *user) user->lastping = 1; return CMD_SUCCESS; } + +COMMAND_INIT(CommandPong) diff --git a/src/commands/cmd_privmsg.cpp b/src/commands/cmd_privmsg.cpp index c6e74db8b..5861bd086 100644 --- a/src/commands/cmd_privmsg.cpp +++ b/src/commands/cmd_privmsg.cpp @@ -12,12 +12,37 @@ */ #include "inspircd.h" -#include "commands/cmd_privmsg.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_PRIVMSG_H__ +#define __CMD_PRIVMSG_H__ + +// include the common header files + +#include "users.h" +#include "channels.h" + +/** Handle /PRIVMSG. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandPrivmsg : public Command { - return new CommandPrivmsg(Instance); -} + public: + /** Constructor for privmsg. + */ + CommandPrivmsg (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"PRIVMSG",0,2) { syntax = "<target>{,<target>} <message>"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, User *user) { @@ -202,3 +227,5 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us } return CMD_SUCCESS; } + +COMMAND_INIT(CommandPrivmsg) diff --git a/src/commands/cmd_qline.cpp b/src/commands/cmd_qline.cpp index 347771453..ebd1d6b31 100644 --- a/src/commands/cmd_qline.cpp +++ b/src/commands/cmd_qline.cpp @@ -13,14 +13,51 @@ #include "inspircd.h" #include "xline.h" -#include "commands/cmd_qline.h" +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * See: http://wiki.inspircd.org/Credits + * + * This program is free but copyrighted software; see + * the file COPYING for details. + * + * --------------------------------------------------- + */ + +#ifndef __CMD_QLINE_H__ +#define __CMD_QLINE_H__ +// include the common header files +#include "users.h" +#include "channels.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +/** Handle /QLINE. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandQline : public Command { - return new CommandQline(Instance); -} + public: + /** Constructor for qline. + */ + CommandQline (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"QLINE","o",1,3,false,0) { syntax = "<nick> [<duration> :<reason>]"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + + + CmdResult CommandQline::Handle (const std::vector<std::string>& parameters, User *user) { @@ -73,3 +110,5 @@ CmdResult CommandQline::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } + +COMMAND_INIT(CommandQline) diff --git a/src/commands/cmd_quit.cpp b/src/commands/cmd_quit.cpp index e29382e84..968374dec 100644 --- a/src/commands/cmd_quit.cpp +++ b/src/commands/cmd_quit.cpp @@ -12,14 +12,39 @@ */ #include "inspircd.h" -#include "commands/cmd_quit.h" +#ifndef __CMD_QUIT_H__ +#define __CMD_QUIT_H__ +// include the common header files -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#include "users.h" +#include "channels.h" + +/** Handle /QUIT. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandQuit : public Command { - return new CommandQuit(Instance); -} + public: + /** Constructor for quit. + */ + CommandQuit (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"QUIT",0,0,true) { syntax = "[<message>]"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + + + CmdResult CommandQuit::Handle (const std::vector<std::string>& parameters, User *user) { @@ -52,3 +77,5 @@ CmdResult CommandQuit::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } + +COMMAND_INIT(CommandQuit) diff --git a/src/commands/cmd_rehash.cpp b/src/commands/cmd_rehash.cpp index 96313829f..60b1e12b6 100644 --- a/src/commands/cmd_rehash.cpp +++ b/src/commands/cmd_rehash.cpp @@ -13,13 +13,50 @@ #include "inspircd.h" #include "xline.h" -#include "commands/cmd_rehash.h" +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * See: http://wiki.inspircd.org/Credits + * + * This program is free but copyrighted software; see + * the file COPYING for details. + * + * --------------------------------------------------- + */ + +#ifndef __CMD_REHASH_H__ +#define __CMD_REHASH_H__ + +// include the common header files +#include "users.h" +#include "channels.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +/** Handle /REHASH. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandRehash : public Command { - return new CommandRehash(Instance); -} + public: + /** Constructor for rehash. + */ + CommandRehash (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"REHASH","o",0,false,3) { syntax = "[<servermask>]"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + + CmdResult CommandRehash::Handle (const std::vector<std::string>& parameters, User *user) { @@ -93,3 +130,5 @@ CmdResult CommandRehash::Handle (const std::vector<std::string>& parameters, Use } } + +COMMAND_INIT(CommandRehash) diff --git a/src/commands/cmd_reloadmodule.cpp b/src/commands/cmd_reloadmodule.cpp index a94493455..5d84fc7d5 100644 --- a/src/commands/cmd_reloadmodule.cpp +++ b/src/commands/cmd_reloadmodule.cpp @@ -12,12 +12,21 @@ */ #include "inspircd.h" -#include "commands/cmd_reloadmodule.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +class CommandReloadmodule : public Command { - return new CommandReloadmodule(Instance); -} + public: + /** Constructor for reloadmodule. + */ + CommandReloadmodule (InspIRCd* Instance, Module* parent) : Command(Instance, parent, "RELOADMODULE","o",1) { syntax = "<modulename>"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; CmdResult CommandReloadmodule::Handle (const std::vector<std::string>& parameters, User *user) { @@ -36,3 +45,5 @@ CmdResult CommandReloadmodule::Handle (const std::vector<std::string>& parameter user->WriteNumeric(975, "%s %s :%s",user->nick.c_str(), parameters[0].c_str(), ServerInstance->Modules->LastError().c_str()); return CMD_FAILURE; } + +COMMAND_INIT(CommandReloadmodule) diff --git a/src/commands/cmd_restart.cpp b/src/commands/cmd_restart.cpp index 964c7755f..ffd0323b7 100644 --- a/src/commands/cmd_restart.cpp +++ b/src/commands/cmd_restart.cpp @@ -12,12 +12,40 @@ */ #include "inspircd.h" -#include "commands/cmd_restart.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_RESTART_H__ +#define __CMD_RESTART_H__ + +// include the common header files + +#include <string> +#include <deque> +#include <vector> +#include "users.h" +#include "channels.h" + +/** Handle /RESTART. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandRestart : public Command { - return new CommandRestart(Instance); -} + public: + /** Constructor for restart. + */ + CommandRestart (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"RESTART","o",1,false,0) { syntax = "<password>"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + CmdResult CommandRestart::Handle (const std::vector<std::string>& parameters, User *user) { @@ -45,3 +73,5 @@ CmdResult CommandRestart::Handle (const std::vector<std::string>& parameters, Us return CMD_SUCCESS; } + +COMMAND_INIT(CommandRestart) diff --git a/src/commands/cmd_rules.cpp b/src/commands/cmd_rules.cpp index c47ff38ad..b5b5fbc15 100644 --- a/src/commands/cmd_rules.cpp +++ b/src/commands/cmd_rules.cpp @@ -12,15 +12,45 @@ */ #include "inspircd.h" -#include "commands/cmd_rules.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_RULES_H__ +#define __CMD_RULES_H__ + +// include the common header files + +#include <string> +#include <vector> +#include "inspircd.h" +#include "users.h" +#include "channels.h" + +/** Handle /RULES. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandRules : public Command { - return new CommandRules(Instance); -} + public: + /** Constructor for rules. + */ + CommandRules (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"RULES",0,0) { syntax = "[<servername>]"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + CmdResult CommandRules::Handle (const std::vector<std::string>& parameters, User *user) { user->ShowRULES(); return CMD_SUCCESS; } + +COMMAND_INIT(CommandRules) diff --git a/src/commands/cmd_server.cpp b/src/commands/cmd_server.cpp index eced487d3..c350dd2a6 100644 --- a/src/commands/cmd_server.cpp +++ b/src/commands/cmd_server.cpp @@ -12,14 +12,39 @@ */ #include "inspircd.h" -#include "commands/cmd_server.h" +#ifndef __CMD_SERVER_H__ +#define __CMD_SERVER_H__ +// include the common header files -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#include "users.h" +#include "channels.h" + +/** Handle /SERVER. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandServer : public Command { - return new CommandServer(Instance); -} + public: + /** Constructor for server. + */ + CommandServer (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"SERVER",0,0,true) { } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + + + CmdResult CommandServer::Handle (const std::vector<std::string>&, User *user) { @@ -33,3 +58,5 @@ CmdResult CommandServer::Handle (const std::vector<std::string>&, User *user) } return CMD_FAILURE; } + +COMMAND_INIT(CommandServer) diff --git a/src/commands/cmd_squit.cpp b/src/commands/cmd_squit.cpp index 46c56c8f5..ada5655d1 100644 --- a/src/commands/cmd_squit.cpp +++ b/src/commands/cmd_squit.cpp @@ -12,20 +12,50 @@ */ #include "inspircd.h" -#include "commands/cmd_squit.h" + +#ifndef __CMD_SQUIT_H__ +#define __CMD_SQUIT_H__ + +// include the common header files + +#include <string> +#include <vector> +#include "inspircd.h" +#include "users.h" +#include "channels.h" + +/** Handle /SQUIT. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandSquit : public Command +{ + public: + /** Constructor for squit. + */ + CommandSquit (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"SQUIT","o",1) { syntax = "<servername> [<reason>]"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + /* * This is handled by the server linking module, if necessary. Do not remove this stub. */ -extern "C" DllExport Command* init_command(InspIRCd* Instance) -{ - return new CommandSquit(Instance); -} - CmdResult CommandSquit::Handle (const std::vector<std::string>&, User *user) { user->WriteServ( "NOTICE %s :Look into loading a linking module (like m_spanningtree) if you want this to do anything useful.", user->nick.c_str()); return CMD_FAILURE; } + +COMMAND_INIT(CommandSquit) diff --git a/src/commands/cmd_stats.cpp b/src/commands/cmd_stats.cpp index ecd19a71e..e3961a906 100644 --- a/src/commands/cmd_stats.cpp +++ b/src/commands/cmd_stats.cpp @@ -25,14 +25,26 @@ #endif #include "xline.h" -#include "commands/cmd_stats.h" -#include "commands/cmd_whowas.h" - -extern "C" DllExport Command* init_command(InspIRCd* Instance) +/** Handle /STATS. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandStats : public Command { - return new CommandStats(Instance); -} + public: + /** Constructor for stats. + */ + CommandStats (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"STATS",0,1) { syntax = "<stats-symbol> [<servername>]"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; CmdResult CommandStats::Handle (const std::vector<std::string>& parameters, User *user) { @@ -45,7 +57,7 @@ CmdResult CommandStats::Handle (const std::vector<std::string>& parameters, User return CMD_FAILURE; } char search = parameters[0][0]; - DoStats(this->ServerInstance, search, user, values); + ServerInstance->DoStats(search, user, values); for (size_t i = 0; i < values.size(); i++) user->Write(":%s", values[i].c_str()); } @@ -53,296 +65,4 @@ CmdResult CommandStats::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } -DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, string_list &results) -{ - std::string sn(ServerInstance->Config->ServerName); - - if (!user->HasPrivPermission("servers/auspex") && !strchr(ServerInstance->Config->UserStats, statschar)) - { - ServerInstance->SNO->WriteToSnoMask('t', - "%s '%c' denied for %s (%s@%s)", - (IS_LOCAL(user) ? "Stats" : "Remote stats"), - statschar, user->nick.c_str(), user->ident.c_str(), user->host.c_str()); - results.push_back(sn + " 481 " + user->nick + " :Permission denied - STATS " + statschar + " requires the servers/auspex priv."); - return; - } - - ModResult MOD_RESULT; - FIRST_MOD_RESULT(ServerInstance, OnStats, MOD_RESULT, (statschar, user, results)); - if (MOD_RESULT == MOD_RES_DENY) - { - results.push_back(sn+" 219 "+user->nick+" "+statschar+" :End of /STATS report"); - ServerInstance->SNO->WriteToSnoMask('t',"%s '%c' requested by %s (%s@%s)", - (IS_LOCAL(user) ? "Stats" : "Remote stats"), statschar, user->nick.c_str(), user->ident.c_str(), user->host.c_str()); - return; - } - - switch (statschar) - { - /* stats p (show listening ports and registered clients on each) */ - case 'p': - { - for (size_t i = 0; i < ServerInstance->ports.size(); i++) - { - std::string ip = ServerInstance->ports[i]->GetIP(); - if (ip.empty()) - ip.assign("*"); - - results.push_back(sn+" 249 "+user->nick+" :"+ ip + ":"+ConvToStr(ServerInstance->ports[i]->GetPort())+" (client, " + - ServerInstance->ports[i]->GetDescription() + ")"); - } - } - break; - - /* These stats symbols must be handled by a linking module */ - case 'n': - case 'c': - break; - - case 'i': - { - int idx = 0; - for (ClassVector::iterator i = ServerInstance->Config->Classes.begin(); i != ServerInstance->Config->Classes.end(); i++) - { - ConnectClass* c = *i; - results.push_back(sn+" 215 "+user->nick+" i NOMATCH * "+c->GetHost()+" "+ConvToStr(c->limit ? c->limit : ServerInstance->SE->GetMaxFds())+" "+ConvToStr(idx)+" "+ServerInstance->Config->ServerName+" *"); - idx++; - } - } - break; - - case 'Y': - { - int idx = 0; - for (ClassVector::iterator i = ServerInstance->Config->Classes.begin(); i != ServerInstance->Config->Classes.end(); i++) - { - ConnectClass* c = *i; - results.push_back(sn+" 218 "+user->nick+" Y "+ConvToStr(idx)+" "+ConvToStr(c->GetPingTime())+" 0 "+ConvToStr(c->GetSendqMax())+" :"+ - ConvToStr(c->GetRecvqMax())+" "+ConvToStr(c->GetRegTimeout())); - idx++; - } - } - break; - - case 'U': - { - char ulined[MAXBUF]; - for (int i = 0; i < ServerInstance->Config->ConfValueEnum("uline"); i++) - { - ServerInstance->Config->ConfValue("uline","server", i, ulined, MAXBUF); - results.push_back(sn+" 248 "+user->nick+" U "+std::string(ulined)); - } - } - break; - - case 'P': - { - int idx = 0; - for (user_hash::iterator i = ServerInstance->Users->clientlist->begin(); i != ServerInstance->Users->clientlist->end(); i++) - { - if (IS_OPER(i->second) && !ServerInstance->ULine(i->second->server)) - { - results.push_back(sn+" 249 "+user->nick+" :"+i->second->nick+" ("+i->second->ident+"@"+i->second->dhost+") Idle: "+ - (IS_LOCAL(i->second) ? ConvToStr(ServerInstance->Time() - i->second->idle_lastmsg) + " secs" : "unavailable")); - idx++; - } - } - results.push_back(sn+" 249 "+user->nick+" :"+ConvToStr(idx)+" OPER(s)"); - } - break; - - case 'k': - ServerInstance->XLines->InvokeStats("K",216,user,results); - break; - case 'g': - ServerInstance->XLines->InvokeStats("G",223,user,results); - break; - case 'q': - ServerInstance->XLines->InvokeStats("Q",217,user,results); - break; - case 'Z': - ServerInstance->XLines->InvokeStats("Z",223,user,results); - break; - case 'e': - ServerInstance->XLines->InvokeStats("E",223,user,results); - break; - case 'E': - results.push_back(sn+" 249 "+user->nick+" :Total events: "+ConvToStr(ServerInstance->SE->TotalEvents)); - results.push_back(sn+" 249 "+user->nick+" :Read events: "+ConvToStr(ServerInstance->SE->ReadEvents)); - results.push_back(sn+" 249 "+user->nick+" :Write events: "+ConvToStr(ServerInstance->SE->WriteEvents)); - results.push_back(sn+" 249 "+user->nick+" :Error events: "+ConvToStr(ServerInstance->SE->ErrorEvents)); - break; - - /* stats m (list number of times each command has been used, plus bytecount) */ - case 'm': - for (Commandtable::iterator i = ServerInstance->Parser->cmdlist.begin(); i != ServerInstance->Parser->cmdlist.end(); i++) - { - if (i->second->use_count) - { - /* RPL_STATSCOMMANDS */ - results.push_back(sn+" 212 "+user->nick+" "+i->second->command+" "+ConvToStr(i->second->use_count)+" "+ConvToStr(i->second->total_bytes)); - } - } - break; - - /* stats z (debug and memory info) */ - case 'z': - { - results.push_back(sn+" 240 "+user->nick+" :InspIRCd: "+ConvToStr(sizeof(InspIRCd))+" bytes"); - results.push_back(sn+" 249 "+user->nick+" :Users: "+ConvToStr(ServerInstance->Users->clientlist->size())); - results.push_back(sn+" 249 "+user->nick+" :Channels: "+ConvToStr(ServerInstance->chanlist->size())); - results.push_back(sn+" 249 "+user->nick+" :Commands: "+ConvToStr(ServerInstance->Parser->cmdlist.size())); - - if (!ServerInstance->Config->WhoWasGroupSize == 0 && !ServerInstance->Config->WhoWasMaxGroups == 0) - { - Command* whowas_command = ServerInstance->Parser->GetHandler("WHOWAS"); - if (whowas_command) - { - std::deque<classbase*> params; - Extensible whowas_stats; - params.push_back(&whowas_stats); - whowas_command->HandleInternal(WHOWAS_STATS, params); - if (whowas_stats.GetExt("stats")) - { - char* stats; - whowas_stats.GetExt("stats", stats); - results.push_back(sn+" 249 "+user->nick+" :"+ConvToStr(stats)); - } - } - } - - results.push_back(sn+" 249 "+user->nick+" :MOTD "+ConvToStr(ServerInstance->Config->MOTD.size())+", RULES "+ConvToStr(ServerInstance->Config->RULES.size())); - - float kbitpersec_in, kbitpersec_out, kbitpersec_total; - char kbitpersec_in_s[30], kbitpersec_out_s[30], kbitpersec_total_s[30]; - - ServerInstance->SE->GetStats(kbitpersec_in, kbitpersec_out, kbitpersec_total); - - snprintf(kbitpersec_total_s, 30, "%03.5f", kbitpersec_total); - snprintf(kbitpersec_out_s, 30, "%03.5f", kbitpersec_out); - snprintf(kbitpersec_in_s, 30, "%03.5f", kbitpersec_in); - - results.push_back(sn+" 249 "+user->nick+" :Bandwidth total: "+ConvToStr(kbitpersec_total_s)+" kilobits/sec"); - results.push_back(sn+" 249 "+user->nick+" :Bandwidth out: "+ConvToStr(kbitpersec_out_s)+" kilobits/sec"); - results.push_back(sn+" 249 "+user->nick+" :Bandwidth in: "+ConvToStr(kbitpersec_in_s)+" kilobits/sec"); - -#ifndef WIN32 - /* Moved this down here so all the not-windows stuff (look w00tie, I didn't say win32!) is in one ifndef. - * Also cuts out some identical code in both branches of the ifndef. -- Om - */ - rusage R; - - /* Not sure why we were doing '0' with a RUSAGE_SELF comment rather than just using RUSAGE_SELF -- Om */ - if (!getrusage(RUSAGE_SELF,&R)) /* RUSAGE_SELF */ - { - results.push_back(sn+" 249 "+user->nick+" :Total allocation: "+ConvToStr(R.ru_maxrss)+"K"); - results.push_back(sn+" 249 "+user->nick+" :Signals: "+ConvToStr(R.ru_nsignals)); - results.push_back(sn+" 249 "+user->nick+" :Page faults: "+ConvToStr(R.ru_majflt)); - results.push_back(sn+" 249 "+user->nick+" :Swaps: "+ConvToStr(R.ru_nswap)); - results.push_back(sn+" 249 "+user->nick+" :Context Switches: Voluntary; "+ConvToStr(R.ru_nvcsw)+" Involuntary; "+ConvToStr(R.ru_nivcsw)); - - timeval tv; - char percent[30]; - gettimeofday(&tv, NULL); - - float n_elapsed = ((tv.tv_sec - ServerInstance->stats->LastSampled.tv_sec) * 1000000 + tv.tv_usec - ServerInstance->stats->LastSampled.tv_usec); - float n_eaten = ((R.ru_utime.tv_sec - ServerInstance->stats->LastCPU.tv_sec) * 1000000 + R.ru_utime.tv_usec - ServerInstance->stats->LastCPU.tv_usec); - float per = (n_eaten / n_elapsed) * 100; - - snprintf(percent, 30, "%03.5f%%", per); - results.push_back(sn+" 249 "+user->nick+" :CPU Usage: "+percent); - } -#else - PROCESS_MEMORY_COUNTERS MemCounters; - if (GetProcessMemoryInfo(GetCurrentProcess(), &MemCounters, sizeof(MemCounters))) - { - results.push_back(sn+" 249 "+user->nick+" :Total allocation: "+ConvToStr((MemCounters.WorkingSetSize + MemCounters.PagefileUsage) / 1024)+"K"); - results.push_back(sn+" 249 "+user->nick+" :Pagefile usage: "+ConvToStr(MemCounters.PagefileUsage / 1024)+"K"); - results.push_back(sn+" 249 "+user->nick+" :Page faults: "+ConvToStr(MemCounters.PageFaultCount)); - results.push_back(sn+" 249 "+user->nick+" :CPU Usage: " + ConvToStr(getcpu()) + "%"); - } -#endif - } - break; - - case 'T': - { - char buffer[MAXBUF]; - results.push_back(sn+" 249 "+user->nick+" :accepts "+ConvToStr(ServerInstance->stats->statsAccept)+" refused "+ConvToStr(ServerInstance->stats->statsRefused)); - results.push_back(sn+" 249 "+user->nick+" :unknown commands "+ConvToStr(ServerInstance->stats->statsUnknown)); - results.push_back(sn+" 249 "+user->nick+" :nick collisions "+ConvToStr(ServerInstance->stats->statsCollisions)); - results.push_back(sn+" 249 "+user->nick+" :dns requests "+ConvToStr(ServerInstance->stats->statsDnsGood+ServerInstance->stats->statsDnsBad)+" succeeded "+ConvToStr(ServerInstance->stats->statsDnsGood)+" failed "+ConvToStr(ServerInstance->stats->statsDnsBad)); - results.push_back(sn+" 249 "+user->nick+" :connection count "+ConvToStr(ServerInstance->stats->statsConnects)); - snprintf(buffer,MAXBUF," 249 %s :bytes sent %5.2fK recv %5.2fK",user->nick.c_str(),ServerInstance->stats->statsSent / 1024,ServerInstance->stats->statsRecv / 1024); - results.push_back(sn+buffer); - } - break; - - /* stats o */ - case 'o': - for (int i = 0; i < ServerInstance->Config->ConfValueEnum("oper"); i++) - { - char LoginName[MAXBUF]; - char HostName[MAXBUF]; - char OperType[MAXBUF]; - ServerInstance->Config->ConfValue("oper","name", i, LoginName, MAXBUF); - ServerInstance->Config->ConfValue("oper","host", i, HostName, MAXBUF); - ServerInstance->Config->ConfValue("oper","type", i, OperType, MAXBUF); - results.push_back(sn+" 243 "+user->nick+" O "+HostName+" * "+LoginName+" "+OperType+" 0"); - } - break; - - /* stats l (show user I/O stats) */ - case 'l': - results.push_back(sn+" 211 "+user->nick+" :nick[ident@host] sendq cmds_out bytes_out cmds_in bytes_in time_open"); - for (std::vector<User*>::iterator n = ServerInstance->Users->local_users.begin(); n != ServerInstance->Users->local_users.end(); n++) - { - User* i = *n; - results.push_back(sn+" 211 "+user->nick+" "+i->nick+"["+i->ident+"@"+i->dhost+"] "+ConvToStr(i->sendq.length())+" "+ConvToStr(i->cmds_out)+" "+ConvToStr(i->bytes_out)+" "+ConvToStr(i->cmds_in)+" "+ConvToStr(i->bytes_in)+" "+ConvToStr(ServerInstance->Time() - i->age)); - } - break; - - /* stats L (show user I/O stats with IP addresses) */ - case 'L': - results.push_back(sn+" 211 "+user->nick+" :nick[ident@ip] sendq cmds_out bytes_out cmds_in bytes_in time_open"); - for (std::vector<User*>::iterator n = ServerInstance->Users->local_users.begin(); n != ServerInstance->Users->local_users.end(); n++) - { - User* i = *n; - results.push_back(sn+" 211 "+user->nick+" "+i->nick+"["+i->ident+"@"+i->GetIPString()+"] "+ConvToStr(i->sendq.length())+" "+ConvToStr(i->cmds_out)+" "+ConvToStr(i->bytes_out)+" "+ConvToStr(i->cmds_in)+" "+ConvToStr(i->bytes_in)+" "+ConvToStr(ServerInstance->Time() - i->age)); - } - break; - - /* stats u (show server uptime) */ - case 'u': - { - time_t current_time = 0; - current_time = ServerInstance->Time(); - time_t server_uptime = current_time - ServerInstance->startup_time; - struct tm* stime; - stime = gmtime(&server_uptime); - /* i dont know who the hell would have an ircd running for over a year nonstop, but - * Craig suggested this, and it seemed a good idea so in it went */ - if (stime->tm_year > 70) - { - char buffer[MAXBUF]; - snprintf(buffer,MAXBUF," 242 %s :Server up %d years, %d days, %.2d:%.2d:%.2d",user->nick.c_str(),(stime->tm_year-70),stime->tm_yday,stime->tm_hour,stime->tm_min,stime->tm_sec); - results.push_back(sn+buffer); - } - else - { - char buffer[MAXBUF]; - snprintf(buffer,MAXBUF," 242 %s :Server up %d days, %.2d:%.2d:%.2d",user->nick.c_str(),stime->tm_yday,stime->tm_hour,stime->tm_min,stime->tm_sec); - results.push_back(sn+buffer); - } - } - break; - - default: - break; - } - - results.push_back(sn+" 219 "+user->nick+" "+statschar+" :End of /STATS report"); - ServerInstance->SNO->WriteToSnoMask('t',"%s '%c' requested by %s (%s@%s)", - (IS_LOCAL(user) ? "Stats" : "Remote stats"), statschar, user->nick.c_str(), user->ident.c_str(), user->host.c_str()); - return; -} +COMMAND_INIT(CommandStats) diff --git a/src/commands/cmd_time.cpp b/src/commands/cmd_time.cpp index 002750dfa..4fdcb8aa6 100644 --- a/src/commands/cmd_time.cpp +++ b/src/commands/cmd_time.cpp @@ -12,14 +12,39 @@ */ #include "inspircd.h" -#include "commands/cmd_time.h" +#ifndef __CMD_TIME_H__ +#define __CMD_TIME_H__ +// include the common header files -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#include "users.h" +#include "channels.h" + +/** Handle /TIME. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandTime : public Command { - return new CommandTime(Instance); -} + public: + /** Constructor for time. + */ + CommandTime (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"TIME",0,0) { syntax = "[<servername>]"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + + + CmdResult CommandTime::Handle (const std::vector<std::string>&, User *user) { @@ -36,3 +61,5 @@ CmdResult CommandTime::Handle (const std::vector<std::string>&, User *user) return CMD_SUCCESS; } + +COMMAND_INIT(CommandTime) diff --git a/src/commands/cmd_topic.cpp b/src/commands/cmd_topic.cpp index 00b588179..97321460e 100644 --- a/src/commands/cmd_topic.cpp +++ b/src/commands/cmd_topic.cpp @@ -12,13 +12,38 @@ */ #include "inspircd.h" -#include "commands/cmd_topic.h" +#ifndef __CMD_TOPIC_H__ +#define __CMD_TOPIC_H__ -extern "C" DllExport Command* init_command(InspIRCd* Instance) +// include the common header files + +#include "users.h" +#include "channels.h" + +/** Handle /TOPIC. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandTopic : public Command { - return new CommandTopic(Instance); -} + public: + /** Constructor for topic. + */ + CommandTopic (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"TOPIC",0,1,false,2) { syntax = "<channel> [<topic>]"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + + CmdResult CommandTopic::Handle (const std::vector<std::string>& parameters, User *user) { @@ -62,3 +87,5 @@ CmdResult CommandTopic::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } + +COMMAND_INIT(CommandTopic) diff --git a/src/commands/cmd_trace.cpp b/src/commands/cmd_trace.cpp index 05597dc1b..9ac590ee1 100644 --- a/src/commands/cmd_trace.cpp +++ b/src/commands/cmd_trace.cpp @@ -12,12 +12,37 @@ */ #include "inspircd.h" -#include "commands/cmd_trace.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_TRACE_H__ +#define __CMD_TRACE_H__ + +// include the common header files + +#include "users.h" +#include "channels.h" + +/** Handle /TRACE. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandTrace : public Command { - return new CommandTrace(Instance); -} + public: + /** Constructor for trace. + */ + CommandTrace (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"TRACE","o",0) { syntax = "[<object>]"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + /** XXX: This is crap. someone fix this when you have time, to be more useful. */ @@ -43,3 +68,5 @@ CmdResult CommandTrace::Handle (const std::vector<std::string>&, User *user) }*/ return CMD_SUCCESS; } + +COMMAND_INIT(CommandTrace) diff --git a/src/commands/cmd_unloadmodule.cpp b/src/commands/cmd_unloadmodule.cpp index 931dfdcbd..af51067dd 100644 --- a/src/commands/cmd_unloadmodule.cpp +++ b/src/commands/cmd_unloadmodule.cpp @@ -12,14 +12,39 @@ */ #include "inspircd.h" -#include "commands/cmd_unloadmodule.h" +#ifndef __CMD_UNLOADMODULE_H__ +#define __CMD_UNLOADMODULE_H__ +// include the common header files -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#include "users.h" +#include "channels.h" + +/** Handle /UNLOADMODULE. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandUnloadmodule : public Command { - return new CommandUnloadmodule(Instance); -} + public: + /** Constructor for unloadmodule. + */ + CommandUnloadmodule (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"UNLOADMODULE","o",1) { syntax = "<modulename>"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + + + CmdResult CommandUnloadmodule::Handle (const std::vector<std::string>& parameters, User *user) { @@ -36,3 +61,5 @@ CmdResult CommandUnloadmodule::Handle (const std::vector<std::string>& parameter return CMD_SUCCESS; } + +COMMAND_INIT(CommandUnloadmodule) diff --git a/src/commands/cmd_user.cpp b/src/commands/cmd_user.cpp index b9ef94c97..9edfb46b6 100644 --- a/src/commands/cmd_user.cpp +++ b/src/commands/cmd_user.cpp @@ -12,12 +12,37 @@ */ #include "inspircd.h" -#include "commands/cmd_user.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_USER_H__ +#define __CMD_USER_H__ + +// include the common header files + +#include "users.h" +#include "channels.h" + +/** Handle /USER. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandUser : public Command { - return new CommandUser(Instance); -} + public: + /** Constructor for user. + */ + CommandUser (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"USER",0,4,true,0) { syntax = "<username> <localhost> <remotehost> <GECOS>"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + CmdResult CommandUser::Handle (const std::vector<std::string>& parameters, User *user) { @@ -65,3 +90,5 @@ CmdResult CommandUser::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } + +COMMAND_INIT(CommandUser) diff --git a/src/commands/cmd_userhost.cpp b/src/commands/cmd_userhost.cpp index 83375a0fd..acb67cf1b 100644 --- a/src/commands/cmd_userhost.cpp +++ b/src/commands/cmd_userhost.cpp @@ -12,12 +12,37 @@ */ #include "inspircd.h" -#include "commands/cmd_userhost.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#ifndef __CMD_USERHOST_H__ +#define __CMD_USERHOST_H__ + +// include the common header files + +#include "users.h" +#include "channels.h" + +/** Handle /USERHOST. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandUserhost : public Command { - return new CommandUserhost(Instance); -} + public: + /** Constructor for userhost. + */ + CommandUserhost (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"USERHOST",0,1) { syntax = "<nick>{,<nick>}"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + CmdResult CommandUserhost::Handle (const std::vector<std::string>& parameters, User *user) { @@ -64,3 +89,5 @@ CmdResult CommandUserhost::Handle (const std::vector<std::string>& parameters, U return CMD_SUCCESS; } + +COMMAND_INIT(CommandUserhost) diff --git a/src/commands/cmd_version.cpp b/src/commands/cmd_version.cpp index 871193c00..86be41a41 100644 --- a/src/commands/cmd_version.cpp +++ b/src/commands/cmd_version.cpp @@ -12,14 +12,39 @@ */ #include "inspircd.h" -#include "commands/cmd_version.h" +#ifndef __CMD_VERSION_H__ +#define __CMD_VERSION_H__ +// include the common header files -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#include "users.h" +#include "channels.h" + +/** Handle /VERSION. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandVersion : public Command { - return new CommandVersion(Instance); -} + public: + /** Constructor for version. + */ + CommandVersion (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"VERSION",0,0) { syntax = "[<servername>]"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + + + CmdResult CommandVersion::Handle (const std::vector<std::string>&, User *user) { @@ -27,3 +52,5 @@ CmdResult CommandVersion::Handle (const std::vector<std::string>&, User *user) ServerInstance->Config->Send005(user); return CMD_SUCCESS; } + +COMMAND_INIT(CommandVersion) diff --git a/src/commands/cmd_wallops.cpp b/src/commands/cmd_wallops.cpp index 6c8468914..98b3d3f34 100644 --- a/src/commands/cmd_wallops.cpp +++ b/src/commands/cmd_wallops.cpp @@ -12,14 +12,39 @@ */ #include "inspircd.h" -#include "commands/cmd_wallops.h" +#ifndef __CMD_WALLOPS_H__ +#define __CMD_WALLOPS_H__ +// include the common header files -extern "C" DllExport Command* init_command(InspIRCd* Instance) +#include "users.h" +#include "channels.h" + +/** Handle /WALLOPS. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandWallops : public Command { - return new CommandWallops(Instance); -} + public: + /** Constructor for wallops. + */ + CommandWallops (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"WALLOPS","o",1,1) { syntax = "<any-text>"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + + + CmdResult CommandWallops::Handle (const std::vector<std::string>& parameters, User *user) { @@ -27,3 +52,5 @@ CmdResult CommandWallops::Handle (const std::vector<std::string>& parameters, Us FOREACH_MOD(I_OnWallops,OnWallops(user,parameters[0])); return CMD_SUCCESS; } + +COMMAND_INIT(CommandWallops) diff --git a/src/commands/cmd_who.cpp b/src/commands/cmd_who.cpp index a85e00fa3..1e7c7d6aa 100644 --- a/src/commands/cmd_who.cpp +++ b/src/commands/cmd_who.cpp @@ -12,7 +12,53 @@ */ #include "inspircd.h" -#include "commands/cmd_who.h" + +#ifndef __CMD_WHO_H__ +#define __CMD_WHO_H__ + +// include the common header files + +#include "users.h" +#include "channels.h" + +/** Handle /WHO. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandWho : public Command +{ + bool CanView(Channel* chan, User* user); + bool opt_viewopersonly; + bool opt_showrealhost; + bool opt_unlimit; + bool opt_realname; + bool opt_mode; + bool opt_ident; + bool opt_metadata; + bool opt_port; + bool opt_away; + bool opt_local; + bool opt_far; + bool opt_time; + + public: + /** Constructor for who. + */ + CommandWho (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"WHO", 0, 1, false, 2) { syntax = "<server>|<nickname>|<channel>|<realname>|<host>|0 [ohurmMiaplf]"; } + void SendWhoLine(User* user, const std::string &initial, Channel* ch, User* u, std::vector<std::string> &whoresults); + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); + bool whomatch(User* user, const char* matchtext); +}; + +#endif + static const std::string star = "*"; @@ -120,11 +166,6 @@ bool CommandWho::whomatch(User* user, const char* matchtext) -extern "C" DllExport Command* init_command(InspIRCd* Instance) -{ - return new CommandWho(Instance); -} - bool CommandWho::CanView(Channel* chan, User* user) { if (!user || !chan) @@ -367,3 +408,5 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User * return CMD_FAILURE; } } + +COMMAND_INIT(CommandWho) diff --git a/src/commands/cmd_whois.cpp b/src/commands/cmd_whois.cpp index b2f322351..9b64d5e8b 100644 --- a/src/commands/cmd_whois.cpp +++ b/src/commands/cmd_whois.cpp @@ -12,85 +12,28 @@ */ #include "inspircd.h" -#include "commands/cmd_whois.h" -#include "hashcomp.h" -void do_whois(InspIRCd* ServerInstance, User* user, User* dest,unsigned long signon, unsigned long idle, const char* nick) +/** Handle /WHOIS. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandWhois : public Command { - ServerInstance->SendWhoisLine(user, dest, 311, "%s %s %s %s * :%s",user->nick.c_str(), dest->nick.c_str(), dest->ident.c_str(), dest->dhost.c_str(), dest->fullname.c_str()); - if (user == dest || user->HasPrivPermission("users/auspex")) - { - ServerInstance->SendWhoisLine(user, dest, 378, "%s %s :is connecting from %s@%s %s", user->nick.c_str(), dest->nick.c_str(), dest->ident.c_str(), dest->host.c_str(), dest->GetIPString()); - } - - std::string cl = dest->ChannelList(user); - - if (cl.length()) - { - if (cl.length() > 400) - { - user->SplitChanList(dest,cl); - } - else - { - ServerInstance->SendWhoisLine(user, dest, 319, "%s %s :%s",user->nick.c_str(), dest->nick.c_str(), cl.c_str()); - } - } - if (user != dest && *ServerInstance->Config->HideWhoisServer && !user->HasPrivPermission("servers/auspex")) - { - ServerInstance->SendWhoisLine(user, dest, 312, "%s %s %s :%s",user->nick.c_str(), dest->nick.c_str(), ServerInstance->Config->HideWhoisServer, ServerInstance->Config->Network); - } - else - { - ServerInstance->SendWhoisLine(user, dest, 312, "%s %s %s :%s",user->nick.c_str(), dest->nick.c_str(), dest->server, ServerInstance->GetServerDescription(dest->server).c_str()); - } - - if (IS_AWAY(dest)) - { - ServerInstance->SendWhoisLine(user, dest, 301, "%s %s :%s",user->nick.c_str(), dest->nick.c_str(), dest->awaymsg.c_str()); - } - - if (IS_OPER(dest)) - { - if (ServerInstance->Config->GenericOper) - ServerInstance->SendWhoisLine(user, dest, 313, "%s %s :is an IRC operator",user->nick.c_str(), dest->nick.c_str()); - else - ServerInstance->SendWhoisLine(user, dest, 313, "%s %s :is %s %s on %s",user->nick.c_str(), dest->nick.c_str(), (strchr("AEIOUaeiou",dest->oper[0]) ? "an" : "a"),irc::Spacify(dest->oper.c_str()), ServerInstance->Config->Network); - } - - if (user == dest || user->HasPrivPermission("users/auspex")) - { - if (dest->IsModeSet('s') != 0) - { - ServerInstance->SendWhoisLine(user, dest, 379, "%s %s :is using modes +%s +%s", user->nick.c_str(), dest->nick.c_str(), dest->FormatModes(), dest->FormatNoticeMasks()); - } - else - { - ServerInstance->SendWhoisLine(user, dest, 379, "%s %s :is using modes +%s", user->nick.c_str(), dest->nick.c_str(), dest->FormatModes()); - } - } - - FOREACH_MOD(I_OnWhois,OnWhois(user,dest)); - - /* - * We only send these if we've been provided them. That is, if hidewhois is turned off, and user is local, or - * if remote whois is queried, too. This is to keep the user hidden, and also since you can't reliably tell remote time. -- w00t + public: + /** Constructor for whois. */ - if ((idle) || (signon)) - { - ServerInstance->SendWhoisLine(user, dest, 317, "%s %s %lu %lu :seconds idle, signon time",user->nick.c_str(), dest->nick.c_str(), idle, signon); - } - - ServerInstance->SendWhoisLine(user, dest, 318, "%s %s :End of /WHOIS list.",user->nick.c_str(), dest->nick.c_str()); -} - + CommandWhois (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"WHOIS",0,1,false,2) { syntax = "<nick>{,<nick>}"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; -extern "C" DllExport Command* init_command(InspIRCd* Instance) -{ - return new CommandWhois(Instance); -} - CmdResult CommandWhois::Handle (const std::vector<std::string>& parameters, User *user) { User *dest; @@ -129,7 +72,7 @@ CmdResult CommandWhois::Handle (const std::vector<std::string>& parameters, User signon = dest->signon; } - do_whois(this->ServerInstance, user,dest,signon,idle,parameters[userindex].c_str()); + ServerInstance->DoWhois(user,dest,signon,idle,parameters[userindex].c_str()); } else { @@ -143,3 +86,5 @@ CmdResult CommandWhois::Handle (const std::vector<std::string>& parameters, User } + +COMMAND_INIT(CommandWhois) diff --git a/src/commands/cmd_whowas.cpp b/src/commands/cmd_whowas.cpp index 1109b4d8b..5e77671a6 100644 --- a/src/commands/cmd_whowas.cpp +++ b/src/commands/cmd_whowas.cpp @@ -16,12 +16,7 @@ WhoWasMaintainTimer * timer; -extern "C" DllExport Command* init_command(InspIRCd* Instance) -{ - return new CommandWhowas(Instance); -} - -CommandWhowas::CommandWhowas(InspIRCd* Instance) : Command(Instance, NULL, "WHOWAS", 0, 1, false, 2) +CommandWhowas::CommandWhowas(InspIRCd* Instance, Module* parent) : Command(Instance,parent, "WHOWAS", 0, 1, false, 2) { syntax = "<nick>{,<nick>}"; timer = new WhoWasMaintainTimer(Instance, 3600); @@ -335,3 +330,5 @@ void WhoWasMaintainTimer::Tick(time_t) whowas_command->HandleInternal(WHOWAS_MAINTAIN, params); } } + +COMMAND_INIT(CommandWhowas) diff --git a/src/commands/cmd_zline.cpp b/src/commands/cmd_zline.cpp index 93ad7f893..81476a032 100644 --- a/src/commands/cmd_zline.cpp +++ b/src/commands/cmd_zline.cpp @@ -13,14 +13,51 @@ #include "inspircd.h" #include "xline.h" -#include "commands/cmd_zline.h" +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * See: http://wiki.inspircd.org/Credits + * + * This program is free but copyrighted software; see + * the file COPYING for details. + * + * --------------------------------------------------- + */ + +#ifndef __CMD_ZLINE_H__ +#define __CMD_ZLINE_H__ +// include the common header files +#include "users.h" +#include "channels.h" -extern "C" DllExport Command* init_command(InspIRCd* Instance) +/** Handle /ZLINE. These command handlers can be reloaded by the core, + * and handle basic RFC1459 commands. Commands within modules work + * the same way, however, they can be fully unloaded, where these + * may not. + */ +class CommandZline : public Command { - return new CommandZline(Instance); -} + public: + /** Constructor for zline. + */ + CommandZline (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"ZLINE","o",1,3,false,0) { syntax = "<ipmask> [<duration> :<reason>]"; } + /** Handle command. + * @param parameters The parameters to the comamnd + * @param pcnt The number of parameters passed to teh command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(const std::vector<std::string>& parameters, User *user); +}; + +#endif + + + CmdResult CommandZline::Handle (const std::vector<std::string>& parameters, User *user) { @@ -91,3 +128,5 @@ CmdResult CommandZline::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } + +COMMAND_INIT(CommandZline) |