* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
*
- * InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * InspIRCd: (C) 2002-2009 InspIRCd Development Team
* See: http://www.inspircd.org/wiki/index.php/Credits
*
* This program is free but copyrighted software; see
Instance->Timers->AddTimer(timer);
}
-CmdResult CommandWhowas::Handle (const char** 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)
{
- user->WriteServ("421 %s %s :This command has been disabled.",user->nick,command.c_str());
+ user->WriteNumeric(421, "%s %s :This command has been disabled.",user->nick.c_str(),command.c_str());
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->WriteServ("406 %s %s :There was no such nickname",user->nick,parameters[0]);
- user->WriteServ("369 %s %s :End of WHOWAS",user->nick,parameters[0]);
+ user->WriteNumeric(406, "%s %s :There was no such nickname",user->nick.c_str(),parameters[0].c_str());
+ user->WriteNumeric(369, "%s %s :End of WHOWAS",user->nick.c_str(),parameters[0].c_str());
return CMD_FAILURE;
}
else
strlcpy(b,asctime(timeinfo),MAXBUF);
b[24] = 0;
- user->WriteServ("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.c_str(),parameters[0].c_str(),u->ident,u->dhost,u->gecos);
- if (IS_OPER(user))
- user->WriteServ("379 %s %s :was connecting from *@%s", user->nick, parameters[0], u->host);
+ if (user->HasPrivPermission("users/auspex"))
+ user->WriteNumeric(379, "%s %s :was connecting from *@%s", user->nick.c_str(), parameters[0].c_str(), u->host);
- if (*ServerInstance->Config->HideWhoisServer && !IS_OPER(user))
- user->WriteServ("312 %s %s %s :%s",user->nick,parameters[0], ServerInstance->Config->HideWhoisServer, b);
+ if (*ServerInstance->Config->HideWhoisServer && !user->HasPrivPermission("servers/auspex"))
+ user->WriteNumeric(312, "%s %s %s :%s",user->nick.c_str(),parameters[0].c_str(), ServerInstance->Config->HideWhoisServer, b);
else
- user->WriteServ("312 %s %s %s :%s",user->nick,parameters[0], u->server, b);
+ user->WriteNumeric(312, "%s %s %s :%s",user->nick.c_str(),parameters[0].c_str(), u->server, b);
}
}
else
{
- user->WriteServ("406 %s %s :There was no such nickname",user->nick,parameters[0]);
- user->WriteServ("369 %s %s :End of WHOWAS",user->nick,parameters[0]);
+ user->WriteNumeric(406, "%s %s :There was no such nickname",user->nick.c_str(),parameters[0].c_str());
+ user->WriteNumeric(369, "%s %s :End of WHOWAS",user->nick.c_str(),parameters[0].c_str());
return CMD_FAILURE;
}
}
- user->WriteServ("369 %s %s :End of WHOWAS",user->nick,parameters[0]);
+ user->WriteNumeric(369, "%s %s :End of WHOWAS",user->nick.c_str(),parameters[0].c_str());
return CMD_SUCCESS;
}
return;
}
- whowas_users::iterator iter = whowas.find(user->nick);
+ whowas_users::iterator iter = whowas.find(irc::string(user->nick.c_str()));
if (iter == whowas.end())
{
whowas_set* n = new whowas_set;
WhoWasGroup *a = new WhoWasGroup(user);
n->push_back(a);
- whowas[user->nick] = n;
- whowas_fifo.push_back(std::make_pair(ServerInstance->Time(),user->nick));
+ whowas[user->nick.c_str()] = n;
+ whowas_fifo.push_back(std::make_pair(ServerInstance->Time(),user->nick.c_str()));
if ((int)(whowas.size()) > ServerInstance->Config->WhoWasMaxGroups)
{
- whowas_users::iterator iter = whowas.find(whowas_fifo[0].second);
- if (iter != whowas.end())
+ whowas_users::iterator iter2 = whowas.find(whowas_fifo[0].second);
+ if (iter2 != whowas.end())
{
- whowas_set* n = (whowas_set*)iter->second;
+ whowas_set* n2 = (whowas_set*)iter2->second;
- if (n->size())
+ if (n2->size())
{
- while (n->begin() != n->end())
+ while (n2->begin() != n2->end())
{
- WhoWasGroup *a = *(n->begin());
- delete a;
- n->pop_front();
+ WhoWasGroup *a2 = *(n2->begin());
+ delete a2;
+ n2->pop_front();
}
}
- delete n;
- whowas.erase(iter);
+ delete n2;
+ whowas.erase(iter2);
}
whowas_fifo.pop_front();
}
if ((int)(group->size()) > ServerInstance->Config->WhoWasGroupSize)
{
- WhoWasGroup *a = (WhoWasGroup*)*(group->begin());
- delete a;
+ WhoWasGroup *a2 = (WhoWasGroup*)*(group->begin());
+ delete a2;
group->pop_front();
}
}
if (iter == whowas.end())
{
/* this should never happen, if it does maps are corrupt */
- ServerInstance->Log(DEFAULT, "BUG: Whowas maps got corrupted! (1)");
+ ServerInstance->Logs->Log("WHOWAS",DEFAULT, "BUG: Whowas maps got corrupted! (1)");
return;
}
if (iter == whowas.end())
{
/* this should never happen, if it does maps are corrupt */
- ServerInstance->Log(DEFAULT, "BUG: Whowas maps got corrupted! (2)");
+ ServerInstance->Logs->Log("WHOWAS",DEFAULT, "BUG: Whowas maps got corrupted! (2)");
return;
}
whowas_set* n = (whowas_set*)iter->second;
if (iter == whowas.end())
{
/* this should never happen, if it does maps are corrupt */
- ServerInstance->Log(DEFAULT, "BUG: Whowas maps got corrupted! (3)");
+ ServerInstance->Logs->Log("WHOWAS",DEFAULT, "BUG: Whowas maps got corrupted! (3)");
return;
}
WhoWasGroup::WhoWasGroup(User* user) : host(NULL), dhost(NULL), ident(NULL), server(NULL), gecos(NULL), signon(user->signon)
{
- this->host = strdup(user->host);
- this->dhost = strdup(user->dhost);
- this->ident = strdup(user->ident);
+ this->host = strdup(user->host.c_str());
+ this->dhost = strdup(user->dhost.c_str());
+ this->ident = strdup(user->ident.c_str());
this->server = user->server;
- this->gecos = strdup(user->fullname);
+ this->gecos = strdup(user->fullname.c_str());
}
WhoWasGroup::~WhoWasGroup()