[cvslog] Module eggdrop1.7: Change committed

cvslog cvs at tsss.org
Tue Oct 16 06:43:01 CST 2001


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.7
Commit time: 2001-10-16 11:42:40 UTC
Commited by: Tothwolf <tothwolf at techmonkeys.org>

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

Log message:

* fixed a typo in deq_kick()
* check_queues() added back to tree
* parse_q() added back to tree
* purge_kicks() added back to tree

---------------------- diff included ----------------------
Index: eggdrop1.7/src/mod/server.mod/server.c
diff -u eggdrop1.7/src/mod/server.mod/server.c:1.89 eggdrop1.7/src/mod/server.mod/server.c:1.90
--- eggdrop1.7/src/mod/server.mod/server.c:1.89	Sun Oct 14 18:13:33 2001
+++ eggdrop1.7/src/mod/server.mod/server.c	Tue Oct 16 06:42:30 2001
@@ -2,7 +2,7 @@
  * server.c -- part of server.mod
  *   basic irc server support
  *
- * $Id: server.c,v 1.89 2001/10/14 23:13:33 stdarg Exp $
+ * $Id: server.c,v 1.90 2001/10/16 11:42:30 tothwolf Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -100,6 +100,9 @@
 static char *get_altbotnick(void);
 static int calc_penalty(char *);
 static int fast_deq(int);
+static void check_queues(char *, char *);
+static void parse_q(struct msgq_head *, char *, char *);
+static void purge_kicks(struct msgq_head *);
 static int deq_kick(int);
 static void msgq_clear(struct msgq_head *qh);
 
@@ -487,6 +490,148 @@
   return 0;
 }
 
+static void check_queues(char *oldnick, char *newnick)
+{
+  if (optimize_kicks == 2) {
+    if (modeq.head)
+      parse_q(&modeq, oldnick, newnick);
+    if (mq.head)
+      parse_q(&mq, oldnick, newnick);
+    if (hq.head)
+      parse_q(&hq, oldnick, newnick);
+  }
+}
+
+static void parse_q(struct msgq_head *q, char *oldnick, char *newnick)
+{
+  struct msgq *m, *lm = NULL;
+  char buf[511], *msg, *nicks, *nick, *chan, newnicks[511], newmsg[511];
+  int changed;
+
+  for (m = q->head; m;) {
+    changed = 0;
+    if (optimize_kicks == 2 && !egg_strncasecmp(m->msg, "KICK ", 5)) {
+      newnicks[0] = 0;
+      strncpyz(buf, m->msg, sizeof buf);
+      if (buf[0] && (buf[strlen(buf)-1] == '\n'))
+	buf[strlen(buf)-1] = '\0';
+      msg = buf;
+      newsplit(&msg);
+      chan = newsplit(&msg);
+      nicks = newsplit(&msg);
+      nick = strtok(nicks, ",");
+      while (nick) {
+	if (!egg_strcasecmp(nick, oldnick) &&
+	    ((9 + strlen(chan) + strlen(newnicks) + strlen(newnick) +
+	  strlen(nicks) + strlen(msg)) < 510)) {
+	  if (newnick)
+	    egg_snprintf(newnicks, sizeof newnicks, "%s,%s", newnicks, newnick);
+	  changed = 1;
+	} else
+	  egg_snprintf(newnicks, sizeof newnicks, ",%s", nick);
+	nick = strtok(NULL, ",");
+      }
+      egg_snprintf(newmsg, sizeof newmsg, "KICK %s %s %s\n", chan,
+		   newnicks + 1, msg);
+    }
+    if (changed) {
+      if (newnicks[0] == 0) {
+	if (!lm)
+	  q->head = m->next;
+	else
+	  lm->next = m->next;
+	free(m->msg);
+	free(m);
+	m = lm;
+	q->tot--;
+	if (!q->head)
+	  q->last = 0;
+      } else {
+	free(m->msg);
+	m->msg = malloc(strlen(newmsg) + 1);
+	m->len = strlen(newmsg);
+	strcpy(m->msg, newmsg);
+      }
+    }
+    lm = m;
+    if (m)
+      m = m->next;
+    else
+      m = q->head;
+  }
+}
+
+static void purge_kicks(struct msgq_head *q)
+{
+  struct msgq *m, *lm = NULL;
+  char buf[511], *reason, *nicks, *nick, *chan, newnicks[511],
+       newmsg[511], chans[511], *chns, *ch;
+  int changed, found;
+  struct chanset_t *cs;
+
+  for (m = q->head; m;) {
+    if (!egg_strncasecmp(m->msg, "KICK", 4)) {
+      newnicks[0] = 0;
+      changed = 0;
+      strncpyz(buf, m->msg, sizeof buf);
+      if (buf[0] && (buf[strlen(buf)-1] == '\n'))
+	buf[strlen(buf)-1] = '\0';
+      reason = buf;
+      newsplit(&reason);
+      chan = newsplit(&reason);
+      nicks = newsplit(&reason);
+      nick = strtok(nicks, ",");
+      while (nick) {
+	found = 0;
+	strncpyz(chans, chan, sizeof chans);
+	chns = chans;
+	while (strlen(chns) > 0) {
+	  ch = newsplit(&chns);
+	  cs = findchan(ch);
+	  if (!cs)
+	    continue;
+	  if (ismember(cs, nick))
+	    found = 1;
+	}
+	if (found)
+	  egg_snprintf(newnicks, sizeof newnicks, "%s,%s", newnicks, nick);
+	else {
+	  putlog(LOG_SRVOUT, "*", "%s isn't on any target channel, removing "
+		 "kick...", nick);
+	  changed = 1;
+	}
+	nick = strtok(NULL, ",");
+      }
+      if (changed) {
+	if (newnicks[0] == 0) {
+	  if (!lm)
+	    q->head = m->next;
+	  else
+	    lm->next = m->next;
+	  free(m->msg);
+	  free(m);
+	  m = lm;
+	  q->tot--;
+	  if (!q->head)
+	    q->last = 0;
+	} else {
+	  free(m->msg);
+	  egg_snprintf(newmsg, sizeof newmsg, "KICK %s %s %s\n", chan,
+		       newnicks + 1, reason);
+	  m->msg = malloc(strlen(newmsg) + 1);
+	  m->len = strlen(newmsg);
+	  strcpy(m->msg, newmsg);
+	}
+      }
+    }
+    lm = m;
+    if (m)
+      m = m->next;
+    else
+      m = q->head;
+  }
+}
+
 static int deq_kick(int which)
 {
   struct msgq_head *h;
@@ -513,6 +658,13 @@
   }
   if (egg_strncasecmp(h->head->msg, "KICK", 4))
     return 0;
+  if (optimize_kicks == 2) {
+    purge_kicks(h);
+    if (!h->head)
+      return 1;
+  }
+  if (egg_strncasecmp(h->head->msg, "KICK", 4))
+    return 0;
   msg = h->head;
   strncpyz(buf, msg->msg, sizeof buf);
   reason = buf;
@@ -537,7 +689,7 @@
       nicks = newsplit(&reason2);
       if (!egg_strcasecmp(chan, chan2) && !egg_strcasecmp(reason, reason2)) {
         nick = strtok(nicks, ",");
-	while (nicks) {
+	while (nick) {
           if ((nr < kick_method) &&
              ((9 + strlen(chan) + strlen(newnicks) + strlen(nick) +
              strlen(reason)) < 510)) {
Index: eggdrop1.7/src/mod/server.mod/servmsg.c
diff -u eggdrop1.7/src/mod/server.mod/servmsg.c:1.76 eggdrop1.7/src/mod/server.mod/servmsg.c:1.77
--- eggdrop1.7/src/mod/server.mod/servmsg.c:1.76	Sun Oct 14 18:13:33 2001
+++ eggdrop1.7/src/mod/server.mod/servmsg.c	Tue Oct 16 06:42:30 2001
@@ -1,7 +1,7 @@
 /*
  * servmsg.c -- part of server.mod
  *
- * $Id: servmsg.c,v 1.76 2001/10/14 23:13:33 stdarg Exp $
+ * $Id: servmsg.c,v 1.77 2001/10/16 11:42:30 tothwolf Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -807,6 +807,7 @@
   fixcolon(msg);
   u = get_user_by_host(from);
   nick = strtok(from, "!");
+  check_queues(nick, msg);
   if (match_my_nick(nick)) {
     /* Regained nick! */
     strncpyz(botname, msg, NICKLEN);
----------------------- End of diff -----------------------



More information about the Changes mailing list