1 split m_check into mo_check (oper) and ms_check (server) message functions
3 diff -r 26edd3f62b02 include/handlers.h
4 --- a/include/handlers.h Fri Jul 26 20:21:47 2013 +0100
5 +++ b/include/handlers.h Fri Jul 26 20:34:34 2013 +0100
8 extern int m_admin(struct Client*, struct Client*, int, char*[]);
9 extern int m_away(struct Client*, struct Client*, int, char*[]);
12 - * - ASUKA ---------------------------------------------------------------------
13 - * Add the command for CHECK.
14 - * This was adapted from Lain for use in Asuka.
15 - * Original code by Durzel (durzel@quakenet.org).
17 - * qoreQ (qoreQ@quakenet.org) - 08/30/2002
18 - * -----------------------------------------------------------------------------
21 -extern int m_check(struct Client *cptr, struct Client *sptr, int parc, char *parv[]);
23 extern int m_cap(struct Client*, struct Client*, int, char*[]);
24 extern int m_cnotice(struct Client*, struct Client*, int, char*[]);
25 extern int m_cprivmsg(struct Client*, struct Client*, int, char*[]);
27 extern int m_whowas(struct Client*, struct Client*, int, char*[]);
28 extern int mo_admin(struct Client*, struct Client*, int, char*[]);
29 extern int mo_asll(struct Client*, struct Client*, int, char*[]);
30 +extern int mo_check(struct Client*, struct Client*, int, char*[]);
31 extern int mo_clearmode(struct Client*, struct Client*, int, char*[]);
32 extern int mo_close(struct Client*, struct Client*, int, char*[]);
33 extern int mo_connect(struct Client*, struct Client*, int, char*[]);
35 extern int ms_asll(struct Client*, struct Client*, int, char*[]);
36 extern int ms_away(struct Client*, struct Client*, int, char*[]);
37 extern int ms_burst(struct Client*, struct Client*, int, char*[]);
38 +extern int ms_check(struct Client*, struct Client*, int, char*[]);
39 extern int ms_clearmode(struct Client*, struct Client*, int, char*[]);
40 extern int ms_connect(struct Client*, struct Client*, int, char*[]);
41 extern int ms_create(struct Client*, struct Client*, int, char*[]);
42 diff -r 26edd3f62b02 ircd/m_check.c
43 --- a/ircd/m_check.c Fri Jul 26 20:21:47 2013 +0100
44 +++ b/ircd/m_check.c Fri Jul 26 20:34:34 2013 +0100
46 #include "ircd_alloc.h"
47 #include "ircd_defs.h"
48 #include "ircd_features.h"
49 +#include "ircd_log.h"
50 #include "ircd_reply.h"
51 #include "ircd_string.h"
52 #include "ircd_snprintf.h"
54 * <hostmask> can be of the form host, user@host, nick!user@host,
55 * with host being host.domain.cc, 127.0.0.1 or 127.0.0.0/24.
56 * Wildcards are supported.
61 -int m_check(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) {
63 + * mo_check - oper message handler
65 + * parv[0] = Send prefix
69 + * or for remote query
71 + * parv[0] = Send prefix
72 + * parv[1] = remote server
77 +int mo_check(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) {
79 + char *doflags = NULL;
81 + assert(0 != IsAnOper(sptr));
84 + if (!HasPriv(sptr, PRIV_CHECK))
85 + return send_reply(sptr, ERR_NOPRIVILEGES);
89 + return send_reply(sptr, ERR_NEEDMOREPARAMS, "CHECK");
96 + if ( parc > 3 || (parc == 3 && parv[2][0] != '-')) {
97 + if (hunt_server_cmd(sptr, CMD_CHECK, cptr, 0, parc > 3 ? "%C %s %s" : "%C %s", 1, parc, parv) != HUNTED_ISME)
104 + return do_check(sptr, mask, doflags);
110 + * ms_check - server message handler
112 + * parv[0] = Send prefix
113 + * parv[1] = target server
118 +int ms_check(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) {
120 + char *doflags = NULL;
122 + assert(0 != IsServer(cptr));
126 + protocol_violation(sptr, "Too few parameters for CHECK (got %d - need 3)", parc);
127 + return send_reply(sptr, ERR_NEEDMOREPARAMS, "CHECK");
130 + /* remote query for me? */
131 + if (hunt_server_cmd(sptr, CMD_CHECK, cptr, 0, parc > 3 ? "%C %s %s" : "%C %s", 1, parc, parv) != HUNTED_ISME)
138 + return do_check(sptr, mask, doflags);
147 +int do_check(struct Client *sptr, char *mask, char *doflags) {
148 struct Channel *chptr;
149 struct Client *acptr;
150 int flags = CHECK_SHOWUSERS, i;
152 - if (!HasPriv(sptr, PRIV_CHECK))
153 - return send_reply(sptr, ERR_NOPRIVILEGES);
156 - send_reply(sptr, ERR_NEEDMOREPARAMS, "CHECK");
161 - (parc==3 && parv[2][0] != '-')) {
163 - if (hunt_server_cmd(sptr, CMD_CHECK, cptr, 0, parc==4 ? "%C %s %s" : "%C %s", 1, parc, parv) != HUNTED_ISME)
168 /* This checks to see if any flags have been supplied */
169 - if ((parc >= 3) && (parv[2][0] == '-')) {
170 - for (i = 0; parv[2][i]; i++) {
171 - switch (parv[2][i]) {
172 + if (doflags && doflags[0] == '-') {
173 + for (i = 0; doflags[i]; i++) {
174 + switch (doflags[i]) {
176 flags |= CHECK_CHECKCHAN;
178 @@ -149,24 +222,24 @@
182 - if (IsChannelName(parv[1])) { /* channel */
183 - if ((chptr = FindChannel(parv[1]))) {
184 + if (IsChannelName(mask)) { /* channel */
185 + if ((chptr = FindChannel(mask))) {
186 checkChannel(sptr, chptr);
187 checkUsers(sptr, chptr, flags);
190 - send_reply(sptr, ERR_SEARCHNOMATCH, "CHECK", parv[1]);
191 + send_reply(sptr, ERR_SEARCHNOMATCH, "CHECK", mask);
193 - else if ((acptr = FindUser(parv[1]))) {
194 + else if ((acptr = FindUser(mask))) {
195 checkClient(sptr, acptr);
197 - else if ((acptr = FindServer(parv[1]))) { /* server */
198 + else if ((acptr = FindServer(mask))) { /* server */
199 checkServer(sptr, acptr);
201 - else if (checkHostmask(sptr, parv[1], flags) > 0) /* hostmask */
202 + else if (checkHostmask(sptr, mask, flags) > 0) /* hostmask */
205 - send_reply(sptr, ERR_SEARCHNOMATCH, "CHECK", parv[1]);
206 + send_reply(sptr, ERR_SEARCHNOMATCH, "CHECK", mask);
210 diff -r 26edd3f62b02 ircd/parse.c
211 --- a/ircd/parse.c Fri Jul 26 20:21:47 2013 +0100
212 +++ b/ircd/parse.c Fri Jul 26 20:34:34 2013 +0100
213 @@ -668,21 +668,12 @@
214 { m_cap, m_cap, m_ignore, m_cap, m_ignore }
219 - * - ASUKA ---------------------------------------------------------------------
220 - * Add the command for CHECK.
221 - * This was adapted from Lain for use in Asuka.
222 - * Original code by Durzel (durzel@quakenet.org).
224 - * qoreQ (qoreQ@quakenet.org) - 08/14/2002
225 - * -----------------------------------------------------------------------------
230 0, MAXPARA, MFLG_SLOW, 0, NULL,
231 - { m_unregistered, m_not_oper, m_check, m_check, m_ignore }
232 + /* UNREG, CLIENT, SERVER, OPER, SERVICE */
233 + { m_unregistered, m_not_oper, ms_check, mo_check, m_ignore }
236 /* This command is an alias for QUIT during the unregistered part of