summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/command_parse.h14
-rw-r--r--include/commands/cmd_admin.h2
-rw-r--r--include/commands/cmd_away.h2
-rw-r--r--include/commands/cmd_clearcache.h2
-rw-r--r--include/commands/cmd_commands.h2
-rw-r--r--include/commands/cmd_connect.h2
-rw-r--r--include/commands/cmd_die.h2
-rw-r--r--include/commands/cmd_eline.h2
-rw-r--r--include/commands/cmd_gline.h2
-rw-r--r--include/commands/cmd_info.h2
-rw-r--r--include/commands/cmd_invite.h2
-rw-r--r--include/commands/cmd_ison.h2
-rw-r--r--include/commands/cmd_join.h2
-rw-r--r--include/commands/cmd_kick.h2
-rw-r--r--include/commands/cmd_kill.h2
-rw-r--r--include/commands/cmd_kline.h2
-rw-r--r--include/commands/cmd_links.h2
-rw-r--r--include/commands/cmd_list.h2
-rw-r--r--include/commands/cmd_loadmodule.h2
-rw-r--r--include/commands/cmd_lusers.h2
-rw-r--r--include/commands/cmd_map.h2
-rw-r--r--include/commands/cmd_mode.h2
-rw-r--r--include/commands/cmd_modules.h2
-rw-r--r--include/commands/cmd_motd.h2
-rw-r--r--include/commands/cmd_names.h2
-rw-r--r--include/commands/cmd_nick.h2
-rw-r--r--include/commands/cmd_notice.h2
-rw-r--r--include/commands/cmd_oper.h2
-rw-r--r--include/commands/cmd_part.h2
-rw-r--r--include/commands/cmd_pass.h2
-rw-r--r--include/commands/cmd_ping.h2
-rw-r--r--include/commands/cmd_pong.h2
-rw-r--r--include/commands/cmd_privmsg.h2
-rw-r--r--include/commands/cmd_qline.h2
-rw-r--r--include/commands/cmd_quit.h2
-rw-r--r--include/commands/cmd_rehash.h2
-rw-r--r--include/commands/cmd_reloadmodule.h2
-rw-r--r--include/commands/cmd_restart.h2
-rw-r--r--include/commands/cmd_rules.h2
-rw-r--r--include/commands/cmd_server.h2
-rw-r--r--include/commands/cmd_squit.h2
-rw-r--r--include/commands/cmd_stats.h2
-rw-r--r--include/commands/cmd_time.h2
-rw-r--r--include/commands/cmd_topic.h2
-rw-r--r--include/commands/cmd_trace.h2
-rw-r--r--include/commands/cmd_unloadmodule.h2
-rw-r--r--include/commands/cmd_user.h2
-rw-r--r--include/commands/cmd_userhost.h2
-rw-r--r--include/commands/cmd_version.h2
-rw-r--r--include/commands/cmd_wallops.h2
-rw-r--r--include/commands/cmd_who.h2
-rw-r--r--include/commands/cmd_whois.h2
-rw-r--r--include/commands/cmd_whowas.h2
-rw-r--r--include/commands/cmd_zline.h2
-rw-r--r--include/ctables.h4
-rw-r--r--include/inspircd.h4
-rw-r--r--include/mode.h2
-rw-r--r--include/modules.h4
-rw-r--r--src/command_parse.cpp96
-rw-r--r--src/commands/cmd_admin.cpp2
-rw-r--r--src/commands/cmd_away.cpp7
-rw-r--r--src/commands/cmd_clearcache.cpp2
-rw-r--r--src/commands/cmd_commands.cpp2
-rw-r--r--src/commands/cmd_connect.cpp2
-rw-r--r--src/commands/cmd_die.cpp4
-rw-r--r--src/commands/cmd_eline.cpp8
-rw-r--r--src/commands/cmd_gline.cpp10
-rw-r--r--src/commands/cmd_info.cpp2
-rw-r--r--src/commands/cmd_invite.cpp16
-rw-r--r--src/commands/cmd_ison.cpp6
-rw-r--r--src/commands/cmd_join.cpp18
-rw-r--r--src/commands/cmd_kick.cpp12
-rw-r--r--src/commands/cmd_kill.cpp20
-rw-r--r--src/commands/cmd_kline.cpp10
-rw-r--r--src/commands/cmd_links.cpp2
-rw-r--r--src/commands/cmd_list.cpp18
-rw-r--r--src/commands/cmd_loadmodule.cpp10
-rw-r--r--src/commands/cmd_lusers.cpp2
-rw-r--r--src/commands/cmd_map.cpp2
-rw-r--r--src/commands/cmd_mode.cpp4
-rw-r--r--src/commands/cmd_modules.cpp2
-rw-r--r--src/commands/cmd_motd.cpp2
-rw-r--r--src/commands/cmd_names.cpp8
-rw-r--r--src/commands/cmd_nick.cpp34
-rw-r--r--src/commands/cmd_notice.cpp23
-rw-r--r--src/commands/cmd_oper.cpp16
-rw-r--r--src/commands/cmd_part.cpp10
-rw-r--r--src/commands/cmd_pass.cpp8
-rw-r--r--src/commands/cmd_ping.cpp4
-rw-r--r--src/commands/cmd_pong.cpp2
-rw-r--r--src/commands/cmd_privmsg.cpp31
-rw-r--r--src/commands/cmd_qline.cpp22
-rw-r--r--src/commands/cmd_quit.cpp6
-rw-r--r--src/commands/cmd_rehash.cpp11
-rw-r--r--src/commands/cmd_reloadmodule.cpp16
-rw-r--r--src/commands/cmd_restart.cpp4
-rw-r--r--src/commands/cmd_rules.cpp2
-rw-r--r--src/commands/cmd_server.cpp2
-rw-r--r--src/commands/cmd_squit.cpp2
-rw-r--r--src/commands/cmd_stats.cpp4
-rw-r--r--src/commands/cmd_time.cpp2
-rw-r--r--src/commands/cmd_topic.cpp16
-rw-r--r--src/commands/cmd_trace.cpp2
-rw-r--r--src/commands/cmd_unloadmodule.cpp10
-rw-r--r--src/commands/cmd_user.cpp8
-rw-r--r--src/commands/cmd_userhost.cpp4
-rw-r--r--src/commands/cmd_version.cpp2
-rw-r--r--src/commands/cmd_wallops.cpp2
-rw-r--r--src/commands/cmd_who.cpp19
-rw-r--r--src/commands/cmd_whois.cpp16
-rw-r--r--src/commands/cmd_whowas.cpp22
-rw-r--r--src/commands/cmd_zline.cpp12
-rw-r--r--src/mode.cpp32
-rw-r--r--src/modes/cmode_b.cpp6
-rw-r--r--src/modes/cmode_h.cpp6
-rw-r--r--src/modes/cmode_k.cpp6
-rw-r--r--src/modes/cmode_o.cpp6
-rw-r--r--src/modes/cmode_v.cpp6
-rw-r--r--src/modes/umode_n.cpp6
-rw-r--r--src/modules.cpp12
-rw-r--r--src/users.cpp15
121 files changed, 395 insertions, 413 deletions
diff --git a/include/command_parse.h b/include/command_parse.h
index 858c1c8e6..a8a14497e 100644
--- a/include/command_parse.h
+++ b/include/command_parse.h
@@ -39,7 +39,7 @@ class CoreExport CommandParser : public classbase
* @param parameters The input string
* @return The number of parameters parsed into command_p
*/
- int ProcessParameters(char **command_p,char *parameters);
+ int ProcessParameters(std::vector<std::string>& command_p, char* parameters);
/** Process a command from a user.
* @param user The user to parse the command for
@@ -84,7 +84,7 @@ class CoreExport CommandParser : public classbase
* @return True if the command was reloaded, false if it could not be found
* or another error occured
*/
- bool ReloadCommand(const char* cmd, User* user);
+ bool ReloadCommand(std::string cmd, User* user);
/** Default constructor.
* @param Instance The creator of this class
@@ -102,7 +102,7 @@ class CoreExport CommandParser : public classbase
* command simply did not exist at all or the wrong number of parameters were given, or the user
* was not privilaged enough to execute the command.
*/
- CmdResult CallHandler(const std::string &commandname,const char* const* parameters, int pcnt, User *user);
+ CmdResult CallHandler(const std::string &commandname, const std::vector<std::string>& parameters, User *user);
/** Get the handler function for a command.
* @param commandname The command required. Always use uppercase for this parameter.
@@ -118,7 +118,7 @@ class CoreExport CommandParser : public classbase
* equal to or greater than the minimum number of parameters to the given command, then this
* function will return true, otherwise it will return false.
*/
- bool IsValidCommand(const std::string &commandname, int pcnt, User * user);
+ bool IsValidCommand(const std::string &commandname, unsigned int pcnt, User * user);
/** LoopCall is used to call a command classes handler repeatedly based on the contents of a comma seperated list.
* There are two overriden versions of this method, one of which takes two potential lists and the other takes one.
@@ -141,7 +141,7 @@ class CoreExport CommandParser : public classbase
* @return This function will return 1 when there are no more parameters to process. When this occurs, its
* caller should return without doing anything, otherwise it should continue into its main section of code.
*/
- int LoopCall(User* user, Command* CommandObj, const char* const* parameters, int pcnt, unsigned int splithere, unsigned int extra);
+ int LoopCall(User* user, Command* CommandObj, const std::vector<std::string>& parameters, unsigned int splithere, unsigned int extra);
/** LoopCall is used to call a command classes handler repeatedly based on the contents of a comma seperated list.
* There are two overriden versions of this method, one of which takes two potential lists and the other takes one.
@@ -164,7 +164,7 @@ class CoreExport CommandParser : public classbase
* @return This function will return 1 when there are no more parameters to process. When this occurs, its
* caller should return without doing anything, otherwise it should continue into its main section of code.
*/
- int LoopCall(User* user, Command* CommandObj, const char* const* parameters, int pcnt, unsigned int splithere);
+ int LoopCall(User* user, Command* CommandObj, const std::vector<std::string>& parameters, unsigned int splithere);
/** Take a raw input buffer from a recvq, and process it on behalf of a user.
* @param buffer The buffer line to process
@@ -219,7 +219,7 @@ class cmd_reload : public Command
cmd_reload (InspIRCd* Instance) : Command(Instance,"RELOAD","o",1) { syntax = "<core-command>"; }
/** Handle RELOAD
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
/** A lookup table of values for multiplier characters used by
diff --git a/include/commands/cmd_admin.h b/include/commands/cmd_admin.h
index f8181971b..a21a8b5dd 100644
--- a/include/commands/cmd_admin.h
+++ b/include/commands/cmd_admin.h
@@ -34,7 +34,7 @@ class CommandAdmin : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_away.h b/include/commands/cmd_away.h
index 48bc35f6f..a1405dc09 100644
--- a/include/commands/cmd_away.h
+++ b/include/commands/cmd_away.h
@@ -36,7 +36,7 @@ class CommandAway : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_clearcache.h b/include/commands/cmd_clearcache.h
index c2edc4a08..248c2cdbe 100644
--- a/include/commands/cmd_clearcache.h
+++ b/include/commands/cmd_clearcache.h
@@ -35,7 +35,7 @@ class CommandClearcache : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_commands.h b/include/commands/cmd_commands.h
index fbb0be259..a29f255cb 100644
--- a/include/commands/cmd_commands.h
+++ b/include/commands/cmd_commands.h
@@ -36,7 +36,7 @@ class CommandCommands : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_connect.h b/include/commands/cmd_connect.h
index 85a78adb7..7d869b8c6 100644
--- a/include/commands/cmd_connect.h
+++ b/include/commands/cmd_connect.h
@@ -36,7 +36,7 @@ class CommandConnect : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_die.h b/include/commands/cmd_die.h
index 7b805ee6e..eb726591a 100644
--- a/include/commands/cmd_die.h
+++ b/include/commands/cmd_die.h
@@ -36,7 +36,7 @@ class CommandDie : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_eline.h b/include/commands/cmd_eline.h
index 0849dcf82..2d5a2130c 100644
--- a/include/commands/cmd_eline.h
+++ b/include/commands/cmd_eline.h
@@ -36,7 +36,7 @@ class CommandEline : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_gline.h b/include/commands/cmd_gline.h
index 509f94de9..7db1f18a5 100644
--- a/include/commands/cmd_gline.h
+++ b/include/commands/cmd_gline.h
@@ -36,7 +36,7 @@ class CommandGline : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_info.h b/include/commands/cmd_info.h
index 692a1938e..28466862f 100644
--- a/include/commands/cmd_info.h
+++ b/include/commands/cmd_info.h
@@ -36,7 +36,7 @@ class CommandInfo : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_invite.h b/include/commands/cmd_invite.h
index 2df7a8a80..594cf2702 100644
--- a/include/commands/cmd_invite.h
+++ b/include/commands/cmd_invite.h
@@ -36,7 +36,7 @@ class CommandInvite : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_ison.h b/include/commands/cmd_ison.h
index 31bd9b659..8bfbd2bee 100644
--- a/include/commands/cmd_ison.h
+++ b/include/commands/cmd_ison.h
@@ -36,7 +36,7 @@ class CommandIson : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_join.h b/include/commands/cmd_join.h
index 9f095c73c..7b5fc76b9 100644
--- a/include/commands/cmd_join.h
+++ b/include/commands/cmd_join.h
@@ -36,7 +36,7 @@ class CommandJoin : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_kick.h b/include/commands/cmd_kick.h
index b29afd899..35de5e52b 100644
--- a/include/commands/cmd_kick.h
+++ b/include/commands/cmd_kick.h
@@ -36,7 +36,7 @@ class CommandKick : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_kill.h b/include/commands/cmd_kill.h
index 7d5b24fb0..c9176a933 100644
--- a/include/commands/cmd_kill.h
+++ b/include/commands/cmd_kill.h
@@ -36,7 +36,7 @@ class CommandKill : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_kline.h b/include/commands/cmd_kline.h
index c0601fe6f..98ac098de 100644
--- a/include/commands/cmd_kline.h
+++ b/include/commands/cmd_kline.h
@@ -36,7 +36,7 @@ class CommandKline : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_links.h b/include/commands/cmd_links.h
index 122de3782..3a4d284c9 100644
--- a/include/commands/cmd_links.h
+++ b/include/commands/cmd_links.h
@@ -36,7 +36,7 @@ class CommandLinks : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_list.h b/include/commands/cmd_list.h
index a84a9c9c6..e3294349c 100644
--- a/include/commands/cmd_list.h
+++ b/include/commands/cmd_list.h
@@ -36,7 +36,7 @@ class CommandList : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_loadmodule.h b/include/commands/cmd_loadmodule.h
index 7255e3de7..3f1d23092 100644
--- a/include/commands/cmd_loadmodule.h
+++ b/include/commands/cmd_loadmodule.h
@@ -36,7 +36,7 @@ class CommandLoadmodule : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_lusers.h b/include/commands/cmd_lusers.h
index 9242d4e8b..4f473076e 100644
--- a/include/commands/cmd_lusers.h
+++ b/include/commands/cmd_lusers.h
@@ -36,7 +36,7 @@ class CommandLusers : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_map.h b/include/commands/cmd_map.h
index 77e77c901..979b8bcd6 100644
--- a/include/commands/cmd_map.h
+++ b/include/commands/cmd_map.h
@@ -36,7 +36,7 @@ class CommandMap : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_mode.h b/include/commands/cmd_mode.h
index f573f7d1a..0025356fb 100644
--- a/include/commands/cmd_mode.h
+++ b/include/commands/cmd_mode.h
@@ -35,7 +35,7 @@ class CommandMode : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_modules.h b/include/commands/cmd_modules.h
index 11e9b106c..50428b73c 100644
--- a/include/commands/cmd_modules.h
+++ b/include/commands/cmd_modules.h
@@ -36,7 +36,7 @@ class CommandModules : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_motd.h b/include/commands/cmd_motd.h
index 42e334398..1aac64824 100644
--- a/include/commands/cmd_motd.h
+++ b/include/commands/cmd_motd.h
@@ -39,7 +39,7 @@ class CommandMotd : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_names.h b/include/commands/cmd_names.h
index 477f86afc..b9fd05ca6 100644
--- a/include/commands/cmd_names.h
+++ b/include/commands/cmd_names.h
@@ -36,7 +36,7 @@ class CommandNames : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_nick.h b/include/commands/cmd_nick.h
index 7cab63c09..18c65b587 100644
--- a/include/commands/cmd_nick.h
+++ b/include/commands/cmd_nick.h
@@ -37,7 +37,7 @@ class CommandNick : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
/** Handle internal command
* @param id Used to indicate if invalid nick changes are allowed.
diff --git a/include/commands/cmd_notice.h b/include/commands/cmd_notice.h
index e565bab0b..583edde51 100644
--- a/include/commands/cmd_notice.h
+++ b/include/commands/cmd_notice.h
@@ -36,7 +36,7 @@ class CommandNotice : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_oper.h b/include/commands/cmd_oper.h
index 80d7c8b37..3ec8cbca7 100644
--- a/include/commands/cmd_oper.h
+++ b/include/commands/cmd_oper.h
@@ -38,7 +38,7 @@ class CommandOper : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_part.h b/include/commands/cmd_part.h
index cf6899163..82bd73621 100644
--- a/include/commands/cmd_part.h
+++ b/include/commands/cmd_part.h
@@ -36,7 +36,7 @@ class CommandPart : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_pass.h b/include/commands/cmd_pass.h
index 85279090c..aa0a35a4e 100644
--- a/include/commands/cmd_pass.h
+++ b/include/commands/cmd_pass.h
@@ -39,7 +39,7 @@ class CommandPass : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_ping.h b/include/commands/cmd_ping.h
index 6db0346b0..b7acb0213 100644
--- a/include/commands/cmd_ping.h
+++ b/include/commands/cmd_ping.h
@@ -36,7 +36,7 @@ class CommandPing : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_pong.h b/include/commands/cmd_pong.h
index 6b065fb21..2c96d5418 100644
--- a/include/commands/cmd_pong.h
+++ b/include/commands/cmd_pong.h
@@ -37,7 +37,7 @@ class CommandPong : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_privmsg.h b/include/commands/cmd_privmsg.h
index eb8e43729..cb39ed99b 100644
--- a/include/commands/cmd_privmsg.h
+++ b/include/commands/cmd_privmsg.h
@@ -36,7 +36,7 @@ class CommandPrivmsg : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_qline.h b/include/commands/cmd_qline.h
index b6e58a4a8..de70bb78b 100644
--- a/include/commands/cmd_qline.h
+++ b/include/commands/cmd_qline.h
@@ -36,7 +36,7 @@ class CommandQline : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_quit.h b/include/commands/cmd_quit.h
index b6ea0e9b0..b26cfa9a7 100644
--- a/include/commands/cmd_quit.h
+++ b/include/commands/cmd_quit.h
@@ -36,7 +36,7 @@ class CommandQuit : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_rehash.h b/include/commands/cmd_rehash.h
index 92282fe8a..23dec0462 100644
--- a/include/commands/cmd_rehash.h
+++ b/include/commands/cmd_rehash.h
@@ -36,7 +36,7 @@ class CommandRehash : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_reloadmodule.h b/include/commands/cmd_reloadmodule.h
index 16976351e..df221952e 100644
--- a/include/commands/cmd_reloadmodule.h
+++ b/include/commands/cmd_reloadmodule.h
@@ -36,7 +36,7 @@ class CommandReloadmodule : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_restart.h b/include/commands/cmd_restart.h
index 5c3c5d733..6ad33655a 100644
--- a/include/commands/cmd_restart.h
+++ b/include/commands/cmd_restart.h
@@ -39,7 +39,7 @@ class CommandRestart : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_rules.h b/include/commands/cmd_rules.h
index 369c39800..c47a7839c 100644
--- a/include/commands/cmd_rules.h
+++ b/include/commands/cmd_rules.h
@@ -39,7 +39,7 @@ class CommandRules : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_server.h b/include/commands/cmd_server.h
index 6853de674..9de4b8381 100644
--- a/include/commands/cmd_server.h
+++ b/include/commands/cmd_server.h
@@ -36,7 +36,7 @@ class CommandServer : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_squit.h b/include/commands/cmd_squit.h
index 0201ab59c..3d950c5f5 100644
--- a/include/commands/cmd_squit.h
+++ b/include/commands/cmd_squit.h
@@ -39,7 +39,7 @@ class CommandSquit : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_stats.h b/include/commands/cmd_stats.h
index b7d02f3a3..25037b6b0 100644
--- a/include/commands/cmd_stats.h
+++ b/include/commands/cmd_stats.h
@@ -39,7 +39,7 @@ class CommandStats : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_time.h b/include/commands/cmd_time.h
index dd86e7890..d45c23ba3 100644
--- a/include/commands/cmd_time.h
+++ b/include/commands/cmd_time.h
@@ -36,7 +36,7 @@ class CommandTime : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_topic.h b/include/commands/cmd_topic.h
index 444e61cfc..27cc2073d 100644
--- a/include/commands/cmd_topic.h
+++ b/include/commands/cmd_topic.h
@@ -36,7 +36,7 @@ class CommandTopic : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_trace.h b/include/commands/cmd_trace.h
index ad91f7a37..29e2af769 100644
--- a/include/commands/cmd_trace.h
+++ b/include/commands/cmd_trace.h
@@ -36,7 +36,7 @@ class CommandTrace : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_unloadmodule.h b/include/commands/cmd_unloadmodule.h
index 3fdc70bfd..63b11f95d 100644
--- a/include/commands/cmd_unloadmodule.h
+++ b/include/commands/cmd_unloadmodule.h
@@ -36,7 +36,7 @@ class CommandUnloadmodule : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_user.h b/include/commands/cmd_user.h
index f0eec34cb..55a5ba115 100644
--- a/include/commands/cmd_user.h
+++ b/include/commands/cmd_user.h
@@ -36,7 +36,7 @@ class CommandUser : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_userhost.h b/include/commands/cmd_userhost.h
index fa26ae1ed..b72315448 100644
--- a/include/commands/cmd_userhost.h
+++ b/include/commands/cmd_userhost.h
@@ -36,7 +36,7 @@ class CommandUserhost : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_version.h b/include/commands/cmd_version.h
index 01e475dfc..3b85fb408 100644
--- a/include/commands/cmd_version.h
+++ b/include/commands/cmd_version.h
@@ -36,7 +36,7 @@ class CommandVersion : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_wallops.h b/include/commands/cmd_wallops.h
index 3a87ce608..fdc522fc6 100644
--- a/include/commands/cmd_wallops.h
+++ b/include/commands/cmd_wallops.h
@@ -36,7 +36,7 @@ class CommandWallops : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_who.h b/include/commands/cmd_who.h
index 87ea44449..bdcf00c0b 100644
--- a/include/commands/cmd_who.h
+++ b/include/commands/cmd_who.h
@@ -49,7 +49,7 @@ class CommandWho : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
bool whomatch(User* user, const char* matchtext);
};
diff --git a/include/commands/cmd_whois.h b/include/commands/cmd_whois.h
index bee2f760f..64e2a94cf 100644
--- a/include/commands/cmd_whois.h
+++ b/include/commands/cmd_whois.h
@@ -39,7 +39,7 @@ class CommandWhois : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/commands/cmd_whowas.h b/include/commands/cmd_whowas.h
index 1b75987df..7ebdef9a0 100644
--- a/include/commands/cmd_whowas.h
+++ b/include/commands/cmd_whowas.h
@@ -79,7 +79,7 @@ class CommandWhowas : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
/** Handle an internal request from another command, the core, or a module
* @param Command ID
* @param Zero or more parameters, whos form is specified by the command ID.
diff --git a/include/commands/cmd_zline.h b/include/commands/cmd_zline.h
index 6b1ca9e0a..ddf4b956e 100644
--- a/include/commands/cmd_zline.h
+++ b/include/commands/cmd_zline.h
@@ -36,7 +36,7 @@ class CommandZline : public Command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const char* const* parameters, int pcnt, User *user);
+ CmdResult Handle(const std::vector<std::string>& parameters, User *user);
};
#endif
diff --git a/include/ctables.h b/include/ctables.h
index ba6773a4c..8ca08d9e4 100644
--- a/include/ctables.h
+++ b/include/ctables.h
@@ -59,7 +59,7 @@ class CoreExport Command : public Extensible
char flags_needed;
/** Minimum number of parameters command takes
*/
- int min_params;
+ unsigned int min_params;
/** used by /stats m
*/
long double use_count;
@@ -113,7 +113,7 @@ class CoreExport Command : public Extensible
* If the command succeeds but should remain local to this server,
* return CMD_LOCALONLY.
*/
- virtual CmdResult Handle(const char* const* parameters, int pcnt, User* user) = 0;
+ virtual CmdResult Handle(const std::vector<std::string>& parameters, User* user) = 0;
/** Handle an internal request from another command, the core, or a module
* @param Command ID
diff --git a/include/inspircd.h b/include/inspircd.h
index 1b88ca0b7..dba38d272 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -679,7 +679,7 @@ class CoreExport InspIRCd : public classbase
* @param pcnt The number of items you have given in the first parameter
* @param user The user to send error messages to
*/
- void SendMode(const char* const* parameters, int pcnt, User *user);
+ void SendMode(const std::vector<std::string>& parameters, User *user);
/** Match two strings using pattern matching.
* This operates identically to the global function match(),
@@ -697,7 +697,7 @@ class CoreExport InspIRCd : public classbase
* @param user The user to execute the command as
* @return True if the command handler was called successfully
*/
- CmdResult CallCommandHandler(const std::string &commandname, const char* const* parameters, int pcnt, User* user);
+ CmdResult CallCommandHandler(const std::string &commandname, const std::vector<std::string>& parameters, User* user);
/** Return true if the command is a module-implemented command and the given parameters are valid for it
* @param parameters The mode parameters
diff --git a/include/mode.h b/include/mode.h
index 5d4ce0c8c..ac0c3135a 100644
--- a/include/mode.h
+++ b/include/mode.h
@@ -502,7 +502,7 @@ class CoreExport ModeParser : public classbase
* and *user->server == NULL.
* @param servermode True if a server is setting the mode.
*/
- void Process(const char* const* parameters, int pcnt, User *user, bool servermode);
+ void Process(const std::vector<std::string>& parameters, User *user, bool servermode);
/** Find the mode handler for a given mode and type.
* @param modeletter mode letter to search for
diff --git a/include/modules.h b/include/modules.h
index ef2e4b0e4..722bf4e3c 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -1037,7 +1037,7 @@ class CoreExport Module : public Extensible
* @param original_line The entire original line as passed to the parser from the user
* @return 1 to block the command, 0 to allow
*/
- virtual int OnPreCommand(const std::string &command, const char* const* parameters, int pcnt, User *user, bool validated, const std::string &original_line);
+ virtual int OnPreCommand(const std::string &command, const std::vector<std::string>& parameters, User *user, bool validated, const std::string &original_line);
/** Called after any command has been executed.
* This event occurs for all registered commands, wether they are registered in the core,
@@ -1051,7 +1051,7 @@ class CoreExport Module : public Extensible
* @param result The return code given by the command handler, one of CMD_SUCCESS or CMD_FAILURE
* @param original_line The entire original line as passed to the parser from the user
*/
- virtual void OnPostCommand(const std::string &command, const char* const* parameters, int pcnt, User *user, CmdResult result, const std::string &original_line);
+ virtual void OnPostCommand(const std::string &command, const std::vector<std::string>& parameters, User *user, CmdResult result, const std::string &original_line);
/** Called to check if a user who is connecting can now be allowed to register
* If any modules return false for this function, the user is held in the waiting
diff --git a/src/command_parse.cpp b/src/command_parse.cpp
index 9e54a63d9..173348338 100644
--- a/src/command_parse.cpp
+++ b/src/command_parse.cpp
@@ -48,12 +48,12 @@ int InspIRCd::PassCompare(Extensible* ex, const char* data,const char* input, co
* The second version is much simpler and just has the one stream to read, and is used in NAMES, WHOIS, PRIVMSG etc.
* Both will only parse until they reach ServerInstance->Config->MaxTargets number of targets, to stop abuse via spam.
*/
-int CommandParser::LoopCall(User* user, Command* CommandObj, const char* const* parameters, int pcnt, unsigned int splithere, unsigned int extra)
+int CommandParser::LoopCall(User* user, Command* CommandObj, const std::vector<std::string>& parameters, unsigned int splithere, unsigned int extra)
{
/* First check if we have more than one item in the list, if we don't we return zero here and the handler
* which called us just carries on as it was.
*/
- if (!strchr(parameters[splithere],','))
+ if (parameters[splithere].find(',') == std::string::npos)
return 0;
/** Some lame ircds will weed out dupes using some shitty O(n^2) algorithm.
@@ -78,10 +78,10 @@ int CommandParser::LoopCall(User* user, Command* CommandObj, const char* const*
{
if (dupes.find(item.c_str()) == dupes.end())
{
- const char* new_parameters[MAXPARAMETERS];
+ std::vector<std::string> new_parameters;
- for (int t = 0; (t < pcnt) && (t < MAXPARAMETERS); t++)
- new_parameters[t] = parameters[t];
+ for (unsigned int t = 0; (t < parameters.size()) && (t < MAXPARAMETERS); t++)
+ new_parameters.push_back(parameters[t]);
if (!items2.GetToken(extrastuff))
extrastuff = "";
@@ -89,7 +89,7 @@ int CommandParser::LoopCall(User* user, Command* CommandObj, const char* const*
new_parameters[splithere] = item.c_str();
new_parameters[extra] = extrastuff.c_str();
- CommandObj->Handle(new_parameters,pcnt,user);
+ CommandObj->Handle(new_parameters, user);
dupes[item.c_str()] = true;
}
@@ -97,12 +97,12 @@ int CommandParser::LoopCall(User* user, Command* CommandObj, const char* const*
return 1;
}
-int CommandParser::LoopCall(User* user, Command* CommandObj, const char* const* parameters, int pcnt, unsigned int splithere)
+int CommandParser::LoopCall(User* user, Command* CommandObj, const std::vector<std::string>& parameters, unsigned int splithere)
{
/* First check if we have more than one item in the list, if we don't we return zero here and the handler
* which called us just carries on as it was.
*/
- if (!strchr(parameters[splithere],','))
+ if (parameters[splithere].find(',') == std::string::npos)
return 0;
std::map<irc::string, bool> dupes;
@@ -120,10 +120,10 @@ int CommandParser::LoopCall(User* user, Command* CommandObj, const char* const*
{
if (dupes.find(item.c_str()) == dupes.end())
{
- const char* new_parameters[MAXPARAMETERS];
+ std::vector<std::string> new_parameters;
- for (int t = 0; (t < pcnt) && (t < MAXPARAMETERS); t++)
- new_parameters[t] = parameters[t];
+ for (unsigned int t = 0; (t < parameters.size()) && (t < MAXPARAMETERS); t++)
+ new_parameters.push_back(parameters[t]);
new_parameters[splithere] = item.c_str();
@@ -131,7 +131,7 @@ int CommandParser::LoopCall(User* user, Command* CommandObj, const char* const*
* record out from under us (e.g. if we /kill a comma sep list, and we're
* in that list ourselves) abort if we're gone.
*/
- CommandObj->Handle(new_parameters,pcnt,user);
+ CommandObj->Handle(new_parameters, user);
dupes[item.c_str()] = true;
}
@@ -143,13 +143,13 @@ int CommandParser::LoopCall(User* user, Command* CommandObj, const char* const*
return 1;
}
-bool CommandParser::IsValidCommand(const std::string &commandname, int pcnt, User * user)
+bool CommandParser::IsValidCommand(const std::string &commandname, unsigned int pcnt, User * user)
{
Commandable::iterator n = cmdlist.find(commandname);
if (n != cmdlist.end())
{
- if ((pcnt>=n->second->min_params) && (n->second->source != "<core>"))
+ if ((pcnt >= n->second->min_params) && (n->second->source != "<core>"))
{
if (IS_LOCAL(user) && n->second->flags_needed)
{
@@ -178,13 +178,13 @@ Command* CommandParser::GetHandler(const std::string &commandname)
// calls a handler function for a command
-CmdResult CommandParser::CallHandler(const std::string &commandname,const char* const* parameters, int pcnt, User *user)
+CmdResult CommandParser::CallHandler(const std::string &commandname, const std::vector<std::string>& parameters, User *user)
{
Commandable::iterator n = cmdlist.find(commandname);
if (n != cmdlist.end())
{
- if (pcnt >= n->second->min_params)
+ if (parameters.size() >= n->second->min_params)
{
bool bOkay = false;
@@ -207,7 +207,7 @@ CmdResult CommandParser::CallHandler(const std::string &commandname,const char*
if (bOkay)
{
- return n->second->Handle(parameters,pcnt,user);
+ return n->second->Handle(parameters,user);
}
}
}
@@ -257,10 +257,9 @@ void CommandParser::DoLines(User* current, bool one_only)
bool CommandParser::ProcessCommand(User *user, std::string &cmd)
{
- const char *command_p[MAXPARAMETERS];
- int items = 0;
+ std::vector<std::string> command_p;
irc::tokenstream tokens(cmd);
- std::string command;
+ std::string command, token;
tokens.GetToken(command);
/* A client sent a nick prefix on their command (ick)
@@ -271,16 +270,13 @@ bool CommandParser::ProcessCommand(User *user, std::string &cmd)
if (*command.c_str() == ':')
tokens.GetToken(command);
- while (tokens.GetToken(para[items]) && (items < MAXPARAMETERS))
- {
- command_p[items] = para[items].c_str();
- items++;
- }
+ while (tokens.GetToken(token) && (command_p.size() < MAXPARAMETERS))
+ command_p.push_back(token);
std::transform(command.begin(), command.end(), command.begin(), ::toupper);
int MOD_RESULT = 0;
- FOREACH_RESULT(I_OnPreCommand,OnPreCommand(command,command_p,items,user,false,cmd));
+ FOREACH_RESULT(I_OnPreCommand,OnPreCommand(command, command_p, user, false, cmd));
if (MOD_RESULT == 1) {
return true;
}
@@ -333,7 +329,7 @@ bool CommandParser::ProcessCommand(User *user, std::string &cmd)
command.c_str(), user->nick, user->ident, user->host);
return do_more;
}
- if (items < cm->second->min_params)
+ if (command_p.size() < cm->second->min_params)
{
user->WriteNumeric(461, "%s %s :Not enough parameters.", user->nick, command.c_str());
if ((ServerInstance->Config->SyntaxHints) && (user->registered == REG_ALL) && (cm->second->syntax.length()))
@@ -353,16 +349,16 @@ bool CommandParser::ProcessCommand(User *user, std::string &cmd)
/* module calls too */
MOD_RESULT = 0;
- FOREACH_RESULT(I_OnPreCommand,OnPreCommand(command,command_p,items,user,true,cmd));
+ FOREACH_RESULT(I_OnPreCommand,OnPreCommand(command, command_p, user, true, cmd));
if (MOD_RESULT == 1)
return do_more;
/*
* WARNING: be careful, the user may be deleted soon
*/
- CmdResult result = cm->second->Handle(command_p,items,user);
+ CmdResult result = cm->second->Handle(command_p, user);
- FOREACH_MOD(I_OnPostCommand,OnPostCommand(command, command_p, items, user, result,cmd));
+ FOREACH_MOD(I_OnPostCommand,OnPostCommand(command, command_p, user, result,cmd));
return do_more;
}
}
@@ -448,38 +444,29 @@ bool CommandParser::FindSym(void** v, void* h, const std::string &name)
return true;
}
-bool CommandParser::ReloadCommand(const char* cmd, User* user)
+bool CommandParser::ReloadCommand(std::string cmd, User* user)
{
char filename[MAXBUF];
- char commandname[MAXBUF];
- int y = 0;
-
- for (const char* x = cmd; *x; x++, y++)
- commandname[y] = toupper(*x);
-
- commandname[y] = 0;
+ std::transform(cmd.begin(), cmd.end(), cmd.begin(), ::toupper);
- SharedObjectList::iterator command = RFCCommands.find(commandname);
+ SharedObjectList::iterator command = RFCCommands.find(cmd);
if (command != RFCCommands.end())
{
- Command* cmdptr = cmdlist.find(commandname)->second;
- cmdlist.erase(cmdlist.find(commandname));
-
- for (char* x = commandname; *x; x++)
- *x = tolower(*x);
-
+ Command* cmdptr = cmdlist.find(cmd)->second;
+ cmdlist.erase(cmdlist.find(cmd));
+ RFCCommands.erase(cmd);
+ std::transform(cmd.begin(), cmd.end(), cmd.begin(), ::tolower);
delete cmdptr;
dlclose(command->second);
- RFCCommands.erase(command);
- snprintf(filename, MAXBUF, "cmd_%s.so", commandname);
+ snprintf(filename, MAXBUF, "cmd_%s.so", cmd.c_str());
const char* err = this->LoadCommand(filename);
if (err)
{
if (user)
- user->WriteServ("NOTICE %s :*** Error loading 'cmd_%s.so': %s", user->nick, cmd, err);
+ user->WriteServ("NOTICE %s :*** Error loading 'cmd_%s.so': %s", user->nick, cmd.c_str(), err);
return false;
}
@@ -489,18 +476,21 @@ bool CommandParser::ReloadCommand(const char* cmd, User* user)
return false;
}
-CmdResult cmd_reload::Handle(const char* const* parameters, int /* pcnt */, User *user)
+CmdResult cmd_reload::Handle(const std::vector<std::string>& parameters, User *user)
{
- user->WriteServ("NOTICE %s :*** Reloading command '%s'",user->nick, parameters[0]);
+ if (parameters.size() < 1)
+ return CMD_FAILURE;
+
+ user->WriteServ("NOTICE %s :*** Reloading command '%s'",user->nick, parameters[0].c_str());
if (ServerInstance->Parser->ReloadCommand(parameters[0], user))
{
- user->WriteServ("NOTICE %s :*** Successfully reloaded command '%s'", user->nick, parameters[0]);
- ServerInstance->SNO->WriteToSnoMask('A', "RELOAD: %s reloaded the '%s' command.", user->nick, parameters[0]);
+ user->WriteServ("NOTICE %s :*** Successfully reloaded command '%s'", user->nick, parameters[0].c_str());
+ ServerInstance->SNO->WriteToSnoMask('A', "RELOAD: %s reloaded the '%s' command.", user->nick, parameters[0].c_str());
return CMD_SUCCESS;
}
else
{
- user->WriteServ("NOTICE %s :*** Could not reload command '%s' -- fix this problem, then /REHASH as soon as possible!", user->nick, parameters[0]);
+ user->WriteServ("NOTICE %s :*** Could not reload command '%s' -- fix this problem, then /REHASH as soon as possible!", user->nick, parameters[0].c_str());
return CMD_FAILURE;
}
}
diff --git a/src/commands/cmd_admin.cpp b/src/commands/cmd_admin.cpp
index bc443fc32..5e9b4b4c7 100644
--- a/src/commands/cmd_admin.cpp
+++ b/src/commands/cmd_admin.cpp
@@ -22,7 +22,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
/** Handle /ADMIN
*/
-CmdResult CommandAdmin::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandAdmin::Handle (const std::vector<std::string>& parameters, User *user)
{
user->WriteNumeric(256, "%s :Administrative info for %s",user->nick,ServerInstance->Config->ServerName);
if (*ServerInstance->Config->AdminName)
diff --git a/src/commands/cmd_away.cpp b/src/commands/cmd_away.cpp
index 33e140beb..7d2522304 100644
--- a/src/commands/cmd_away.cpp
+++ b/src/commands/cmd_away.cpp
@@ -21,11 +21,11 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
/** Handle /AWAY
*/
-CmdResult CommandAway::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandAway::Handle (const std::vector<std::string>& parameters, User *user)
{
int MOD_RESULT = 0;
- if ((pcnt) && (*parameters[0]))
+ if ((parameters.size()) && (!parameters[0].empty()))
{
FOREACH_RESULT(I_OnSetAway, OnSetAway(user, parameters[0]));
@@ -33,7 +33,8 @@ CmdResult CommandAway::Handle (const char* const* parameters, int pcnt, User *us
return CMD_FAILURE;
user->awaytime = ServerInstance->Time();
- strlcpy(user->awaymsg,parameters[0],MAXAWAY);
+ strlcpy(user->awaymsg, parameters[0].c_str(), MAXAWAY);
+
user->WriteNumeric(306, "%s :You have been marked as being away",user->nick);
}
else
diff --git a/src/commands/cmd_clearcache.cpp b/src/commands/cmd_clearcache.cpp
index c7354df07..5f1792928 100644
--- a/src/commands/cmd_clearcache.cpp
+++ b/src/commands/cmd_clearcache.cpp
@@ -21,7 +21,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
/** Handle /CLEARCACHE
*/
-CmdResult CommandClearcache::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandClearcache::Handle (const std::vector<std::string>& parameters, User *user)
{
int n = ServerInstance->Res->ClearCache();
user->WriteServ("NOTICE %s :*** Cleared DNS cache of %d items.", user->nick, n);
diff --git a/src/commands/cmd_commands.cpp b/src/commands/cmd_commands.cpp
index 2b2e7ffa0..eddcb6bd8 100644
--- a/src/commands/cmd_commands.cpp
+++ b/src/commands/cmd_commands.cpp
@@ -21,7 +21,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandCommands(Instance);
}
-CmdResult CommandCommands::Handle (const char* const*, int, User *user)
+CmdResult CommandCommands::Handle (const std::vector<std::string>&, User *user)
{
for (Commandable::iterator i = ServerInstance->Parser->cmdlist.begin(); i != ServerInstance->Parser->cmdlist.end(); i++)
{
diff --git a/src/commands/cmd_connect.cpp b/src/commands/cmd_connect.cpp
index 04aada207..81340c37a 100644
--- a/src/commands/cmd_connect.cpp
+++ b/src/commands/cmd_connect.cpp
@@ -25,7 +25,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
/** Handle /CONNECT
*/
-CmdResult CommandConnect::Handle (const char* const*, int, User *user)
+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);
return CMD_SUCCESS;
diff --git a/src/commands/cmd_die.cpp b/src/commands/cmd_die.cpp
index 2723ecca3..4278a3a90 100644
--- a/src/commands/cmd_die.cpp
+++ b/src/commands/cmd_die.cpp
@@ -22,9 +22,9 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
/** Handle /DIE
*/
-CmdResult CommandDie::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandDie::Handle (const std::vector<std::string>& parameters, User *user)
{
- if (!ServerInstance->PassCompare(user, ServerInstance->Config->diepass, parameters[0], ServerInstance->Config->powerhash))
+ if (!ServerInstance->PassCompare(user, ServerInstance->Config->diepass, parameters[0].c_str(), ServerInstance->Config->powerhash))
{
{
std::string diebuf = std::string("*** DIE command from ") + user->nick + "!" + user->ident + "@" + user->dhost + ". Terminating in " + ConvToStr(ServerInstance->Config->DieDelay) + " seconds.";
diff --git a/src/commands/cmd_eline.cpp b/src/commands/cmd_eline.cpp
index fa9ddd708..57f0e193c 100644
--- a/src/commands/cmd_eline.cpp
+++ b/src/commands/cmd_eline.cpp
@@ -22,11 +22,11 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
/** Handle /ELINE
*/
-CmdResult CommandEline::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandEline::Handle (const std::vector<std::string>& parameters, User *user)
{
std::string target = parameters[0];
- if (pcnt >= 3)
+ if (parameters.size() >= 3)
{
IdentHostPair ih;
User* find = ServerInstance->FindNick(target.c_str());
@@ -48,9 +48,9 @@ CmdResult CommandEline::Handle (const char* const* parameters, int pcnt, User *u
if (ServerInstance->HostMatchesEveryone(ih.first+"@"+ih.second,user))
return CMD_FAILURE;
- long duration = ServerInstance->Duration(parameters[1]);
+ long duration = ServerInstance->Duration(parameters[1].c_str());
- ELine* el = new ELine(ServerInstance, ServerInstance->Time(), duration, user->nick, parameters[2], ih.first.c_str(), ih.second.c_str());
+ ELine* el = new ELine(ServerInstance, ServerInstance->Time(), duration, user->nick, parameters[2].c_str(), ih.first.c_str(), ih.second.c_str());
if (ServerInstance->XLines->AddLine(el, user))
{
if (!duration)
diff --git a/src/commands/cmd_gline.cpp b/src/commands/cmd_gline.cpp
index a6bec9c0e..d2a1f69d6 100644
--- a/src/commands/cmd_gline.cpp
+++ b/src/commands/cmd_gline.cpp
@@ -22,11 +22,11 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
/** Handle /GLINE
*/
-CmdResult CommandGline::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandGline::Handle (const std::vector<std::string>& parameters, User *user)
{
std::string target = parameters[0];
- if (pcnt >= 3)
+ if (parameters.size() >= 3)
{
IdentHostPair ih;
User* find = ServerInstance->FindNick(target.c_str());
@@ -48,14 +48,14 @@ CmdResult CommandGline::Handle (const char* const* parameters, int pcnt, User *u
if (ServerInstance->HostMatchesEveryone(ih.first+"@"+ih.second,user))
return CMD_FAILURE;
- else if (strchr(target.c_str(),'!'))
+ else if (target.find('!') != std::string::npos)
{
user->WriteServ("NOTICE %s :*** G-Line cannot operate on nick!user@host masks",user->nick);
return CMD_FAILURE;
}
- long duration = ServerInstance->Duration(parameters[1]);
- GLine* gl = new GLine(ServerInstance, ServerInstance->Time(), duration, user->nick, parameters[2], ih.first.c_str(), ih.second.c_str());
+ long duration = ServerInstance->Duration(parameters[1].c_str());
+ GLine* gl = new GLine(ServerInstance, ServerInstance->Time(), duration, user->nick, parameters[2].c_str(), ih.first.c_str(), ih.second.c_str());
if (ServerInstance->XLines->AddLine(gl, user))
{
if (!duration)
diff --git a/src/commands/cmd_info.cpp b/src/commands/cmd_info.cpp
index 31f98ddfe..346168960 100644
--- a/src/commands/cmd_info.cpp
+++ b/src/commands/cmd_info.cpp
@@ -21,7 +21,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
/** Handle /INFO
*/
-CmdResult CommandInfo::Handle (const char* const*, int, User *user)
+CmdResult CommandInfo::Handle (const std::vector<std::string>&, User *user)
{
user->WriteServ( "371 %s : -/\\- \2InspIRCd\2 -\\/-", user->nick);
user->WriteServ( "371 %s : November 2002 - Present", user->nick);
diff --git a/src/commands/cmd_invite.cpp b/src/commands/cmd_invite.cpp
index 553915ac9..db1c64eac 100644
--- a/src/commands/cmd_invite.cpp
+++ b/src/commands/cmd_invite.cpp
@@ -21,31 +21,23 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
/** Handle /INVITE
*/
-CmdResult CommandInvite::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, User *user)
{
int MOD_RESULT = 0;
- if (pcnt == 2 || pcnt == 3)
+ if (parameters.size() == 2 || parameters.size() == 3)
{
User* u = ServerInstance->FindNick(parameters[0]);
Channel* c = ServerInstance->FindChan(parameters[1]);
time_t timeout = 0;
- if (pcnt == 3)
+ if (parameters.size() == 3)
{
timeout = time(NULL) + ServerInstance->Duration(parameters[2]);
}
if ((!c) || (!u))
{
- if (!c)
- {
- user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[1]);
- }
- else
- {
- user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0]);
- }
-
+ user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, c ? parameters[0].c_str() : parameters[1].c_str());
return CMD_FAILURE;
}
diff --git a/src/commands/cmd_ison.cpp b/src/commands/cmd_ison.cpp
index ba119e251..3c2ebad58 100644
--- a/src/commands/cmd_ison.cpp
+++ b/src/commands/cmd_ison.cpp
@@ -21,13 +21,13 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
/** Handle /ISON
*/
-CmdResult CommandIson::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandIson::Handle (const std::vector<std::string>& parameters, User *user)
{
std::map<User*,User*> ison_already;
User *u;
std::string reply = std::string("303 ") + user->nick + " :";
- for (int i = 0; i < pcnt; i++)
+ for (unsigned int i = 0; i < parameters.size(); i++)
{
u = ServerInstance->FindNick(parameters[i]);
if (ison_already.find(u) != ison_already.end())
@@ -48,7 +48,7 @@ CmdResult CommandIson::Handle (const char* const* parameters, int pcnt, User *us
}
else
{
- if ((i == pcnt-1) && (strchr(parameters[i],' ')))
+ if ((i == parameters.size() - 1) && (parameters[i].find(' ') != std::string::npos))
{
/* Its a space seperated list of nicks (RFC1459 says to support this)
*/
diff --git a/src/commands/cmd_join.cpp b/src/commands/cmd_join.cpp
index d34409e7c..e7c841399 100644
--- a/src/commands/cmd_join.cpp
+++ b/src/commands/cmd_join.cpp
@@ -21,31 +21,31 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
/** Handle /JOIN
*/
-CmdResult CommandJoin::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandJoin::Handle (const std::vector<std::string>& parameters, User *user)
{
- if (pcnt > 1)
+ if (parameters.size() > 1)
{
- if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0, 1))
+ if (ServerInstance->Parser->LoopCall(user, this, parameters, 0, 1))
return CMD_SUCCESS;
- if (ServerInstance->IsChannel(parameters[0]))
+ if (ServerInstance->IsChannel(parameters[0].c_str()))
{
- Channel::JoinUser(ServerInstance, user, parameters[0], false, parameters[1], false);
+ Channel::JoinUser(ServerInstance, user, parameters[0].c_str(), false, parameters[1].c_str(), false);
return CMD_SUCCESS;
}
}
else
{
- if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0))
+ if (ServerInstance->Parser->LoopCall(user, this, parameters, 0))
return CMD_SUCCESS;
- if (ServerInstance->IsChannel(parameters[0]))
+ if (ServerInstance->IsChannel(parameters[0].c_str()))
{
- Channel::JoinUser(ServerInstance, user, parameters[0], false, "", false);
+ Channel::JoinUser(ServerInstance, user, parameters[0].c_str(), false, "", false);
return CMD_SUCCESS;
}
}
- user->WriteNumeric(403, "%s %s :Invalid channel name",user->nick, parameters[0]);
+ user->WriteNumeric(403, "%s %s :Invalid channel name",user->nick, parameters[0].c_str());
return CMD_FAILURE;
}
diff --git a/src/commands/cmd_kick.cpp b/src/commands/cmd_kick.cpp
index 9cf4f8b5c..e4acbbbf1 100644
--- a/src/commands/cmd_kick.cpp
+++ b/src/commands/cmd_kick.cpp
@@ -21,30 +21,30 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
/** Handle /KICK
*/
-CmdResult CommandKick::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User *user)
{
char reason[MAXKICK];
Channel* c = ServerInstance->FindChan(parameters[0]);
User* u = ServerInstance->FindNick(parameters[1]);
- if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 1))
+ if (ServerInstance->Parser->LoopCall(user, this, parameters, parameters.size(), 1))
return CMD_SUCCESS;
if (!u || !c)
{
- user->WriteServ( "401 %s %s :No such nick/channel", user->nick, u ? parameters[0] : parameters[1]);
+ user->WriteServ( "401 %s %s :No such nick/channel", user->nick, u ? parameters[0].c_str() : parameters[1].c_str());
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]);
+ user->WriteServ( "442 %s %s :You're not on that channel!", user->nick, parameters[0].c_str());
return CMD_FAILURE;
}
- if (pcnt > 2)
+ if (parameters.size() > 2)
{
- strlcpy(reason, parameters[2], MAXKICK - 1);
+ strlcpy(reason, parameters[2].c_str(), MAXKICK - 1);
}
else
{
diff --git a/src/commands/cmd_kill.cpp b/src/commands/cmd_kill.cpp
index 6932c8ed6..0d95b1cf0 100644
--- a/src/commands/cmd_kill.cpp
+++ b/src/commands/cmd_kill.cpp
@@ -21,10 +21,10 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
/** Handle /KILL
*/
-CmdResult CommandKill::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandKill::Handle (const std::vector<std::string>& parameters, User *user)
{
/* Allow comma seperated lists of users for /KILL (thanks w00t) */
- if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0))
+ if (ServerInstance->Parser->LoopCall(user, this, parameters, parameters.size(), 0))
return CMD_SUCCESS;
User *u = ServerInstance->FindNick(parameters[0]);
@@ -54,18 +54,18 @@ CmdResult CommandKill::Handle (const char* const* parameters, int pcnt, User *us
if (*ServerInstance->Config->HideKillsServer)
{
// hidekills is on, use it
- snprintf(killreason, MAXQUIT, "Killed (%s (%s))", ServerInstance->Config->HideKillsServer, parameters[1]);
+ snprintf(killreason, MAXQUIT, "Killed (%s (%s))", ServerInstance->Config->HideKillsServer, parameters[1].c_str());
}
else
{
// hidekills is off, do nothing
- snprintf(killreason, MAXQUIT, "Killed (%s (%s))", user->nick, parameters[1]);
+ snprintf(killreason, MAXQUIT, "Killed (%s (%s))", user->nick, parameters[1].c_str());
}
}
else
{
/* Leave it alone, remote server has already formatted it */
- snprintf(killreason, MAXQUIT, "%s", parameters[1]);
+ strlcpy(killreason, parameters[1].c_str(), MAXQUIT);
}
/*
@@ -75,7 +75,7 @@ CmdResult CommandKill::Handle (const char* const* parameters, int pcnt, User *us
if (!IS_LOCAL(u))
{
// remote kill
- ServerInstance->SNO->WriteToSnoMask('K', "Remote kill by %s: %s!%s@%s (%s)", user->nick, u->nick, u->ident, u->host, parameters[1]);
+ ServerInstance->SNO->WriteToSnoMask('K', "Remote kill by %s: %s!%s@%s (%s)", user->nick, u->nick, u->ident, u->host, parameters[1].c_str());
FOREACH_MOD(I_OnRemoteKill, OnRemoteKill(user, u, killreason, killreason));
}
else
@@ -85,8 +85,8 @@ CmdResult CommandKill::Handle (const char* const* parameters, int pcnt, User *us
* XXX - this isn't entirely correct, servers A - B - C, oper on A, client on C. Oper kills client, A and B will get remote kill
* snotices, C will get a local kill snotice. this isn't accurate, and needs fixing at some stage. -- w00t
*/
- ServerInstance->SNO->WriteToSnoMask('k',"Local Kill by %s: %s!%s@%s (%s)", user->nick, u->nick, u->ident, u->host, parameters[1]);
- ServerInstance->Logs->Log("KILL",DEFAULT,"LOCAL KILL: %s :%s!%s!%s (%s)", u->nick, ServerInstance->Config->ServerName, user->dhost, user->nick, parameters[1]);
+ ServerInstance->SNO->WriteToSnoMask('k',"Local Kill by %s: %s!%s@%s (%s)", user->nick, u->nick, u->ident, u->host, parameters[1].c_str());
+ ServerInstance->Logs->Log("KILL",DEFAULT,"LOCAL KILL: %s :%s!%s!%s (%s)", u->nick, ServerInstance->Config->ServerName, user->dhost, user->nick, parameters[1].c_str());
/* Bug #419, make sure this message can only occur once even in the case of multiple KILL messages crossing the network, and change to show
* hidekillsserver as source if possible
*/
@@ -97,7 +97,7 @@ CmdResult CommandKill::Handle (const char* const* parameters, int pcnt, User *us
ServerInstance->Config->ServerName,
user->dhost,
*ServerInstance->Config->HideKillsServer ? ServerInstance->Config->HideKillsServer : user->nick,
- parameters[1]);
+ parameters[1].c_str());
}
}
@@ -106,7 +106,7 @@ CmdResult CommandKill::Handle (const char* const* parameters, int pcnt, User *us
}
else
{
- user->WriteServ( "401 %s %s :No such nick/channel", user->nick, parameters[0]);
+ user->WriteServ( "401 %s %s :No such nick/channel", user->nick, parameters[0].c_str());
return CMD_FAILURE;
}
diff --git a/src/commands/cmd_kline.cpp b/src/commands/cmd_kline.cpp
index b4464a6d3..ddf5d218b 100644
--- a/src/commands/cmd_kline.cpp
+++ b/src/commands/cmd_kline.cpp
@@ -22,11 +22,11 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
/** Handle /KLINE
*/
-CmdResult CommandKline::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandKline::Handle (const std::vector<std::string>& parameters, User *user)
{
std::string target = parameters[0];
- if (pcnt >= 3)
+ if (parameters.size() >= 3)
{
IdentHostPair ih;
User* find = ServerInstance->FindNick(target.c_str());
@@ -48,14 +48,14 @@ CmdResult CommandKline::Handle (const char* const* parameters, int pcnt, User *u
if (ServerInstance->HostMatchesEveryone(ih.first+"@"+ih.second,user))
return CMD_FAILURE;
- if (strchr(target.c_str(),'!'))
+ if (target.find('!') != std::string::npos)
{
user->WriteServ("NOTICE %s :*** K-Line cannot operate on nick!user@host masks",user->nick);
return CMD_FAILURE;
}
- long duration = ServerInstance->Duration(parameters[1]);
- KLine* kl = new KLine(ServerInstance, ServerInstance->Time(), duration, user->nick, parameters[2], ih.first.c_str(), ih.second.c_str());
+ long duration = ServerInstance->Duration(parameters[1].c_str());
+ KLine* kl = new KLine(ServerInstance, ServerInstance->Time(), duration, user->nick, parameters[2].c_str(), ih.first.c_str(), ih.second.c_str());
if (ServerInstance->XLines->AddLine(kl,user))
{
if (!duration)
diff --git a/src/commands/cmd_links.cpp b/src/commands/cmd_links.cpp
index e3111831e..554e6d962 100644
--- a/src/commands/cmd_links.cpp
+++ b/src/commands/cmd_links.cpp
@@ -21,7 +21,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
/** Handle /LINKS
*/
-CmdResult CommandLinks::Handle (const char* const*, int, User *user)
+CmdResult CommandLinks::Handle (const std::vector<std::string>&, User *user)
{
user->WriteNumeric(364, "%s %s %s :0 %s",user->nick,ServerInstance->Config->ServerName,ServerInstance->Config->ServerName,ServerInstance->Config->ServerDesc);
user->WriteNumeric(365, "%s * :End of /LINKS list.",user->nick);
diff --git a/src/commands/cmd_list.cpp b/src/commands/cmd_list.cpp
index 2c7971edd..518aee62f 100644
--- a/src/commands/cmd_list.cpp
+++ b/src/commands/cmd_list.cpp
@@ -22,24 +22,22 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandList(Instance);
}
-CmdResult CommandList::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandList::Handle (const std::vector<std::string>& parameters, User *user)
{
int minusers = 0, maxusers = 0;
user->WriteNumeric(321, "%s Channel :Users Name",user->nick);
/* Work around mIRC suckyness. YOU SUCK, KHALED! */
- if (pcnt == 1)
+ if (parameters.size() == 1)
{
- if (*parameters[0] == '<')
+ if (parameters[0][0] == '<')
{
- maxusers = atoi(parameters[0]+1);
- pcnt = 0;
+ maxusers = atoi((parameters[0].c_str())+1);
}
- else if (*parameters[0] == '>')
+ else if (parameters[0][0] == '>')
{
- minusers = atoi(parameters[0]+1);
- pcnt = 0;
+ minusers = atoi((parameters[0].c_str())+1);
}
}
@@ -54,9 +52,9 @@ CmdResult CommandList::Handle (const char* const* parameters, int pcnt, User *us
if (too_many || too_few)
continue;
- if (pcnt)
+ if (parameters.size() && parameters[0][0] != '<' && parameters[0][0] == '>')
{
- if (!match(i->second->name, parameters[0]) && !match(i->second->topic, parameters[0]))
+ if (!match(i->second->name, parameters[0].c_str()) && !match(i->second->topic, parameters[0].c_str()))
continue;
}
diff --git a/src/commands/cmd_loadmodule.cpp b/src/commands/cmd_loadmodule.cpp
index 744928a86..31bb02ca0 100644
--- a/src/commands/cmd_loadmodule.cpp
+++ b/src/commands/cmd_loadmodule.cpp
@@ -21,17 +21,17 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
/** Handle /LOADMODULE
*/
-CmdResult CommandLoadmodule::Handle (const char* const* parameters, int, User *user)
+CmdResult CommandLoadmodule::Handle (const std::vector<std::string>& parameters, User *user)
{
- if (ServerInstance->Modules->Load(parameters[0]))
+ if (ServerInstance->Modules->Load(parameters[0].c_str()))
{
- ServerInstance->SNO->WriteToSnoMask('A', "NEW MODULE: %s loaded %s",user->nick, parameters[0]);
- user->WriteNumeric(975, "%s %s :Module successfully loaded.",user->nick, parameters[0]);
+ ServerInstance->SNO->WriteToSnoMask('A', "NEW MODULE: %s loaded %s",user->nick, parameters[0].c_str());
+ user->WriteNumeric(975, "%s %s :Module successfully loaded.",user->nick, parameters[0].c_str());
return CMD_SUCCESS;
}
else
{
- user->WriteNumeric(974, "%s %s :%s",user->nick, parameters[0], ServerInstance->Modules->LastError().c_str());
+ user->WriteNumeric(974, "%s %s :%s",user->nick, parameters[0].c_str(), ServerInstance->Modules->LastError().c_str());
return CMD_FAILURE;
}
}
diff --git a/src/commands/cmd_lusers.cpp b/src/commands/cmd_lusers.cpp
index 313e2d2b5..11f34d8d7 100644
--- a/src/commands/cmd_lusers.cpp
+++ b/src/commands/cmd_lusers.cpp
@@ -21,7 +21,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
/** Handle /LUSERS
*/
-CmdResult CommandLusers::Handle (const char* const*, int, User *user)
+CmdResult CommandLusers::Handle (const std::vector<std::string>&, User *user)
{
// this lusers command shows one server at all times because
// a protocol module must override it to show those stats.
diff --git a/src/commands/cmd_map.cpp b/src/commands/cmd_map.cpp
index 5e729c98c..cea9f39cf 100644
--- a/src/commands/cmd_map.cpp
+++ b/src/commands/cmd_map.cpp
@@ -21,7 +21,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
/** Handle /MAP
*/
-CmdResult CommandMap::Handle (const char* const*, int, User *user)
+CmdResult CommandMap::Handle (const std::vector<std::string>&, User *user)
{
// as with /LUSERS this does nothing without a linking
// module to override its behaviour and display something
diff --git a/src/commands/cmd_mode.cpp b/src/commands/cmd_mode.cpp
index 25fec59b9..7bc417fd1 100644
--- a/src/commands/cmd_mode.cpp
+++ b/src/commands/cmd_mode.cpp
@@ -21,9 +21,9 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
/** Handle /MODE
*/
-CmdResult CommandMode::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandMode::Handle (const std::vector<std::string>& parameters, User *user)
{
- ServerInstance->Modes->Process(parameters, pcnt, user, false);
+ ServerInstance->Modes->Process(parameters, user, false);
return CMD_SUCCESS;
}
diff --git a/src/commands/cmd_modules.cpp b/src/commands/cmd_modules.cpp
index 4e4679ce4..0409e6341 100644
--- a/src/commands/cmd_modules.cpp
+++ b/src/commands/cmd_modules.cpp
@@ -38,7 +38,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
/** Handle /MODULES
*/
-CmdResult CommandModules::Handle (const char* const*, int, User *user)
+CmdResult CommandModules::Handle (const std::vector<std::string>&, User *user)
{
std::vector<std::string> module_names = ServerInstance->Modules->GetAllModuleNames(0);
diff --git a/src/commands/cmd_motd.cpp b/src/commands/cmd_motd.cpp
index b6584303d..b2f909f90 100644
--- a/src/commands/cmd_motd.cpp
+++ b/src/commands/cmd_motd.cpp
@@ -21,7 +21,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
/** Handle /MOTD
*/
-CmdResult CommandMotd::Handle (const char* const*, int, User *user)
+CmdResult CommandMotd::Handle (const std::vector<std::string>&, User *user)
{
user->ShowMOTD();
return CMD_SUCCESS;
diff --git a/src/commands/cmd_names.cpp b/src/commands/cmd_names.cpp
index 0c3492630..7e2b9cdee 100644
--- a/src/commands/cmd_names.cpp
+++ b/src/commands/cmd_names.cpp
@@ -21,17 +21,17 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
/** Handle /NAMES
*/
-CmdResult CommandNames::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandNames::Handle (const std::vector<std::string>& parameters, User *user)
{
Channel* c;
- if (!pcnt)
+ if (!parameters.size())
{
user->WriteNumeric(366, "%s * :End of /NAMES list.",user->nick);
return CMD_SUCCESS;
}
- if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0))
+ if (ServerInstance->Parser->LoopCall(user, this, parameters, 0))
return CMD_SUCCESS;
c = ServerInstance->FindChan(parameters[0]);
@@ -46,7 +46,7 @@ CmdResult CommandNames::Handle (const char* const* parameters, int pcnt, User *u
}
else
{
- user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0]);
+ user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0].c_str());
}
return CMD_SUCCESS;
diff --git a/src/commands/cmd_nick.cpp b/src/commands/cmd_nick.cpp
index 059a97806..eac29dd24 100644
--- a/src/commands/cmd_nick.cpp
+++ b/src/commands/cmd_nick.cpp
@@ -25,21 +25,21 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
* for the client introduction code in here, youre in the wrong place.
* You need to look in the spanningtree module for this!
*/
-CmdResult CommandNick::Handle (const char* const* parameters, int, User *user)
+CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User *user)
{
char oldnick[NICKMAX];
- if (!*parameters[0] || !*user->nick)
+ if (parameters[0].empty())
{
/* We cant put blanks in the parameters, so for this (extremely rare) issue we just put '*' here. */
user->WriteNumeric(432, "%s * :Erroneous Nickname", *user->nick ? user->nick : "*");
return CMD_FAILURE;
}
- if (irc::string(user->nick) == irc::string(parameters[0]))
+ if (irc::string(user->nick) == assign(parameters[0]))
{
/* If its exactly the same, even case, dont do anything. */
- if (!strcmp(user->nick,parameters[0]))
+ if (parameters[0] == user->nick)
return CMD_SUCCESS;
/* Its a change of case. People insisted that they should be
@@ -48,12 +48,12 @@ CmdResult CommandNick::Handle (const char* const* parameters, int, User *user)
*/
strlcpy(oldnick, user->nick, NICKMAX - 1);
int MOD_RESULT = 0;
- FOREACH_RESULT(I_OnUserPreNick,OnUserPreNick(user,parameters[0]));
+ FOREACH_RESULT(I_OnUserPreNick,OnUserPreNick(user,parameters[0].c_str()));
if (MOD_RESULT)
return CMD_FAILURE;
if (user->registered == REG_ALL)
- user->WriteCommon("NICK %s",parameters[0]);
- strlcpy(user->nick, parameters[0], NICKMAX - 1);
+ user->WriteCommon("NICK %s",parameters[0].c_str());
+ strlcpy(user->nick, parameters[0].c_str(), NICKMAX - 1);
user->InvalidateCache();
FOREACH_MOD(I_OnUserPostNick,OnUserPostNick(user,oldnick));
return CMD_SUCCESS;
@@ -73,8 +73,8 @@ CmdResult CommandNick::Handle (const char* const* parameters, int, User *user)
XLine* mq = ServerInstance->XLines->MatchesLine("Q",parameters[0]);
if (mq)
{
- ServerInstance->SNO->WriteToSnoMask('x', "Q-Lined nickname %s from %s!%s@%s: %s", parameters[0], user->nick, user->ident, user->host, mq->reason);
- user->WriteNumeric(432, "%s %s :Invalid nickname: %s",user->nick,parameters[0], mq->reason);
+ ServerInstance->SNO->WriteToSnoMask('x', "Q-Lined nickname %s from %s!%s@%s: %s", parameters[0].c_str(), user->nick, user->ident, user->host, mq->reason);
+ user->WriteNumeric(432, "%s %s :Invalid nickname: %s",user->nick, parameters[0].c_str(), mq->reason);
return CMD_FAILURE;
}
}
@@ -89,7 +89,7 @@ CmdResult CommandNick::Handle (const char* const* parameters, int, User *user)
* because the nick is already (rightfully) in use. -- w00t
*/
User* InUse = ServerInstance->FindNickOnly(parameters[0]);
- if (InUse && (InUse != user) && ((ServerInstance->IsNick(parameters[0]) || allowinvalid)))
+ if (InUse && (InUse != user) && ((ServerInstance->IsNick(parameters[0].c_str()) || allowinvalid)))
{
if (InUse->registered != REG_ALL)
{
@@ -104,33 +104,33 @@ CmdResult CommandNick::Handle (const char* const* parameters, int, User *user)
else
{
/* No camping, tell the incoming user to stop trying to change nick ;p */
- user->WriteNumeric(433, "%s %s :Nickname is already in use.", user->registered >= REG_NICK ? user->nick : "*", parameters[0]);
+ user->WriteNumeric(433, "%s %s :Nickname is already in use.", user->registered >= REG_NICK ? user->nick : "*", parameters[0].c_str());
return CMD_FAILURE;
}
}
}
- if (((!ServerInstance->IsNick(parameters[0]))) && (IS_LOCAL(user)))
+ if (((!ServerInstance->IsNick(parameters[0].c_str()))) && (IS_LOCAL(user)))
{
if (!allowinvalid)
{
- user->WriteNumeric(432, "%s %s :Erroneous Nickname",user->nick,parameters[0]);
+ user->WriteNumeric(432, "%s %s :Erroneous Nickname", user->nick,parameters[0].c_str());
return CMD_FAILURE;
}
}
int MOD_RESULT = 0;
- FOREACH_RESULT(I_OnUserPreNick,OnUserPreNick(user,parameters[0]));
+ FOREACH_RESULT(I_OnUserPreNick,OnUserPreNick(user, parameters[0]));
if (MOD_RESULT)
// if a module returns true, the nick change is silently forbidden.
return CMD_FAILURE;
if (user->registered == REG_ALL)
- user->WriteCommon("NICK %s",parameters[0]);
+ user->WriteCommon("NICK %s", parameters[0].c_str());
strlcpy(oldnick, user->nick, NICKMAX - 1);
/* change the nick of the user in the users_hash */
- user = user->UpdateNickHash(parameters[0]);
+ user = user->UpdateNickHash(parameters[0].c_str());
/* actually change the nick within the record */
if (!user)
@@ -138,7 +138,7 @@ CmdResult CommandNick::Handle (const char* const* parameters, int, User *user)
if (!*user->nick)
return CMD_FAILURE;
- strlcpy(user->nick, parameters[0], NICKMAX - 1);
+ strlcpy(user->nick, parameters[0].c_str(), NICKMAX - 1);
user->InvalidateCache();
diff --git a/src/commands/cmd_notice.cpp b/src/commands/cmd_notice.cpp
index 1a47b56fb..d6e11a803 100644
--- a/src/commands/cmd_notice.cpp
+++ b/src/commands/cmd_notice.cpp
@@ -20,7 +20,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandNotice(Instance);
}
-CmdResult CommandNotice::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, User *user)
{
User *dest;
Channel *chan;
@@ -29,28 +29,29 @@ CmdResult CommandNotice::Handle (const char* const* parameters, int pcnt, User *
user->idle_lastmsg = ServerInstance->Time();
- if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0))
+ if (ServerInstance->Parser->LoopCall(user, this, parameters, parameters.size(), 0))
return CMD_SUCCESS;
if ((parameters[0][0] == '$') && (IS_OPER(user) || 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,exempt_list));
+ FOREACH_RESULT(I_OnUserPreNotice,OnUserPreNotice(user, (void*)parameters[0].c_str(), TYPE_SERVER, temp, 0, exempt_list));
if (MOD_RESULT)
return CMD_FAILURE;
const char* text = temp.c_str();
- const char* servermask = parameters[0] + 1;
+ const char* servermask = (parameters[0].c_str()) + 1;
- FOREACH_MOD(I_OnText,OnText(user,(void*)parameters[0],TYPE_SERVER,text,0,exempt_list));
+ FOREACH_MOD(I_OnText,OnText(user, (void*)parameters[0].c_str(), TYPE_SERVER, text, 0, exempt_list));
if (match(ServerInstance->Config->ServerName,servermask))
{
user->SendAll("NOTICE", "%s", text);
}
- FOREACH_MOD(I_OnUserNotice,OnUserNotice(user,(void*)parameters[0],TYPE_SERVER,text,0,exempt_list));
+ FOREACH_MOD(I_OnUserNotice,OnUserNotice(user, (void*)parameters[0].c_str(), TYPE_SERVER, text, 0, exempt_list));
return CMD_SUCCESS;
}
char status = 0;
- const char* target = parameters[0];
+ const char* target = parameters[0].c_str();
+
if (ServerInstance->Modes->FindPrefix(*target))
{
status = *target;
@@ -121,7 +122,7 @@ CmdResult CommandNotice::Handle (const char* const* parameters, int pcnt, User *
return CMD_SUCCESS;
}
- const char* destnick = parameters[0];
+ const char* destnick = parameters[0].c_str();
if (IS_LOCAL(user))
{
@@ -135,7 +136,7 @@ CmdResult CommandNotice::Handle (const char* const* parameters, int pcnt, User *
if (dest && strcasecmp(dest->server, targetserver + 1))
{
/* Incorrect server for user */
- user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0]);
+ user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0].c_str());
return CMD_FAILURE;
}
}
@@ -147,7 +148,7 @@ CmdResult CommandNotice::Handle (const char* const* parameters, int pcnt, User *
if (dest)
{
- if (!*parameters[1])
+ if (parameters[1].empty())
{
user->WriteNumeric(412, "%s :No text to send", user->nick);
return CMD_FAILURE;
@@ -174,7 +175,7 @@ CmdResult CommandNotice::Handle (const char* const* parameters, int pcnt, User *
else
{
/* no such nick/channel */
- user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0]);
+ user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0].c_str());
return CMD_FAILURE;
}
diff --git a/src/commands/cmd_oper.cpp b/src/commands/cmd_oper.cpp
index 0b17c4dca..a397f5b0d 100644
--- a/src/commands/cmd_oper.cpp
+++ b/src/commands/cmd_oper.cpp
@@ -35,7 +35,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandOper(Instance);
}
-CmdResult CommandOper::Handle (const char* const* parameters, int, User *user)
+CmdResult CommandOper::Handle (const std::vector<std::string>& parameters, User *user)
{
char LoginName[MAXBUF];
char Password[MAXBUF];
@@ -65,8 +65,8 @@ CmdResult CommandOper::Handle (const char* const* parameters, int, User *user)
ServerInstance->Config->ConfValue(ServerInstance->Config->config_data, "oper", "host", i, HostName, MAXBUF);
ServerInstance->Config->ConfValue(ServerInstance->Config->config_data, "oper", "hash", i, HashType, MAXBUF);
- match_login = !strcmp(LoginName,parameters[0]);
- match_pass = !ServerInstance->PassCompare(user, Password,parameters[1], HashType);
+ match_login = (LoginName == parameters[0]);
+ match_pass = !ServerInstance->PassCompare(user, Password,parameters[1].c_str(), HashType);
match_hosts = OneOfMatches(TheHost,TheIP,HostName);
if (match_login && match_pass && match_hosts)
@@ -107,7 +107,7 @@ CmdResult CommandOper::Handle (const char* const* parameters, int, User *user)
if (found)
{
/* correct oper credentials */
- ServerInstance->SNO->WriteToSnoMask('o',"%s (%s@%s) is now an IRC operator of type %s (using oper '%s')",user->nick,user->ident,user->host,irc::Spacify(OperType),parameters[0]);
+ ServerInstance->SNO->WriteToSnoMask('o',"%s (%s@%s) is now an IRC operator of type %s (using oper '%s')",user->nick,user->ident,user->host,irc::Spacify(OperType),parameters[0].c_str());
user->WriteNumeric(381, "%s :You are now %s %s",user->nick, strchr("aeiouAEIOU", *OperType) ? "an" : "a", irc::Spacify(OperType));
if (!user->IsModeSet('o'))
user->Oper(OperType, LoginName);
@@ -133,21 +133,21 @@ CmdResult CommandOper::Handle (const char* const* parameters, int, User *user)
user->WriteNumeric(491, "%s :Invalid oper credentials",user->nick);
user->IncreasePenalty(10);
- snprintf(broadcast, MAXBUF, "WARNING! Failed oper attempt by %s!%s@%s using login '%s': The following fields do not match: %s",user->nick,user->ident,user->host, parameters[0], fields.c_str());
+ snprintf(broadcast, MAXBUF, "WARNING! Failed oper attempt by %s!%s@%s using login '%s': The following fields do not match: %s",user->nick,user->ident,user->host, parameters[0].c_str(), fields.c_str());
ServerInstance->SNO->WriteToSnoMask('o',std::string(broadcast));
- ServerInstance->Logs->Log("OPER",DEFAULT,"OPER: Failed oper attempt by %s!%s@%s using login '%s': The following fields did not match: %s",user->nick,user->ident,user->host,parameters[0],fields.c_str());
+ ServerInstance->Logs->Log("OPER",DEFAULT,"OPER: Failed oper attempt by %s!%s@%s using login '%s': The following fields did not match: %s",user->nick,user->ident,user->host,parameters[0].c_str(),fields.c_str());
return CMD_FAILURE;
}
else
{
user->WriteNumeric(491, "%s :Your oper block does not have a valid opertype associated with it",user->nick);
- snprintf(broadcast, MAXBUF, "CONFIGURATION ERROR! Oper block '%s': missing OperType %s",parameters[0],OperType);
+ snprintf(broadcast, MAXBUF, "CONFIGURATION ERROR! Oper block '%s': missing OperType %s",parameters[0].c_str(),OperType);
ServerInstance->SNO->WriteToSnoMask('o', std::string(broadcast));
- ServerInstance->Logs->Log("OPER",DEFAULT,"OPER: Failed oper attempt by %s!%s@%s using login '%s': credentials valid, but oper type nonexistent.",user->nick,user->ident,user->host,parameters[0]);
+ ServerInstance->Logs->Log("OPER",DEFAULT,"OPER: Failed oper attempt by %s!%s@%s using login '%s': credentials valid, but oper type nonexistent.",user->nick,user->ident,user->host,parameters[0].c_str());
return CMD_FAILURE;
}
}
diff --git a/src/commands/cmd_part.cpp b/src/commands/cmd_part.cpp
index 360287c45..07b45367f 100644
--- a/src/commands/cmd_part.cpp
+++ b/src/commands/cmd_part.cpp
@@ -19,7 +19,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandPart(Instance);
}
-CmdResult CommandPart::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandPart::Handle (const std::vector<std::string>& parameters, User *user)
{
std::string reason;
@@ -29,7 +29,7 @@ CmdResult CommandPart::Handle (const char* const* parameters, int pcnt, User *us
reason = ServerInstance->Config->FixedPart;
else
{
- if (pcnt > 1)
+ if (parameters.size() > 1)
reason = ServerInstance->Config->PrefixPart + std::string(parameters[1]) + ServerInstance->Config->SuffixPart;
else
reason = "";
@@ -37,10 +37,10 @@ CmdResult CommandPart::Handle (const char* const* parameters, int pcnt, User *us
}
else
{
- reason = pcnt > 1 ? parameters[1] : "";
+ reason = parameters.size() > 1 ? parameters[1] : "";
}
- if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0))
+ if (ServerInstance->Parser->LoopCall(user, this, parameters, 0))
return CMD_SUCCESS;
Channel* c = ServerInstance->FindChan(parameters[0]);
@@ -54,7 +54,7 @@ CmdResult CommandPart::Handle (const char* const* parameters, int pcnt, User *us
}
else
{
- user->WriteServ( "401 %s %s :No such channel", user->nick, parameters[0]);
+ user->WriteServ( "401 %s %s :No such channel", user->nick, parameters[0].c_str());
return CMD_FAILURE;
}
diff --git a/src/commands/cmd_pass.cpp b/src/commands/cmd_pass.cpp
index 2333661e7..2e1a702a2 100644
--- a/src/commands/cmd_pass.cpp
+++ b/src/commands/cmd_pass.cpp
@@ -19,7 +19,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandPass(Instance);
}
-CmdResult CommandPass::Handle (const char* const* parameters, int, User *user)
+CmdResult CommandPass::Handle (const std::vector<std::string>& parameters, User *user)
{
// Check to make sure they havnt registered -- Fix by FCS
if (user->registered == REG_ALL)
@@ -31,11 +31,9 @@ CmdResult CommandPass::Handle (const char* const* parameters, int, User *user)
if (!a)
return CMD_FAILURE;
- strlcpy(user->password,parameters[0],63);
- if (!ServerInstance->PassCompare(user, a->GetPass().c_str(), parameters[0], a->GetHash().c_str()))
- {
+ strlcpy(user->password, parameters[0].c_str(), 63);
+ if (!ServerInstance->PassCompare(user, a->GetPass().c_str(), parameters[0].c_str(), a->GetHash().c_str()))
user->haspassed = true;
- }
return CMD_SUCCESS;
}
diff --git a/src/commands/cmd_ping.cpp b/src/commands/cmd_ping.cpp
index 3aeafe15e..38e5d49ab 100644
--- a/src/commands/cmd_ping.cpp
+++ b/src/commands/cmd_ping.cpp
@@ -19,8 +19,8 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandPing(Instance);
}
-CmdResult CommandPing::Handle (const char* const* parameters, int, User *user)
+CmdResult CommandPing::Handle (const std::vector<std::string>& parameters, User *user)
{
- user->WriteServ("PONG %s :%s",ServerInstance->Config->ServerName,parameters[0]);
+ user->WriteServ("PONG %s :%s", ServerInstance->Config->ServerName, parameters[0].c_str());
return CMD_SUCCESS;
}
diff --git a/src/commands/cmd_pong.cpp b/src/commands/cmd_pong.cpp
index 51c951eba..7e7cba3b9 100644
--- a/src/commands/cmd_pong.cpp
+++ b/src/commands/cmd_pong.cpp
@@ -19,7 +19,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandPong(Instance);
}
-CmdResult CommandPong::Handle (const char* const*, int, User *user)
+CmdResult CommandPong::Handle (const std::vector<std::string>&, User *user)
{
// set the user as alive so they survive to next ping
user->lastping = 1;
diff --git a/src/commands/cmd_privmsg.cpp b/src/commands/cmd_privmsg.cpp
index 9ce089dc0..a3d64f084 100644
--- a/src/commands/cmd_privmsg.cpp
+++ b/src/commands/cmd_privmsg.cpp
@@ -20,7 +20,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandPrivmsg(Instance);
}
-CmdResult CommandPrivmsg::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, User *user)
{
User *dest;
Channel *chan;
@@ -28,28 +28,31 @@ CmdResult CommandPrivmsg::Handle (const char* const* parameters, int pcnt, User
user->idle_lastmsg = ServerInstance->Time();
- if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0))
+ if (ServerInstance->Parser->LoopCall(user, this, parameters, parameters.size(), 0))
return CMD_SUCCESS;
if ((parameters[0][0] == '$') && (IS_OPER(user) || ServerInstance->ULine(user->server)))
{
int MOD_RESULT = 0;
std::string temp = parameters[1];
- FOREACH_RESULT(I_OnUserPreMessage,OnUserPreMessage(user,(void*)parameters[0],TYPE_SERVER,temp,0,except_list));
+ FOREACH_RESULT(I_OnUserPreMessage,OnUserPreMessage(user, (void*)parameters[0].c_str(), TYPE_SERVER, temp, 0, except_list));
if (MOD_RESULT)
return CMD_FAILURE;
+
const char* text = temp.c_str();
- const char* servermask = parameters[0] + 1;
- FOREACH_MOD(I_OnText,OnText(user,(void*)parameters[0],TYPE_SERVER,text,0,except_list));
+ const char* servermask = (parameters[0].c_str()) + 1;
+
+ FOREACH_MOD(I_OnText,OnText(user, (void*)parameters[0].c_str(), TYPE_SERVER, text, 0, except_list));
if (match(ServerInstance->Config->ServerName,servermask))
{
user->SendAll("PRIVMSG", "%s", text);
}
- FOREACH_MOD(I_OnUserMessage,OnUserMessage(user,(void*)parameters[0],TYPE_SERVER,text,0,except_list));
+ FOREACH_MOD(I_OnUserMessage,OnUserMessage(user, (void*)parameters[0].c_str(), TYPE_SERVER, text, 0, except_list));
return CMD_SUCCESS;
}
char status = 0;
- const char* target = parameters[0];
+ const char* target = parameters[0].c_str();
+
if (ServerInstance->Modes->FindPrefix(*target))
{
status = *target;
@@ -121,7 +124,7 @@ CmdResult CommandPrivmsg::Handle (const char* const* parameters, int pcnt, User
return CMD_SUCCESS;
}
- const char* destnick = parameters[0];
+ const char* destnick = parameters[0].c_str();
if (IS_LOCAL(user))
{
@@ -135,7 +138,7 @@ CmdResult CommandPrivmsg::Handle (const char* const* parameters, int pcnt, User
if (dest && strcasecmp(dest->server, targetserver + 1))
{
/* Incorrect server for user */
- user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0]);
+ user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0].c_str());
return CMD_FAILURE;
}
}
@@ -147,7 +150,7 @@ CmdResult CommandPrivmsg::Handle (const char* const* parameters, int pcnt, User
if (dest)
{
- if (!*parameters[1])
+ if (parameters[1].empty())
{
user->WriteNumeric(412, "%s :No text to send", user->nick);
return CMD_FAILURE;
@@ -162,13 +165,13 @@ CmdResult CommandPrivmsg::Handle (const char* const* parameters, int pcnt, User
int MOD_RESULT = 0;
std::string temp = parameters[1];
- FOREACH_RESULT(I_OnUserPreMessage,OnUserPreMessage(user,dest,TYPE_USER,temp,0,except_list));
+ FOREACH_RESULT(I_OnUserPreMessage,OnUserPreMessage(user, dest, TYPE_USER, temp, 0, except_list));
if (MOD_RESULT) {
return CMD_FAILURE;
}
const char* text = temp.c_str();
- FOREACH_MOD(I_OnText,OnText(user,dest,TYPE_USER,text,0,except_list));
+ FOREACH_MOD(I_OnText,OnText(user, dest, TYPE_USER, text, 0, except_list));
if (IS_LOCAL(dest))
{
@@ -176,12 +179,12 @@ CmdResult CommandPrivmsg::Handle (const char* const* parameters, int pcnt, User
user->WriteTo(dest, "PRIVMSG %s :%s", dest->nick, text);
}
- FOREACH_MOD(I_OnUserMessage,OnUserMessage(user,dest,TYPE_USER,text,0,except_list));
+ FOREACH_MOD(I_OnUserMessage,OnUserMessage(user, dest, TYPE_USER, text, 0, except_list));
}
else
{
/* no such nick/channel */
- user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0]);
+ user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0].c_str());
return CMD_FAILURE;
}
return CMD_SUCCESS;
diff --git a/src/commands/cmd_qline.cpp b/src/commands/cmd_qline.cpp
index 97d26ba9f..f3471a6b3 100644
--- a/src/commands/cmd_qline.cpp
+++ b/src/commands/cmd_qline.cpp
@@ -22,31 +22,31 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandQline(Instance);
}
-CmdResult CommandQline::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandQline::Handle (const std::vector<std::string>& parameters, User *user)
{
- if (pcnt >= 3)
+ if (parameters.size() >= 3)
{
if (ServerInstance->NickMatchesEveryone(parameters[0],user))
return CMD_FAILURE;
- if (strchr(parameters[0],'@') || strchr(parameters[0],'!') || strchr(parameters[0],'.'))
+ if (parameters[0].find('@') != std::string::npos || parameters[0].find('!') != std::string::npos || parameters[0].find('.') != std::string::npos)
{
user->WriteServ("NOTICE %s :*** A Q-Line only bans a nick pattern, not a nick!user@host pattern.",user->nick);
return CMD_FAILURE;
}
- long duration = ServerInstance->Duration(parameters[1]);
- QLine* ql = new QLine(ServerInstance, ServerInstance->Time(), duration, user->nick, parameters[2], parameters[0]);
+ long duration = ServerInstance->Duration(parameters[1].c_str());
+ QLine* ql = new QLine(ServerInstance, ServerInstance->Time(), duration, user->nick, parameters[2].c_str(), parameters[0].c_str());
if (ServerInstance->XLines->AddLine(ql,user))
{
if (!duration)
{
- ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent Q-line for %s.",user->nick,parameters[0]);
+ ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent Q-line for %s.",user->nick,parameters[0].c_str());
}
else
{
time_t c_requires_crap = duration + ServerInstance->Time();
- ServerInstance->SNO->WriteToSnoMask('x',"%s added timed Q-line for %s, expires on %s",user->nick,parameters[0],
+ ServerInstance->SNO->WriteToSnoMask('x',"%s added timed Q-line for %s, expires on %s",user->nick,parameters[0].c_str(),
ServerInstance->TimeString(c_requires_crap).c_str());
}
ServerInstance->XLines->ApplyLines();
@@ -54,18 +54,18 @@ CmdResult CommandQline::Handle (const char* const* parameters, int pcnt, User *u
else
{
delete ql;
- user->WriteServ("NOTICE %s :*** Q-Line for %s already exists",user->nick,parameters[0]);
+ user->WriteServ("NOTICE %s :*** Q-Line for %s already exists",user->nick,parameters[0].c_str());
}
}
else
{
- if (ServerInstance->XLines->DelLine(parameters[0],"Q",user))
+ if (ServerInstance->XLines->DelLine(parameters[0].c_str(), "Q", user))
{
- ServerInstance->SNO->WriteToSnoMask('x',"%s Removed Q-line on %s.",user->nick,parameters[0]);
+ ServerInstance->SNO->WriteToSnoMask('x',"%s Removed Q-line on %s.",user->nick,parameters[0].c_str());
}
else
{
- user->WriteServ("NOTICE %s :*** Q-Line %s not found in list, try /stats q.",user->nick,parameters[0]);
+ user->WriteServ("NOTICE %s :*** Q-Line %s not found in list, try /stats q.",user->nick,parameters[0].c_str());
return CMD_FAILURE;
}
}
diff --git a/src/commands/cmd_quit.cpp b/src/commands/cmd_quit.cpp
index f7cbd00bf..9de1faa04 100644
--- a/src/commands/cmd_quit.cpp
+++ b/src/commands/cmd_quit.cpp
@@ -21,7 +21,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandQuit(Instance);
}
-CmdResult CommandQuit::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandQuit::Handle (const std::vector<std::string>& parameters, User *user)
{
std::string quitmsg;
@@ -31,12 +31,12 @@ CmdResult CommandQuit::Handle (const char* const* parameters, int pcnt, User *us
if (*ServerInstance->Config->FixedQuit)
quitmsg = ServerInstance->Config->FixedQuit;
else
- quitmsg = pcnt ?
+ quitmsg = parameters.size() ?
ServerInstance->Config->PrefixQuit + std::string(parameters[0]) + ServerInstance->Config->SuffixQuit
: "Client exited";
}
else
- quitmsg = pcnt ? parameters[0] : "Client exited";
+ quitmsg = parameters.size() ? parameters[0] : "Client exited";
ServerInstance->Users->QuitUser(user, quitmsg);
diff --git a/src/commands/cmd_rehash.cpp b/src/commands/cmd_rehash.cpp
index 0f60f4a6d..ce34239a5 100644
--- a/src/commands/cmd_rehash.cpp
+++ b/src/commands/cmd_rehash.cpp
@@ -22,23 +22,20 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandRehash(Instance);
}
-CmdResult CommandRehash::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandRehash::Handle (const std::vector<std::string>& parameters, User *user)
{
std::string old_disabled = ServerInstance->Config->DisabledCommands;
- ServerInstance->Logs->Log("fuckingrehash", DEBUG, "parc %d p0 %s", pcnt, parameters[0]);
- if (pcnt && parameters[0][0] != '-')
+ if (parameters.size() && parameters[0][0] != '-')
{
if (!ServerInstance->MatchText(ServerInstance->Config->ServerName, parameters[0]))
{
- ServerInstance->Logs->Log("fuckingrehash", DEBUG, "rehash for a server, and not for us");
FOREACH_MOD(I_OnRehash,OnRehash(user, parameters[0]));
return CMD_SUCCESS; // rehash for a server, and not for us
}
}
- else if (pcnt)
+ else if (parameters.size())
{
- ServerInstance->Logs->Log("fuckingrehash", DEBUG, "rehash for a subsystem, ignoring");
FOREACH_MOD(I_OnRehash,OnRehash(user, parameters[0]));
return CMD_SUCCESS;
}
@@ -65,7 +62,7 @@ CmdResult CommandRehash::Handle (const char* const* parameters, int pcnt, User *
if (!ServerInstance->ConfigThread)
{
ServerInstance->Config->RehashUser = user;
- ServerInstance->Config->RehashParameter = pcnt ? parameters[0] : "";
+ ServerInstance->Config->RehashParameter = parameters.size() ? parameters[0] : "";
ServerInstance->ConfigThread = new ConfigReaderThread(ServerInstance, false, user);
ServerInstance->Threads->Create(ServerInstance->ConfigThread);
diff --git a/src/commands/cmd_reloadmodule.cpp b/src/commands/cmd_reloadmodule.cpp
index fcdc4cb1e..05162e631 100644
--- a/src/commands/cmd_reloadmodule.cpp
+++ b/src/commands/cmd_reloadmodule.cpp
@@ -19,20 +19,20 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandReloadmodule(Instance);
}
-CmdResult CommandReloadmodule::Handle (const char* const* parameters, int, User *user)
+CmdResult CommandReloadmodule::Handle (const std::vector<std::string>& parameters, User *user)
{
- if (ServerInstance->Modules->Unload(parameters[0]))
+ if (ServerInstance->Modules->Unload(parameters[0].c_str()))
{
- ServerInstance->SNO->WriteToSnoMask('A', "RELOAD MODULE: %s unloaded %s",user->nick, parameters[0]);
- if (ServerInstance->Modules->Load(parameters[0]))
+ ServerInstance->SNO->WriteToSnoMask('A', "RELOAD MODULE: %s unloaded %s",user->nick, parameters[0].c_str());
+ if (ServerInstance->Modules->Load(parameters[0].c_str()))
{
- ServerInstance->SNO->WriteToSnoMask('A', "RELOAD MODULE: %s reloaded %s",user->nick, parameters[0]);
- user->WriteNumeric(975, "%s %s :Module successfully reloaded.",user->nick, parameters[0]);
+ ServerInstance->SNO->WriteToSnoMask('A', "RELOAD MODULE: %s reloaded %s",user->nick, parameters[0].c_str());
+ user->WriteNumeric(975, "%s %s :Module successfully reloaded.",user->nick, parameters[0].c_str());
return CMD_SUCCESS;
}
}
- ServerInstance->SNO->WriteToSnoMask('A', "RELOAD MODULE: %s unsuccessfully reloaded %s",user->nick, parameters[0]);
- user->WriteNumeric(975, "%s %s :%s",user->nick, parameters[0], ServerInstance->Modules->LastError().c_str());
+ ServerInstance->SNO->WriteToSnoMask('A', "RELOAD MODULE: %s unsuccessfully reloaded %s",user->nick, parameters[0].c_str());
+ user->WriteNumeric(975, "%s %s :%s",user->nick, parameters[0].c_str(), ServerInstance->Modules->LastError().c_str());
return CMD_FAILURE;
}
diff --git a/src/commands/cmd_restart.cpp b/src/commands/cmd_restart.cpp
index cc634d860..334fb621f 100644
--- a/src/commands/cmd_restart.cpp
+++ b/src/commands/cmd_restart.cpp
@@ -19,10 +19,10 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandRestart(Instance);
}
-CmdResult CommandRestart::Handle (const char* const* parameters, int, User *user)
+CmdResult CommandRestart::Handle (const std::vector<std::string>& parameters, User *user)
{
ServerInstance->Logs->Log("COMMAND",DEFAULT,"Restart: %s",user->nick);
- if (!ServerInstance->PassCompare(user, ServerInstance->Config->restartpass, parameters[0], ServerInstance->Config->powerhash))
+ if (!ServerInstance->PassCompare(user, ServerInstance->Config->restartpass, parameters[0].c_str(), ServerInstance->Config->powerhash))
{
ServerInstance->SNO->WriteToSnoMask('A', "RESTART command from %s!%s@%s, restarting server.",user->nick,user->ident,user->host);
diff --git a/src/commands/cmd_rules.cpp b/src/commands/cmd_rules.cpp
index 685d04389..fd03e1d4c 100644
--- a/src/commands/cmd_rules.cpp
+++ b/src/commands/cmd_rules.cpp
@@ -19,7 +19,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandRules(Instance);
}
-CmdResult CommandRules::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandRules::Handle (const std::vector<std::string>& parameters, User *user)
{
user->ShowRULES();
return CMD_SUCCESS;
diff --git a/src/commands/cmd_server.cpp b/src/commands/cmd_server.cpp
index f82263cca..5385428b8 100644
--- a/src/commands/cmd_server.cpp
+++ b/src/commands/cmd_server.cpp
@@ -21,7 +21,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandServer(Instance);
}
-CmdResult CommandServer::Handle (const char* const*, int, User *user)
+CmdResult CommandServer::Handle (const std::vector<std::string>&, User *user)
{
user->WriteNumeric(666, "%s :You cannot identify as a server, you are a USER. IRC Operators informed.",user->nick);
ServerInstance->SNO->WriteToSnoMask('A', "WARNING: %s attempted to issue a SERVER command and is registered as a user!", user->nick);
diff --git a/src/commands/cmd_squit.cpp b/src/commands/cmd_squit.cpp
index e98790380..61d0a601d 100644
--- a/src/commands/cmd_squit.cpp
+++ b/src/commands/cmd_squit.cpp
@@ -24,7 +24,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandSquit(Instance);
}
-CmdResult CommandSquit::Handle (const char* const*, int, User *user)
+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);
return CMD_FAILURE;
diff --git a/src/commands/cmd_stats.cpp b/src/commands/cmd_stats.cpp
index fb1aaf20b..174094afa 100644
--- a/src/commands/cmd_stats.cpp
+++ b/src/commands/cmd_stats.cpp
@@ -31,12 +31,12 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandStats(Instance);
}
-CmdResult CommandStats::Handle (const char* const* parameters, int /* pcnt */, User *user)
+CmdResult CommandStats::Handle (const std::vector<std::string>& parameters, User *user)
{
if (IS_LOCAL(user))
{
string_list values;
- DoStats(this->ServerInstance, *parameters[0], user, values);
+ DoStats(this->ServerInstance, parameters[0][0], user, values);
for (size_t i = 0; i < values.size(); i++)
user->Write(":%s", values[i].c_str());
}
diff --git a/src/commands/cmd_time.cpp b/src/commands/cmd_time.cpp
index c84b02122..d8c3561b0 100644
--- a/src/commands/cmd_time.cpp
+++ b/src/commands/cmd_time.cpp
@@ -21,7 +21,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandTime(Instance);
}
-CmdResult CommandTime::Handle (const char* const*, int, User *user)
+CmdResult CommandTime::Handle (const std::vector<std::string>&, User *user)
{
struct tm* timeinfo;
time_t local = ServerInstance->Time();
diff --git a/src/commands/cmd_topic.cpp b/src/commands/cmd_topic.cpp
index 35d83c140..9f9d56b14 100644
--- a/src/commands/cmd_topic.cpp
+++ b/src/commands/cmd_topic.cpp
@@ -20,11 +20,11 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandTopic(Instance);
}
-CmdResult CommandTopic::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandTopic::Handle (const std::vector<std::string>& parameters, User *user)
{
Channel* Ptr;
- if (pcnt == 1)
+ if (parameters.size() == 1)
{
Ptr = ServerInstance->FindChan(parameters[0]);
if (Ptr)
@@ -46,12 +46,12 @@ CmdResult CommandTopic::Handle (const char* const* parameters, int pcnt, User *u
}
else
{
- user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0]);
+ user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0].c_str());
return CMD_FAILURE;
}
return CMD_SUCCESS;
}
- else if (pcnt>1)
+ else if (parameters.size()>1)
{
Ptr = ServerInstance->FindChan(parameters[0]);
if (Ptr)
@@ -79,17 +79,17 @@ CmdResult CommandTopic::Handle (const char* const* parameters, int pcnt, User *u
*/
int MOD_RESULT = 0;
- strlcpy(topic,parameters[1],MAXTOPIC-1);
+ strlcpy(topic, parameters[1].c_str(), MAXTOPIC-1);
FOREACH_RESULT(I_OnLocalTopicChange,OnLocalTopicChange(user,Ptr,topic));
if (MOD_RESULT)
return CMD_FAILURE;
- strlcpy(Ptr->topic,topic,MAXTOPIC-1);
+ strlcpy(Ptr->topic, topic, MAXTOPIC-1);
}
else
{
/* Sneaky shortcut, one string copy for a remote topic */
- strlcpy(Ptr->topic, parameters[1], MAXTOPIC-1);
+ strlcpy(Ptr->topic, parameters[1].c_str(), MAXTOPIC-1);
}
if (ServerInstance->Config->FullHostInTopic)
@@ -106,7 +106,7 @@ CmdResult CommandTopic::Handle (const char* const* parameters, int pcnt, User *u
}
else
{
- user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0]);
+ user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0].c_str());
return CMD_FAILURE;
}
}
diff --git a/src/commands/cmd_trace.cpp b/src/commands/cmd_trace.cpp
index 972080b70..9aa4eff53 100644
--- a/src/commands/cmd_trace.cpp
+++ b/src/commands/cmd_trace.cpp
@@ -21,7 +21,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
/** XXX: This is crap. someone fix this when you have time, to be more useful.
*/
-CmdResult CommandTrace::Handle (const char* const*, int, User *user)
+CmdResult CommandTrace::Handle (const std::vector<std::string>&, User *user)
{
/*for (user_hash::iterator i = ServerInstance->clientlist->begin(); i != ServerInstance->clientlist->end(); i++)
{
diff --git a/src/commands/cmd_unloadmodule.cpp b/src/commands/cmd_unloadmodule.cpp
index f2e798f54..68ad591ce 100644
--- a/src/commands/cmd_unloadmodule.cpp
+++ b/src/commands/cmd_unloadmodule.cpp
@@ -21,16 +21,16 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandUnloadmodule(Instance);
}
-CmdResult CommandUnloadmodule::Handle (const char* const* parameters, int, User *user)
+CmdResult CommandUnloadmodule::Handle (const std::vector<std::string>& parameters, User *user)
{
- if (ServerInstance->Modules->Unload(parameters[0]))
+ if (ServerInstance->Modules->Unload(parameters[0].c_str()))
{
- ServerInstance->SNO->WriteToSnoMask('A', "MODULE UNLOADED: %s unloaded %s", user->nick, parameters[0]);
- user->WriteNumeric(973, "%s %s :Module successfully unloaded.",user->nick, parameters[0]);
+ ServerInstance->SNO->WriteToSnoMask('A', "MODULE UNLOADED: %s unloaded %s", user->nick, parameters[0].c_str());
+ user->WriteNumeric(973, "%s %s :Module successfully unloaded.",user->nick, parameters[0].c_str());
}
else
{
- user->WriteNumeric(972, "%s %s :%s",user->nick, parameters[0], ServerInstance->Modules->LastError().c_str());
+ user->WriteNumeric(972, "%s %s :%s",user->nick, parameters[0].c_str(), ServerInstance->Modules->LastError().c_str());
return CMD_FAILURE;
}
diff --git a/src/commands/cmd_user.cpp b/src/commands/cmd_user.cpp
index 3ee96b2f9..46d42771b 100644
--- a/src/commands/cmd_user.cpp
+++ b/src/commands/cmd_user.cpp
@@ -19,12 +19,12 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandUser(Instance);
}
-CmdResult CommandUser::Handle (const char* const* parameters, int, User *user)
+CmdResult CommandUser::Handle (const std::vector<std::string>& parameters, User *user)
{
/* A user may only send the USER command once */
if (!(user->registered & REG_USER))
{
- if (!ServerInstance->IsIdent(parameters[0]))
+ if (!ServerInstance->IsIdent(parameters[0].c_str()))
{
/*
* RFC says we must use this numeric, so we do. Let's make it a little more nub friendly though. :)
@@ -40,8 +40,8 @@ CmdResult CommandUser::Handle (const char* const* parameters, int, User *user)
* ~ character, and +1 for null termination, therefore we can safely use up to
* IDENTMAX here.
*/
- strlcpy(user->ident, parameters[0], IDENTMAX);
- strlcpy(user->fullname, *parameters[3] ? parameters[3] : "No info", MAXGECOS);
+ strlcpy(user->ident, parameters[0].c_str(), IDENTMAX);
+ strlcpy(user->fullname, !parameters[3].empty() ? parameters[3].c_str() : "No info", MAXGECOS);
user->registered = (user->registered | REG_USER);
}
}
diff --git a/src/commands/cmd_userhost.cpp b/src/commands/cmd_userhost.cpp
index c8a33535f..9ed8b30ab 100644
--- a/src/commands/cmd_userhost.cpp
+++ b/src/commands/cmd_userhost.cpp
@@ -19,12 +19,12 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandUserhost(Instance);
}
-CmdResult CommandUserhost::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandUserhost::Handle (const std::vector<std::string>& parameters, User *user)
{
std::string retbuf = std::string("302 ") + user->nick + " :";
- for (int i = 0; i < pcnt; i++)
+ for (unsigned int i = 0; i < parameters.size(); i++)
{
User *u = ServerInstance->FindNick(parameters[i]);
diff --git a/src/commands/cmd_version.cpp b/src/commands/cmd_version.cpp
index 5c87ca8e4..1951417d7 100644
--- a/src/commands/cmd_version.cpp
+++ b/src/commands/cmd_version.cpp
@@ -21,7 +21,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandVersion(Instance);
}
-CmdResult CommandVersion::Handle (const char* const*, int, User *user)
+CmdResult CommandVersion::Handle (const std::vector<std::string>&, User *user)
{
user->WriteNumeric(351, "%s :%s",user->nick,ServerInstance->GetVersionString().c_str());
ServerInstance->Config->Send005(user);
diff --git a/src/commands/cmd_wallops.cpp b/src/commands/cmd_wallops.cpp
index cd8995ad8..849457b23 100644
--- a/src/commands/cmd_wallops.cpp
+++ b/src/commands/cmd_wallops.cpp
@@ -21,7 +21,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandWallops(Instance);
}
-CmdResult CommandWallops::Handle (const char* const* parameters, int, User *user)
+CmdResult CommandWallops::Handle (const std::vector<std::string>& parameters, User *user)
{
user->WriteWallOps(std::string(parameters[0]));
FOREACH_MOD(I_OnWallops,OnWallops(user,parameters[0]));
diff --git a/src/commands/cmd_who.cpp b/src/commands/cmd_who.cpp
index 2758f6b85..51590f143 100644
--- a/src/commands/cmd_who.cpp
+++ b/src/commands/cmd_who.cpp
@@ -165,7 +165,7 @@ void CommandWho::SendWhoLine(User* user, const std::string &initial, Channel* ch
whoresults.push_back(wholine);
}
-CmdResult CommandWho::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User *user)
{
/*
* XXX - RFC says:
@@ -191,13 +191,14 @@ CmdResult CommandWho::Handle (const char* const* parameters, int pcnt, User *use
std::vector<std::string> whoresults;
std::string initial = "352 " + std::string(user->nick) + " ";
- const char* matchtext = NULL;
+ char matchtext[MAXBUF];
bool usingwildcards = false;
/* Change '0' into '*' so the wildcard matcher can grok it */
- matchtext = parameters[0];
- if (!strcmp(matchtext,"0"))
- matchtext = "*";
+ if (parameters[0] == "0")
+ strlcpy(matchtext, "*", MAXBUF);
+ else
+ strlcpy(matchtext, parameters[0].c_str(), MAXBUF);
for (const char* check = matchtext; *check; check++)
{
@@ -208,10 +209,10 @@ CmdResult CommandWho::Handle (const char* const* parameters, int pcnt, User *use
}
}
- if (pcnt > 1)
+ if (parameters.size() > 1)
{
/* parse flags */
- const char *iter = parameters[1];
+ const char *iter = parameters[1].c_str();
/* Fix for bug #444, WHO flags count as a wildcard */
usingwildcards = true;
@@ -336,13 +337,13 @@ CmdResult CommandWho::Handle (const char* const* parameters, int pcnt, User *use
{
for (std::vector<std::string>::const_iterator n = whoresults.begin(); n != whoresults.end(); n++)
user->WriteServ(*n);
- user->WriteNumeric(315, "%s %s :End of /WHO list.",user->nick, *parameters[0] ? parameters[0] : "*");
+ user->WriteNumeric(315, "%s %s :End of /WHO list.",user->nick, *parameters[0].c_str() ? parameters[0].c_str() : "*");
return CMD_SUCCESS;
}
else
{
/* BZZT! Too many results. */
- user->WriteNumeric(315, "%s %s :Too many results",user->nick, parameters[0]);
+ user->WriteNumeric(315, "%s %s :Too many results",user->nick, parameters[0].c_str());
return CMD_FAILURE;
}
}
diff --git a/src/commands/cmd_whois.cpp b/src/commands/cmd_whois.cpp
index a10f170f1..263377b8f 100644
--- a/src/commands/cmd_whois.cpp
+++ b/src/commands/cmd_whois.cpp
@@ -103,13 +103,13 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandWhois(Instance);
}
-CmdResult CommandWhois::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandWhois::Handle (const std::vector<std::string>& parameters, User *user)
{
User *dest;
int userindex = 0;
unsigned long idle = 0, signon = 0;
- if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0))
+ if (ServerInstance->Parser->LoopCall(user, this, parameters, parameters.size(), 0))
return CMD_SUCCESS;
@@ -117,7 +117,7 @@ CmdResult CommandWhois::Handle (const char* const* parameters, int pcnt, User *u
* If 2 paramters are specified (/whois nick nick), ignore the first one like spanningtree
* does, and use the second one, otherwise, use the only paramter. -- djGrrr
*/
- if (pcnt > 1)
+ if (parameters.size() > 1)
userindex = 1;
if (IS_LOCAL(user))
@@ -130,24 +130,24 @@ CmdResult CommandWhois::Handle (const char* const* parameters, int pcnt, User *u
/*
* Okay. Umpteenth attempt at doing this, so let's re-comment...
* For local users (/w localuser), we show idletime if hidewhois is disabled
- * For local users (/w localuser localuser), we always show idletime, hence pcnt > 1 check.
+ * For local users (/w localuser localuser), we always show idletime, hence parameters.size() > 1 check.
* For remote users (/w remoteuser), we do NOT show idletime
* For remote users (/w remoteuser remoteuser), spanningtree will handle calling do_whois, so we can ignore this case.
* Thanks to djGrrr for not being impatient while I have a crap day coding. :p -- w00t
*/
- if (IS_LOCAL(dest) && (!*ServerInstance->Config->HideWhoisServer || pcnt > 1))
+ if (IS_LOCAL(dest) && (!*ServerInstance->Config->HideWhoisServer || parameters.size() > 1))
{
idle = abs((dest->idle_lastmsg)-ServerInstance->Time());
signon = dest->signon;
}
- do_whois(this->ServerInstance, user,dest,signon,idle,parameters[userindex]);
+ do_whois(this->ServerInstance, user,dest,signon,idle,parameters[userindex].c_str());
}
else
{
/* no such nick/channel */
- user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, *parameters[userindex] ? parameters[userindex] : "*");
- user->WriteNumeric(318, "%s %s :End of /WHOIS list.",user->nick, *parameters[userindex] ? parameters[userindex] : "*");
+ user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, !parameters[userindex].empty() ? parameters[userindex].c_str() : "*");
+ user->WriteNumeric(318, "%s %s :End of /WHOIS list.",user->nick, parameters[userindex].empty() ? parameters[userindex].c_str() : "*");
return CMD_FAILURE;
}
diff --git a/src/commands/cmd_whowas.cpp b/src/commands/cmd_whowas.cpp
index 485106e27..8bc188eee 100644
--- a/src/commands/cmd_whowas.cpp
+++ b/src/commands/cmd_whowas.cpp
@@ -28,7 +28,7 @@ CommandWhowas::CommandWhowas(InspIRCd* Instance) : Command(Instance, "WHOWAS", 0
Instance->Timers->AddTimer(timer);
}
-CmdResult CommandWhowas::Handle (const char* const* parameters, int, User* user)
+CmdResult CommandWhowas::Handle (const std::vector<std::string>& parameters, User* user)
{
/* if whowas disabled in config */
if (ServerInstance->Config->WhoWasGroupSize == 0 || ServerInstance->Config->WhoWasMaxGroups == 0)
@@ -37,12 +37,12 @@ CmdResult CommandWhowas::Handle (const char* const* parameters, int, User* user)
return CMD_FAILURE;
}
- whowas_users::iterator i = whowas.find(parameters[0]);
+ whowas_users::iterator i = whowas.find(assign(parameters[0]));
if (i == whowas.end())
{
- user->WriteNumeric(406, "%s %s :There was no such nickname",user->nick,parameters[0]);
- user->WriteNumeric(369, "%s %s :End of WHOWAS",user->nick,parameters[0]);
+ user->WriteNumeric(406, "%s %s :There was no such nickname",user->nick,parameters[0].c_str());
+ user->WriteNumeric(369, "%s %s :End of WHOWAS",user->nick,parameters[0].c_str());
return CMD_FAILURE;
}
else
@@ -63,26 +63,26 @@ CmdResult CommandWhowas::Handle (const char* const* parameters, int, User* user)
strlcpy(b,asctime(timeinfo),MAXBUF);
b[24] = 0;
- user->WriteNumeric(314, "%s %s %s %s * :%s",user->nick,parameters[0],u->ident,u->dhost,u->gecos);
+ user->WriteNumeric(314, "%s %s %s %s * :%s",user->nick,parameters[0].c_str(),u->ident,u->dhost,u->gecos);
if (IS_OPER(user))
- user->WriteNumeric(379, "%s %s :was connecting from *@%s", user->nick, parameters[0], u->host);
+ user->WriteNumeric(379, "%s %s :was connecting from *@%s", user->nick, parameters[0].c_str(), u->host);
if (*ServerInstance->Config->HideWhoisServer && !IS_OPER(user))
- user->WriteNumeric(312, "%s %s %s :%s",user->nick,parameters[0], ServerInstance->Config->HideWhoisServer, b);
+ user->WriteNumeric(312, "%s %s %s :%s",user->nick,parameters[0].c_str(), ServerInstance->Config->HideWhoisServer, b);
else
- user->WriteNumeric(312, "%s %s %s :%s",user->nick,parameters[0], u->server, b);
+ user->WriteNumeric(312, "%s %s %s :%s",user->nick,parameters[0].c_str(), u->server, b);
}
}
else
{
- user->WriteNumeric(406, "%s %s :There was no such nickname",user->nick,parameters[0]);
- user->WriteNumeric(369, "%s %s :End of WHOWAS",user->nick,parameters[0]);
+ user->WriteNumeric(406, "%s %s :There was no such nickname",user->nick,parameters[0].c_str());
+ user->WriteNumeric(369, "%s %s :End of WHOWAS",user->nick,parameters[0].c_str());
return CMD_FAILURE;
}
}
- user->WriteNumeric(369, "%s %s :End of WHOWAS",user->nick,parameters[0]);
+ user->WriteNumeric(369, "%s %s :End of WHOWAS",user->nick,parameters[0].c_str());
return CMD_SUCCESS;
}
diff --git a/src/commands/cmd_zline.cpp b/src/commands/cmd_zline.cpp
index c4bc750c7..c1951d447 100644
--- a/src/commands/cmd_zline.cpp
+++ b/src/commands/cmd_zline.cpp
@@ -22,15 +22,15 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
return new CommandZline(Instance);
}
-CmdResult CommandZline::Handle (const char* const* parameters, int pcnt, User *user)
+CmdResult CommandZline::Handle (const std::vector<std::string>& parameters, User *user)
{
std::string target = parameters[0];
- if (pcnt >= 3)
+ if (parameters.size() >= 3)
{
- if (strchr(target.c_str(),'@') || strchr(target.c_str(),'!'))
+ if (target.find('!') != std::string::npos)
{
- user->WriteServ("NOTICE %s :*** You cannot include a username or nickname in a zline, a zline must ban only an IP mask",user->nick);
+ user->WriteServ("NOTICE %s :*** You cannot include a nickname in a zline, a zline must ban only an IP mask",user->nick);
return CMD_FAILURE;
}
@@ -44,7 +44,7 @@ CmdResult CommandZline::Handle (const char* const* parameters, int pcnt, User *u
if (ServerInstance->IPMatchesEveryone(target.c_str(),user))
return CMD_FAILURE;
- long duration = ServerInstance->Duration(parameters[1]);
+ long duration = ServerInstance->Duration(parameters[1].c_str());
const char* ipaddr = target.c_str();
User* find = ServerInstance->FindNick(target.c_str());
@@ -62,7 +62,7 @@ CmdResult CommandZline::Handle (const char* const* parameters, int pcnt, User *u
ipaddr++;
}
}
- ZLine* zl = new ZLine(ServerInstance, ServerInstance->Time(), duration, user->nick, parameters[2], ipaddr);
+ ZLine* zl = new ZLine(ServerInstance, ServerInstance->Time(), duration, user->nick, parameters[2].c_str(), ipaddr);
if (ServerInstance->XLines->AddLine(zl,user))
{
if (!duration)
diff --git a/src/mode.cpp b/src/mode.cpp
index 8712e63b5..d73a5d1b8 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -354,7 +354,7 @@ void ModeParser::DisplayCurrentModes(User *user, User* targetuser, Channel* targ
return;
}
-void ModeParser::Process(const char* const* parameters, int pcnt, User *user, bool servermode)
+void ModeParser::Process(const std::vector<std::string>& parameters, User *user, bool servermode)
{
std::string target = parameters[0];
ModeType type = MODETYPE_USER;
@@ -367,9 +367,9 @@ void ModeParser::Process(const char* const* parameters, int pcnt, User *user, bo
/* Special case for displaying the list for listmodes,
* e.g. MODE #chan b, or MODE #chan +b without a parameter
*/
- if ((targetchannel) && (pcnt == 2))
+ if ((targetchannel) && (parameters.size() == 2))
{
- const char* mode = parameters[1];
+ const char* mode = parameters[1].c_str();
int nonlistmodes_found = 0;
seq++;
@@ -445,11 +445,11 @@ void ModeParser::Process(const char* const* parameters, int pcnt, User *user, bo
return;
}
- if (pcnt == 1)
+ if (parameters.size() == 1)
{
- this->DisplayCurrentModes(user, targetuser, targetchannel, parameters[0]);
+ this->DisplayCurrentModes(user, targetuser, targetchannel, parameters[0].c_str());
}
- else if (pcnt > 1)
+ else if (parameters.size() > 1)
{
bool SkipAccessChecks = false;
@@ -485,7 +485,7 @@ void ModeParser::Process(const char* const* parameters, int pcnt, User *user, bo
else
{
/* No such nick/channel */
- user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0]);
+ user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0].c_str());
return;
}
@@ -495,8 +495,8 @@ void ModeParser::Process(const char* const* parameters, int pcnt, User *user, bo
std::string output_sequence;
bool adding = true, state_change = false;
unsigned char handler_id = 0;
- int parameter_counter = 2; /* Index of first parameter */
- int parameter_count = 0;
+ unsigned int parameter_counter = 2; /* Index of first parameter */
+ unsigned int parameter_count = 0;
bool last_successful_state_change = false;
/* A mode sequence that doesnt start with + or -. Assume +. - Thanks for the suggestion spike (bug#132) */
@@ -559,7 +559,7 @@ void ModeParser::Process(const char* const* parameters, int pcnt, User *user, bo
if (modehandlers[handler_id]->GetNumParams(adding))
{
/* This mode expects a parameter, do we have any parameters left in our list to use? */
- if (parameter_counter < pcnt)
+ if (parameter_counter < parameters.size())
{
parameter = parameters[parameter_counter++];
@@ -1127,7 +1127,7 @@ bool ModeParser::DelModeWatcher(ModeWatcher* mw)
void ModeHandler::RemoveMode(User* user, irc::modestacker* stack)
{
char moderemove[MAXBUF];
- const char* parameters[] = { user->nick, moderemove };
+ std::vector<std::string> parameters;
if (user->IsModeSet(this->GetModeChar()))
{
@@ -1138,7 +1138,9 @@ void ModeHandler::RemoveMode(User* user, irc::modestacker* stack)
else
{
sprintf(moderemove,"-%c",this->GetModeChar());
- ServerInstance->Parser->CallHandler("MODE", parameters, 2, user);
+ parameters.push_back(user->nick);
+ parameters.push_back(moderemove);
+ ServerInstance->Parser->CallHandler("MODE", parameters, user);
}
}
}
@@ -1149,7 +1151,7 @@ void ModeHandler::RemoveMode(User* user, irc::modestacker* stack)
void ModeHandler::RemoveMode(Channel* channel, irc::modestacker* stack)
{
char moderemove[MAXBUF];
- const char* parameters[] = { channel->name, moderemove };
+ std::vector<std::string> parameters;
if (channel->IsModeSet(this->GetModeChar()))
{
@@ -1160,7 +1162,9 @@ void ModeHandler::RemoveMode(Channel* channel, irc::modestacker* stack)
else
{
sprintf(moderemove,"-%c",this->GetModeChar());
- ServerInstance->SendMode(parameters, 2, ServerInstance->FakeClient);
+ parameters.push_back(channel->name);
+ parameters.push_back(moderemove);
+ ServerInstance->SendMode(parameters, ServerInstance->FakeClient);
}
}
}
diff --git a/src/modes/cmode_b.cpp b/src/modes/cmode_b.cpp
index 4eea2e44d..d6495313a 100644
--- a/src/modes/cmode_b.cpp
+++ b/src/modes/cmode_b.cpp
@@ -52,7 +52,6 @@ ModeAction ModeChannelBan::OnModeChange(User* source, User*, Channel* channel, s
void ModeChannelBan::RemoveMode(Channel* channel, irc::modestacker* stack)
{
BanList copy;
- char moderemove[MAXBUF];
for (BanList::iterator i = channel->bans.begin(); i != channel->bans.end(); i++)
{
@@ -67,9 +66,8 @@ void ModeChannelBan::RemoveMode(Channel* channel, irc::modestacker* stack)
}
else
{
- sprintf(moderemove,"-%c",this->GetModeChar());
- const char* parameters[] = { channel->name, moderemove, i->data };
- ServerInstance->SendMode(parameters, 3, ServerInstance->FakeClient);
+ std::vector<std::string> parameters; parameters.push_back(channel->name); parameters.push_back("-b"); parameters.push_back(i->data);
+ ServerInstance->SendMode(parameters, ServerInstance->FakeClient);
}
}
}
diff --git a/src/modes/cmode_h.cpp b/src/modes/cmode_h.cpp
index 8217ccc2d..6dd941353 100644
--- a/src/modes/cmode_h.cpp
+++ b/src/modes/cmode_h.cpp
@@ -49,7 +49,6 @@ void ModeChannelHalfOp::RemoveMode(Channel* channel, irc::modestacker* stack)
{
CUList* clist = channel->GetHalfoppedUsers();
CUList copy;
- char moderemove[MAXBUF];
for (CUList::iterator i = clist->begin(); i != clist->end(); i++)
{
@@ -65,9 +64,8 @@ void ModeChannelHalfOp::RemoveMode(Channel* channel, irc::modestacker* stack)
}
else
{
- sprintf(moderemove,"-%c",this->GetModeChar());
- const char* parameters[] = { channel->name, moderemove, i->first->nick };
- ServerInstance->SendMode(parameters, 3, ServerInstance->FakeClient);
+ std::vector<std::string> parameters; parameters.push_back(channel->name); parameters.push_back("-h"); parameters.push_back(i->first->nick);
+ ServerInstance->SendMode(parameters, ServerInstance->FakeClient);
}
}
diff --git a/src/modes/cmode_k.cpp b/src/modes/cmode_k.cpp
index 194c0efcb..0ab35b954 100644
--- a/src/modes/cmode_k.cpp
+++ b/src/modes/cmode_k.cpp
@@ -38,8 +38,6 @@ void ModeChannelKey::RemoveMode(Channel* channel, irc::modestacker* stack)
/** +k needs a parameter when being removed,
* so we have a special-case RemoveMode here for it
*/
- char moderemove[MAXBUF];
- const char* parameters[] = { channel->name, moderemove, channel->key };
if (channel->IsModeSet(this->GetModeChar()))
{
@@ -47,8 +45,8 @@ void ModeChannelKey::RemoveMode(Channel* channel, irc::modestacker* stack)
stack->Push(this->GetModeChar(), channel->key);
else
{
- sprintf(moderemove,"-%c",this->GetModeChar());
- ServerInstance->SendMode(parameters, 3, ServerInstance->FakeClient);
+ std::vector<std::string> parameters; parameters.push_back(channel->name); parameters.push_back("-k"); parameters.push_back(channel->key);
+ ServerInstance->SendMode(parameters, ServerInstance->FakeClient);
}
}
}
diff --git a/src/modes/cmode_o.cpp b/src/modes/cmode_o.cpp
index 3105d64ae..0582dbee5 100644
--- a/src/modes/cmode_o.cpp
+++ b/src/modes/cmode_o.cpp
@@ -50,7 +50,6 @@ void ModeChannelOp::RemoveMode(Channel* channel, irc::modestacker* stack)
{
CUList* clist = channel->GetOppedUsers();
CUList copy;
- char moderemove[MAXBUF];
for (CUList::iterator i = clist->begin(); i != clist->end(); i++)
{
@@ -64,9 +63,8 @@ void ModeChannelOp::RemoveMode(Channel* channel, irc::modestacker* stack)
stack->Push(this->GetModeChar(), i->first->nick);
else
{
- sprintf(moderemove,"-%c",this->GetModeChar());
- const char* parameters[] = { channel->name, moderemove, i->first->nick };
- ServerInstance->SendMode(parameters, 3, ServerInstance->FakeClient);
+ std::vector<std::string> parameters; parameters.push_back(channel->name); parameters.push_back("-o"); parameters.push_back(i->first->nick);
+ ServerInstance->SendMode(parameters, ServerInstance->FakeClient);
}
}
}
diff --git a/src/modes/cmode_v.cpp b/src/modes/cmode_v.cpp
index 15196d4a8..8e13ba6f1 100644
--- a/src/modes/cmode_v.cpp
+++ b/src/modes/cmode_v.cpp
@@ -50,7 +50,6 @@ void ModeChannelVoice::RemoveMode(Channel* channel, irc::modestacker* stack)
{
CUList* clist = channel->GetVoicedUsers();
CUList copy;
- char moderemove[MAXBUF];
for (CUList::iterator i = clist->begin(); i != clist->end(); i++)
{
@@ -64,9 +63,8 @@ void ModeChannelVoice::RemoveMode(Channel* channel, irc::modestacker* stack)
stack->Push(this->GetModeChar(), i->first->nick);
else
{
- sprintf(moderemove,"-%c",this->GetModeChar());
- const char* parameters[] = { channel->name, moderemove, i->first->nick };
- ServerInstance->SendMode(parameters, 3, ServerInstance->FakeClient);
+ std::vector<std::string> parameters; parameters.push_back(channel->name); parameters.push_back("-v"); parameters.push_back(i->first->nick);
+ ServerInstance->SendMode(parameters, ServerInstance->FakeClient);
}
}
}
diff --git a/src/modes/umode_n.cpp b/src/modes/umode_n.cpp
index db386a32b..fe75fd222 100644
--- a/src/modes/umode_n.cpp
+++ b/src/modes/umode_n.cpp
@@ -38,8 +38,10 @@ ModeAction ModeUserServerNoticeMask::OnModeChange(User* source, User* dest, Chan
dest->modes[UM_SNOMASK] = true;
if (!dest->modes[UM_SERVERNOTICE])
{
- const char* newmodes[] = { dest->nick, "+s" };
- ServerInstance->Modes->Process(newmodes, 2, source, true);
+ std::vector<std::string> newmodes;
+ newmodes.push_back(dest->nick);
+ newmodes.push_back("+s");
+ ServerInstance->Modes->Process(newmodes, source, true);
}
return MODEACTION_ALLOW;
}
diff --git a/src/modules.cpp b/src/modules.cpp
index 617d5a0fa..b051085fd 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -132,8 +132,8 @@ int Module::OnKill(User*, User*, const std::string&) { return 0; }
void Module::OnLoadModule(Module*, const std::string&) { }
void Module::OnUnloadModule(Module*, const std::string&) { }
void Module::OnBackgroundTimer(time_t) { }
-int Module::OnPreCommand(const std::string&, const char* const*, int, User *, bool, const std::string&) { return 0; }
-void Module::OnPostCommand(const std::string&, const char* const*, int, User *, CmdResult, const std::string&) { }
+int Module::OnPreCommand(const std::string&, const std::vector<std::string>&, User *, bool, const std::string&) { return 0; }
+void Module::OnPostCommand(const std::string&, const std::vector<std::string>&, User *, CmdResult, const std::string&) { }
bool Module::OnCheckReady(User*) { return true; }
int Module::OnUserRegister(User*) { return 0; }
int Module::OnUserPreKick(User*, User*, Channel*, const std::string&) { return 0; }
@@ -718,9 +718,9 @@ bool InspIRCd::MatchText(const std::string &sliteral, const std::string &spatter
return match(sliteral.c_str(),spattern.c_str());
}
-CmdResult InspIRCd::CallCommandHandler(const std::string &commandname, const char* const* parameters, int pcnt, User* user)
+CmdResult InspIRCd::CallCommandHandler(const std::string &commandname, const std::vector<std::string>& parameters, User* user)
{
- return this->Parser->CallHandler(commandname,parameters,pcnt,user);
+ return this->Parser->CallHandler(commandname, parameters, user);
}
bool InspIRCd::IsValidModuleCommand(const std::string &commandname, int pcnt, User* user)
@@ -737,9 +737,9 @@ void InspIRCd::AddCommand(Command *f)
}
}
-void InspIRCd::SendMode(const char* const* parameters, int pcnt, User *user)
+void InspIRCd::SendMode(const std::vector<std::string>& parameters, User *user)
{
- this->Modes->Process(parameters,pcnt,user,true);
+ this->Modes->Process(parameters, user, true);
}
void InspIRCd::DumpText(User* User, const std::string &LinePrefix, std::stringstream &TextStream)
diff --git a/src/users.cpp b/src/users.cpp
index 70f90a0a9..d8ed553a7 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -789,8 +789,11 @@ void User::UnOper()
}
}
- const char* parameters[] = { this->nick, moderemove.c_str() };
- ServerInstance->Parser->CallHandler("MODE", parameters, 2, this);
+ std::vector<std::string> parameters;
+ parameters.push_back(this->nick);
+ parameters.push_back(moderemove);
+
+ ServerInstance->Parser->CallHandler("MODE", parameters, this);
/* unset their oper type (what IS_OPER checks), and remove +o */
*this->oper = 0;
@@ -921,9 +924,9 @@ void User::FullConnect()
/* Trigger LUSERS output, give modules a chance too */
int MOD_RESULT = 0;
- FOREACH_RESULT(I_OnPreCommand, OnPreCommand("LUSERS", NULL, 0, this, true, "LUSERS"));
+ FOREACH_RESULT(I_OnPreCommand, OnPreCommand("LUSERS", std::vector<std::string>(), this, true, "LUSERS"));
if (!MOD_RESULT)
- ServerInstance->CallCommandHandler("LUSERS", NULL, 0, this);
+ ServerInstance->CallCommandHandler("LUSERS", std::vector<std::string>(), this);
/*
* We don't set REG_ALL until triggering OnUserConnect, so some module events don't spew out stuff
@@ -993,8 +996,10 @@ bool User::ForceNickChange(const char* newnick)
Command* nickhandler = ServerInstance->Parser->GetHandler("NICK");
if (nickhandler) // wtfbbq, when would this not be here
{
+ std::vector<std::string> parameters;
nickhandler->HandleInternal(1, dummy);
- bool result = (ServerInstance->Parser->CallHandler("NICK", &newnick, 1, this) == CMD_SUCCESS);
+ parameters.push_back(newnick);
+ bool result = (ServerInstance->Parser->CallHandler("NICK", parameters, this) == CMD_SUCCESS);
nickhandler->HandleInternal(0, dummy);
return result;
}