[hackers] [sic] some changes

From: Anselm R. Garbe <jg_AT_suckless.org>
Date: Fri Feb 09 14:40:44 2007

changeset: 75:2d59ad24f377
tag: tip
user: Anselm R. Garbe <arg_AT_suckless.org>
date: Fri Feb 09 14:40:11 2007 +0100
summary: some changes

diff -r 3fcdffcc2a63 -r 2d59ad24f377 sic.c
--- a/sic.c Thu Feb 08 20:42:29 2007 +0100
+++ b/sic.c Fri Feb 09 14:40:11 2007 +0100
@@ -102,45 +102,43 @@ parsesrv(char *msg) {
         if(!msg || !(*msg))
                 return;
         pout("debug", msg);
- if(msg[0] == ':') { /* check prefix */
- if(!(p = strchr(msg, ' ')))
- return;
- *p = 0;
- usr = &msg[1];
- cmd = ++p;
- if((p = strchr(usr, '!')))
- *p = 0;
- } else
- cmd = msg;
+ if(msg[0] != ':')
+ return; /* don't handle prefix-less server commands */
+ if(!(p = strchr(msg, ' ')))
+ return;
+ usr = &msg[1];
+ *p = 0;
+ cmd = ++p;
+ if((p = strchr(usr, '!')))
+ *p = 0;
         /* remove CRLFs */
- for(p = cmd; *p; p++)
+ if(!(p = strchr(cmd, ':')))
+ return;
+ *p = 0;
+ txt = ++p;
+ for(p = txt; *p; p++)
                 if(*p == '\r' || *p == '\n')
                         *p = 0;
         if(!strncmp("PONG", cmd, 4))
                 return;
- if(!strncmp("PRIVMSG", cmd, 7) || !strncmp("PING", cmd, 4)) {
+ if(!strncmp("PRIVMSG", cmd, 7)) {
                 if(!(p = strchr(cmd, ' ')))
                         return;
                 *p = 0;
                 chan = ++p;
                 for(; *p && *p != ' '; p++);
                 *p = 0;
- if(!(p = strchr(++p, ':')))
- return;
- *p = 0;
- txt = ++p;
- if(!strncmp("PRIVMSG", cmd, 8) && chan && txt) {
- snprintf(bufout, sizeof bufout, "<%s> %s", usr, txt);
- pout(chan, bufout);
- }
- else if(!strncmp("PING", cmd, 5) && txt) {
- snprintf(bufout, sizeof bufout, "PONG %s\r\n", txt);
- write(srv, bufout, strlen(bufout));
- }
- return;
- }
- snprintf(bufout, sizeof bufout, "-!- %s", cmd);
- pout(host, bufout);
+ snprintf(bufout, sizeof bufout, "<%s> %s", usr, txt);
+ pout(chan, bufout);
+ }
+ else if(!strncmp("PING", cmd, 4) && txt) {
+ snprintf(bufout, sizeof bufout, "PONG %s\r\n", txt);
+ write(srv, bufout, strlen(bufout));
+ }
+ else {
+ snprintf(bufout, sizeof bufout, "-!- %s", cmd);
+ pout(usr, bufout);
+ }
 }
 
 int
Received on Fri Feb 09 2007 - 14:40:44 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:55:04 UTC