]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/modules.cpp
a785a3f5100075b52dcac985a34afbd83b1ef13f
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / modules.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 #include "inspircd.h"
15 #include "xline.h"
16
17 #include "m_spanningtree/treesocket.h"
18 #include "m_spanningtree/treeserver.h"
19 #include "m_spanningtree/utils.h"
20
21 /* $ModDep: m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
22
23
24 bool TreeSocket::Modules(const std::string &prefix, std::deque<std::string> &params)
25 {
26         if (params.empty())
27                 return true;
28
29         if (!InspIRCd::Match(this->ServerInstance->Config->ServerName, params[0]))
30         {
31                 /* Pass it on, not for us */
32                 Utils->DoOneToOne(prefix, "MODULES", params, params[0]);
33                 return true;
34         }
35
36         char strbuf[MAXBUF];
37         std::deque<std::string> par;
38         par.push_back(prefix);
39         par.push_back("");
40
41         User* source = this->ServerInstance->FindNick(prefix);
42         if (!source)
43                 return true;
44
45         std::vector<std::string> module_names = ServerInstance->Modules->GetAllModuleNames(0);
46
47         for (unsigned int i = 0; i < module_names.size(); i++)
48         {
49                 Module* m = ServerInstance->Modules->Find(module_names[i]);
50                 Version V = m->GetVersion();
51
52                 if (IS_OPER(source))
53                 {
54                         std::string flags("Svsc");
55                         int pos = 0;
56                         for (int mult = 1; mult <= VF_SERVICEPROVIDER; mult *= 2, ++pos)
57                                 if (!(V.Flags & mult))
58                                         flags[pos] = '-';
59
60                         snprintf(strbuf, MAXBUF, "::%s 702 %s :0x%08lx %s %s :%s", ServerInstance->Config->ServerName, source->nick.c_str(),(unsigned long)m, module_names[i].c_str(), flags.c_str(), V.version.c_str());
61                 }
62                 else
63                 {
64                         snprintf(strbuf, MAXBUF, "::%s 702 %s :%s", ServerInstance->Config->ServerName, source->nick.c_str(), module_names[i].c_str());
65                 }
66                 par[1] = strbuf;
67                 Utils->DoOneToOne(ServerInstance->Config->GetSID(), "PUSH", par, source->server);
68         }
69         snprintf(strbuf, MAXBUF, "::%s 703 %s :End of MODULES list", ServerInstance->Config->ServerName, source->nick.c_str());
70         par[1] = strbuf;
71         Utils->DoOneToOne(ServerInstance->Config->GetSID(), "PUSH", par, source->server);
72         return true;
73 }
74