diff options
109 files changed, 312 insertions, 202 deletions
diff --git a/include/command_parse.h b/include/command_parse.h index a0d27be17..635db619c 100644 --- a/include/command_parse.h +++ b/include/command_parse.h @@ -189,7 +189,7 @@ class cmd_reload : public command_t cmd_reload (InspIRCd* Instance) : command_t(Instance,"RELOAD",'o',1) { syntax = "<core-command>"; } /** Handle RELOAD */ - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; diff --git a/include/commands/cmd_admin.h b/include/commands/cmd_admin.h index 310819d1b..f2c08f14c 100644 --- a/include/commands/cmd_admin.h +++ b/include/commands/cmd_admin.h @@ -25,7 +25,7 @@ class cmd_admin : public command_t { public: cmd_admin (InspIRCd* Instance) : command_t(Instance,"ADMIN",0,0) { syntax = "[<servername>]"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_away.h b/include/commands/cmd_away.h index 3f9eddb87..9fc56081a 100644 --- a/include/commands/cmd_away.h +++ b/include/commands/cmd_away.h @@ -26,7 +26,7 @@ class cmd_away : public command_t { public: cmd_away (InspIRCd* Instance) : command_t(Instance,"AWAY",0,0) { syntax = "[<message>]"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_commands.h b/include/commands/cmd_commands.h index 2f9c5f4cb..70adc4f41 100644 --- a/include/commands/cmd_commands.h +++ b/include/commands/cmd_commands.h @@ -26,7 +26,7 @@ class cmd_commands : public command_t { public: cmd_commands (InspIRCd* Instance) : command_t(Instance,"COMMANDS",0,0) { } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_connect.h b/include/commands/cmd_connect.h index 203fbe9c0..642c30030 100644 --- a/include/commands/cmd_connect.h +++ b/include/commands/cmd_connect.h @@ -26,7 +26,7 @@ class cmd_connect : public command_t { public: cmd_connect (InspIRCd* Instance) : command_t(Instance,"CONNECT",'o',1) { syntax = "<servername> [<remote-server>]"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_die.h b/include/commands/cmd_die.h index e2b8099a2..d16196eff 100644 --- a/include/commands/cmd_die.h +++ b/include/commands/cmd_die.h @@ -26,7 +26,7 @@ class cmd_die : public command_t { public: cmd_die (InspIRCd* Instance) : command_t(Instance,"DIE",'o',1) { syntax = "<password>"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_eline.h b/include/commands/cmd_eline.h index 03a1a7df8..8293d11bc 100644 --- a/include/commands/cmd_eline.h +++ b/include/commands/cmd_eline.h @@ -26,7 +26,7 @@ class cmd_eline : public command_t { public: cmd_eline (InspIRCd* Instance) : command_t(Instance,"ELINE",'o',1) { syntax = "<ident@host> [<duration> :<reason>]"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_gline.h b/include/commands/cmd_gline.h index 726933576..c0e745077 100644 --- a/include/commands/cmd_gline.h +++ b/include/commands/cmd_gline.h @@ -26,7 +26,7 @@ class cmd_gline : public command_t { public: cmd_gline (InspIRCd* Instance) : command_t(Instance,"GLINE",'o',1) { syntax = "<ident@host> [<duration> :<reason>]"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_info.h b/include/commands/cmd_info.h index 368f1efbd..e2630c7e7 100644 --- a/include/commands/cmd_info.h +++ b/include/commands/cmd_info.h @@ -26,7 +26,7 @@ class cmd_info : public command_t { public: cmd_info (InspIRCd* Instance) : command_t(Instance,"INFO",0,0) { syntax = "[<servermask>]"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_invite.h b/include/commands/cmd_invite.h index 9b68d2239..1d4b0f6b2 100644 --- a/include/commands/cmd_invite.h +++ b/include/commands/cmd_invite.h @@ -26,7 +26,7 @@ class cmd_invite : public command_t { public: cmd_invite (InspIRCd* Instance) : command_t(Instance,"INVITE",0,0) { syntax = "[<nick> <channel>]"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_ison.h b/include/commands/cmd_ison.h index 567f8e608..cb94bc16e 100644 --- a/include/commands/cmd_ison.h +++ b/include/commands/cmd_ison.h @@ -26,7 +26,7 @@ class cmd_ison : public command_t { public: cmd_ison (InspIRCd* Instance) : command_t(Instance,"ISON",0,0) { syntax = "<nick> {nick}"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_join.h b/include/commands/cmd_join.h index c57268cd6..fd3e948a9 100644 --- a/include/commands/cmd_join.h +++ b/include/commands/cmd_join.h @@ -26,7 +26,7 @@ class cmd_join : public command_t { public: cmd_join (InspIRCd* Instance) : command_t(Instance,"JOIN",0,1) { syntax = "<channel>{,<channel>} {<key>{,<key>}}"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_kick.h b/include/commands/cmd_kick.h index 356338b24..56f2b5bbf 100644 --- a/include/commands/cmd_kick.h +++ b/include/commands/cmd_kick.h @@ -26,7 +26,7 @@ class cmd_kick : public command_t { public: cmd_kick (InspIRCd* Instance) : command_t(Instance,"KICK",0,2) { syntax = "<channel> <nick>{,<nick>} [<reason>]"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_kill.h b/include/commands/cmd_kill.h index a2f361a95..8362d67e4 100644 --- a/include/commands/cmd_kill.h +++ b/include/commands/cmd_kill.h @@ -26,7 +26,7 @@ class cmd_kill : public command_t { public: cmd_kill (InspIRCd* Instance) : command_t(Instance,"KILL",'o',2) { syntax = "<nickname> <reason>"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_kline.h b/include/commands/cmd_kline.h index 7e79f1021..81650bbd9 100644 --- a/include/commands/cmd_kline.h +++ b/include/commands/cmd_kline.h @@ -26,7 +26,7 @@ class cmd_kline : public command_t { public: cmd_kline (InspIRCd* Instance) : command_t(Instance,"KLINE",'o',1) { syntax = "<ident@host> [<duration> :<reason>]"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_links.h b/include/commands/cmd_links.h index 89ee7e15c..fb3b7aaf4 100644 --- a/include/commands/cmd_links.h +++ b/include/commands/cmd_links.h @@ -26,7 +26,7 @@ class cmd_links : public command_t { public: cmd_links (InspIRCd* Instance) : command_t(Instance,"LINKS",0,0) { } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_list.h b/include/commands/cmd_list.h index be24b87c7..279849a69 100644 --- a/include/commands/cmd_list.h +++ b/include/commands/cmd_list.h @@ -26,7 +26,7 @@ class cmd_list : public command_t { public: cmd_list (InspIRCd* Instance) : command_t(Instance,"LIST",0,0) { } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_loadmodule.h b/include/commands/cmd_loadmodule.h index c82560653..f74e8dd04 100644 --- a/include/commands/cmd_loadmodule.h +++ b/include/commands/cmd_loadmodule.h @@ -26,7 +26,7 @@ class cmd_loadmodule : public command_t { public: cmd_loadmodule (InspIRCd* Instance) : command_t(Instance,"LOADMODULE",'o',1) { syntax = "<modulename>"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_lusers.h b/include/commands/cmd_lusers.h index ab3c2f601..b833bad50 100644 --- a/include/commands/cmd_lusers.h +++ b/include/commands/cmd_lusers.h @@ -26,7 +26,7 @@ class cmd_lusers : public command_t { public: cmd_lusers (InspIRCd* Instance) : command_t(Instance,"LUSERS",0,0) { } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_map.h b/include/commands/cmd_map.h index 4a06b3069..aa097bbf2 100644 --- a/include/commands/cmd_map.h +++ b/include/commands/cmd_map.h @@ -26,7 +26,7 @@ class cmd_map : public command_t { public: cmd_map (InspIRCd* Instance) : command_t(Instance,"MAP",0,0) { } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_mode.h b/include/commands/cmd_mode.h index e52042f6a..c9e82f572 100644 --- a/include/commands/cmd_mode.h +++ b/include/commands/cmd_mode.h @@ -25,7 +25,7 @@ class cmd_mode : public command_t { public: cmd_mode (InspIRCd* Instance) : command_t(Instance,"MODE",0,1) { syntax = "<target> <modes> {<mode-parameters>}"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_modules.h b/include/commands/cmd_modules.h index 537f510f5..05e4c92e2 100644 --- a/include/commands/cmd_modules.h +++ b/include/commands/cmd_modules.h @@ -26,7 +26,7 @@ class cmd_modules : public command_t { public: cmd_modules (InspIRCd* Instance) : command_t(Instance,"MODULES",0,0) { syntax = "[debug]"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_motd.h b/include/commands/cmd_motd.h index 310627ab1..884422257 100644 --- a/include/commands/cmd_motd.h +++ b/include/commands/cmd_motd.h @@ -29,7 +29,7 @@ class cmd_motd : public command_t { public: cmd_motd (InspIRCd* Instance) : command_t(Instance,"MOTD",0,0) { syntax = "[<servername>]"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_names.h b/include/commands/cmd_names.h index c3e87e324..ad939e94b 100644 --- a/include/commands/cmd_names.h +++ b/include/commands/cmd_names.h @@ -26,7 +26,7 @@ class cmd_names : public command_t { public: cmd_names (InspIRCd* Instance) : command_t(Instance,"NAMES",0,0) { syntax = "{<channel>{,<channel>}}"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_nick.h b/include/commands/cmd_nick.h index f63a6195c..058aa1981 100644 --- a/include/commands/cmd_nick.h +++ b/include/commands/cmd_nick.h @@ -26,7 +26,7 @@ class cmd_nick : public command_t { public: cmd_nick (InspIRCd* Instance) : command_t(Instance,"NICK",0,1,true) { syntax = "<newnick>"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_notice.h b/include/commands/cmd_notice.h index 24aa773c1..b50589dfe 100644 --- a/include/commands/cmd_notice.h +++ b/include/commands/cmd_notice.h @@ -26,7 +26,7 @@ class cmd_notice : public command_t { public: cmd_notice (InspIRCd* Instance) : command_t(Instance,"NOTICE",0,2) { syntax = "<target>{,<target>} <message>"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_oper.h b/include/commands/cmd_oper.h index cfbdb8815..07756f76c 100644 --- a/include/commands/cmd_oper.h +++ b/include/commands/cmd_oper.h @@ -28,7 +28,7 @@ class cmd_oper : public command_t { public: cmd_oper (InspIRCd* Instance) : command_t(Instance,"OPER",0,2) { syntax = "<username> <password>"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_part.h b/include/commands/cmd_part.h index 60e7911d1..6532762e0 100644 --- a/include/commands/cmd_part.h +++ b/include/commands/cmd_part.h @@ -26,7 +26,7 @@ class cmd_part : public command_t { public: cmd_part (InspIRCd* Instance) : command_t(Instance,"PART",0,1) { syntax = "<channel>{,<channel>} [<reason>]"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_pass.h b/include/commands/cmd_pass.h index 922f12c02..24c0e6b82 100644 --- a/include/commands/cmd_pass.h +++ b/include/commands/cmd_pass.h @@ -29,7 +29,7 @@ class cmd_pass : public command_t { public: cmd_pass (InspIRCd* Instance) : command_t(Instance,"PASS",0,1,true) { syntax = "<password>"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_ping.h b/include/commands/cmd_ping.h index 2ad2aca68..c2da1d5ce 100644 --- a/include/commands/cmd_ping.h +++ b/include/commands/cmd_ping.h @@ -26,7 +26,7 @@ class cmd_ping : public command_t { public: cmd_ping (InspIRCd* Instance) : command_t(Instance,"PING",0,1) { syntax = "<servername> [:<servername>]"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_pong.h b/include/commands/cmd_pong.h index d89b3b877..db2b76f25 100644 --- a/include/commands/cmd_pong.h +++ b/include/commands/cmd_pong.h @@ -27,7 +27,7 @@ class cmd_pong : public command_t { public: cmd_pong (InspIRCd* Instance) : command_t(Instance,"PONG",0,1) { syntax = "<ping-text>"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_privmsg.h b/include/commands/cmd_privmsg.h index c50d826d2..3f224c11e 100644 --- a/include/commands/cmd_privmsg.h +++ b/include/commands/cmd_privmsg.h @@ -26,7 +26,7 @@ class cmd_privmsg : public command_t { public: cmd_privmsg (InspIRCd* Instance) : command_t(Instance,"PRIVMSG",0,2) { syntax = "<target>{,<target>} <message>"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_qline.h b/include/commands/cmd_qline.h index e6468b4eb..04fd9ce92 100644 --- a/include/commands/cmd_qline.h +++ b/include/commands/cmd_qline.h @@ -26,7 +26,7 @@ class cmd_qline : public command_t { public: cmd_qline (InspIRCd* Instance) : command_t(Instance,"QLINE",'o',1) { syntax = "<nick> [<duration> :<reason>]"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_quit.h b/include/commands/cmd_quit.h index 9d11538df..85e0b3d9d 100644 --- a/include/commands/cmd_quit.h +++ b/include/commands/cmd_quit.h @@ -26,7 +26,7 @@ class cmd_quit : public command_t { public: cmd_quit (InspIRCd* Instance) : command_t(Instance,"QUIT",0,0) { syntax = "[<message>]"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_rehash.h b/include/commands/cmd_rehash.h index f410f37b1..78abf4648 100644 --- a/include/commands/cmd_rehash.h +++ b/include/commands/cmd_rehash.h @@ -26,7 +26,7 @@ class cmd_rehash : public command_t { public: cmd_rehash (InspIRCd* Instance) : command_t(Instance,"REHASH",'o',0) { syntax = "[<servermask>]"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_restart.h b/include/commands/cmd_restart.h index 6d7e82f23..9ced78607 100644 --- a/include/commands/cmd_restart.h +++ b/include/commands/cmd_restart.h @@ -32,7 +32,7 @@ class cmd_restart : public command_t { public: cmd_restart (InspIRCd* Instance) : command_t(Instance,"RESTART",'o',1) { syntax = "<password>"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_rules.h b/include/commands/cmd_rules.h index 496f4a0f0..ed7e56ca4 100644 --- a/include/commands/cmd_rules.h +++ b/include/commands/cmd_rules.h @@ -29,7 +29,7 @@ class cmd_rules : public command_t { public: cmd_rules (InspIRCd* Instance) : command_t(Instance,"RULES",0,0) { syntax = "[<servername>]"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_server.h b/include/commands/cmd_server.h index 181e53af2..0b0f5e3d1 100644 --- a/include/commands/cmd_server.h +++ b/include/commands/cmd_server.h @@ -26,7 +26,7 @@ class cmd_server : public command_t { public: cmd_server (InspIRCd* Instance) : command_t(Instance,"SERVER",0,0) { } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_squit.h b/include/commands/cmd_squit.h index 0c6f06f1a..3aaeea339 100644 --- a/include/commands/cmd_squit.h +++ b/include/commands/cmd_squit.h @@ -29,7 +29,7 @@ class cmd_squit : public command_t { public: cmd_squit (InspIRCd* Instance) : command_t(Instance,"SQUIT",'o',1) { syntax = "<servername> [<reason>]"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_stats.h b/include/commands/cmd_stats.h index 591b3e755..6beca59aa 100644 --- a/include/commands/cmd_stats.h +++ b/include/commands/cmd_stats.h @@ -29,7 +29,7 @@ class cmd_stats : public command_t { public: cmd_stats (InspIRCd* Instance) : command_t(Instance,"STATS",0,1) { syntax = "[<servername>] <stats-symbol>"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_summon.h b/include/commands/cmd_summon.h index eaf4735d1..db25ab7d5 100644 --- a/include/commands/cmd_summon.h +++ b/include/commands/cmd_summon.h @@ -29,7 +29,7 @@ class cmd_summon : public command_t { public: cmd_summon (InspIRCd* Instance) : command_t(Instance,"SUMMON",0,0) { } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_time.h b/include/commands/cmd_time.h index a75747a6e..847cc343b 100644 --- a/include/commands/cmd_time.h +++ b/include/commands/cmd_time.h @@ -26,7 +26,7 @@ class cmd_time : public command_t { public: cmd_time (InspIRCd* Instance) : command_t(Instance,"TIME",0,0) { syntax = "[<servername>]"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_topic.h b/include/commands/cmd_topic.h index 3b3f7090c..052759e12 100644 --- a/include/commands/cmd_topic.h +++ b/include/commands/cmd_topic.h @@ -26,7 +26,7 @@ class cmd_topic : public command_t { public: cmd_topic (InspIRCd* Instance) : command_t(Instance,"TOPIC",0,1) { syntax = "<channel> [<topic>]"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_trace.h b/include/commands/cmd_trace.h index 8fe3b166a..8276a1e92 100644 --- a/include/commands/cmd_trace.h +++ b/include/commands/cmd_trace.h @@ -26,7 +26,7 @@ class cmd_trace : public command_t { public: cmd_trace (InspIRCd* Instance) : command_t(Instance,"TRACE",'o',0) { syntax = "[<object>]"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_unloadmodule.h b/include/commands/cmd_unloadmodule.h index 0104d04b1..ba19bc5e1 100644 --- a/include/commands/cmd_unloadmodule.h +++ b/include/commands/cmd_unloadmodule.h @@ -26,7 +26,7 @@ class cmd_unloadmodule : public command_t { public: cmd_unloadmodule (InspIRCd* Instance) : command_t(Instance,"UNLOADMODULE",'o',1) { syntax = "<modulename>"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_user.h b/include/commands/cmd_user.h index ac8a1a6c4..f5d7cb242 100644 --- a/include/commands/cmd_user.h +++ b/include/commands/cmd_user.h @@ -26,7 +26,7 @@ class cmd_user : public command_t { public: cmd_user (InspIRCd* Instance) : command_t(Instance,"USER",0,4,true) { syntax = "<username> <localhost> <remotehost> <GECOS>"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_userhost.h b/include/commands/cmd_userhost.h index 83ae27678..d15c6b623 100644 --- a/include/commands/cmd_userhost.h +++ b/include/commands/cmd_userhost.h @@ -26,7 +26,7 @@ class cmd_userhost : public command_t { public: cmd_userhost (InspIRCd* Instance) : command_t(Instance,"USERHOST",0,1) { syntax = "<nick>{,<nick>}"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_users.h b/include/commands/cmd_users.h index bd1607607..479bb1a7b 100644 --- a/include/commands/cmd_users.h +++ b/include/commands/cmd_users.h @@ -29,7 +29,7 @@ class cmd_users : public command_t { public: cmd_users (InspIRCd* Instance) : command_t(Instance,"USERS",0,0) { } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_version.h b/include/commands/cmd_version.h index 6a77725c1..accbd7452 100644 --- a/include/commands/cmd_version.h +++ b/include/commands/cmd_version.h @@ -26,7 +26,7 @@ class cmd_version : public command_t { public: cmd_version (InspIRCd* Instance) : command_t(Instance,"VERSION",0,0) { syntax = "[<servername>]"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_wallops.h b/include/commands/cmd_wallops.h index 819fa121e..da8b95fe4 100644 --- a/include/commands/cmd_wallops.h +++ b/include/commands/cmd_wallops.h @@ -26,7 +26,7 @@ class cmd_wallops : public command_t { public: cmd_wallops (InspIRCd* Instance) : command_t(Instance,"WALLOPS",'o',1) { syntax = "<any-text>"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_who.h b/include/commands/cmd_who.h index fff9737ad..a52836cbf 100644 --- a/include/commands/cmd_who.h +++ b/include/commands/cmd_who.h @@ -26,7 +26,7 @@ class cmd_who : public command_t { public: cmd_who (InspIRCd* Instance) : command_t(Instance,"WHO",0,1) { syntax = "<server>|<nickname>|<channel>|<realname>|<host>|0 [ohur]"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_whois.h b/include/commands/cmd_whois.h index 26e2e52c3..76d445cf5 100644 --- a/include/commands/cmd_whois.h +++ b/include/commands/cmd_whois.h @@ -28,7 +28,7 @@ class cmd_whois : public command_t { public: cmd_whois (InspIRCd* Instance) : command_t(Instance,"WHOIS",0,1) { syntax = "<nick>{,<nick>}"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_whowas.h b/include/commands/cmd_whowas.h index 1664a847d..12e59863d 100644 --- a/include/commands/cmd_whowas.h +++ b/include/commands/cmd_whowas.h @@ -26,7 +26,7 @@ class cmd_whowas : public command_t { public: cmd_whowas (InspIRCd* Instance) : command_t(Instance,"WHOWAS",0,1) { syntax = "<nick>{,<nick>}"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/commands/cmd_zline.h b/include/commands/cmd_zline.h index eefd3c642..8dd2c2988 100644 --- a/include/commands/cmd_zline.h +++ b/include/commands/cmd_zline.h @@ -26,7 +26,7 @@ class cmd_zline : public command_t { public: cmd_zline (InspIRCd* Instance) : command_t(Instance,"ZLINE",'o',1) { syntax = "<ipmask> [<duration> :<reason>]"; } - void Handle(const char** parameters, int pcnt, userrec *user); + CmdResult Handle(const char** parameters, int pcnt, userrec *user); }; #endif diff --git a/include/ctables.h b/include/ctables.h index 870efadac..9adf6c37c 100644 --- a/include/ctables.h +++ b/include/ctables.h @@ -25,7 +25,14 @@ class userrec; class InspIRCd; -/*typedef void (handlerfunc) (char**, int, userrec*);*/ +/** Used to indicate command success codes + */ +enum CmdResult +{ + CMD_FAILURE = 0, /* Command exists, but failed */ + CMD_SUCCESS = 1, /* Command exists, and succeeded */ + CMD_INVALID = 2, /* Command doesnt exist at all! */ +}; /** A structure that defines a command */ @@ -70,7 +77,7 @@ class command_t : public Extensible syntax = ""; } - virtual void Handle(const char** parameters, int pcnt, userrec* user) = 0; + virtual CmdResult Handle(const char** parameters, int pcnt, userrec* user) = 0; void Disable(bool setting) { diff --git a/src/cmd_admin.cpp b/src/cmd_admin.cpp index 86072a5ed..5b04bafb7 100644 --- a/src/cmd_admin.cpp +++ b/src/cmd_admin.cpp @@ -25,10 +25,11 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_admin(Instance); } -void cmd_admin::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_admin::Handle (const char** parameters, int pcnt, userrec *user) { user->WriteServ("256 %s :Administrative info for %s",user->nick,ServerInstance->Config->ServerName); user->WriteServ("257 %s :Name - %s",user->nick,ServerInstance->Config->AdminName); user->WriteServ("258 %s :Nickname - %s",user->nick,ServerInstance->Config->AdminNick); user->WriteServ("258 %s :E-Mail - %s",user->nick,ServerInstance->Config->AdminEmail); + return CMD_SUCCESS; } diff --git a/src/cmd_away.cpp b/src/cmd_away.cpp index fa944932f..aecc711e4 100644 --- a/src/cmd_away.cpp +++ b/src/cmd_away.cpp @@ -26,7 +26,7 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_away(Instance); } -void cmd_away::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_away::Handle (const char** parameters, int pcnt, userrec *user) { if ((pcnt) && (*parameters[0])) { @@ -40,4 +40,5 @@ void cmd_away::Handle (const char** parameters, int pcnt, userrec *user) user->WriteServ("305 %s :You are no longer marked as being away",user->nick); FOREACH_MOD(I_OnCancelAway,OnCancelAway(user)); } + return CMD_SUCCESS; } diff --git a/src/cmd_commands.cpp b/src/cmd_commands.cpp index 6ffd0c469..b6c0b1a24 100644 --- a/src/cmd_commands.cpp +++ b/src/cmd_commands.cpp @@ -25,11 +25,12 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_commands(Instance); } -void cmd_commands::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_commands::Handle (const char** parameters, int pcnt, userrec *user) { for (nspace::hash_map<std::string,command_t*>::iterator i = ServerInstance->Parser->cmdlist.begin(); i != ServerInstance->Parser->cmdlist.end(); i++) { user->WriteServ("902 %s :%s %s %d",user->nick,i->second->command.c_str(),i->second->source.c_str(),i->second->min_params); } user->WriteServ("903 %s :End of COMMANDS list",user->nick); + return CMD_SUCCESS; } diff --git a/src/cmd_connect.cpp b/src/cmd_connect.cpp index cf885c5bb..4c1d6d7a9 100644 --- a/src/cmd_connect.cpp +++ b/src/cmd_connect.cpp @@ -27,7 +27,8 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_connect(Instance); } -void cmd_connect::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_connect::Handle (const char** parameters, int pcnt, userrec *user) { user->WriteServ( "NOTICE %s :You are a nub. Load a linking module.", user->nick); + return CMD_SUCCESS; } diff --git a/src/cmd_die.cpp b/src/cmd_die.cpp index fc2cc473e..06b8b79e8 100644 --- a/src/cmd_die.cpp +++ b/src/cmd_die.cpp @@ -25,7 +25,7 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_die(Instance); } -void cmd_die::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_die::Handle (const char** parameters, int pcnt, userrec *user) { if (!strcmp(parameters[0],ServerInstance->Config->diepass)) { @@ -53,5 +53,7 @@ void cmd_die::Handle (const char** parameters, int pcnt, userrec *user) { ServerInstance->Log(SPARSE, "Failed /DIE command from %s!%s@%s", user->nick, user->ident, user->host); ServerInstance->WriteOpers("*** Failed DIE Command from %s!%s@%s.",user->nick,user->ident,user->host); + return CMD_FAILURE; } + return CMD_SUCCESS; } diff --git a/src/cmd_eline.cpp b/src/cmd_eline.cpp index 971649989..3a11fe024 100644 --- a/src/cmd_eline.cpp +++ b/src/cmd_eline.cpp @@ -27,17 +27,17 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_eline(Instance); } -void cmd_eline::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_eline::Handle (const char** parameters, int pcnt, userrec *user) { if (pcnt >= 3) { if (ServerInstance->HostMatchesEveryone(parameters[0],user)) - return; + return CMD_FAILURE; if (!strchr(parameters[0],'@')) { user->WriteServ("NOTICE %s :*** E-Line must contain a username, e.g. *@%s",user->nick,parameters[0]); - return; + return CMD_FAILURE; } ServerInstance->XLines->add_eline(ServerInstance->Duration(parameters[1]),user->nick,parameters[2],parameters[0]); @@ -65,5 +65,5 @@ void cmd_eline::Handle (const char** parameters, int pcnt, userrec *user) } } - // no need to apply the lines for an eline + return CMD_SUCCESS; } diff --git a/src/cmd_gline.cpp b/src/cmd_gline.cpp index 2d14fff22..85fe137b4 100644 --- a/src/cmd_gline.cpp +++ b/src/cmd_gline.cpp @@ -27,17 +27,17 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_gline(Instance); } -void cmd_gline::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_gline::Handle (const char** parameters, int pcnt, userrec *user) { if (pcnt >= 3) { if (ServerInstance->HostMatchesEveryone(parameters[0],user)) - return; + return CMD_FAILURE; if (!strchr(parameters[0],'@')) { user->WriteServ("NOTICE %s :*** G-Line must contain a username, e.g. *@%s",user->nick,parameters[0]); - return; + return CMD_FAILURE; } ServerInstance->XLines->add_gline(ServerInstance->Duration(parameters[1]),user->nick,parameters[2],parameters[0]); @@ -66,4 +66,7 @@ void cmd_gline::Handle (const char** parameters, int pcnt, userrec *user) user->WriteServ("NOTICE %s :*** G-Line %s not found in list, try /stats g.",user->nick,parameters[0]); } } + + return CMD_SUCCESS; } + diff --git a/src/cmd_info.cpp b/src/cmd_info.cpp index ce6358fd0..b592b7869 100644 --- a/src/cmd_info.cpp +++ b/src/cmd_info.cpp @@ -26,7 +26,7 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_info(Instance); } -void cmd_info::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_info::Handle (const char** parameters, int pcnt, userrec *user) { user->WriteServ( "371 %s :. o O (The Inspire Internet Relay Chat Server) O o .", user->nick); user->WriteServ( "371 %s : ", user->nick); @@ -74,4 +74,5 @@ void cmd_info::Handle (const char** parameters, int pcnt, userrec *user) user->WriteServ( "371 %s :Best experienced with: An IRC client.", user->nick); FOREACH_MOD(I_OnInfo,OnInfo(user)); user->WriteServ( "374 %s :End of /INFO list", user->nick); + return CMD_SUCCESS; } diff --git a/src/cmd_invite.cpp b/src/cmd_invite.cpp index 306823b8b..587dbc5f3 100644 --- a/src/cmd_invite.cpp +++ b/src/cmd_invite.cpp @@ -26,7 +26,7 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_invite(Instance); } -void cmd_invite::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_invite::Handle (const char** parameters, int pcnt, userrec *user) { int MOD_RESULT = 0; @@ -46,7 +46,7 @@ void cmd_invite::Handle (const char** parameters, int pcnt, userrec *user) user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]); } - return; + return CMD_FAILURE; } if ((c->modes[CM_INVITEONLY]) && (IS_LOCAL(user))) @@ -54,27 +54,27 @@ void cmd_invite::Handle (const char** parameters, int pcnt, userrec *user) if (c->GetStatus(user) < STATUS_HOP) { user->WriteServ("482 %s %s :You must be at least a half-operator to change modes on this channel",user->nick, c->name); - return; + return CMD_FAILURE; } } if (c->HasUser(u)) { user->WriteServ("443 %s %s %s :Is already on channel %s",user->nick,u->nick,c->name,c->name); - return; + return CMD_FAILURE; } if ((IS_LOCAL(user)) && (!c->HasUser(user))) { user->WriteServ("442 %s %s :You're not on that channel!",user->nick, c->name); - return; + return CMD_FAILURE; } FOREACH_RESULT(I_OnUserPreInvite,OnUserPreInvite(user,u,c)); if (MOD_RESULT == 1) { - return; + return CMD_FAILURE; } irc::string xname(c->name); @@ -94,4 +94,6 @@ void cmd_invite::Handle (const char** parameters, int pcnt, userrec *user) } user->WriteServ("347 %s :End of INVITE list",user->nick); } + return CMD_SUCCESS; } + diff --git a/src/cmd_ison.cpp b/src/cmd_ison.cpp index bd5fdac9f..72f5ded7c 100644 --- a/src/cmd_ison.cpp +++ b/src/cmd_ison.cpp @@ -25,7 +25,7 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_ison(Instance); } -void cmd_ison::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_ison::Handle (const char** parameters, int pcnt, userrec *user) { char retbuf[MAXBUF]; userrec *u; @@ -43,5 +43,8 @@ void cmd_ison::Handle (const char** parameters, int pcnt, userrec *user) } } - user->WriteServ( retbuf); + user->WriteServ(retbuf); + + return CMD_SUCCESS; } + diff --git a/src/cmd_join.cpp b/src/cmd_join.cpp index ee2131482..89483e1b4 100644 --- a/src/cmd_join.cpp +++ b/src/cmd_join.cpp @@ -25,30 +25,31 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_join(Instance); } -void cmd_join::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_join::Handle (const char** parameters, int pcnt, userrec *user) { if (pcnt > 1) { if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0, 1)) - return; + return CMD_SUCCESS; if (ServerInstance->IsChannel(parameters[0])) { chanrec::JoinUser(ServerInstance, user, parameters[0], false, parameters[1]); - return; + return CMD_SUCCESS; } } else { if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0)) - return; + return CMD_SUCCESS; if (ServerInstance->IsChannel(parameters[0])) { chanrec::JoinUser(ServerInstance, user, parameters[0], false); - return; + return CMD_SUCCESS; } } user->WriteServ("403 %s %s :Invalid channel name",user->nick, parameters[0]); + return CMD_FAILURE; } diff --git a/src/cmd_kick.cpp b/src/cmd_kick.cpp index fd098c468..b20266e29 100644 --- a/src/cmd_kick.cpp +++ b/src/cmd_kick.cpp @@ -25,7 +25,7 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_kick(Instance); } -void cmd_kick::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_kick::Handle (const char** parameters, int pcnt, userrec *user) { char reason[MAXKICK]; chanrec* c = ServerInstance->FindChan(parameters[0]); @@ -34,13 +34,13 @@ void cmd_kick::Handle (const char** parameters, int pcnt, userrec *user) if (!u || !c) { user->WriteServ( "401 %s %s :No such nick/channel", user->nick, u ? parameters[0] : parameters[1]); - return; + return CMD_FAILURE; } if ((IS_LOCAL(user)) && (!c->HasUser(user)) && (!ServerInstance->ULine(user->server))) { user->WriteServ( "442 %s %s :You're not on that channel!", user->nick, parameters[0]); - return; + return CMD_FAILURE; } if (pcnt > 2) @@ -55,4 +55,6 @@ void cmd_kick::Handle (const char** parameters, int pcnt, userrec *user) if (!c->KickUser(user, u, reason)) /* Nobody left here, delete the chanrec */ delete c; + + return CMD_SUCCESS; } diff --git a/src/cmd_kill.cpp b/src/cmd_kill.cpp index 91dbca8bd..6fe855a19 100644 --- a/src/cmd_kill.cpp +++ b/src/cmd_kill.cpp @@ -26,7 +26,7 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_kill(Instance); } -void cmd_kill::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_kill::Handle (const char** parameters, int pcnt, userrec *user) { userrec *u = ServerInstance->FindNick(parameters[0]); char killreason[MAXBUF]; @@ -42,7 +42,7 @@ void cmd_kill::Handle (const char** parameters, int pcnt, userrec *user) if (MOD_RESULT) { ServerInstance->Log(DEBUG, "A module prevented the kill with result %d", MOD_RESULT); - return; + return CMD_FAILURE; } if (!IS_LOCAL(u)) @@ -81,6 +81,9 @@ void cmd_kill::Handle (const char** parameters, int pcnt, userrec *user) else { user->WriteServ( "401 %s %s :No such nick/channel", user->nick, parameters[0]); + return CMD_FAILURE; } + + return CMD_SUCCESS; } diff --git a/src/cmd_kline.cpp b/src/cmd_kline.cpp index 105c8c3c2..a72ea085d 100644 --- a/src/cmd_kline.cpp +++ b/src/cmd_kline.cpp @@ -27,17 +27,17 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_kline(Instance); } -void cmd_kline::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_kline::Handle (const char** parameters, int pcnt, userrec *user) { if (pcnt >= 3) { if (ServerInstance->HostMatchesEveryone(parameters[0],user)) - return; + return CMD_FAILURE; if (!strchr(parameters[0],'@')) { user->WriteServ("NOTICE %s :*** K-Line must contain a username, e.g. *@%s",user->nick,parameters[0]); - return; + return CMD_FAILURE; } ServerInstance->XLines->add_kline(ServerInstance->Duration(parameters[1]),user->nick,parameters[2],parameters[0]); @@ -66,5 +66,7 @@ void cmd_kline::Handle (const char** parameters, int pcnt, userrec *user) user->WriteServ("NOTICE %s :*** K-Line %s not found in list, try /stats k.",user->nick,parameters[0]); } } + + return CMD_SUCCESS; } diff --git a/src/cmd_links.cpp b/src/cmd_links.cpp index 46c35ca53..edb27ea31 100644 --- a/src/cmd_links.cpp +++ b/src/cmd_links.cpp @@ -26,8 +26,9 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_links(Instance); } -void cmd_links::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_links::Handle (const char** parameters, int pcnt, userrec *user) { user->WriteServ("364 %s %s %s :0 %s",user->nick,ServerInstance->Config->ServerName,ServerInstance->Config->ServerName,ServerInstance->Config->ServerDesc); user->WriteServ("365 %s * :End of /LINKS list.",user->nick); + return CMD_SUCCESS; } diff --git a/src/cmd_list.cpp b/src/cmd_list.cpp index f281ce195..a5f5ed75f 100644 --- a/src/cmd_list.cpp +++ b/src/cmd_list.cpp @@ -26,7 +26,7 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_list(Instance); } -void cmd_list::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_list::Handle (const char** parameters, int pcnt, userrec *user) { user->WriteServ("321 %s Channel :Users Name",user->nick); for (chan_hash::const_iterator i = ServerInstance->chanlist.begin(); i != ServerInstance->chanlist.end(); i++) @@ -44,4 +44,6 @@ void cmd_list::Handle (const char** parameters, int pcnt, userrec *user) } } user->WriteServ("323 %s :End of channel list.",user->nick); + + return CMD_SUCCESS; } diff --git a/src/cmd_loadmodule.cpp b/src/cmd_loadmodule.cpp index 2f1dc75d3..5e0c7ab6f 100644 --- a/src/cmd_loadmodule.cpp +++ b/src/cmd_loadmodule.cpp @@ -25,15 +25,18 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_loadmodule(Instance); } -void cmd_loadmodule::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_loadmodule::Handle (const char** parameters, int pcnt, userrec *user) { if (ServerInstance->LoadModule(parameters[0])) { ServerInstance->WriteOpers("*** NEW MODULE: %s",parameters[0]); user->WriteServ("975 %s %s :Module successfully loaded.",user->nick, parameters[0]); + return CMD_SUCCESS; } else { user->WriteServ("974 %s %s :Failed to load module: %s",user->nick, parameters[0],ServerInstance->ModuleError()); + return CMD_FAILURE; } } + diff --git a/src/cmd_lusers.cpp b/src/cmd_lusers.cpp index 23b8754e0..93b87a94d 100644 --- a/src/cmd_lusers.cpp +++ b/src/cmd_lusers.cpp @@ -25,7 +25,7 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_lusers(Instance); } -void cmd_lusers::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_lusers::Handle (const char** parameters, int pcnt, userrec *user) { // this lusers command shows one server at all times because // a protocol module must override it to show those stats. @@ -38,5 +38,7 @@ void cmd_lusers::Handle (const char** parameters, int pcnt, userrec *user) user->WriteServ("254 %s %d :channels formed",user->nick,ServerInstance->ChannelCount()); if (ServerInstance->LocalUserCount()) user->WriteServ("254 %s :I have %d clients and 0 servers",user->nick,ServerInstance->LocalUserCount()); + + return CMD_SUCCESS; } diff --git a/src/cmd_map.cpp b/src/cmd_map.cpp index 702038aa0..a44030eeb 100644 --- a/src/cmd_map.cpp +++ b/src/cmd_map.cpp @@ -25,11 +25,13 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_map(Instance); } -void cmd_map::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_map::Handle (const char** parameters, int pcnt, userrec *user) { // as with /LUSERS this does nothing without a linking // module to override its behaviour and display something // better. user->WriteServ("006 %s :%s",user->nick,ServerInstance->Config->ServerName); user->WriteServ("007 %s :End of /MAP",user->nick); + + return CMD_SUCCESS; } diff --git a/src/cmd_mode.cpp b/src/cmd_mode.cpp index c1d128bf9..545a14f8d 100644 --- a/src/cmd_mode.cpp +++ b/src/cmd_mode.cpp @@ -23,13 +23,9 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_mode(Instance); } -void cmd_mode::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_mode::Handle (const char** parameters, int pcnt, userrec *user) { - if (!user) - return; - ServerInstance->Modes->Process(parameters, pcnt, user, false); - - return; + return CMD_SUCCESS; } diff --git a/src/cmd_modules.cpp b/src/cmd_modules.cpp index e1a5b6d4b..fe6fa0258 100644 --- a/src/cmd_modules.cpp +++ b/src/cmd_modules.cpp @@ -43,7 +43,7 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_modules(Instance); } -void cmd_modules::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_modules::Handle (const char** parameters, int pcnt, userrec *user) { for (unsigned int i = 0; i < ServerInstance->Config->module_names.size(); i++) { @@ -108,4 +108,6 @@ void cmd_modules::Handle (const char** parameters, int pcnt, userrec *user) } } user->WriteServ("901 %s :End of MODULES list",user->nick); + + return CMD_SUCCESS; } diff --git a/src/cmd_motd.cpp b/src/cmd_motd.cpp index 04542db17..44c6fba9e 100644 --- a/src/cmd_motd.cpp +++ b/src/cmd_motd.cpp @@ -24,7 +24,8 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_motd(Instance); } -void cmd_motd::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_motd::Handle (const char** parameters, int pcnt, userrec *user) { user->ShowMOTD(); + return CMD_SUCCESS; } diff --git a/src/cmd_names.cpp b/src/cmd_names.cpp index e419c4172..8302136eb 100644 --- a/src/cmd_names.cpp +++ b/src/cmd_names.cpp @@ -25,18 +25,18 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_names(Instance); } -void cmd_names::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_names::Handle (const char** parameters, int pcnt, userrec *user) { chanrec* c; if (!pcnt) { user->WriteServ("366 %s * :End of /NAMES list.",user->nick); - return; + return CMD_SUCCESS; } if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0)) - return; + return CMD_SUCCESS; c = ServerInstance->FindChan(parameters[0]); if (c) @@ -44,7 +44,7 @@ void cmd_names::Handle (const char** parameters, int pcnt, userrec *user) if ((c->modes[CM_SECRET]) && (!c->HasUser(user))) { user->WriteServ("401 %s %s :No such nick/channel",user->nick, c->name); - return; + return CMD_FAILURE; } c->UserList(user); user->WriteServ("366 %s %s :End of /NAMES list.", user->nick, c->name); @@ -53,4 +53,6 @@ void cmd_names::Handle (const char** parameters, int pcnt, userrec *user) { user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]); } + + return CMD_SUCCESS; } diff --git a/src/cmd_nick.cpp b/src/cmd_nick.cpp index e6e2a98bc..10d95ed46 100644 --- a/src/cmd_nick.cpp +++ b/src/cmd_nick.cpp @@ -28,40 +28,25 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_nick(Instance); } -void cmd_nick::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_nick::Handle (const char** parameters, int pcnt, userrec *user) { char oldnick[NICKMAX]; - if (pcnt < 1) - { - ServerInstance->Log(DEBUG,"not enough params for handle_nick"); - return; - } - if (!parameters[0]) - { - ServerInstance->Log(DEBUG,"invalid parameter passed to handle_nick"); - return; - } - if (!parameters[0][0]) + if (!*parameters[0]) { ServerInstance->Log(DEBUG,"zero length new nick passed to handle_nick"); - return; + return CMD_FAILURE; } - if (!user) - { - ServerInstance->Log(DEBUG,"invalid user passed to handle_nick"); - return; - } - if (!user->nick) + if (!*user->nick) { ServerInstance->Log(DEBUG,"invalid old nick passed to handle_nick"); - return; + return CMD_FAILURE; } if (irc::string(user->nick) == irc::string(parameters[0])) { /* If its exactly the same, even case, dont do anything. */ if (!strcmp(user->nick,parameters[0])) - return; + return CMD_SUCCESS; /* Its a change of case. People insisted that they should be * able to do silly things like this even though the RFC says * the nick AAA is the same as the nick aaa. @@ -71,12 +56,12 @@ void cmd_nick::Handle (const char** parameters, int pcnt, userrec *user) int MOD_RESULT = 0; FOREACH_RESULT(I_OnUserPreNick,OnUserPreNick(user,parameters[0])); if (MOD_RESULT) - return; + return CMD_FAILURE; if (user->registered == REG_ALL) user->WriteCommon("NICK %s",parameters[0]); strlcpy(user->nick, parameters[0], NICKMAX - 1); FOREACH_MOD(I_OnUserPostNick,OnUserPostNick(user,oldnick)); - return; + return CMD_SUCCESS; } else { @@ -89,18 +74,26 @@ void cmd_nick::Handle (const char** parameters, int pcnt, userrec *user) { ServerInstance->WriteOpers("*** Q-Lined nickname %s from %s!%s@%s: %s",parameters[0],user->nick,user->ident,user->host,mq); user->WriteServ("432 %s %s :Invalid nickname: %s",user->nick,parameters[0],mq); - return; + return CMD_FAILURE; } - if ((ServerInstance->FindNick(parameters[0])) && (ServerInstance->FindNick(parameters[0]) != user)) + if ((ServerInstance->FindNick(parameters[0])) && (ServerInstance->FindNick(parameters[0]) != user) && (ServerInstance->IsNick(parameters[0]))) { - user->WriteServ("433 %s %s :Nickname is already in use.",user->nick,parameters[0]); - return; + userrec* InUse = ServerInstance->FindNick(parameters[0]); + if (InUse->registered != REG_ALL) + { + userrec::QuitUser(ServerInstance, InUse, "Nickname overruled"); + } + else + { + user->WriteServ("433 %s %s :Nickname is already in use.",user->nick,parameters[0]); + return CMD_FAILURE; + } } } if ((!ServerInstance->IsNick(parameters[0])) && (IS_LOCAL(user))) { user->WriteServ("432 %s %s :Erroneous Nickname",user->nick,parameters[0]); - return; + return CMD_FAILURE; } if (user->registered == REG_ALL) @@ -109,7 +102,7 @@ void cmd_nick::Handle (const char** parameters, int pcnt, userrec *user) FOREACH_RESULT(I_OnUserPreNick,OnUserPreNick(user,parameters[0])); if (MOD_RESULT) { // if a module returns true, the nick change is silently forbidden. - return; + return CMD_FAILURE; } user->WriteCommon("NICK %s",parameters[0]); @@ -121,8 +114,8 @@ void cmd_nick::Handle (const char** parameters, int pcnt, userrec *user) /* change the nick of the user in the users_hash */ user = user->UpdateNickHash(parameters[0]); /* actually change the nick within the record */ - if (!user) return; - if (!user->nick) return; + if (!user) return CMD_FAILURE; + if (!*user->nick) return CMD_FAILURE; strlcpy(user->nick, parameters[0], NICKMAX - 1); @@ -158,4 +151,8 @@ void cmd_nick::Handle (const char** parameters, int pcnt, userrec *user) { FOREACH_MOD(I_OnUserPostNick,OnUserPostNick(user,oldnick)); } + + return CMD_SUCCESS; + } + diff --git a/src/cmd_notice.cpp b/src/cmd_notice.cpp index 7cd53aa3d..d018e1eb2 100644 --- a/src/cmd_notice.cpp +++ b/src/cmd_notice.cpp @@ -27,7 +27,7 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_notice(Instance); } -void cmd_notice::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_notice::Handle (const char** parameters, int pcnt, userrec *user) { userrec *dest; chanrec *chan; @@ -35,14 +35,14 @@ void cmd_notice::Handle (const char** parameters, int pcnt, userrec *user) user->idle_lastmsg = ServerInstance->Time(); if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0)) - return; + return CMD_SUCCESS; if ((parameters[0][0] == '$') && ((*user->oper) || (ServerInstance->ULine(user->server)))) { int MOD_RESULT = 0; std::string temp = parameters[1]; FOREACH_RESULT(I_OnUserPreNotice,OnUserPreNotice(user,(void*)parameters[0],TYPE_SERVER,temp,0)); if (MOD_RESULT) - return; + return CMD_FAILURE; parameters[1] = (char*)temp.c_str(); // notice to server mask const char* servermask = parameters[0] + 1; @@ -51,7 +51,7 @@ void cmd_notice::Handle (const char** parameters, int pcnt, userrec *user) user->NoticeAll("%s",parameters[1]); } FOREACH_MOD(I_OnUserMessage,OnUserNotice(user,(void*)parameters[0],TYPE_SERVER,parameters[1],0)); - return; + return CMD_SUCCESS; } char status = 0; if ((*parameters[0] == '@') || (*parameters[0] == '%') || (*parameters[0] == '+')) @@ -69,12 +69,12 @@ void cmd_notice::Handle (const char** parameters, int pcnt, userrec *user) if ((chan->modes[CM_NOEXTERNAL]) && (!chan->HasUser(user))) { user->WriteServ("404 %s %s :Cannot send to channel (no external messages)", user->nick, chan->name); - return; + return CMD_FAILURE; } if ((chan->modes[CM_MODERATED]) && (chan->GetStatus(user) < STATUS_VOICE)) { user->WriteServ("404 %s %s :Cannot send to channel (+m)", user->nick, chan->name); - return; + return CMD_FAILURE; } } @@ -83,14 +83,14 @@ void cmd_notice::Handle (const char** parameters, int pcnt, userrec *user) std::string temp = parameters[1]; FOREACH_RESULT(I_OnUserPreNotice,OnUserPreNotice(user,chan,TYPE_CHANNEL,temp,status)); if (MOD_RESULT) { - return; + return CMD_FAILURE; } parameters[1] = (char*)temp.c_str(); if (temp == "") { user->WriteServ("412 %s No text to send", user->nick); - return; + return CMD_FAILURE; } chan->WriteAllExceptSender(user, status, "NOTICE %s :%s", chan->name, parameters[1]); @@ -101,8 +101,9 @@ void cmd_notice::Handle (const char** parameters, int pcnt, userrec *user) { /* no such nick/channel */ user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]); + return CMD_FAILURE; } - return; + return CMD_SUCCESS; } dest = ServerInstance->FindNick(parameters[0]); @@ -113,7 +114,7 @@ void cmd_notice::Handle (const char** parameters, int pcnt, userrec *user) std::string temp = parameters[1]; FOREACH_RESULT(I_OnUserPreNotice,OnUserPreNotice(user,dest,TYPE_USER,temp,0)); if (MOD_RESULT) { - return; + return CMD_FAILURE; } parameters[1] = (char*)temp.c_str(); @@ -129,5 +130,10 @@ void cmd_notice::Handle (const char** parameters, int pcnt, userrec *user) { /* no such nick/channel */ user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]); + return CMD_FAILURE; } + + return CMD_SUCCESS; + } + diff --git a/src/cmd_oper.cpp b/src/cmd_oper.cpp index 7db6627e9..f2fbabc18 100644 --- a/src/cmd_oper.cpp +++ b/src/cmd_oper.cpp @@ -42,7 +42,7 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_oper(Instance); } -void cmd_oper::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_oper::Handle (const char** parameters, int pcnt, userrec *user) { char LoginName[MAXBUF]; char Password[MAXBUF]; @@ -83,7 +83,7 @@ void cmd_oper::Handle (const char** parameters, int pcnt, userrec *user) user->WriteServ("491 %s :Invalid oper type (oper types must follow the same syntax as nicknames)",user->nick); ServerInstance->SNO->WriteToSnoMask('o',"CONFIGURATION ERROR! Oper type invalid for OperType '%s'",OperType); ServerInstance->Log(DEFAULT,"OPER: Failed oper attempt by %s!%s@%s: credentials valid, but oper type erroneous.",user->nick,user->ident,user->host); - return; + return CMD_FAILURE; } found = true; fail2 = false; @@ -109,14 +109,16 @@ void cmd_oper::Handle (const char** parameters, int pcnt, userrec *user) user->WriteServ("491 %s :Invalid oper credentials",user->nick); ServerInstance->SNO->WriteToSnoMask('o',"WARNING! Failed oper attempt by %s!%s@%s!",user->nick,user->ident,user->host); ServerInstance->Log(DEFAULT,"OPER: Failed oper attempt by %s!%s@%s: user, host or password did not match.",user->nick,user->ident,user->host); + return CMD_FAILURE; } else { user->WriteServ("491 %s :Your oper block does not have a valid opertype associated with it",user->nick); ServerInstance->SNO->WriteToSnoMask('o',"CONFIGURATION ERROR! Oper block mismatch for OperType %s",OperType); ServerInstance->Log(DEFAULT,"OPER: Failed oper attempt by %s!%s@%s: credentials valid, but oper type nonexistent.",user->nick,user->ident,user->host); + return CMD_FAILURE; } } - return; + return CMD_SUCCESS; } diff --git a/src/cmd_part.cpp b/src/cmd_part.cpp index 9fd01d058..cb5dde28e 100644 --- a/src/cmd_part.cpp +++ b/src/cmd_part.cpp @@ -25,10 +25,10 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_part(Instance); } -void cmd_part::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_part::Handle (const char** parameters, int pcnt, userrec *user) { if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0)) - return; + return CMD_SUCCESS; chanrec* c = ServerInstance->FindChan(parameters[0]); @@ -41,5 +41,8 @@ void cmd_part::Handle (const char** parameters, int pcnt, userrec *user) else { user->WriteServ( "401 %s %s :No such channel", user->nick, parameters[0]); + return CMD_FAILURE; } + + return CMD_SUCCESS; } diff --git a/src/cmd_pass.cpp b/src/cmd_pass.cpp index e761f8d42..4e5e739c2 100644 --- a/src/cmd_pass.cpp +++ b/src/cmd_pass.cpp @@ -24,13 +24,13 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_pass(Instance); } -void cmd_pass::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_pass::Handle (const char** parameters, int pcnt, userrec *user) { // Check to make sure they havnt registered -- Fix by FCS if (user->registered == REG_ALL) { user->WriteServ("462 %s :You may not reregister",user->nick); - return; + return CMD_FAILURE; } ConnectClass a = user->GetClass(); strlcpy(user->password,parameters[0],63); @@ -38,4 +38,6 @@ void cmd_pass::Handle (const char** parameters, int pcnt, userrec *user) { user->haspassed = true; } + + return CMD_SUCCESS; } diff --git a/src/cmd_ping.cpp b/src/cmd_ping.cpp index 9ecec693c..bf5824133 100644 --- a/src/cmd_ping.cpp +++ b/src/cmd_ping.cpp @@ -25,7 +25,8 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_ping(Instance); } -void cmd_ping::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_ping::Handle (const char** parameters, int pcnt, userrec *user) { user->WriteServ("PONG %s :%s",ServerInstance->Config->ServerName,parameters[0]); + return CMD_SUCCESS; } diff --git a/src/cmd_pong.cpp b/src/cmd_pong.cpp index 9a388c021..5e619b5b1 100644 --- a/src/cmd_pong.cpp +++ b/src/cmd_pong.cpp @@ -24,8 +24,9 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_pong(Instance); } -void cmd_pong::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_pong::Handle (const char** parameters, int pcnt, userrec *user) { // set the user as alive so they survive to next ping user->lastping = 1; + return CMD_SUCCESS; } diff --git a/src/cmd_privmsg.cpp b/src/cmd_privmsg.cpp index e387b6ae3..0623fcd85 100644 --- a/src/cmd_privmsg.cpp +++ b/src/cmd_privmsg.cpp @@ -28,7 +28,7 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_privmsg(Instance); } -void cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user) { userrec *dest; chanrec *chan; @@ -36,7 +36,7 @@ void cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user) user->idle_lastmsg = ServerInstance->Time(); if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0)) - return; + return CMD_SUCCESS; if ((parameters[0][0] == '$') && ((*user->oper) || (ServerInstance->ULine(user->server)))) { @@ -44,7 +44,7 @@ void cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user) std::string temp = parameters[1]; FOREACH_RESULT(I_OnUserPreMessage,OnUserPreMessage(user,(void*)parameters[0],TYPE_SERVER,temp,0)); if (MOD_RESULT) - return; + return CMD_FAILURE; parameters[1] = (char*)temp.c_str(); // notice to server mask const char* servermask = parameters[0] + 1; @@ -53,7 +53,7 @@ void cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user) ServerInstance->ServerPrivmsgAll("%s",parameters[1]); } FOREACH_MOD(I_OnUserMessage,OnUserMessage(user,(void*)parameters[0],TYPE_SERVER,parameters[1],0)); - return; + return CMD_SUCCESS; } char status = 0; if ((*parameters[0] == '@') || (*parameters[0] == '%') || (*parameters[0] == '+')) @@ -71,12 +71,12 @@ void cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user) if ((chan->modes[CM_NOEXTERNAL]) && (!chan->HasUser(user))) { user->WriteServ("404 %s %s :Cannot send to channel (no external messages)", user->nick, chan->name); - return; + return CMD_FAILURE; } if ((chan->modes[CM_MODERATED]) && (chan->GetStatus(user) < STATUS_VOICE)) { user->WriteServ("404 %s %s :Cannot send to channel (+m)", user->nick, chan->name); - return; + return CMD_FAILURE; } } int MOD_RESULT = 0; @@ -84,14 +84,14 @@ void cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user) std::string temp = parameters[1]; FOREACH_RESULT(I_OnUserPreMessage,OnUserPreMessage(user,chan,TYPE_CHANNEL,temp,status)); if (MOD_RESULT) { - return; + return CMD_FAILURE; } parameters[1] = (char*)temp.c_str(); if (temp == "") { user->WriteServ("412 %s No text to send", user->nick); - return; + return CMD_FAILURE; } chan->WriteAllExceptSender(user, status, "PRIVMSG %s :%s", chan->name, parameters[1]); @@ -101,8 +101,9 @@ void cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user) { /* no such nick/channel */ user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]); + return CMD_FAILURE; } - return; + return CMD_SUCCESS; } dest = ServerInstance->FindNick(parameters[0]); @@ -119,7 +120,7 @@ void cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user) std::string temp = parameters[1]; FOREACH_RESULT(I_OnUserPreMessage,OnUserPreMessage(user,dest,TYPE_USER,temp,0)); if (MOD_RESULT) { - return; + return CMD_FAILURE; } parameters[1] = (char*)temp.c_str(); @@ -135,5 +136,8 @@ void cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user) { /* no such nick/channel */ user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]); + return CMD_FAILURE; } + return CMD_SUCCESS; } + diff --git a/src/cmd_qline.cpp b/src/cmd_qline.cpp index 68e315822..a76302421 100644 --- a/src/cmd_qline.cpp +++ b/src/cmd_qline.cpp @@ -27,12 +27,12 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_qline(Instance); } -void cmd_qline::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_qline::Handle (const char** parameters, int pcnt, userrec *user) { if (pcnt >= 3) { if (ServerInstance->NickMatchesEveryone(parameters[0],user)) - return; + return CMD_FAILURE; ServerInstance->XLines->add_qline(ServerInstance->Duration(parameters[1]),user->nick,parameters[2],parameters[0]); FOREACH_MOD(I_OnAddQLine,OnAddQLine(ServerInstance->Duration(parameters[1]), user, parameters[2], parameters[0])); if (!ServerInstance->Duration(parameters[1])) @@ -55,6 +55,10 @@ void cmd_qline::Handle (const char** parameters, int pcnt, userrec *user) else { user->WriteServ("NOTICE %s :*** Q-Line %s not found in list, try /stats q.",user->nick,parameters[0]); + return CMD_FAILURE; } } + + return CMD_SUCCESS; } + diff --git a/src/cmd_quit.cpp b/src/cmd_quit.cpp index 102d9adc5..bf64aea3d 100644 --- a/src/cmd_quit.cpp +++ b/src/cmd_quit.cpp @@ -27,7 +27,7 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_quit(Instance); } -void cmd_quit::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_quit::Handle (const char** parameters, int pcnt, userrec *user) { user_hash::iterator iter = ServerInstance->clientlist.find(user->nick); char reason[MAXBUF]; @@ -100,5 +100,7 @@ void cmd_quit::Handle (const char** parameters, int pcnt, userrec *user) user->PurgeEmptyChannels(); } DELETE(user); + + return CMD_SUCCESS; } diff --git a/src/cmd_rehash.cpp b/src/cmd_rehash.cpp index c4ee2f94f..f53f810a4 100644 --- a/src/cmd_rehash.cpp +++ b/src/cmd_rehash.cpp @@ -26,7 +26,7 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_rehash(Instance); } -void cmd_rehash::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_rehash::Handle (const char** parameters, int pcnt, userrec *user) { user->WriteServ("382 %s %s :Rehashing",user->nick,ServerConfig::CleanFilename(CONFIG_FILE)); std::string parameter = ""; @@ -40,4 +40,7 @@ void cmd_rehash::Handle (const char** parameters, int pcnt, userrec *user) ServerInstance->Config->Read(false,user); } FOREACH_MOD(I_OnRehash,OnRehash(parameter)); + + return CMD_SUCCESS; } + diff --git a/src/cmd_restart.cpp b/src/cmd_restart.cpp index 18f8d2fc9..2ab046f7e 100644 --- a/src/cmd_restart.cpp +++ b/src/cmd_restart.cpp @@ -25,7 +25,7 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_restart(Instance); } -void cmd_restart::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_restart::Handle (const char** parameters, int pcnt, userrec *user) { char *argv[32]; ServerInstance->Log(DEFAULT,"Restart: %s",user->nick); @@ -62,5 +62,9 @@ void cmd_restart::Handle (const char** parameters, int pcnt, userrec *user) else { ServerInstance->WriteOpers("*** Failed RESTART Command from %s!%s@%s.",user->nick,user->ident,user->host); + return CMD_FAILURE; } + + return CMD_SUCCESS; } + diff --git a/src/cmd_rules.cpp b/src/cmd_rules.cpp index e08b7c775..9e42b8a66 100644 --- a/src/cmd_rules.cpp +++ b/src/cmd_rules.cpp @@ -24,7 +24,8 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_rules(Instance); } -void cmd_rules::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_rules::Handle (const char** parameters, int pcnt, userrec *user) { user->ShowRULES(); + return CMD_SUCCESS; } diff --git a/src/cmd_server.cpp b/src/cmd_server.cpp index b1f9a89d8..8ec65f681 100644 --- a/src/cmd_server.cpp +++ b/src/cmd_server.cpp @@ -25,8 +25,9 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_server(Instance); } -void cmd_server::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_server::Handle (const char** parameters, int pcnt, userrec *user) { user->WriteServ("666 %s :You cannot identify as a server, you are a USER. IRC Operators informed.",user->nick); ServerInstance->WriteOpers("*** WARNING: %s attempted to issue a SERVER command and is registered as a user!",user->nick); + return CMD_FAILURE; } diff --git a/src/cmd_squit.cpp b/src/cmd_squit.cpp index facfcf694..fa3aadc78 100644 --- a/src/cmd_squit.cpp +++ b/src/cmd_squit.cpp @@ -27,7 +27,8 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_squit(Instance); } -void cmd_squit::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_squit::Handle (const char** parameters, int pcnt, userrec *user) { user->WriteServ( "NOTICE %s :You are a nub. Load a linking module.", user->nick); + return CMD_FAILURE; } diff --git a/src/cmd_stats.cpp b/src/cmd_stats.cpp index 44755451d..0e2935e5d 100644 --- a/src/cmd_stats.cpp +++ b/src/cmd_stats.cpp @@ -29,12 +29,14 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_stats(Instance); } -void cmd_stats::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_stats::Handle (const char** parameters, int pcnt, userrec *user) { string_list values; DoStats(this->ServerInstance, *parameters[0], user, values); for (size_t i = 0; i < values.size(); i++) user->Write(":%s", values[i].c_str()); + + return CMD_SUCCESS; } void DoStats(InspIRCd* ServerInstance, char statschar, userrec* user, string_list &results) diff --git a/src/cmd_summon.cpp b/src/cmd_summon.cpp index 968d62767..f8e493fc0 100644 --- a/src/cmd_summon.cpp +++ b/src/cmd_summon.cpp @@ -24,7 +24,8 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_summon(Instance); } -void cmd_summon::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_summon::Handle (const char** parameters, int pcnt, userrec *user) { user->WriteServ("445 %s :SUMMON has been disabled (depreciated command)",user->nick); + return CMD_FAILURE; } diff --git a/src/cmd_time.cpp b/src/cmd_time.cpp index 04005a9a7..c034d4715 100644 --- a/src/cmd_time.cpp +++ b/src/cmd_time.cpp @@ -25,7 +25,7 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_time(Instance); } -void cmd_time::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_time::Handle (const char** parameters, int pcnt, userrec *user) { struct tm* timeinfo; time_t local = ServerInstance->Time(); @@ -37,5 +37,6 @@ void cmd_time::Handle (const char** parameters, int pcnt, userrec *user) tms[24] = 0; user->WriteServ("391 %s %s :%s",user->nick,ServerInstance->Config->ServerName,tms); - + + return CMD_SUCCESS; } diff --git a/src/cmd_topic.cpp b/src/cmd_topic.cpp index b97821434..6d2f6cf9e 100644 --- a/src/cmd_topic.cpp +++ b/src/cmd_topic.cpp @@ -26,7 +26,7 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_topic(Instance); } -void cmd_topic::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_topic::Handle (const char** parameters, int pcnt, userrec *user) { chanrec* Ptr; @@ -38,7 +38,7 @@ void cmd_topic::Handle (const char** parameters, int pcnt, userrec *user) if ((Ptr->modes[CM_SECRET]) && (!Ptr->HasUser(user))) { user->WriteServ("401 %s %s :No such nick/channel",user->nick, Ptr->name); - return; + return CMD_FAILURE; } if (Ptr->topicset) { @@ -53,8 +53,9 @@ void cmd_topic::Handle (const char** parameters, int pcnt, userrec *user) else { user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]); + return CMD_FAILURE; } - return; + return CMD_SUCCESS; } else if (pcnt>1) { @@ -66,12 +67,12 @@ void cmd_topic::Handle (const char** parameters, int pcnt, userrec *user) if (!Ptr->HasUser(user)) { user->WriteServ("442 %s %s :You're not on that channel!",user->nick, Ptr->name); - return; + return CMD_FAILURE; } if ((Ptr->modes[CM_TOPICLOCK]) && (Ptr->GetStatus(user) < STATUS_HOP)) { user->WriteServ("482 %s %s :You must be at least a half-operator to change modes on this channel", user->nick, Ptr->name); - return; + return CMD_FAILURE; } } char topic[MAXTOPIC]; @@ -82,7 +83,7 @@ void cmd_topic::Handle (const char** parameters, int pcnt, userrec *user) int MOD_RESULT = 0; FOREACH_RESULT(I_OnLocalTopicChange,OnLocalTopicChange(user,Ptr,topic)); if (MOD_RESULT) - return; + return CMD_FAILURE; } strlcpy(Ptr->topic,topic,MAXTOPIC-1); @@ -97,7 +98,9 @@ void cmd_topic::Handle (const char** parameters, int pcnt, userrec *user) else { user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]); + return CMD_FAILURE; } } + return CMD_SUCCESS; } diff --git a/src/cmd_trace.cpp b/src/cmd_trace.cpp index 7332f4631..31dc27a28 100644 --- a/src/cmd_trace.cpp +++ b/src/cmd_trace.cpp @@ -25,7 +25,7 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_trace(Instance); } -void cmd_trace::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_trace::Handle (const char** parameters, int pcnt, userrec *user) { for (user_hash::iterator i = ServerInstance->clientlist.begin(); i != ServerInstance->clientlist.end(); i++) { @@ -48,4 +48,5 @@ void cmd_trace::Handle (const char** parameters, int pcnt, userrec *user) } } } + return CMD_SUCCESS; } diff --git a/src/cmd_unloadmodule.cpp b/src/cmd_unloadmodule.cpp index 1bb99014b..ba8e1f99d 100644 --- a/src/cmd_unloadmodule.cpp +++ b/src/cmd_unloadmodule.cpp @@ -25,7 +25,7 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_unloadmodule(Instance); } -void cmd_unloadmodule::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_unloadmodule::Handle (const char** parameters, int pcnt, userrec *user) { if (ServerInstance->UnloadModule(parameters[0])) { @@ -35,5 +35,8 @@ void cmd_unloadmodule::Handle (const char** parameters, int pcnt, userrec *user) else { user->WriteServ("972 %s %s :Failed to unload module: %s",user->nick, parameters[0],ServerInstance->ModuleError()); + return CMD_FAILURE; } + + return CMD_SUCCESS; } diff --git a/src/cmd_user.cpp b/src/cmd_user.cpp index 13e42f043..f7a22eb01 100644 --- a/src/cmd_user.cpp +++ b/src/cmd_user.cpp @@ -25,7 +25,7 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_user(Instance); } -void cmd_user::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_user::Handle (const char** parameters, int pcnt, userrec *user) { if (user->registered < REG_NICKUSER) { @@ -33,6 +33,7 @@ void cmd_user::Handle (const char** parameters, int pcnt, userrec *user) // This kinda Sucks, According to the RFC thou, its either this, // or "You have already registered" :p -- Craig user->WriteServ("461 %s USER :Not enough parameters",user->nick); + return CMD_FAILURE; } else { /* We're not checking ident, but I'm not sure I like the idea of '~' prefixing.. */ @@ -48,13 +49,14 @@ void cmd_user::Handle (const char** parameters, int pcnt, userrec *user) else { user->WriteServ("462 %s :You may not reregister",user->nick); - return; + return CMD_FAILURE; } /* parameters 2 and 3 are local and remote hosts, ignored when sent by client connection */ if (user->registered == REG_NICKUSER) { /* user is registered now, bit 0 = USER command, bit 1 = sent a NICK command */ FOREACH_MOD(I_OnUserRegister,OnUserRegister(user)); - //ConnectUser(user,NULL); } + + return CMD_SUCCESS; } diff --git a/src/cmd_userhost.cpp b/src/cmd_userhost.cpp index c124b24d3..52c0f0612 100644 --- a/src/cmd_userhost.cpp +++ b/src/cmd_userhost.cpp @@ -25,7 +25,7 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_userhost(Instance); } -void cmd_userhost::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_userhost::Handle (const char** parameters, int pcnt, userrec *user) { char Return[MAXBUF],junk[MAXBUF]; snprintf(Return,MAXBUF,"302 %s :",user->nick); @@ -50,4 +50,6 @@ void cmd_userhost::Handle (const char** parameters, int pcnt, userrec *user) } } user->WriteServ(Return); + + return CMD_SUCCESS; } diff --git a/src/cmd_users.cpp b/src/cmd_users.cpp index 43f5c2105..d9e3a72cf 100644 --- a/src/cmd_users.cpp +++ b/src/cmd_users.cpp @@ -24,7 +24,8 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_users(Instance); } -void cmd_users::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_users::Handle (const char** parameters, int pcnt, userrec *user) { user->WriteServ("445 %s :USERS has been disabled (depreciated command)",user->nick); + return CMD_FAILURE; } diff --git a/src/cmd_version.cpp b/src/cmd_version.cpp index 5e1db8c2e..311659e59 100644 --- a/src/cmd_version.cpp +++ b/src/cmd_version.cpp @@ -26,7 +26,7 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_version(Instance); } -void cmd_version::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_version::Handle (const char** parameters, int pcnt, userrec *user) { std::stringstream out(ServerInstance->Config->data005); std::string token = ""; @@ -48,4 +48,6 @@ void cmd_version::Handle (const char** parameters, int pcnt, userrec *user) token_counter = 0; } } + + return CMD_SUCCESS; } diff --git a/src/cmd_wallops.cpp b/src/cmd_wallops.cpp index 93256ec64..ae2ee6d9d 100644 --- a/src/cmd_wallops.cpp +++ b/src/cmd_wallops.cpp @@ -25,8 +25,9 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_wallops(Instance); } -void cmd_wallops::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_wallops::Handle (const char** parameters, int pcnt, userrec *user) { user->WriteWallOps(std::string(parameters[0])); FOREACH_MOD(I_OnWallops,OnWallops(user,parameters[0])); + return CMD_SUCCESS; } diff --git a/src/cmd_who.cpp b/src/cmd_who.cpp index e48e013ec..0add5a09f 100644 --- a/src/cmd_who.cpp +++ b/src/cmd_who.cpp @@ -61,7 +61,7 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_who(Instance); } -void cmd_who::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_who::Handle (const char** parameters, int pcnt, userrec *user) { /* * XXX - RFC says: @@ -235,10 +235,12 @@ void cmd_who::Handle (const char** parameters, int pcnt, userrec *user) for (std::vector<std::string>::const_iterator n = whoresults.begin(); n != whoresults.end(); n++) user->WriteServ(*n); user->WriteServ("315 %s %s :End of /WHO list.",user->nick, *parameters[0] ? parameters[0] : "*"); + return CMD_SUCCESS; } else { /* BZZT! Too many results. */ user->WriteServ("315 %s %s :Too many results",user->nick, parameters[0]); + return CMD_FAILURE; } } diff --git a/src/cmd_whois.cpp b/src/cmd_whois.cpp index a9577f168..d48d1a10c 100644 --- a/src/cmd_whois.cpp +++ b/src/cmd_whois.cpp @@ -98,11 +98,11 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_whois(Instance); } -void cmd_whois::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_whois::Handle (const char** parameters, int pcnt, userrec *user) { userrec *dest; if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0)) - return; + return CMD_SUCCESS; dest = ServerInstance->FindNick(parameters[0]); if (dest) @@ -114,6 +114,9 @@ void cmd_whois::Handle (const char** parameters, int pcnt, userrec *user) /* no such nick/channel */ user->WriteServ("401 %s %s :No such nick/channel",user->nick, *parameters[0] ? parameters[0] : "*"); user->WriteServ("318 %s %s :End of /WHOIS list.",user->nick, *parameters[0] ? parameters[0] : "*"); + return CMD_FAILURE; } + + return CMD_SUCCESS; } diff --git a/src/cmd_whowas.cpp b/src/cmd_whowas.cpp index 4f0cfdc21..fe3171fc5 100644 --- a/src/cmd_whowas.cpp +++ b/src/cmd_whowas.cpp @@ -25,13 +25,14 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_whowas(Instance); } -void cmd_whowas::Handle (const char** parameters, int pcnt, userrec* user) +CmdResult cmd_whowas::Handle (const char** parameters, int pcnt, userrec* user) { irc::whowas::whowas_users::iterator i = ServerInstance->whowas.find(parameters[0]); if (i == ServerInstance->whowas.end()) { user->WriteServ("406 %s %s :There was no such nickname",user->nick,parameters[0]); + return CMD_FAILURE; } else { @@ -65,8 +66,11 @@ void cmd_whowas::Handle (const char** parameters, int pcnt, userrec* user) else { user->WriteServ("406 %s %s :There was no such nickname",user->nick,parameters[0]); + return CMD_FAILURE; } } user->WriteServ("369 %s %s :End of WHOWAS",user->nick,parameters[0]); + + return CMD_SUCCESS; } diff --git a/src/cmd_zline.cpp b/src/cmd_zline.cpp index 183fec5d5..9b24489b8 100644 --- a/src/cmd_zline.cpp +++ b/src/cmd_zline.cpp @@ -28,17 +28,19 @@ extern "C" command_t* init_command(InspIRCd* Instance) return new cmd_zline(Instance); } -void cmd_zline::Handle (const char** parameters, int pcnt, userrec *user) +CmdResult cmd_zline::Handle (const char** parameters, int pcnt, userrec *user) { if (pcnt >= 3) { if (strchr(parameters[0],'@')) { user->WriteServ("NOTICE %s :*** You cannot include a username in a zline, a zline must ban only an IP mask",user->nick); - return; + return CMD_FAILURE; } + if (ServerInstance->IPMatchesEveryone(parameters[0],user)) - return; + return CMD_FAILURE; + ServerInstance->XLines->add_zline(ServerInstance->Duration(parameters[1]),user->nick,parameters[2],parameters[0]); FOREACH_MOD(I_OnAddZLine,OnAddZLine(ServerInstance->Duration(parameters[1]), user, parameters[2], parameters[0])); if (!ServerInstance->Duration(parameters[1])) @@ -61,6 +63,9 @@ void cmd_zline::Handle (const char** parameters, int pcnt, userrec *user) else { user->WriteServ("NOTICE %s :*** Z-Line %s not found in list, try /stats Z.",user->nick,parameters[0]); + return CMD_FAILURE; } } + + return CMD_SUCCESS; } diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index 369aac19f..b9113dfc5 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -594,7 +594,7 @@ class cmd_rconnect : public command_t syntax = "<remote-server-mask> <servermask>"; } - void Handle (const char** parameters, int pcnt, userrec *user) + CmdResult Handle (const char** parameters, int pcnt, userrec *user) { user->WriteServ("NOTICE %s :*** RCONNECT: Sending remote connect to \002%s\002 to connect server \002%s\002.",user->nick,parameters[0],parameters[1]); /* Is this aimed at our server? */ @@ -605,7 +605,11 @@ class cmd_rconnect : public command_t const char* para[1]; para[0] = parameters[1]; Creator->OnPreCommand("CONNECT", para, 1, user, true); + + return CMD_SUCCESS; } + + return CMD_FAILURE; } }; |