]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/commands/cmd_modules.cpp
463ea9047f37a6e073cbf8bba996745fb286a593
[user/henk/code/inspircd.git] / src / commands / cmd_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_modules.h"
16
17 extern "C" DllExport Command* init_command(InspIRCd* Instance)
18 {
19         return new CommandModules(Instance);
20 }
21
22 /** Handle /MODULES
23  */
24 CmdResult CommandModules::Handle (const std::vector<std::string>&, User *user)
25 {
26         std::vector<std::string> module_names = ServerInstance->Modules->GetAllModuleNames(0);
27
28         for (unsigned int i = 0; i < module_names.size(); i++)
29         {
30                 Module* m = ServerInstance->Modules->Find(module_names[i]);
31                 Version V = m->GetVersion();
32                 char modulename[MAXBUF];
33                 char flagstate[MAXBUF];
34                 *flagstate = 0;
35                 if (V.Flags & VF_STATIC)
36                         strlcat(flagstate,", static",MAXBUF);
37                 if (V.Flags & VF_VENDOR)
38                         strlcat(flagstate,", vendor",MAXBUF);
39                 if (V.Flags & VF_COMMON)
40                         strlcat(flagstate,", common",MAXBUF);
41                 if (V.Flags & VF_SERVICEPROVIDER)
42                         strlcat(flagstate,", service provider",MAXBUF);
43                 if (!flagstate[0])
44                         strcpy(flagstate,"  <no flags>");
45                 strlcpy(modulename,module_names[i].c_str(),256);
46                 if (IS_OPER(user))
47                 {
48                         user->WriteNumeric(702, "%s :0x%08lx %d.%d.%d.%d %s (%s)",user->nick.c_str(),(unsigned long)m,V.Major,V.Minor,V.Revision,V.Build,ServerConfig::CleanFilename(modulename),flagstate+2);
49                 }
50                 else
51                 {
52                         user->WriteNumeric(702, "%s :%s",user->nick.c_str(),ServerConfig::CleanFilename(modulename));
53                 }
54         }
55         user->WriteNumeric(703, "%s :End of MODULES list",user->nick.c_str());
56
57         return CMD_SUCCESS;
58 }