]> git.armaanb.net Git - sic.git/blobdiff - sic.c
consistency patch
[sic.git] / sic.c
diff --git a/sic.c b/sic.c
index 3ef526cac58e3d5ed2eebf7ccc4a0dbbd4366711..6580bdf3d128cf6600568ce1e687808e985f1031 100644 (file)
--- a/sic.c
+++ b/sic.c
@@ -47,8 +47,8 @@ pout(char *channel, char *msg) {
        static char timestr[18];
        time_t t = time(0);
 
-       strftime(timestr, sizeof timestr, "%F %R", localtime(&t));
-       fprintf(stdout, "%-8.8s: %s %s\n", channel, timestr, msg);
+       strftime(timestr, sizeof timestr, "%D %R", localtime(&t));
+       fprintf(stdout, "%-12.12s: %s %s\n", channel, timestr, msg);
 }
 
 static void
@@ -72,26 +72,26 @@ parsein(char *msg) {
                return;
        }
        if(!strncmp(msg + 1, "j ", 2) && (msg[3] == '#'))
-               snprintf(bufout, sizeof bufout, "JOIN %s\r\n", &msg[3]);
+               snprintf(bufout, sizeof bufout, "JOIN %s\r\n", msg + 3);
        else if(!strncmp(msg + 1, "l ", 2))
-               snprintf(bufout, sizeof bufout, "PART %s :sic - 250 LOC are too much!\r\n", &msg[3]);
+               snprintf(bufout, sizeof bufout, "PART %s :sic - 250 LOC are too much!\r\n", msg + 3);
        else if(!strncmp(msg + 1, "m ", 2)) {
-               if((p = strchr(&msg[3], ' ')))
+               if((p = strchr(msg + 3, ' ')))
                        *(p++) = 0;
-               privmsg(&msg[3], p);
+               privmsg(msg + 3, p);
                return;
        }
        else if(!strncmp(msg + 1, "s ", 2)) {
-               strncpy(channel, &msg[3], sizeof channel);
+               strncpy(channel, msg + 3, sizeof channel);
                return;
        }
        else if(!strncmp(msg + 1, "t ", 2)) {
-               if((p = strchr(&msg[3], ' ')))
+               if((p = strchr(msg + 3, ' ')))
                        *(p++) = 0;
-               snprintf(bufout, sizeof bufout, "TOPIC %s :%s\r\n", &msg[3], p);
+               snprintf(bufout, sizeof bufout, "TOPIC %s :%s\r\n", msg + 3, p);
        }
        else
-               snprintf(bufout, sizeof bufout, "%s\r\n", &msg[1]);
+               snprintf(bufout, sizeof bufout, "%s\r\n", msg + 1);
        write(srv, bufout, strlen(bufout));
 }
 
@@ -99,26 +99,25 @@ static void
 parsesrv(char *msg) {
        char *chan, *cmd, *p, *txt, *usr; 
 
+       txt = NULL;
        if(!msg || !(*msg))
                return;
-       pout("debug", msg);
        if(msg[0] != ':')
                return; /* don't handle prefix-less server commands */
        if(!(p = strchr(msg, ' ')))
                return;
-       usr = &msg[1];
+       usr = msg + 1;
        *p = 0;
        cmd = ++p;
        if((p = strchr(usr, '!')))
                *p = 0;
-       /* remove CRLFs */
-       if(!(p = strchr(cmd, ':')))
-               return;
-       *p = 0;
-       txt = ++p;
-       for(p = txt; *p; p++)
+       for(p = cmd; *p; p++) /* remove CRLFs */
                if(*p == '\r' || *p == '\n')
                        *p = 0;
+       if((p = strchr(cmd, ':'))) {
+               *p = 0;
+               txt = ++p;
+       }
        if(!strncmp("PONG", cmd, 4))
                return;
        if(!strncmp("PRIVMSG", cmd, 7) && txt) {
@@ -136,7 +135,7 @@ parsesrv(char *msg) {
                write(srv, bufout, strlen(bufout));
        }
        else {
-               snprintf(bufout, sizeof bufout, "-!- %s: %s", cmd, txt ? txt : "");
+               snprintf(bufout, sizeof bufout, ">< %s: %s", cmd, txt ? txt : "");
                pout(usr, bufout);
        }
 }