]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/base.cpp
Optimized connects - motd is sent faster
[user/henk/code/inspircd.git] / src / base.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 #include "base.h"
18 #include "inspircd_config.h" 
19 #include <time.h>
20 #include <map>
21 #include <string>
22 #include "inspircd.h"
23 #include "modules.h"
24
25 bool Extensible::Extend(std::string key, char* p)
26 {
27         // only add an item if it doesnt already exist
28         if (this->Extension_Items.find(key) == this->Extension_Items.end())
29         {
30                 this->Extension_Items[key] = p;
31                 log(DEBUG,"Extending object with item %s",key.c_str());
32                 return true;
33         }
34         // item already exists, return false
35         return false;
36 }
37
38 bool Extensible::Shrink(std::string key)
39 {
40         // only attempt to remove a map item that exists
41         if (this->Extension_Items.find(key) != this->Extension_Items.end())
42         {
43                 this->Extension_Items.erase(this->Extension_Items.find(key));
44                 log(DEBUG,"Shrinking object with item %s",key.c_str());
45                 return true;
46         }
47         return false;
48 }
49
50 char* Extensible::GetExt(std::string key)
51 {
52         log(DEBUG,"Checking extension items for %s",key.c_str());
53         if (this->Extension_Items.find(key) != this->Extension_Items.end())
54         {
55                 log(DEBUG,"Found item %s %s",key.c_str(),(this->Extension_Items.find(key))->second);
56                 return (this->Extension_Items.find(key))->second;
57         }
58         log(DEBUG,"Cant find item %s",key.c_str());
59         return NULL;
60 }
61