[cvslog] Module eggdrop1.7: Change committed

cvslog cvs at tsss.org
Fri Oct 12 08:44:00 CST 2001


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.7
Commit time: 2001-10-12 13:43:44 UTC
Commited by: Tothwolf <tothwolf at techmonkeys.org>

Modified files:
     src/mod/server.mod/server.c

Log message:

* Getting rid of splitnicks()...

---------------------- diff included ----------------------
Index: eggdrop1.7/src/mod/server.mod/server.c
diff -u eggdrop1.7/src/mod/server.mod/server.c:1.85 eggdrop1.7/src/mod/server.mod/server.c:1.86
--- eggdrop1.7/src/mod/server.mod/server.c:1.85	Thu Oct 11 13:24:03 2001
+++ eggdrop1.7/src/mod/server.mod/server.c	Fri Oct 12 08:43:34 2001
@@ -2,7 +2,7 @@
  * server.c -- part of server.mod
  *   basic irc server support
  *
- * $Id: server.c,v 1.85 2001/10/11 18:24:03 tothwolf Exp $
+ * $Id: server.c,v 1.86 2001/10/12 13:43:34 tothwolf Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -100,7 +100,6 @@
 static char *get_altbotnick(void);
 static int calc_penalty(char *);
 static int fast_deq(int);
-static char *splitnicks(char **);
 static void check_queues(char *, char *);
 static void parse_q(struct msgq_head *, char *, char *);
 static void purge_kicks(struct msgq_head *);
@@ -133,6 +132,25 @@
 #include "tclserv.c"
 
 
+/* FIXME: get rid of this */
+char *splitnicks(char **rest)
+{
+  register char *o, *r;
+
+  if (!rest)
+    return *rest = "";
+  o = *rest;
+  while (*o == ' ')
+    o++;
+  r = o;
+  while (*o && *o != ',')
+    o++;
+  if (*o)
+    *o++ = 0;
+  *rest = o;
+  return r;
+}
+
 /*
  *     Bot server queues
  */
@@ -241,7 +259,7 @@
 
 static int calc_penalty(char * msg)
 {
-  char *cmd, *par1, *par2, *par3;
+  char *cmd, *par1, *par2;
   register int penalty, i, ii;
 
   if (!use_penalties &&
@@ -263,18 +281,14 @@
   if (!egg_strcasecmp(cmd, "KICK")) {
     par1 = newsplit(&msg); /* channel */
     par2 = newsplit(&msg); /* victim(s) */
-    par3 = splitnicks(&par2);
+    strtok(par2, ",");
     penalty++;
-    while (strlen(par3) > 0) {
-      par3 = splitnicks(&par2);
+    while (strtok(NULL, ",") != NULL)
       penalty++;
-    }
     ii = penalty;
-    par3 = splitnicks(&par1);
-    while (strlen(par1) > 0) {
-      par3 = splitnicks(&par1);
+    strtok(par1, " ");
+    while (strtok(NULL, ",") != NULL)
       penalty += ii;
-    }
   } else if (!egg_strcasecmp(cmd, "MODE")) {
     i = 0;
     par1 = newsplit(&msg); /* channel */
@@ -293,9 +307,11 @@
       i += 2;
     }
     ii = 0;
-    while (strlen(par1) > 0) {
-      splitnicks(&par1);
+    if (strlen(par1)) {
+      strtok(par1, ",");
       ii++;
+      while (strtok(NULL, ",") != NULL)
+        ii++;
     }
     penalty += (ii * i);
   } else if (!egg_strcasecmp(cmd, "TOPIC")) {
@@ -303,30 +319,35 @@
     par1 = newsplit(&msg); /* channel */
     par2 = newsplit(&msg); /* topic */
     if (strlen(par2) > 0) {  /* topic manipulation => 2 penalty points */
+      strtok(par1, ",");
       penalty += 2;
-      par3 = splitnicks(&par1);
-      while (strlen(par1) > 0) {
-        par3 = splitnicks(&par1);
+      while (strtok(NULL, ",") != NULL)
         penalty += 2;
-      }
     }
   } else if (!egg_strcasecmp(cmd, "PRIVMSG") ||
 	     !egg_strcasecmp(cmd, "NOTICE")) {
     par1 = newsplit(&msg); /* channel(s)/nick(s) */
     /* Add one sec penalty for each recipient */
-    while (strlen(par1) > 0) {
-      splitnicks(&par1);
+    if (strlen(par1)) {
+      strtok(par1, ",");
       penalty++;
+      while (strtok(NULL, ",") != NULL)
+        penalty++;
     }
   } else if (!egg_strcasecmp(cmd, "WHO")) {
     par1 = newsplit(&msg); /* masks */
-    par2 = par1;
-    while (strlen(par1) > 0) {
-      par2 = splitnicks(&par1);
+    if (strlen(par1)) {
+      par2 = strtok(par1, ",");
       if (strlen(par2) > 4)   /* long WHO-masks receive less penalty */
-        penalty += 3;
+	penalty += 3;
       else
-        penalty += 5;
+	penalty += 5;
+      while ((par2 = strtok(NULL, ",")) != NULL) {
+	if (strlen(par2) > 4)   /* long WHO-masks receive less penalty */
+	  penalty += 3;
+	else
+	  penalty += 5;
+      }
     }
   } else if (!egg_strcasecmp(cmd, "AWAY")) {
     if (strlen(msg) > 0)
@@ -370,24 +391,6 @@
   return penalty;
 }
 
-char *splitnicks(char **rest)
-{
-  register char *o, *r;
-
-  if (!rest)
-    return *rest = "";
-  o = *rest;
-  while (*o == ' ')
-    o++;
-  r = o;
-  while (*o && *o != ',')
-    o++;
-  if (*o)
-    *o++ = 0;
-  *rest = o;
-  return r;
-}
-
 static int fast_deq(int which)
 {
   struct msgq_head *h;
@@ -538,8 +541,9 @@
       newsplit(&msg);
       chan = newsplit(&msg);
       nicks = newsplit(&msg);
+/* FIXME: get rid of splitnicks() */
       while (strlen(nicks) > 0) {
-        nick = splitnicks(&nicks);
+	nick = splitnicks(&nicks);
         if (!egg_strcasecmp(nick, oldnick) &&
             ((9 + strlen(chan) + strlen(newnicks) + strlen(newnick) +
               strlen(nicks) + strlen(msg)) < 510)) {
@@ -598,9 +602,10 @@
       newsplit(&reason);
       chan = newsplit(&reason);
       nicks = newsplit(&reason);
+/* FIXME: get rid of splitnicks() */
       while (strlen(nicks) > 0) {
         found = 0;
-        nick = splitnicks(&nicks);
+	nick = splitnicks(&nicks);
         strncpyz(chans, chan, sizeof chans);
         chns = chans;
         while (strlen(chns) > 0) {
@@ -705,8 +710,9 @@
       chan2 = newsplit(&reason2);
       nicks = newsplit(&reason2);
       if (!egg_strcasecmp(chan, chan2) && !egg_strcasecmp(reason, reason2)) {
-        while (strlen(nicks) > 0) {
-          nick = splitnicks(&nicks);
+/* FIXME: get rid of splitnicks() */
+	while (strlen(nicks) > 0) {
+	  nick = splitnicks(&nicks);
           if ((nr < kick_method) &&
              ((9 + strlen(chan) + strlen(newnicks) + strlen(nick) +
              strlen(reason)) < 510)) {
----------------------- End of diff -----------------------



More information about the Changes mailing list