]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/cmd_modules.cpp
93908d21d3adc7c4f566cff8ee96962a08d54d00
[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 >= 2) && (!strcasecmp(parameters[0],"debug")))
102                         {
103                                 if (match(Config->module_names[i].c_str(),parameters[1]))
104                                 {
105                                         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);
106                                         for (int it = 0; itab[it];)
107                                         {
108                                                 char data[MAXBUF];
109                                                 char dlist[MAXBUF];
110                                                 *dlist = 0;
111                                                 for (int v = 0; v < 4; v++)
112                                                 {
113                                                         if (itab[it])
114                                                         {
115                                                                 if (Config->implement_lists[i][it])
116                                                                 {
117                                                                         snprintf(data,MAXBUF,"%s=>%c ",itab[it],(Config->implement_lists[i][it] ? '1' : '0'));
118                                                                         strncat(dlist,data,MAXBUF);
119                                                                 }
120                                                                 it++;
121                                                         }
122                                                 }
123                                                 if (*dlist)
124                                                         WriteServ(user->fd,"900 %s :%s [ %s]",user->nick,CleanFilename(modulename),dlist);
125                                         }
126                                         WriteServ(user->fd,"900 %s :=== DEBUG: Implementation counts ===",user->nick);
127                                         for (int it = 0; itab[it]; it++)
128                                         {
129                                                 if (Config->global_implementation[it])
130                                                         WriteServ(user->fd,"900 %s :%s: %d times",user->nick, itab[it],(int)Config->global_implementation[it]);
131                                         }
132                                 }
133                         }
134                         else
135                         {
136                                 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);
137                         }
138                 }
139                 else
140                 {
141                         WriteServ(user->fd,"900 %s :%s",user->nick,CleanFilename(modulename));
142                 }
143         }
144         WriteServ(user->fd,"901 %s :End of MODULES list",user->nick);
145 }
146
147