]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/server.cpp
Shorthand macros DEFINE_HANDLER1()...DEFINE_HANDLER9() to save on defining functor...
[user/henk/code/inspircd.git] / src / server.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 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 #include "inspircd.h"
15
16 void InspIRCd::Rehash(int status)
17 {
18 /*
19         SI->WriteOpers("*** Rehashing config file %s due to SIGHUP",ServerConfig::CleanFilename(SI->ConfigFileName));
20         SI->CloseLog();
21         SI->OpenLog(SI->Config->argv, SI->Config->argc);
22         SI->RehashUsersAndChans();
23         FOREACH_MOD_I(SI, I_OnGarbageCollect, OnGarbageCollect());
24         SI->Config->Read(false,NULL);
25         SI->ResetMaxBans();
26         SI->Res->Rehash();
27         FOREACH_MOD_I(SI,I_OnRehash,OnRehash(NULL,""));
28         SI->BuildISupport();
29 */
30 }
31
32 void InspIRCd::RehashServer()
33 {
34         this->WriteOpers("*** Rehashing config file");
35         this->RehashUsersAndChans();
36         this->Config->Read(false,NULL);
37         this->ResetMaxBans();
38         this->Res->Rehash();
39 }
40
41 std::string InspIRCd::GetVersionString()
42 {
43         char versiondata[MAXBUF];
44         char dnsengine[] = "singlethread-object";
45
46         if (*Config->CustomVersion)
47         {
48                 snprintf(versiondata,MAXBUF,"%s %s :%s",VERSION,Config->ServerName,Config->CustomVersion);
49         }
50         else
51         {
52                 snprintf(versiondata,MAXBUF,"%s %s :%s [FLAGS=%s,%s,%s]",VERSION,Config->ServerName,SYSTEM,REVISION,SE->GetName().c_str(),dnsengine);
53         }
54         return versiondata;
55 }
56
57 void InspIRCd::BuildISupport()
58 {
59         // the neatest way to construct the initial 005 numeric, considering the number of configure constants to go in it...
60         std::stringstream v;
61         v << "WALLCHOPS WALLVOICES MODES=" << MAXMODES-1 << " CHANTYPES=# PREFIX=" << this->Modes->BuildPrefixes() << " MAP MAXCHANNELS=" << Config->MaxChans << " MAXBANS=60 VBANLIST NICKLEN=" << NICKMAX-1;
62         v << " CASEMAPPING=rfc1459 STATUSMSG=@%+ CHARSET=ascii TOPICLEN=" << MAXTOPIC << " KICKLEN=" << MAXKICK << " MAXTARGETS=" << Config->MaxTargets << " AWAYLEN=";
63         v << MAXAWAY << " CHANMODES=" << this->Modes->ChanModes() << " FNC NETWORK=" << Config->Network << " MAXPARA=32 ELIST=MU";
64         Config->data005 = v.str();
65         FOREACH_MOD_I(this,I_On005Numeric,On005Numeric(Config->data005));
66         Config->Update005();
67 }
68
69 std::string InspIRCd::GetRevision()
70 {
71         return REVISION;
72 }
73
74 void InspIRCd::AddServerName(const std::string &servername)
75 {
76         servernamelist::iterator itr = servernames.begin();
77         for(; itr != servernames.end(); ++itr)
78                 if(**itr == servername)
79                         return;
80
81         string * ns = new string(servername);
82         servernames.push_back(ns);
83 }
84
85 const char* InspIRCd::FindServerNamePtr(const std::string &servername)
86 {
87         servernamelist::iterator itr = servernames.begin();
88         for(; itr != servernames.end(); ++itr)
89                 if(**itr == servername)
90                         return (*itr)->c_str();
91
92         servernames.push_back(new string(servername));
93         itr = --servernames.end();
94         return (*itr)->c_str();
95 }
96
97 bool InspIRCd::FindServerName(const std::string &servername)
98 {
99         servernamelist::iterator itr = servernames.begin();
100         for(; itr != servernames.end(); ++itr)
101                 if(**itr == servername)
102                         return true;
103         return false;
104 }
105