- /* +------------------------------------+
+/* +------------------------------------+
* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
*
/** Refactored by Brain, Jun 2007. Much faster with some clever O(1) array
* lookups and pointer maths.
*/
-long InspIRCd::Duration(const char* str)
+long InspIRCd::Duration(const std::string &str)
{
unsigned char multiplier = 0;
long total = 0;
long subtotal = 0;
/* Iterate each item in the string, looking for number or multiplier */
- for (const char* i = str + strlen(str) - 1; i >= str; --i)
+ for (std::string::const_reverse_iterator i = str.rbegin(); i != str.rend(); ++i)
{
/* Found a number, queue it onto the current number */
if ((*i >= '0') && (*i <= '9'))
*/
irc::commasepstream items1(parameters[splithere]);
irc::commasepstream items2(parameters[extra]);
- std::string item = "*";
+ std::string item("*");
unsigned int max = 0;
/* Attempt to iterate these lists and call the command objech
{
if (dupes.find(item.c_str()) == dupes.end())
{
- const char* new_parameters[127];
+ const char* new_parameters[MAXPARAMETERS];
- for (int t = 0; (t < pcnt) && (t < 127); t++)
+ for (int t = 0; (t < pcnt) && (t < MAXPARAMETERS); t++)
new_parameters[t] = parameters[t];
std::string extrastuff = items2.GetToken();
/* Only one commasepstream here */
irc::commasepstream items1(parameters[splithere]);
- std::string item = "*";
+ std::string item("*");
unsigned int max = 0;
/* Parse the commasepstream until there are no tokens remaining.
{
if (dupes.find(item.c_str()) == dupes.end())
{
- const char* new_parameters[127];
+ const char* new_parameters[MAXPARAMETERS];
- for (int t = 0; (t < pcnt) && (t < 127); t++)
+ for (int t = 0; (t < pcnt) && (t < MAXPARAMETERS); t++)
new_parameters[t] = parameters[t];
new_parameters[splithere] = item.c_str();
{
if ((pcnt>=n->second->min_params) && (n->second->source != "<core>"))
{
- if ((!n->second->flags_needed) || (user->modes[n->second->flags_needed-65]))
+ if ((!n->second->flags_needed) || (user->IsModeSet(n->second->flags_needed)))
{
if (n->second->flags_needed)
{
{
if (pcnt >= n->second->min_params)
{
- if ((!n->second->flags_needed) || (user->modes[n->second->flags_needed-65]))
+ if ((!n->second->flags_needed) || (user->IsModeSet(n->second->flags_needed)))
{
if (n->second->flags_needed)
{
void CommandParser::ProcessCommand(userrec *user, std::string &cmd)
{
- const char *command_p[127];
+ const char *command_p[MAXPARAMETERS];
int items = 0;
irc::tokenstream tokens(cmd);
std::string command;
if (*command.c_str() == ':')
tokens.GetToken(command);
- while (tokens.GetToken(para[items]) && (items < 127))
+ while (tokens.GetToken(para[items]) && (items < MAXPARAMETERS))
{
command_p[items] = para[items].c_str();
items++;
if (items < cm->second->min_params)
{
user->WriteServ("461 %s %s :Not enough parameters.", user->nick, command.c_str());
- /* If syntax is given, display this as the 461 reply */
if ((ServerInstance->Config->SyntaxHints) && (user->registered == REG_ALL) && (cm->second->syntax.length()))
user->WriteServ("304 %s :SYNTAX %s %s", user->nick, cm->second->command.c_str(), cm->second->syntax.c_str());
return;
return;
/*
- * WARNING: nothing may come after the
- * command handler call, as the handler
- * may free the user structure!
+ * WARNING: nothing should come after this, as the user may be on a cull list to
+ * be nuked next loop iteration. be sensible.
*/
CmdResult result = cm->second->Handle(command_p,items,user);
if (x->source == std::string(source))
{
cmdlist.erase(safei);
+ delete x;
}
}