]> jfr.im git - irc/quakenet/snircd-patchqueue.git/blob - checkmscheck.patch
rename patch files
[irc/quakenet/snircd-patchqueue.git] / checkmscheck.patch
1 split m_check into mo_check (oper) and ms_check (server) message functions
2
3 diff -r 3a5d0499141a include/handlers.h
4 --- a/include/handlers.h Tue Mar 23 21:30:55 2010 +0100
5 +++ b/include/handlers.h Tue Mar 23 21:31:57 2010 +0100
6 @@ -88,19 +88,6 @@
7
8 extern int m_admin(struct Client*, struct Client*, int, char*[]);
9 extern int m_away(struct Client*, struct Client*, int, char*[]);
10 -
11 -/*
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).
16 - *
17 - * qoreQ (qoreQ@quakenet.org) - 08/30/2002
18 - * -----------------------------------------------------------------------------
19 - */
20 -
21 -extern int m_check(struct Client *cptr, struct Client *sptr, int parc, char *parv[]);
22 -
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*[]);
26 @@ -156,6 +143,7 @@
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*[]);
34 @@ -194,6 +182,7 @@
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 3a5d0499141a ircd/m_check.c
43 --- a/ircd/m_check.c Tue Mar 23 21:30:55 2010 +0100
44 +++ b/ircd/m_check.c Tue Mar 23 21:31:57 2010 +0100
45 @@ -31,6 +31,7 @@
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"
53 @@ -87,33 +88,105 @@
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.
57 + *
58 + *
59 */
60
61 -int m_check(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) {
62 +/*
63 + * mo_check - oper message handler
64 + *
65 + * parv[0] = Send prefix
66 + * parv[1] = mask
67 + * parv[2] = -flags
68 + *
69 + * or for remote query
70 + *
71 + * parv[0] = Send prefix
72 + * parv[1] = remote server
73 + * parv[2] = mask
74 + * parv[3] = -flags
75 + *
76 + */
77 +int mo_check(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) {
78 + char *mask;
79 + char *doflags = NULL;
80 +
81 + assert(0 != IsAnOper(sptr));
82 +
83 + /* check privs */
84 + if (!HasPriv(sptr, PRIV_CHECK))
85 + return send_reply(sptr, ERR_NOPRIVILEGES);
86 +
87 + /* check params */
88 + if (parc < 2)
89 + return send_reply(sptr, ERR_NEEDMOREPARAMS, "CHECK");
90 +
91 + mask = parv[1];
92 + if (parc > 2)
93 + doflags = parv[2];
94 +
95 + /* remote query? */
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)
98 + return 0;
99 + mask = parv[2];
100 + if (parc > 3)
101 + doflags = parv[3];
102 + }
103 +
104 + return do_check(sptr, mask, doflags);
105 +}
106 +
107 +
108 +
109 +/*
110 + * ms_check - server message handler
111 + *
112 + * parv[0] = Send prefix
113 + * parv[1] = target server
114 + * parv[2] = mask
115 + * parv[3] = -flags
116 + *
117 + */
118 +int ms_check(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) {
119 + char *mask;
120 + char *doflags = NULL;
121 +
122 + assert(0 != IsServer(cptr));
123 +
124 + /* check params */
125 + if (parc < 3) {
126 + protocol_violation(sptr, "Too few parameters for CHECK (got %d - need 3)", parc);
127 + return send_reply(sptr, ERR_NEEDMOREPARAMS, "CHECK");
128 + }
129 +
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)
132 + return 0;
133 +
134 + mask = parv[2];
135 + if (parc > 3)
136 + doflags = parv[3];
137 +
138 + return do_check(sptr, mask, doflags);
139 +}
140 +
141 +
142 +
143 +/*
144 + * do_check
145 + *
146 + */
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;
151
152 - if (!HasPriv(sptr, PRIV_CHECK))
153 - return send_reply(sptr, ERR_NOPRIVILEGES);
154 -
155 - if (parc < 2) {
156 - send_reply(sptr, ERR_NEEDMOREPARAMS, "CHECK");
157 - return 0;
158 - }
159 -
160 - if ( parc>=4 ||
161 - (parc==3 && parv[2][0] != '-')) {
162 - /* remote query */
163 - if (hunt_server_cmd(sptr, CMD_CHECK, cptr, 0, parc==4 ? "%C %s %s" : "%C %s", 1, parc, parv) != HUNTED_ISME)
164 - return 0;
165 - parv++; parc--;
166 - }
167
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]) {
175 case 'c':
176 flags |= CHECK_CHECKCHAN;
177 break;
178 @@ -149,29 +222,29 @@
179 }
180 }
181
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);
188 }
189 else
190 - send_reply(sptr, ERR_SEARCHNOMATCH, "CHECK", parv[1]);
191 + send_reply(sptr, ERR_SEARCHNOMATCH, "CHECK", mask);
192 }
193 - else if ((acptr = FindClient(parv[1])) && !(FindServer(parv[1]))) { /* client and not a server */
194 + else if ((acptr = FindClient(mask)) && !(FindServer(mask))) { /* client and not a server */
195 if (!IsRegistered(acptr)) {
196 - send_reply(sptr, ERR_SEARCHNOMATCH, "CHECK", parv[1]);
197 + send_reply(sptr, ERR_SEARCHNOMATCH, "CHECK", mask);
198 return 0;
199 }
200
201 checkClient(sptr, acptr);
202 }
203 - else if ((acptr = FindServer(parv[1]))) { /* server */
204 + else if ((acptr = FindServer(mask))) { /* server */
205 checkServer(sptr, acptr);
206 }
207 - else if (checkHostmask(sptr, parv[1], flags) > 0) /* hostmask */
208 + else if (checkHostmask(sptr, mask, flags) > 0) /* hostmask */
209 return 1;
210 else /* no match */
211 - send_reply(sptr, ERR_SEARCHNOMATCH, "CHECK", parv[1]);
212 + send_reply(sptr, ERR_SEARCHNOMATCH, "CHECK", mask);
213
214 return 1;
215 }
216 diff -r 3a5d0499141a ircd/parse.c
217 --- a/ircd/parse.c Tue Mar 23 21:30:55 2010 +0100
218 +++ b/ircd/parse.c Tue Mar 23 21:31:57 2010 +0100
219 @@ -654,21 +654,12 @@
220 { m_cap, m_cap, m_ignore, m_cap, m_ignore }
221 },
222 #endif
223 -
224 - /*
225 - * - ASUKA ---------------------------------------------------------------------
226 - * Add the command for CHECK.
227 - * This was adapted from Lain for use in Asuka.
228 - * Original code by Durzel (durzel@quakenet.org).
229 - *
230 - * qoreQ (qoreQ@quakenet.org) - 08/14/2002
231 - * -----------------------------------------------------------------------------
232 - */
233 {
234 MSG_CHECK,
235 TOK_CHECK,
236 0, MAXPARA, MFLG_SLOW, 0, NULL,
237 - { m_unregistered, m_not_oper, m_check, m_check, m_ignore }
238 + /* UNREG, CLIENT, SERVER, OPER, SERVICE */
239 + { m_unregistered, m_not_oper, ms_check, mo_check, m_ignore }
240 },
241
242 /* This command is an alias for QUIT during the unregistered part of