summaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/cmd_whowas.cpp10
-rw-r--r--src/inspircd.cpp4
-rw-r--r--src/users.cpp95
3 files changed, 58 insertions, 51 deletions
diff --git a/src/cmd_whowas.cpp b/src/cmd_whowas.cpp
index 9d93517fe..ae3bdb953 100644
--- a/src/cmd_whowas.cpp
+++ b/src/cmd_whowas.cpp
@@ -22,11 +22,11 @@
#include "commands/cmd_whowas.h"
extern ServerConfig* Config;
-extern whowas_users whowas;
+extern irc::whowas::whowas_users whowas;
void cmd_whowas::Handle (const char** parameters, int pcnt, userrec* user)
{
- whowas_users::iterator i = whowas.find(parameters[0]);
+ irc::whowas::whowas_users::iterator i = whowas.find(parameters[0]);
if (i == whowas.end())
{
@@ -34,12 +34,12 @@ void cmd_whowas::Handle (const char** parameters, int pcnt, userrec* user)
}
else
{
- whowas_set* grp = i->second;
+ irc::whowas::whowas_set* grp = i->second;
if (grp->size())
{
- for (whowas_set::iterator ux = grp->begin(); ux != grp->end(); ux++)
+ for (irc::whowas::whowas_set::iterator ux = grp->begin(); ux != grp->end(); ux++)
{
- WhoWasGroup* u = *ux;
+ irc::whowas::WhoWasGroup* u = *ux;
time_t rawtime = u->signon;
tm *timeinfo;
char b[MAXBUF];
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 27029a6e4..a9d4cfb19 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -746,7 +746,7 @@ void InspIRCd::DoOneIteration(bool process_module_sockets)
WriteOpers("*** \002EH?!\002 -- Time is flowing BACKWARDS in this dimension! Clock drifted backwards %d secs.",abs(OLDTIME-TIME));
if ((TIME % 3600) == 0)
{
- MaintainWhoWas(TIME);
+ irc::whowas::MaintainWhoWas(TIME);
}
}
@@ -879,7 +879,7 @@ void InspIRCd::DoOneIteration(bool process_module_sockets)
AddClient(incomingSockfd, in_port, false, client.sin6_addr);
#else
log(DEBUG,"Add ipv4 client");
- AddClient(incomingSockfd, in_port, false, client.sin_addr);
+ userrec::AddClient(incomingSockfd, in_port, false, client.sin_addr);
#endif
log(DEBUG,"Adding client on port %d fd=%d",in_port,incomingSockfd);
}
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);