]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/usermanager.cpp
2bb4ee6853892dd341332460e0a655e1349b8ecd
[user/henk/code/inspircd.git] / src / usermanager.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *          the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 /* $Core: libIRCDusermanager */
15
16 #include "inspircd.h"
17
18 void UserManager::AddLocalClone(User *user)
19 {
20         clonemap::iterator x = local_clones.find(user->GetIPString());
21         if (x != local_clones.end())
22                 x->second++;
23         else
24                 local_clones[user->GetIPString()] = 1;
25 }
26
27 void UserManager::AddGlobalClone(User *user)
28 {
29         clonemap::iterator y = global_clones.find(user->GetIPString());
30         if (y != global_clones.end())
31                 y->second++;
32         else
33                 global_clones[user->GetIPString()] = 1;
34 }
35
36 void UserManager::RemoveCloneCounts(User *user)
37 {
38         clonemap::iterator x = local_clones.find(user->GetIPString());
39         if (x != local_clones.end())
40         {
41                 x->second--;
42                 if (!x->second)
43                 {
44                         local_clones.erase(x);
45                 }
46         }
47         
48         clonemap::iterator y = global_clones.find(user->GetIPString());
49         if (y != global_clones.end())
50         {
51                 y->second--;
52                 if (!y->second)
53                 {
54                         global_clones.erase(y);
55                 }
56         }
57 }
58
59 unsigned long UserManager::GlobalCloneCount(User *user)
60 {
61         clonemap::iterator x = global_clones.find(user->GetIPString());
62         if (x != global_clones.end())
63                 return x->second;
64         else
65                 return 0;
66 }
67
68 unsigned long UserManager::LocalCloneCount(User *user)
69 {
70         clonemap::iterator x = local_clones.find(user->GetIPString());
71         if (x != local_clones.end())
72                 return x->second;
73         else
74                 return 0;
75 }