summaryrefslogtreecommitdiff
path: root/src/users.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-08 16:07:25 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-08 16:07:25 +0000
commitc18d1040a312b36335783e742c8ec66be246d6ab (patch)
tree9b3b07d08a14b53c6779d643dca3e7c4509dd7ff /src/users.cpp
parent4f1d3a7192ea1b081b47f2ca1899aa25061b270d (diff)
Move whowas stuff into its own namespace, move more stuff into userrec
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4795 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/users.cpp')
-rw-r--r--src/users.cpp95
1 files changed, 51 insertions, 44 deletions
diff --git a/src/users.cpp b/src/users.cpp
index dabbc870f..3ecedaf58 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -46,7 +46,7 @@ extern ServerConfig *Config;
extern user_hash clientlist;
extern Server* MyServer;
-whowas_users whowas;
+irc::whowas::whowas_users whowas;
extern std::vector<userrec*> local_users;
@@ -725,75 +725,82 @@ void userrec::QuitUser(userrec *user,const std::string &quitreason)
}
}
-WhoWasGroup::WhoWasGroup(userrec* user) : host(NULL), dhost(NULL), ident(NULL), server(NULL), gecos(NULL), signon(user->signon)
+namespace irc
{
- this->host = strdup(user->host);
- this->dhost = strdup(user->dhost);
- this->ident = strdup(user->ident);
- this->server = user->server;
- this->gecos = strdup(user->fullname);
-}
+ namespace whowas
+ {
-WhoWasGroup::~WhoWasGroup()
-{
- if (host)
- free(host);
- if (dhost)
- free(dhost);
- if (ident)
- free(ident);
- if (gecos)
- free(gecos);
-}
+ WhoWasGroup::WhoWasGroup(userrec* 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->server = user->server;
+ this->gecos = strdup(user->fullname);
+ }
+
+ WhoWasGroup::~WhoWasGroup()
+ {
+ if (host)
+ free(host);
+ if (dhost)
+ free(dhost);
+ if (ident)
+ free(ident);
+ if (gecos)
+ free(gecos);
+ }
+
+ /* every hour, run this function which removes all entries over 3 days */
+ void MaintainWhoWas(time_t TIME)
+ {
+ for (whowas_users::iterator iter = ::whowas.begin(); iter != ::whowas.end(); iter++)
+ {
+ whowas_set* n = (whowas_set*)iter->second;
+ if (n->size())
+ {
+ while ((n->begin() != n->end()) && ((*n->begin())->signon < TIME - 259200)) // 3 days
+ {
+ WhoWasGroup *a = *(n->begin());
+ DELETE(a);
+ n->erase(n->begin());
+ }
+ }
+ }
+ }
+ };
+};
/* adds or updates an entry in the whowas list */
void userrec::AddToWhoWas()
{
- whowas_users::iterator iter = whowas.find(this->nick);
+ irc::whowas::whowas_users::iterator iter = whowas.find(this->nick);
if (iter == whowas.end())
{
- whowas_set* n = new whowas_set;
- WhoWasGroup *a = new WhoWasGroup(this);
+ irc::whowas::whowas_set* n = new irc::whowas::whowas_set;
+ irc::whowas::WhoWasGroup *a = new irc::whowas::WhoWasGroup(this);
n->push_back(a);
whowas[this->nick] = n;
}
else
{
- whowas_set* group = (whowas_set*)iter->second;
+ irc::whowas::whowas_set* group = (irc::whowas::whowas_set*)iter->second;
if (group->size() > 10)
{
- WhoWasGroup *a = (WhoWasGroup*)*(group->begin());
+ irc::whowas::WhoWasGroup *a = (irc::whowas::WhoWasGroup*)*(group->begin());
DELETE(a);
group->pop_front();
}
- WhoWasGroup *a = new WhoWasGroup(this);
+ irc::whowas::WhoWasGroup *a = new irc::whowas::WhoWasGroup(this);
group->push_back(a);
}
}
-/* every hour, run this function which removes all entries over 3 days */
-void MaintainWhoWas(time_t TIME)
-{
- for (whowas_users::iterator iter = whowas.begin(); iter != whowas.end(); iter++)
- {
- whowas_set* n = (whowas_set*)iter->second;
- if (n->size())
- {
- while ((n->begin() != n->end()) && ((*n->begin())->signon < TIME - 259200)) // 3 days
- {
- WhoWasGroup *a = *(n->begin());
- DELETE(a);
- n->erase(n->begin());
- }
- }
- }
-}
-
/* add a client connection to the sockets list */
-void AddClient(int socket, int port, bool iscached, insp_inaddr ip)
+void userrec::AddClient(int socket, int port, bool iscached, insp_inaddr ip)
{
std::string tempnick = ConvToStr(socket) + "-unknown";
user_hash::iterator iter = clientlist.find(tempnick);