]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/modules.cpp
Fix warnings (thanks owine)
[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 "commands/cmd_whois.h"
16 #include "commands/cmd_stats.h"
17 #include "socket.h"
18 #include "wildcard.h"
19 #include "xline.h"
20 #include "transport.h"
21 #include "socketengine.h"
22
23 #include "m_spanningtree/main.h"
24 #include "m_spanningtree/utils.h"
25 #include "m_spanningtree/treeserver.h"
26 #include "m_spanningtree/link.h"
27 #include "m_spanningtree/treesocket.h"
28 #include "m_spanningtree/resolvers.h"
29 #include "m_spanningtree/handshaketimer.h"
30
31 /* $ModDep: m_spanningtree/timesynctimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h */
32
33 bool TreeSocket::Modules(const std::string &prefix, std::deque<std::string> &params)
34 {
35         if (params.empty())
36                 return true;
37
38         if (!this->Instance->MatchText(this->Instance->Config->ServerName, params[0]))
39         {
40                 /* Pass it on, not for us */
41                 Utils->DoOneToOne(prefix, "MODULES", params, params[0]);
42                 return true;
43         }
44
45         char strbuf[MAXBUF];
46         std::deque<std::string> par;
47         par.push_back(prefix);
48         par.push_back("");
49
50         User* source = this->Instance->FindNick(prefix);
51         if (!source)
52                 return true;
53
54         std::vector<std::string> module_names = Instance->Modules->GetAllModuleNames(0);
55
56         for (unsigned int i = 0; i < module_names.size(); i++)
57         {
58                 Module* m = Instance->Modules->Find(module_names[i]);
59                 Version V = m->GetVersion();
60                 char modulename[MAXBUF];
61                 char flagstate[MAXBUF];
62                 *flagstate = 0;
63                 if (V.Flags & VF_STATIC)
64                         strlcat(flagstate,", static",MAXBUF);
65                 if (V.Flags & VF_VENDOR)
66                         strlcat(flagstate,", vendor",MAXBUF);
67                 if (V.Flags & VF_COMMON)
68                         strlcat(flagstate,", common",MAXBUF);
69                 if (V.Flags & VF_SERVICEPROVIDER)
70                         strlcat(flagstate,", service provider",MAXBUF);
71                 if (!flagstate[0])
72                         strcpy(flagstate,"  <no flags>");
73                 strlcpy(modulename,module_names[i].c_str(),256);
74                 if (*source->oper)
75                 {
76                         snprintf(strbuf, MAXBUF, "::%s 900 %s :0x%08lx %d.%d.%d.%d %s (%s)",Instance->Config->ServerName,source->nick,(unsigned long)m,
77                                         V.Major,V.Minor,V.Revision,V.Build,ServerConfig::CleanFilename(modulename),flagstate+2);
78                 }
79                 else
80                 {
81                         snprintf(strbuf, MAXBUF, "::%s 900 %s :%s",Instance->Config->ServerName,source->nick,ServerConfig::CleanFilename(modulename));
82                 }
83                 par[1] = strbuf;
84                 Utils->DoOneToOne(Instance->Config->GetSID(), "PUSH", par, source->server);
85         }
86         snprintf(strbuf, MAXBUF, "::%s 901 %s :End of MODULES list", Instance->Config->ServerName, source->nick);
87         par[1] = strbuf;
88         Utils->DoOneToOne(Instance->Config->GetSID(), "PUSH", par, source->server);
89         return true;
90 }
91