diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-03-07 19:11:50 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-03-07 19:11:50 +0000 |
commit | 1e639377cbad496a0b5f7d969a88fb808508f811 (patch) | |
tree | 7369e1f51e3781e6e24e15463cdd88f00bdf033c /src | |
parent | 8dc8387e8cfb253029cf11ae2df252517da5d073 (diff) |
Whowas refactor - probably wont compile yet
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3523 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd_kline.cpp | 2 | ||||
-rw-r--r-- | src/cmd_map.cpp | 29 | ||||
-rw-r--r-- | src/cmd_modules.cpp | 2 | ||||
-rw-r--r-- | src/cmd_motd.cpp | 1 | ||||
-rw-r--r-- | src/cmd_names.cpp | 1 | ||||
-rw-r--r-- | src/cmd_nick.cpp | 1 | ||||
-rw-r--r-- | src/cmd_notice.cpp | 1 | ||||
-rw-r--r-- | src/cmd_oper.cpp | 1 | ||||
-rw-r--r-- | src/cmd_part.cpp | 1 | ||||
-rw-r--r-- | src/cmd_pass.cpp | 1 | ||||
-rw-r--r-- | src/cmd_ping.cpp | 1 | ||||
-rw-r--r-- | src/cmd_pong.cpp | 1 | ||||
-rw-r--r-- | src/cmd_privmsg.cpp | 1 | ||||
-rw-r--r-- | src/cmd_quit.cpp | 1 | ||||
-rw-r--r-- | src/cmd_rehash.cpp | 1 | ||||
-rw-r--r-- | src/cmd_restart.cpp | 1 | ||||
-rw-r--r-- | src/cmd_rules.cpp | 1 | ||||
-rw-r--r-- | src/cmd_server.cpp | 1 | ||||
-rw-r--r-- | src/cmd_squit.cpp | 1 | ||||
-rw-r--r-- | src/cmd_stats.cpp | 1 | ||||
-rw-r--r-- | src/cmd_time.cpp | 1 | ||||
-rw-r--r-- | src/cmd_topic.cpp | 1 | ||||
-rw-r--r-- | src/cmd_trace.cpp | 1 | ||||
-rw-r--r-- | src/cmd_user.cpp | 1 | ||||
-rw-r--r-- | src/cmd_userhost.cpp | 1 | ||||
-rw-r--r-- | src/cmd_who.cpp | 1 | ||||
-rw-r--r-- | src/cmd_whois.cpp | 1 | ||||
-rw-r--r-- | src/cmd_whowas.cpp | 40 | ||||
-rw-r--r-- | src/commands.cpp | 1 | ||||
-rw-r--r-- | src/inspircd.cpp | 2 | ||||
-rw-r--r-- | src/users.cpp | 109 |
31 files changed, 87 insertions, 122 deletions
diff --git a/src/cmd_kline.cpp b/src/cmd_kline.cpp index dadd2f487..370c3a45f 100644 --- a/src/cmd_kline.cpp +++ b/src/cmd_kline.cpp @@ -57,7 +57,7 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; + extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_map.cpp b/src/cmd_map.cpp index 458c6dd37..5949420aa 100644 --- a/src/cmd_map.cpp +++ b/src/cmd_map.cpp @@ -19,48 +19,19 @@ using namespace std; #include "inspircd_config.h" #include "inspircd.h" #include "inspircd_io.h" -#include <time.h> -#include <string> -#ifdef GCC3 -#include <ext/hash_map> -#else -#include <hash_map> -#endif -#include <map> -#include <sstream> -#include <vector> -#include <deque> #include "users.h" #include "ctables.h" #include "globals.h" #include "modules.h" -#include "dynamic.h" -#include "wildcard.h" #include "message.h" #include "commands.h" -#include "mode.h" -#include "xline.h" -#include "inspstring.h" -#include "dnsqueue.h" #include "helperfuncs.h" #include "hashcomp.h" -#include "socketengine.h" #include "typedefs.h" #include "command_parse.h" #include "cmd_map.h" extern ServerConfig* Config; -extern InspIRCd* ServerInstance; -extern int MODCOUNT; -extern std::vector<Module*> modules; -extern std::vector<ircd_module*> factory; -extern time_t TIME; -extern user_hash clientlist; -extern chan_hash chanlist; -extern whowas_hash whowas; -extern std::vector<userrec*> all_opers; -extern std::vector<userrec*> local_users; -extern userrec* fd_ref_table[MAX_DESCRIPTORS]; void cmd_map::Handle (char **parameters, int pcnt, userrec *user) { diff --git a/src/cmd_modules.cpp b/src/cmd_modules.cpp index 0a7108267..0e5b12672 100644 --- a/src/cmd_modules.cpp +++ b/src/cmd_modules.cpp @@ -57,7 +57,7 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; + extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_motd.cpp b/src/cmd_motd.cpp index d8fce0396..ff9b37e02 100644 --- a/src/cmd_motd.cpp +++ b/src/cmd_motd.cpp @@ -57,7 +57,6 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_names.cpp b/src/cmd_names.cpp index e2effdcf6..bc1eb69c7 100644 --- a/src/cmd_names.cpp +++ b/src/cmd_names.cpp @@ -57,7 +57,6 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_nick.cpp b/src/cmd_nick.cpp index 3f6085362..26a603867 100644 --- a/src/cmd_nick.cpp +++ b/src/cmd_nick.cpp @@ -58,7 +58,6 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_notice.cpp b/src/cmd_notice.cpp index fe7fea5ca..6dcab9553 100644 --- a/src/cmd_notice.cpp +++ b/src/cmd_notice.cpp @@ -57,7 +57,6 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_oper.cpp b/src/cmd_oper.cpp index 7cbf4b79f..0c0026121 100644 --- a/src/cmd_oper.cpp +++ b/src/cmd_oper.cpp @@ -57,7 +57,6 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_part.cpp b/src/cmd_part.cpp index 6cb5a26df..668506fc3 100644 --- a/src/cmd_part.cpp +++ b/src/cmd_part.cpp @@ -57,7 +57,6 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_pass.cpp b/src/cmd_pass.cpp index 663215281..18fc18a99 100644 --- a/src/cmd_pass.cpp +++ b/src/cmd_pass.cpp @@ -57,7 +57,6 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_ping.cpp b/src/cmd_ping.cpp index f0a937e39..ee43c0cb8 100644 --- a/src/cmd_ping.cpp +++ b/src/cmd_ping.cpp @@ -57,7 +57,6 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_pong.cpp b/src/cmd_pong.cpp index d70ebfe04..0b357562d 100644 --- a/src/cmd_pong.cpp +++ b/src/cmd_pong.cpp @@ -57,7 +57,6 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_privmsg.cpp b/src/cmd_privmsg.cpp index 35707d5a3..41999a4ec 100644 --- a/src/cmd_privmsg.cpp +++ b/src/cmd_privmsg.cpp @@ -57,7 +57,6 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_quit.cpp b/src/cmd_quit.cpp index 50166ffd9..dd36de9b3 100644 --- a/src/cmd_quit.cpp +++ b/src/cmd_quit.cpp @@ -57,7 +57,6 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_rehash.cpp b/src/cmd_rehash.cpp index ac42cdaa7..421ad9b13 100644 --- a/src/cmd_rehash.cpp +++ b/src/cmd_rehash.cpp @@ -57,7 +57,6 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_restart.cpp b/src/cmd_restart.cpp index 0d723ead9..c16570a74 100644 --- a/src/cmd_restart.cpp +++ b/src/cmd_restart.cpp @@ -57,7 +57,6 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_rules.cpp b/src/cmd_rules.cpp index 62e897147..f62d0b16b 100644 --- a/src/cmd_rules.cpp +++ b/src/cmd_rules.cpp @@ -57,7 +57,6 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_server.cpp b/src/cmd_server.cpp index 297e4dba9..691a6db24 100644 --- a/src/cmd_server.cpp +++ b/src/cmd_server.cpp @@ -57,7 +57,6 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_squit.cpp b/src/cmd_squit.cpp index 6726de534..2546614b5 100644 --- a/src/cmd_squit.cpp +++ b/src/cmd_squit.cpp @@ -57,7 +57,6 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_stats.cpp b/src/cmd_stats.cpp index f6ab7d996..bf34edd62 100644 --- a/src/cmd_stats.cpp +++ b/src/cmd_stats.cpp @@ -67,7 +67,6 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_time.cpp b/src/cmd_time.cpp index 054e469fa..214592ea8 100644 --- a/src/cmd_time.cpp +++ b/src/cmd_time.cpp @@ -57,7 +57,6 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_topic.cpp b/src/cmd_topic.cpp index cb852dabc..e1e77bf58 100644 --- a/src/cmd_topic.cpp +++ b/src/cmd_topic.cpp @@ -57,7 +57,6 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_trace.cpp b/src/cmd_trace.cpp index 242ff7586..37b711bf7 100644 --- a/src/cmd_trace.cpp +++ b/src/cmd_trace.cpp @@ -57,7 +57,6 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_user.cpp b/src/cmd_user.cpp index 7c4f6ae92..d088a80f0 100644 --- a/src/cmd_user.cpp +++ b/src/cmd_user.cpp @@ -57,7 +57,6 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_userhost.cpp b/src/cmd_userhost.cpp index aa4d3de3e..4fe9eb1b4 100644 --- a/src/cmd_userhost.cpp +++ b/src/cmd_userhost.cpp @@ -57,7 +57,6 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_who.cpp b/src/cmd_who.cpp index d2cc05332..d82b7906f 100644 --- a/src/cmd_who.cpp +++ b/src/cmd_who.cpp @@ -57,7 +57,6 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_whois.cpp b/src/cmd_whois.cpp index c2072eaea..f15bce87e 100644 --- a/src/cmd_whois.cpp +++ b/src/cmd_whois.cpp @@ -57,7 +57,6 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; diff --git a/src/cmd_whowas.cpp b/src/cmd_whowas.cpp index 19898bdea..b2b3dcc58 100644 --- a/src/cmd_whowas.cpp +++ b/src/cmd_whowas.cpp @@ -57,35 +57,45 @@ extern std::vector<ircd_module*> factory; extern time_t TIME; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; +extern whowas_users whowas; + void cmd_whowas::Handle (char **parameters, int pcnt, userrec* user) { - whowas_hash::iterator i = whowas.find(parameters[0]); + whowas_users::iterator i = whowas.find(parameters[0]); if (i == whowas.end()) { WriteServ(user->fd,"406 %s %s :There was no such nickname",user->nick,parameters[0]); - WriteServ(user->fd,"369 %s %s :End of WHOWAS",user->nick,parameters[0]); } else { - time_t rawtime = i->second->signon; - tm *timeinfo; - char b[MAXBUF]; - - timeinfo = localtime(&rawtime); - strlcpy(b,asctime(timeinfo),MAXBUF); - b[24] = 0; + whowas_group* grp = (whowas_group*)i; + if (grp->size()) + { + for (whowas_group::iterator u = grp->begin(); u != grp->end(); u++) + { + time_t rawtime = u->signon; + tm *timeinfo; + char b[MAXBUF]; + + timeinfo = localtime(&rawtime); + strlcpy(b,asctime(timeinfo),MAXBUF); + b[24] = 0; - WriteServ(user->fd,"314 %s %s %s %s * :%s",user->nick,i->second->nick,i->second->ident,i->second->dhost,i->second->fullname); - WriteServ(user->fd,"312 %s %s %s :%s",user->nick,i->second->nick, *Config->HideWhoisServer ? Config->HideWhoisServer : i->second->server,b); - WriteServ(user->fd,"369 %s %s :End of WHOWAS",user->nick,parameters[0]); + WriteServ(user->fd,"314 %s %s %s %s * :%s",user->nick,parameters[0],u->ident,u->dhost,u->gecos); + WriteServ(user->fd,"312 %s %s %s :%s",user->nick,parameters[0], *Config->HideWhoisServer ? Config->HideWhoisServer : u->server,b); + WriteServ(user->fd,"369 %s %s :End of WHOWAS",user->nick,parameters[0]); + } + } + else + { + WriteServ(user->fd,"406 %s %s :There was no such nickname",user->nick,parameters[0]); + } } - + WriteServ(user->fd,"369 %s %s :End of WHOWAS",user->nick,parameters[0]); } - diff --git a/src/commands.cpp b/src/commands.cpp index 9bf4883f9..f60b85f67 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -79,7 +79,6 @@ const long duration_y = duration_w * 52; extern user_hash clientlist; extern chan_hash chanlist; -extern whowas_hash whowas; extern std::vector<userrec*> all_opers; extern std::vector<userrec*> local_users; diff --git a/src/inspircd.cpp b/src/inspircd.cpp index eae26c64e..58c833902 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -90,7 +90,7 @@ ServerConfig *Config = new ServerConfig; user_hash clientlist; chan_hash chanlist; -whowas_hash whowas; + servernamelist servernames; char lowermap[255]; diff --git a/src/users.cpp b/src/users.cpp index 516c58e70..a50787a17 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -49,7 +49,9 @@ extern time_t TIME; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; extern ServerConfig *Config; extern user_hash clientlist; -extern whowas_hash whowas; + +whowas_users whowas; + extern std::vector<userrec*> local_users; std::vector<userrec*> all_opers; @@ -479,58 +481,65 @@ void kill_link(userrec *user,const char* r) delete user; } +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); +} + /* adds or updates an entry in the whowas list */ void AddWhoWas(userrec* u) { - whowas_hash::iterator iter = whowas.find(u->nick); - WhoWasUser *a = new WhoWasUser(); - strlcpy(a->nick,u->nick,NICKMAX-1); - strlcpy(a->ident,u->ident,IDENTMAX); - strlcpy(a->dhost,u->dhost,63); - strlcpy(a->host,u->host,63); - strlcpy(a->fullname,u->fullname,MAXGECOS); - if (u->server) - strlcpy(a->server,u->server,256); - a->signon = u->signon; - - /* MAX_WHOWAS: max number of /WHOWAS items - * WHOWAS_STALE: number of hours before a WHOWAS item is marked as stale and - * can be replaced by a newer one - */ - - if (iter == whowas.end()) - { - if (whowas.size() >= (unsigned)WHOWAS_MAX) - { - for (whowas_hash::iterator i = whowas.begin(); i != whowas.end(); i++) - { - // 3600 seconds in an hour ;) - if ((i->second->signon)<(TIME-(WHOWAS_STALE*3600))) - { - // delete an old one - if (i->second) delete i->second; - whowas.erase(i); - // replace with new one - whowas[a->nick] = a; - log(DEBUG,"added WHOWAS entry, purged an old record"); - return; - } - } - // no space left and user doesnt exist. Don't leave ram in use! - delete a; - } - else - { - log(DEBUG,"added fresh WHOWAS entry"); - whowas[a->nick] = a; - } - } - else - { - log(DEBUG,"updated WHOWAS entry"); - if (iter->second) delete iter->second; - iter->second = a; - } + whowas_users::iterator iter = whowas.find(u->nick); + if (iter == whowas.end()) + { + whowas_set* n = new whowas_set; + WhoWasGroup *a = new WhoWasGroup(u); + n->push_back(a); + whowas[u->nick] = n; + } + else + { + if (iter->size() > 10) + { + iter->pop_front(); + } + WhoWasGroup *a = new WhoWasGroup(u); + iter->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; + 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 */ |