Anope IRC Services  Version 1.8
os_modlist.c
Go to the documentation of this file.
1 /* OperServ core functions
2  *
3  * (C) 2003-2014 Anope Team
4  * Contact us at team@anope.org
5  *
6  * Please read COPYING and README for further details.
7  *
8  * Based on the original code of Epona by Lara.
9  * Based on the original code of Services by Andy Church.
10  *
11  *
12  */
13 /*************************************************************************/
14 
15 #include "module.h"
16 
17 static int do_modlist(User * u);
18 static void myOperServHelp(User * u);
19 
26 int AnopeInit(int argc, char **argv)
27 {
28  Command *c;
29 
30  moduleAddAuthor("Anope");
31  moduleAddVersion(VERSION_STRING);
33 
34  c = createCommand("MODLIST", do_modlist, NULL, -1, -1, -1, -1,
35  OPER_HELP_MODLIST);
37 
39 
40  return MOD_CONT;
41 }
42 
46 void AnopeFini(void)
47 {
48 
49 }
50 
51 
56 static void myOperServHelp(User * u)
57 {
58  notice_lang(s_OperServ, u, OPER_HELP_CMD_MODLIST);
59 }
60 
66 static int do_modlist(User * u)
67 {
68  int idx;
69  int count = 0;
70  int showCore = 0;
71  int showThird = 1;
72  int showProto = 1;
73  int showEnc = 1;
74  int showSupported = 1;
75  int showQA = 1;
76 
77  char *param;
78  ModuleHash *current = NULL;
79 
80  char core[] = "Core";
81  char third[] = "3rd";
82  char proto[] = "Protocol";
83  char enc[] = "Encryption";
84  char supported[] = "Supported";
85  char qa[] = "QATested";
86 
87  param = strtok(NULL, "");
88  if (param) {
89  if (stricmp(param, core) == 0) {
90  showCore = 1;
91  showThird = 0;
92  showProto = 0;
93  showEnc = 0;
94  showSupported = 0;
95  showQA = 0;
96  } else if (stricmp(param, third) == 0) {
97  showCore = 0;
98  showThird = 1;
99  showSupported = 0;
100  showQA = 0;
101  showProto = 0;
102  showEnc = 0;
103  } else if (stricmp(param, proto) == 0) {
104  showCore = 0;
105  showThird = 0;
106  showProto = 1;
107  showEnc = 0;
108  showSupported = 0;
109  showQA = 0;
110  } else if (stricmp(param, supported) == 0) {
111  showCore = 0;
112  showThird = 0;
113  showProto = 0;
114  showSupported = 1;
115  showEnc = 0;
116  showQA = 0;
117  } else if (stricmp(param, qa) == 0) {
118  showCore = 0;
119  showThird = 0;
120  showProto = 0;
121  showSupported = 0;
122  showEnc = 0;
123  showQA = 1;
124  } else if (stricmp(param, enc) == 0) {
125  showCore = 0;
126  showThird = 0;
127  showProto = 0;
128  showSupported = 0;
129  showEnc = 1;
130  showQA = 0;
131  }
132  }
133 
134  notice_lang(s_OperServ, u, OPER_MODULE_LIST_HEADER);
135 
136  for (idx = 0; idx != MAX_CMD_HASH; idx++) {
137  for (current = MODULE_HASH[idx]; current; current = current->next) {
138  switch (current->m->type) {
139  case CORE:
140  if (showCore) {
141  notice_lang(s_OperServ, u, OPER_MODULE_LIST,
142  current->name, current->m->version, core);
143  count++;
144  }
145  break;
146  case THIRD:
147  if (showThird) {
148  notice_lang(s_OperServ, u, OPER_MODULE_LIST,
149  current->name, current->m->version, third);
150  count++;
151  }
152  break;
153  case PROTOCOL:
154  if (showProto) {
155  notice_lang(s_OperServ, u, OPER_MODULE_LIST,
156  current->name, current->m->version, proto);
157  count++;
158  }
159  break;
160  case SUPPORTED:
161  if (showSupported) {
162  notice_lang(s_OperServ, u, OPER_MODULE_LIST,
163  current->name, current->m->version,
164  supported);
165  count++;
166  }
167  break;
168  case QATESTED:
169  if (showQA) {
170  notice_lang(s_OperServ, u, OPER_MODULE_LIST,
171  current->name, current->m->version, qa);
172  count++;
173  }
174  break;
175  case ENCRYPTION:
176  if (showEnc) {
177  notice_lang(s_OperServ, u, OPER_MODULE_LIST,
178  current->name, current->m->version, enc);
179  count++;
180  }
181  break;
182 
183  }
184 
185  }
186  }
187  if (count == 0) {
188  notice_lang(s_OperServ, u, OPER_MODULE_NO_LIST);
189  } else {
190  notice_lang(s_OperServ, u, OPER_MODULE_LIST_FOOTER, count);
191  }
192 
193  return MOD_CONT;
194 }
ModuleHash * next
Definition: modules.h:162
static Channel * current
Definition: channels.c:427
static int do_modlist(User *u)
Definition: os_modlist.c:66
#define MAX_CMD_HASH
Definition: modules.h:51
E int stricmp(const char *s1, const char *s2)
Definition: compat.c:58
void AnopeFini(void)
Definition: os_modlist.c:46
MDE void moduleAddAuthor(const char *author)
Definition: modules.c:1772
E void notice_lang(char *source, User *dest, int message,...)
Definition: send.c:169
MDE void moduleSetType(MODType type)
Definition: modules.c:818
char * version
Definition: modules.h:141
#define OPERSERV
Definition: modules.h:62
E char * s_OperServ
Definition: extern.h:289
#define MODULE_HASH
Definition: modules.h:64
Definition: modules.h:99
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
Command * c
Definition: ns_recover.c:17
static void myOperServHelp(User *u)
Definition: os_modlist.c:56
MDE void moduleSetOperHelp(void(*func)(User *u))
Definition: modules.c:2126
#define MOD_CONT
Definition: modules.h:54
Module * m
Definition: modules.h:161
char * name
Definition: modules.h:160
Definition: modules.h:99
MDE Command * createCommand(const char *name, int(*func)(User *u), int(*has_priv)(User *u), int help_all, int help_reg, int help_oper, int help_admin, int help_root)
Definition: modules.c:987
MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos)
Definition: modules.c:1082
int AnopeInit(int argc, char **argv)
Definition: os_modlist.c:26
MODType type
Definition: modules.h:144
#define MOD_UNIQUE
Definition: module.h:11