ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/src/parse.C
(Generate patch)

Comparing cvsroot/ermyth/src/parse.C (file contents):
Revision 1.4 by pippijn, Tue Aug 28 17:08:12 2007 UTC vs.
Revision 1.5 by pippijn, Wed Aug 29 21:01:18 2007 UTC

3 * Rights to this code are documented in doc/pod/license.pod. 3 * Rights to this code are documented in doc/pod/license.pod.
4 * 4 *
5 * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) 5 * Copyright © 2005-2007 Atheme Project (http://www.atheme.org)
6 */ 6 */
7 7
8static char const rcsid[] = "$Id: parse.C,v 1.4 2007/08/28 17:08:12 pippijn Exp $"; 8static char const rcsid[] = "$Id: parse.C,v 1.5 2007/08/29 21:01:18 pippijn Exp $";
9 9
10#include "atheme.h" 10#include "atheme.h"
11#include "uplink.h" 11#include "uplink.h"
12#include "pmodule.h" 12#include "pmodule.h"
13 13
100 } 100 }
101 command = line; 101 command = line;
102 message = NULL; 102 message = NULL;
103 } 103 }
104 if (!si.s && !si.su && me.recvsvr) 104 if (!si.s && !si.su && me.recvsvr)
105 {
106 slog (LG_INFO, "irc_parse(): got message from nonexistant user or server: %s", origin); 105 return slog (LG_INFO, "irc_parse(): got message from nonexistant user or server: %s", origin);
107 return;
108 }
109 si.smu = si.su != NULL ? si.su->myuser : NULL; 106 si.smu = si.su != NULL ? si.su->myuser : NULL;
110 107
111 /* okay, the nasty part is over, now we need to make a 108 /* okay, the nasty part is over, now we need to make a
112 * parv out of what's left 109 * parv out of what's left
113 */ 110 */
128 125
129 /* now we should have origin (or NULL), command, and a parv 126 /* now we should have origin (or NULL), command, and a parv
130 * with it's accompanying parc... let's make ABSOLUTELY sure 127 * with it's accompanying parc... let's make ABSOLUTELY sure
131 */ 128 */
132 if (!command) 129 if (!command)
133 {
134 slog (LG_DEBUG, "irc_parse(): command not found: %s", coreLine); 130 return slog (LG_DEBUG, "irc_parse(): command not found: %s", coreLine);
135 return;
136 }
137 131
138 /* take the command through the hash table */ 132 /* take the command through the hash table */
139 if ((pcmd = pcommand_find (command))) 133 if ((pcmd = pcommand_find (command)))
140 { 134 {
141 if (si.su && !(pcmd->sourcetype & MSRC_USER)) 135 if (si.su && !(pcmd->sourcetype & MSRC_USER))
142 {
143 slog (LG_INFO, "irc_parse(): user %s sent disallowed command %s", si.su->nick, pcmd->token); 136 return slog (LG_INFO, "irc_parse(): user %s sent disallowed command %s", si.su->nick, pcmd->token);
144 return;
145 }
146 else if (si.s && !(pcmd->sourcetype & MSRC_SERVER)) 137 else if (si.s && !(pcmd->sourcetype & MSRC_SERVER))
147 {
148 slog (LG_INFO, "irc_parse(): server %s sent disallowed command %s", si.s->name, pcmd->token); 138 return slog (LG_INFO, "irc_parse(): server %s sent disallowed command %s", si.s->name, pcmd->token);
149 return;
150 }
151 else if (!me.recvsvr && !(pcmd->sourcetype & MSRC_UNREG)) 139 else if (!me.recvsvr && !(pcmd->sourcetype & MSRC_UNREG))
152 {
153 slog (LG_INFO, "irc_parse(): unregistered server sent disallowed command %s", pcmd->token); 140 return slog (LG_INFO, "irc_parse(): unregistered server sent disallowed command %s", pcmd->token);
154 return;
155 }
156 if (parc < pcmd->minparc) 141 if (parc < pcmd->minparc)
157 {
158 slog (LG_INFO, "irc_parse(): insufficient parameters for command %s", pcmd->token); 142 return slog (LG_INFO, "irc_parse(): insufficient parameters for command %s", pcmd->token);
159 return;
160 }
161 if (pcmd->handler) 143 if (pcmd->handler)
162 {
163 pcmd->handler (&si, parc, parv); 144 pcmd->handler (&si, parc, parv);
164 }
165 } 145 }
166 } 146 }
167} 147}
168 148
169/* parses a P10 IRC stream */ 149/* parses a P10 IRC stream */
246 command = line; 226 command = line;
247 } 227 }
248 } 228 }
249 229
250 if (!si.s && !si.su && me.recvsvr) 230 if (!si.s && !si.su && me.recvsvr)
251 {
252 slog (LG_DEBUG, "irc_parse(): got message from nonexistant user or server: %s", origin); 231 return slog (LG_DEBUG, "p10_parse(): got message from nonexistant user or server: %s", origin);
253 return;
254 }
255 si.smu = si.su != NULL ? si.su->myuser : NULL; 232 si.smu = si.su != NULL ? si.su->myuser : NULL;
256 233
257 /* okay, the nasty part is over, now we need to make a 234 /* okay, the nasty part is over, now we need to make a
258 * parv out of what's left 235 * parv out of what's left
259 */ 236 */
274 251
275 /* now we should have origin (or NULL), command, and a parv 252 /* now we should have origin (or NULL), command, and a parv
276 * with it's accompanying parc... let's make ABSOLUTELY sure 253 * with it's accompanying parc... let's make ABSOLUTELY sure
277 */ 254 */
278 if (!command) 255 if (!command)
279 {
280 slog (LG_DEBUG, "irc_parse(): command not found: %s", coreLine); 256 return slog (LG_DEBUG, "p10_parse(): command not found: %s", coreLine);
281 return;
282 }
283 257
284 /* take the command through the hash table */ 258 /* take the command through the hash table */
285 if ((pcmd = pcommand_find (command))) 259 if ((pcmd = pcommand_find (command)))
286 { 260 {
287 if (si.su && !(pcmd->sourcetype & MSRC_USER)) 261 if (si.su && !(pcmd->sourcetype & MSRC_USER))
288 {
289 slog (LG_INFO, "irc_parse(): user %s sent disallowed command %s", si.su->nick, pcmd->token); 262 return slog (LG_INFO, "p10_parse(): user %s sent disallowed command %s", si.su->nick, pcmd->token);
290 return;
291 }
292 else if (si.s && !(pcmd->sourcetype & MSRC_SERVER)) 263 else if (si.s && !(pcmd->sourcetype & MSRC_SERVER))
293 {
294 slog (LG_INFO, "irc_parse(): server %s sent disallowed command %s", si.s->name, pcmd->token); 264 return slog (LG_INFO, "p10_parse(): server %s sent disallowed command %s", si.s->name, pcmd->token);
295 return;
296 }
297 else if (!me.recvsvr && !(pcmd->sourcetype & MSRC_UNREG)) 265 else if (!me.recvsvr && !(pcmd->sourcetype & MSRC_UNREG))
298 {
299 slog (LG_INFO, "irc_parse(): unregistered server sent disallowed command %s", pcmd->token); 266 return slog (LG_INFO, "p10_parse(): unregistered server sent disallowed command %s", pcmd->token);
300 return;
301 }
302 if (parc < pcmd->minparc) 267 if (parc < pcmd->minparc)
303 {
304 slog (LG_INFO, "irc_parse(): insufficient parameters for command %s", pcmd->token); 268 return slog (LG_INFO, "p10_parse(): insufficient parameters for command %s", pcmd->token);
305 return;
306 }
307 if (pcmd->handler) 269 if (pcmd->handler)
308 {
309 pcmd->handler (&si, parc, parv); 270 pcmd->handler (&si, parc, parv);
310 return;
311 }
312 } 271 }
313 } 272 }
314} 273}
315
316/* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
317 * vim:ts=8
318 * vim:sw=8
319 * vim:noexpandtab
320 */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines