]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/cmd_modules.cpp
ac25f18883c964b4386ab21b8a200f871d1dcb1b
[user/henk/code/inspircd.git] / src / cmd_modules.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain.net>
8  *                <Craig.net>
9  *
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 using namespace std;
18
19 #include "inspircd_config.h"
20 #include "inspircd.h"
21 #include "inspircd_io.h"
22 #include <time.h>
23 #include <string>
24 #ifdef GCC3
25 #include <ext/hash_map>
26 #else
27 #include <hash_map>
28 #endif
29 #include <map>
30 #include <sstream>
31 #include <vector>
32 #include <deque>
33 #include "users.h"
34 #include "ctables.h"
35 #include "globals.h"
36 #include "modules.h"
37 #include "dynamic.h"
38 #include "wildcard.h"
39 #include "message.h"
40 #include "commands.h"
41 #include "mode.h"
42 #include "xline.h"
43 #include "inspstring.h"
44 #include "dnsqueue.h"
45 #include "helperfuncs.h"
46 #include "hashcomp.h"
47 #include "socketengine.h"
48 #include "typedefs.h"
49 #include "command_parse.h"
50 #include "cmd_modules.h"
51
52 extern ServerConfig* Config;
53 extern InspIRCd* ServerInstance;
54 extern int MODCOUNT;
55 extern std::vector<Module*> modules;
56 extern std::vector<ircd_module*> factory;
57 extern time_t TIME;
58 extern user_hash clientlist;
59 extern chan_hash chanlist;
60 extern whowas_hash whowas;
61 extern std::vector<userrec*> all_opers;
62 extern std::vector<userrec*> local_users;
63 extern userrec* fd_ref_table[65536];
64
65 char* itab[] = {
66 "OnUserConnect", "OnUserQuit", "OnUserDisconnect", "OnUserJoin", "OnUserPart", "OnRehash", "OnServerRaw",
67 "OnExtendedMode", "OnUserPreJoin", "OnUserPreKick", "OnUserKick", "OnOper", "OnInfo", "OnWhois", "OnUserPreInvite",
68 "OnUserInvite", "OnUserPreMessage", "OnUserPreNotice", "OnUserPreNick", "OnUserMessage", "OnUserNotice", "OnMode",
69 "OnGetServerDescription", "OnSyncUser", "OnSyncChannel", "OnSyncChannelMetaData", "OnSyncUserMetaData",
70 "OnDecodeMetaData", "ProtoSendMode", "ProtoSendMetaData", "OnWallops", "OnChangeHost", "OnChangeName", "OnAddGLine",
71 "OnAddZLine", "OnAddQLine", "OnAddKLine", "OnAddELine", "OnDelGLine", "OnDelZLine", "OnDelKLine", "OnDelELine", "OnDelQLine",
72 "OnCleanup", "OnUserPostNick", "OnAccessCheck", "On005Numeric", "OnKill", "OnRemoteKill", "OnLoadModule", "OnUnloadModule",
73 "OnBackgroundTimer", "OnSendList", "OnPreCommand", "OnCheckReady", "OnUserRrgister", "OnRawMode", "OnCheckInvite",
74 "OnCheckKey", "OnCheckLimit", "OnCheckBan", "OnStats", "OnChangeLocalUserHost", "OnChangeLocalUserGecos", "OnLocalTopicChange",
75 "OnPostLocalTopicChange", "OnEvent", "OnRequest", "OnOperCompre", "OnGlobalOper", "OnGlobalConnect", "OnAddBan", "OnDelBan",
76 "OnRawSocketAccept", "OnRawSocketClose", "OnRawSocketWrite", "OnRawSocketRead", "OnChangeLocalUserGECOS", "OnUserRegister",
77 "OnOperCompare", NULL
78 };
79
80 void cmd_modules::Handle (char **parameters, int pcnt, userrec *user)
81 {
82         for (unsigned int i = 0; i < Config->module_names.size(); i++)
83         {
84                 Version V = modules[i]->GetVersion();
85                 char modulename[MAXBUF];
86                 char flagstate[MAXBUF];
87                 *flagstate = 0;
88                 if (V.Flags & VF_STATIC)
89                         strlcat(flagstate,", static",MAXBUF);
90                 if (V.Flags & VF_VENDOR)
91                         strlcat(flagstate,", vendor",MAXBUF);
92                 if (V.Flags & VF_COMMON)
93                         strlcat(flagstate,", common",MAXBUF);
94                 if (V.Flags & VF_SERVICEPROVIDER)
95                         strlcat(flagstate,", service provider",MAXBUF);
96                 if (!flagstate[0])
97                         strcpy(flagstate,"  <no flags>");
98                 strlcpy(modulename,Config->module_names[i].c_str(),256);
99                 if (strchr(user->modes,'o'))
100                 {
101                         if ((pcnt > 0) && (!strcasecmp(parameters[0],"debug")))
102                         {
103                                 WriteServ(user->fd,"900 %s :0x%08lx %d.%d.%d.%d %s (%s)",user->nick,modules[i],V.Major,V.Minor,V.Revision,V.Build,CleanFilename(modulename),flagstate+2);
104                                 for (int it = 0; itab[it]; it++)
105                                         WriteServ(user->fd,"900 %s :%s [%s = %d]",user->nick,CleanFilename(modulename),itab[it],Config->implement_lists[i]);
106                         }
107                         else
108                         {
109                                 WriteServ(user->fd,"900 %s :0x%08lx %d.%d.%d.%d %s (%s)",user->nick,modules[i],V.Major,V.Minor,V.Revision,V.Build,CleanFilename(modulename),flagstate+2);
110                         }
111                 }
112                 else
113                 {
114                         WriteServ(user->fd,"900 %s :%s",user->nick,CleanFilename(modulename));
115                 }
116         }
117         WriteServ(user->fd,"901 %s :End of MODULES list",user->nick);
118 }
119
120