]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/commands/cmd_modules.cpp
0b7ce2577b0e836f85a99547ea255e54cc00254b
[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 const char* itab[] = {
18         "OnUserConnect", "OnUserQuit", "OnUserDisconnect", "OnUserJoin", "OnUserPart", "OnRehash", "OnServerRaw",
19         "OnUserPreJoin", "OnUserPreKick", "OnUserKick", "OnOper", "OnInfo", "OnWhois", "OnUserPreInvite",
20         "OnUserInvite", "OnUserPreMessage", "OnUserPreNotice", "OnUserPreNick", "OnUserMessage", "OnUserNotice", "OnMode",
21         "OnGetServerDescription", "OnSyncUser", "OnSyncChannel", "OnSyncChannelMetaData", "OnSyncUserMetaData",
22         "OnDecodeMetaData", "ProtoSendMode", "ProtoSendMetaData", "OnWallops", "OnChangeHost", "OnChangeName", "OnAddGLine",
23         "OnAddZLine", "OnAddQLine", "OnAddKLine", "OnAddELine", "OnDelGLine", "OnDelZLine", "OnDelKLine", "OnDelELine", "OnDelQLine",
24         "OnCleanup", "OnUserPostNick", "OnAccessCheck", "On005Numeric", "OnKill", "OnRemoteKill", "OnLoadModule", "OnUnloadModule",
25         "OnBackgroundTimer", "OnSendList", "OnPreCommand", "OnCheckReady", "OnUserRegister", "OnCheckInvite",
26         "OnCheckKey", "OnCheckLimit", "OnCheckBan", "OnStats", "OnChangeLocalUserHost", "OnChangeLocalUserGecos", "OnLocalTopicChange",
27         "OnPostLocalTopicChange", "OnEvent", "OnRequest", "OnOperCompre", "OnGlobalOper", "OnPostConnect", "OnAddBan", "OnDelBan",
28         "OnRawSocketAccept", "OnRawSocketClose", "OnRawSocketWrite", "OnRawSocketRead", "OnChangeLocalUserGECOS", "OnUserRegister",
29         "OnOperCompare", "OnChannelDelete", "OnPostOper", "OnSyncOtherMetaData", "OnSetAway", "OnCancelAway", "OnNamesList",
30         "OnPostCommand", "OnPostJoin", "OnWhoisLine", "OnBuildExemptList", "OnRawSocketConnect", "OnGarbageCollect", NULL
31 };
32
33 extern "C" DllExport Command* init_command(InspIRCd* Instance)
34 {
35         return new CommandModules(Instance);
36 }
37
38 /** Handle /MODULES
39  */
40 CmdResult CommandModules::Handle (const std::vector<std::string>&, User *user)
41 {
42         std::vector<std::string> module_names = ServerInstance->Modules->GetAllModuleNames(0);
43
44         for (unsigned int i = 0; i < module_names.size(); i++)
45         {
46                 Module* m = ServerInstance->Modules->Find(module_names[i]);
47                 Version V = m->GetVersion();
48                 char modulename[MAXBUF];
49                 char flagstate[MAXBUF];
50                 *flagstate = 0;
51                 if (V.Flags & VF_STATIC)
52                         strlcat(flagstate,", static",MAXBUF);
53                 if (V.Flags & VF_VENDOR)
54                         strlcat(flagstate,", vendor",MAXBUF);
55                 if (V.Flags & VF_COMMON)
56                         strlcat(flagstate,", common",MAXBUF);
57                 if (V.Flags & VF_SERVICEPROVIDER)
58                         strlcat(flagstate,", service provider",MAXBUF);
59                 if (!flagstate[0])
60                         strcpy(flagstate,"  <no flags>");
61                 strlcpy(modulename,module_names[i].c_str(),256);
62                 if (IS_OPER(user))
63                 {
64                         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);
65                 }
66                 else
67                 {
68                         user->WriteNumeric(702, "%s :%s",user->nick.c_str(),ServerConfig::CleanFilename(modulename));
69                 }
70         }
71         user->WriteNumeric(703, "%s :End of MODULES list",user->nick.c_str());
72
73         return CMD_SUCCESS;
74 }