[cvslog] Module eggdrop1.7: Change committed

cvslog cvs at tsss.org
Sat Oct 13 10:56:01 CST 2001


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

Modified files:
     src/chanprog.c src/misc.c src/modules.c src/proto.h
     src/mod/module.h src/mod/channels.mod/userchan.c
     src/mod/irc.mod/chan.c src/mod/irc.mod/irc.c
     src/mod/irc.mod/mode.c src/mod/server.mod/server.c
     src/mod/server.mod/servmsg.c

Log message:

* splitnick() removed
* cleanup where splitnicks() was removed
* removed unused "existant" check from tell_bans/tell_exempts/tell_invites

---------------------- diff included ----------------------
Index: eggdrop1.7/src/chanprog.c
diff -u eggdrop1.7/src/chanprog.c:1.30 eggdrop1.7/src/chanprog.c:1.31
--- eggdrop1.7/src/chanprog.c:1.30	Thu Oct 11 13:24:01 2001
+++ eggdrop1.7/src/chanprog.c	Sat Oct 13 10:55:33 2001
@@ -5,7 +5,7 @@
  *   telling the current programmed settings
  *   initializing a lot of stuff and loading the tcl scripts
  *
- * $Id: chanprog.c,v 1.30 2001/10/11 18:24:01 tothwolf Exp $
+ * $Id: chanprog.c,v 1.31 2001/10/13 15:55:33 tothwolf Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -130,8 +130,8 @@
   register struct chanset_t	*chan;
 
   strncpyz(buf, host, sizeof buf);
-  uhost = buf;
-  nick = splitnick(&uhost);
+  nick = strtok(buf, "!");
+  uhost = strtok(NULL, "!");
   for (chan = chanset; chan; chan = chan->next)
     for (m = chan->channel.member; m && m->nick[0]; m = m->next)
       if (!irccmp(nick, m->nick) && !egg_strcasecmp(uhost, m->userhost))
@@ -195,8 +195,8 @@
   register struct chanset_t	*chan;
 
   strncpyz(buf, host, sizeof buf);
-  uhost = buf;
-  nick = splitnick(&uhost);
+  uhost = strtok(buf, "!");
+  nick = strtok(NULL, "!");
   for (chan = chanset; chan; chan = chan->next)
     for (m = chan->channel.member; m && m->nick[0]; m = m->next)
       if (!irccmp(nick, m->nick) && !egg_strcasecmp(uhost, m->userhost))
Index: eggdrop1.7/src/misc.c
diff -u eggdrop1.7/src/misc.c:1.48 eggdrop1.7/src/misc.c:1.49
--- eggdrop1.7/src/misc.c:1.48	Thu Oct 11 13:24:01 2001
+++ eggdrop1.7/src/misc.c	Sat Oct 13 10:55:33 2001
@@ -7,7 +7,7 @@
  *   help system
  *   motd display and %var substitution
  *
- * $Id: misc.c,v 1.48 2001/10/11 18:24:01 tothwolf Exp $
+ * $Id: misc.c,v 1.49 2001/10/13 15:55:33 tothwolf Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -223,18 +223,6 @@
      *  guaranteed to be at least 2 bytes higher in memory than dest. <Cybah>
      */
     strcpy(rest, p + 1);
-}
-
-char *splitnick(char **blah)
-{
-  char *p = strchr(*blah, '!'), *q = *blah;
-
-  if (p) {
-    *p = 0;
-    *blah = p + 1;
-    return q;
-  }
-  return "";
 }
 
 char *newsplit(char **rest)
Index: eggdrop1.7/src/mod/channels.mod/userchan.c
diff -u eggdrop1.7/src/mod/channels.mod/userchan.c:1.28 eggdrop1.7/src/mod/channels.mod/userchan.c:1.29
--- eggdrop1.7/src/mod/channels.mod/userchan.c:1.28	Thu Oct 11 13:24:02 2001
+++ eggdrop1.7/src/mod/channels.mod/userchan.c	Sat Oct 13 10:55:33 2001
@@ -1,7 +1,7 @@
 /*
  * userchan.c -- part of channels.mod
  *
- * $Id: userchan.c,v 1.28 2001/10/11 18:24:02 tothwolf Exp $
+ * $Id: userchan.c,v 1.29 2001/10/13 15:55:33 tothwolf Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -778,26 +778,25 @@
   }
   if (chan->status & CHAN_ACTIVE) {
     masklist *b;
-    char s[UHOSTLEN], *s1, *s2, fill[256];
+    /* FIXME: possible buffer overflow in fill[] */
+    char buf[UHOSTLEN], *nick, *uhost, fill[UHOSTLEN * 2];
     int min, sec;
 
     for (b = chan->channel.ban; b && b->mask[0]; b = b->next) {    
       if ((!u_equals_mask(global_bans, b->mask)) &&
 	  (!u_equals_mask(chan->bans, b->mask))) {
-	strcpy(s, b->who);
-	s2 = s;
-	s1 = splitnick(&s2);
-	if (s1[0])
-	  sprintf(fill, "%s (%s!%s)", b->mask, s1, s2);
-	else if (!egg_strcasecmp(s, "existant"))
-	  sprintf(fill, "%s (%s)", b->mask, s2);
+	strncpyz(buf, b->who, sizeof buf);
+	nick = strtok(buf, "!");
+	uhost = strtok(NULL, "!");
+	if (nick[0])
+	  sprintf(fill, "%s (%s!%s)", b->mask, nick, uhost);
 	else
-	  sprintf(fill, "%s (server %s)", b->mask, s2);
+	  sprintf(fill, "%s (server %s)", b->mask, uhost);
 	if (b->timer != 0) {
 	  min = (now - b->timer) / 60;
 	  sec = (now - b->timer) - (min * 60);
-	  sprintf(s, " (active %02d:%02d)", min, sec);
-	  strcat(fill, s);
+	  sprintf(buf, " (active %02d:%02d)", min, sec);
+	  strcat(fill, buf);
 	}
 	if ((!match[0]) || (wild_match(match, b->mask)))
 	  dprintf(idx, "* [%3d] %s\n", k, fill);
@@ -869,26 +868,25 @@
   }
   if (chan->status & CHAN_ACTIVE) {
     masklist *e;
-    char s[UHOSTLEN], *s1, *s2,fill[256];
+    /* FIXME: possible buffer overflow in fill[] */
+    char buf[UHOSTLEN], *nick, *uhost, fill[UHOSTLEN * 2];
     int min, sec;
 
     for (e = chan->channel.exempt; e && e->mask[0]; e = e->next) {
       if ((!u_equals_mask(global_exempts,e->mask)) &&
 	  (!u_equals_mask(chan->exempts, e->mask))) {
-	strcpy(s, e->who);
-	s2 = s;
-	s1 = splitnick(&s2);
-	if (s1[0])
-	  sprintf(fill, "%s (%s!%s)", e->mask, s1, s2);
-	else if (!egg_strcasecmp(s, "existant"))
-	  sprintf(fill, "%s (%s)", e->mask, s2);
+	strncpyz(buf, e->who, sizeof buf);
+	nick = strtok(buf, "!");
+	uhost = strtok(NULL, "!");
+	if (nick[0])
+	  sprintf(fill, "%s (%s!%s)", e->mask, nick, uhost);
 	else
-	  sprintf(fill, "%s (server %s)", e->mask, s2);
+	  sprintf(fill, "%s (server %s)", e->mask, uhost);
 	if (e->timer != 0) {
 	  min = (now - e->timer) / 60;
 	  sec = (now - e->timer) - (min * 60);
-	  sprintf(s, " (active %02d:%02d)", min, sec);
-	  strcat(fill, s);
+	  sprintf(buf, " (active %02d:%02d)", min, sec);
+	  strcat(fill, buf);
 	}
 	if ((!match[0]) || (wild_match(match, e->mask)))
 	  dprintf(idx, "* [%3d] %s\n", k, fill);
@@ -960,26 +958,25 @@
   }
   if (chan->status & CHAN_ACTIVE) {
     masklist *i;
-    char s[UHOSTLEN], *s1, *s2,fill[256];
+    /* FIXME: possible buffer overflow in fill[] */
+    char buf[UHOSTLEN], *nick, *uhost, fill[UHOSTLEN * 2];
     int min, sec;
 
     for (i = chan->channel.invite; i && i->mask[0]; i = i->next) {
       if ((!u_equals_mask(global_invites,i->mask)) &&
 	  (!u_equals_mask(chan->invites, i->mask))) {
-	strcpy(s, i->who);
-	s2 = s;
-	s1 = splitnick(&s2);
-	if (s1[0])
-	  sprintf(fill, "%s (%s!%s)", i->mask, s1, s2);
-	else if (!egg_strcasecmp(s, "existant"))
-	  sprintf(fill, "%s (%s)", i->mask, s2);
+	strncpyz(buf, i->who, sizeof buf);
+	nick = strtok(buf, "!");
+	uhost = strtok(NULL, "!");
+	if (nick[0])
+	  sprintf(fill, "%s (%s!%s)", i->mask, nick, uhost);
 	else
-	  sprintf(fill, "%s (server %s)", i->mask, s2);
+	  sprintf(fill, "%s (server %s)", i->mask, uhost);
 	if (i->timer != 0) {
 	  min = (now - i->timer) / 60;
 	  sec = (now - i->timer) - (min * 60);
-	  sprintf(s, " (active %02d:%02d)", min, sec);
-	  strcat(fill, s);
+	  sprintf(buf, " (active %02d:%02d)", min, sec);
+	  strcat(fill, buf);
 	}
 	if ((!match[0]) || (wild_match(match, i->mask)))
 	  dprintf(idx, "* [%3d] %s\n", k, fill);
@@ -1206,25 +1203,25 @@
  */
 static int expired_mask(struct chanset_t *chan, char *who)
 {
-  memberlist		*m, *m2;
-  char			 buf[UHOSTLEN], *snick, *sfrom;
-  struct userrec	*u;
+  char buf[UHOSTLEN], *nick, *uhost;
+  struct userrec *u;
+  memberlist *m, *m2;
 
   /* Always expire masks, regardless of who set it? */
   if (force_expire)
     return 1;
 
-  strcpy(buf, who);
-  sfrom = buf;
-  snick = splitnick(&sfrom);
+  strncpyz(buf, who, sizeof buf);
+  nick = strtok(buf, "!");
+  uhost = strtok(NULL, "!");
 
-  if (!snick[0])
+  if (!nick[0])
     return 1;
 
-  m = ismember(chan, snick);
+  m = ismember(chan, nick);
   if (!m)
     for (m2 = chan->channel.member; m2 && m2->nick[0]; m2 = m2->next)
-      if (!egg_strcasecmp(sfrom, m2->userhost)) {
+      if (!egg_strcasecmp(uhost, m2->userhost)) {
 	m = m2;
 	break;
       }
Index: eggdrop1.7/src/mod/irc.mod/chan.c
diff -u eggdrop1.7/src/mod/irc.mod/chan.c:1.76 eggdrop1.7/src/mod/irc.mod/chan.c:1.77
--- eggdrop1.7/src/mod/irc.mod/chan.c:1.76	Thu Oct 11 13:24:02 2001
+++ eggdrop1.7/src/mod/irc.mod/chan.c	Sat Oct 13 10:55:33 2001
@@ -6,7 +6,7 @@
  *   user kickban, kick, op, deop
  *   idle kicking
  *
- * $Id: chan.c,v 1.76 2001/10/11 18:24:02 tothwolf Exp $
+ * $Id: chan.c,v 1.77 2001/10/13 15:55:33 tothwolf Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -1324,16 +1324,18 @@
  */
 static int gotinvite(char *from, char *ignore, char *msg)
 {
-  char *nick;
+  char buf[UHOSTLEN], *nick, *uhost;
   struct chanset_t *chan;
 
   newsplit(&msg);
   fixcolon(msg);
-  nick = splitnick(&from);
+  strncpyz(buf, from, sizeof buf);
+  nick = strtok(buf, "!");
+  uhost = strtok(NULL, "!");
   if (!irccmp(last_invchan, msg))
     if (now - last_invtime < 30)
       return 0;		/* Two invites to the same channel in 30 seconds? */
-  putlog(LOG_MISC, "*", "%s!%s invited me to %s", nick, from, msg);
+  putlog(LOG_MISC, "*", "%s!%s invited me to %s", nick, uhost, msg);
   strncpy(last_invchan, msg, 299);
   last_invchan[299] = 0;
   last_invtime = now;
@@ -1341,7 +1343,6 @@
   if (!chan)
     /* Might be a short-name */
     chan = findchan_by_dname(msg);
-
   if (chan && (channel_pending(chan) || channel_active(chan)))
     dprintf(DP_HELP, "NOTICE %s :I'm already here.\n", nick);
   else if (chan && !channel_inactive(chan))
@@ -1367,7 +1368,7 @@
  */
 static int gottopic(char *from, char *ignore, char *msg)
 {
-  char *nick, *chname;
+  char buf[UHOSTLEN], *nick, *uhost, *chname;
   memberlist *m;
   struct chanset_t *chan;
   struct userrec *u;
@@ -1375,16 +1376,18 @@
   chname = newsplit(&msg);
   fixcolon(msg);
   u = get_user_by_host(from);
-  nick = splitnick(&from);
+  strncpyz(buf, from, sizeof buf);
+  nick = strtok(buf, "!");
+  uhost = strtok(NULL, "!");
   chan = findchan(chname);
   if (chan) {
     putlog(LOG_JOIN, chan->dname, "Topic changed on %s by %s!%s: %s",
-           chan->dname, nick, from, msg);
+	   chan->dname, nick, uhost, msg);
     m = ismember(chan, nick);
     if (m != NULL)
       m->last = now;
     set_topic(chan, msg);
-    check_tcl_topc(nick, from, u, chan->dname, msg);
+    check_tcl_topc(nick, uhost, u, chan->dname, msg);
   }
   return 0;
 }
@@ -1458,7 +1461,7 @@
  */
 static int gotjoin(char *from, char *ignore, char *chname)
 {
-  char *nick, *p, buf[UHOSTLEN], *uhost = buf;
+  char buf[UHOSTLEN], *nick, *uhost, *p;
   char *ch_dname = NULL;
   struct chanset_t *chan;
   memberlist *m;
@@ -1513,8 +1516,9 @@
     dprintf(DP_MODE, "PART %s\n", chname);
   } else if (!channel_pending(chan)) {
     chan->status &= ~CHAN_STOP_CYCLE;
-    strcpy(uhost, from);
-    nick = splitnick(&uhost);
+    strncpyz(buf, from, sizeof buf);
+    nick = strtok(buf, "!");
+    uhost = strtok(NULL, "!");
     detect_chan_flood(nick, uhost, from, chan, FLOOD_JOIN, NULL);
     /* Grab last time joined before we update it */
     u = get_user_by_host(from);
@@ -1709,7 +1713,7 @@
  */
 static int gotpart(char *from, char *ignore, char *msg)
 {
-  char *nick, *chname;
+  char buf[UHOSTLEN], *nick, *uhost, *chname;
   struct chanset_t *chan;
   struct userrec *u;
 
@@ -1722,8 +1726,6 @@
     return 0;
   }
   if (chan && !channel_pending(chan)) {
-    u = get_user_by_host(from);
-    nick = splitnick(&from);
     if (!channel_active(chan)) {
       /* whoa! */
       putlog(LOG_MISC, chan->dname,
@@ -1732,15 +1734,19 @@
       chan->status &= ~CHAN_PEND;
       reset_chan_info(chan);
     }
+    u = get_user_by_host(from);
     set_handle_laston(chan->dname, u, now);
-    check_tcl_part(nick, from, u, chan->dname, msg); /* This must be directly above the killmember, in case
+    strncpyz(buf, from, sizeof buf);
+    nick = strtok(buf, "!");
+    uhost = strtok(NULL, "!");
+    check_tcl_part(nick, uhost, u, chan->dname, msg); /* This must be directly above the killmember, in case
     							we're doing anything to the record that would affect
 							the above */
     killmember(chan, nick);
     if (msg[0])
-      putlog(LOG_JOIN, chan->dname, "%s (%s) left %s (%s).", nick, from, chan->dname, msg);
+      putlog(LOG_JOIN, chan->dname, "%s (%s) left %s (%s).", nick, uhost, chan->dname, msg);
     else
-      putlog(LOG_JOIN, chan->dname, "%s (%s) left %s.", nick, from, chan->dname);
+      putlog(LOG_JOIN, chan->dname, "%s (%s) left %s.", nick, uhost, chan->dname);
     /* If it was me, all hell breaks loose... */
     if (match_my_nick(nick)) {
       clear_channel(chan, 1);
@@ -1759,33 +1765,33 @@
  */
 static int gotkick(char *from, char *ignore, char *origmsg)
 {
-  char *nick, *whodid, *chname, s1[UHOSTLEN], buf[UHOSTLEN], *uhost = buf;
+  char buf[UHOSTLEN], *nick, *uhost, *kicked, *chname, s1[UHOSTLEN];
   char buf2[511], *msg;
   memberlist *m;
   struct chanset_t *chan;
   struct userrec *u;
   struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
 
-  strncpy(buf2, origmsg, 510);
-  buf2[510] = 0;
+  strncpyz(buf2, origmsg, sizeof buf2);
   msg = buf2;
   chname = newsplit(&msg);
   chan = findchan(chname);
   if (chan && channel_active(chan)) {
-    nick = newsplit(&msg);
+    kicked = newsplit(&msg);
     fixcolon(msg);
     u = get_user_by_host(from);
-    strcpy(uhost, from);
-    whodid = splitnick(&uhost);
-    detect_chan_flood(whodid, uhost, from, chan, FLOOD_KICK, nick);
-    m = ismember(chan, whodid);
+    strncpyz(buf, from, sizeof buf);
+    nick = strtok(buf, "!");
+    uhost = strtok(NULL, "!");
+    detect_chan_flood(nick, uhost, from, chan, FLOOD_KICK, kicked);
+    m = ismember(chan, nick);
     if (m)
       m->last = now;
     /* This _needs_ to use chan->dname <cybah> */
     get_user_flagrec(u, &fr, chan->dname);
     set_handle_laston(chan->dname, u, now);
-    check_tcl_kick(whodid, uhost, u, chan->dname, nick, msg);
-    m = ismember(chan, nick);
+    check_tcl_kick(nick, uhost, u, chan->dname, kicked, msg);
+    m = ismember(chan, kicked);
     if (m) {
       struct userrec *u2;
 
@@ -1797,14 +1803,14 @@
     putlog(LOG_MODES, chan->dname, "%s kicked from %s by %s: %s", s1,
 	   chan->dname, from, msg);
     /* Kicked ME?!? the sods! */
-    if (match_my_nick(nick)) {
+    if (match_my_nick(kicked)) {
       chan->status &= ~(CHAN_ACTIVE | CHAN_PEND);
       dprintf(DP_MODE, "JOIN %s %s\n",
               (chan->name[0]) ? chan->name : chan->dname,
               chan->channel.key[0] ? chan->channel.key : chan->key_prot);
       clear_channel(chan, 1);
     } else {
-      killmember(chan, nick);
+      killmember(chan, kicked);
       check_lonely_channel(chan);
     }
   }
@@ -1815,14 +1821,15 @@
  */
 static int gotnick(char *from, char *ignore, char *msg)
 {
-  char *nick, s1[UHOSTLEN], buf[UHOSTLEN], *uhost = buf;
+  char buf[UHOSTLEN], *nick, *uhost, s1[UHOSTLEN];
   memberlist *m, *mm;
   struct chanset_t *chan;
   struct userrec *u;
 
-  strcpy(uhost, from);
-  nick = splitnick(&uhost);
   fixcolon(msg);
+  strncpyz(buf, from, sizeof buf);
+  nick = strtok(buf, "!");
+  uhost = strtok(NULL, "!");
   for (chan = chanset; chan; chan = chan->next) { 
     m = ismember(chan, nick);
     if (m) {
@@ -1873,17 +1880,16 @@
  */
 static int gotquit(char *from, char *ignore, char *msg)
 {
-  char *nick, *p, *alt;
-  char from2[NICKMAX + UHOSTMAX +1];
+  char buf[UHOSTLEN], *nick, *uhost, *p, *alt;
   int split = 0;
   memberlist *m;
   struct chanset_t *chan;
   struct userrec *u;
 
-  strcpy(from2,from);
-  u = get_user_by_host(from2);
-  nick = splitnick(&from);
   fixcolon(msg);
+  strncpyz(buf, from, sizeof buf);
+  nick = strtok(from, "!");
+  uhost = strtok(NULL, "!");
   /* Fred1: Instead of expensive wild_match on signoff, quicker method.
    *        Determine if signoff string matches "%.% %.%", and only one
    *        space.
@@ -1907,7 +1913,7 @@
   for (chan = chanset; chan; chan = chan->next) {
     m = ismember(chan, nick);
     if (m) {
-      u = get_user_by_host(from2);
+      u = get_user_by_host(from);
       if (u) {
         set_handle_laston(chan->dname, u, now); /* If you remove this, the bot will crash when the user record in question
 						   is removed/modified during the tcl binds below, and the users was on more
@@ -1915,13 +1921,13 @@
       }
       if (split) {
 	m->split = now;
-	check_tcl_splt(nick, from, u, chan->dname);
+	check_tcl_splt(nick, uhost, u, chan->dname);
 	putlog(LOG_JOIN, chan->dname, "%s (%s) got netsplit.", nick,
-	       from);
+	       uhost);
       } else {
-	check_tcl_sign(nick, from, u, chan->dname, msg);
+	check_tcl_sign(nick, uhost, u, chan->dname, msg);
 	putlog(LOG_JOIN, chan->dname, "%s (%s) left irc: %s", nick,
-	       from, msg);
+	       uhost, msg);
 	killmember(chan, nick);
 	check_lonely_channel(chan);
       }
@@ -1949,8 +1955,8 @@
  */
 static int gotmsg(char *from, char *ignore, char *msg)
 {
-  char *to, *realto, buf[UHOSTLEN], *nick, buf2[512], *uhost = buf;
-  char *p, *p1, *code, *ctcp;
+  char buf[UHOSTLEN], *nick, *uhost, *to, *realto, buf2[512], *p, *p1;
+  char *code, *ctcp;
   int ctcp_count = 0;
   struct chanset_t *chan;
   int ignoring;
@@ -1967,8 +1973,9 @@
   if (!chan)
     return 0;			/* Private msg to an unknown channel?? */
   fixcolon(msg);
-  strcpy(uhost, from);
-  nick = splitnick(&uhost);
+  strncpyz(buf, from, sizeof buf);
+  nick = strtok(buf, "!");
+  uhost = strtok(NULL, "!");
   /* Only check if flood-ctcp is active */
   if (flud_ctcp_thr && detect_avalanche(msg)) {
     u = get_user_by_host(from);
@@ -1998,6 +2005,7 @@
     if (!ignoring) {
       putlog(LOG_MODES, "*", "Avalanche from %s!%s in %s - ignoring",
 	     nick, uhost, chan->dname);
+      /* FIXME: get rid of this mess */
       p = strchr(uhost, '@');
       if (p)
 	p++;
@@ -2087,7 +2095,7 @@
  */
 static int gotnotice(char *from, char *ignore, char *msg)
 {
-  char *to, *realto, *nick, buf2[512], *p, *p1, buf[512], *uhost = buf;
+  char buf[UHOSTLEN], *nick, *uhost, *to, *realto, buf2[512], *p, *p1;
   char *ctcp, *code;
   struct userrec *u;
   memberlist *m;
@@ -2104,8 +2112,9 @@
   if (!chan)
     return 0;			/* Notice to an unknown channel?? */
   fixcolon(msg);
-  strcpy(uhost, from);
-  nick = splitnick(&uhost);
+  strncpyz(buf, from, sizeof buf);
+  nick = strtok(buf, "!");
+  uhost = strtok(NULL, "!");
   u = get_user_by_host(from);
   if (flud_ctcp_thr && detect_avalanche(msg)) {
     get_user_flagrec(u, &fr, chan->dname);
Index: eggdrop1.7/src/mod/irc.mod/irc.c
diff -u eggdrop1.7/src/mod/irc.mod/irc.c:1.68 eggdrop1.7/src/mod/irc.mod/irc.c:1.69
--- eggdrop1.7/src/mod/irc.mod/irc.c:1.68	Thu Oct 11 13:24:02 2001
+++ eggdrop1.7/src/mod/irc.mod/irc.c	Sat Oct 13 10:55:33 2001
@@ -2,7 +2,7 @@
  * irc.c -- part of irc.mod
  *   support for channels within the bot
  *
- * $Id: irc.c,v 1.68 2001/10/11 18:24:02 tothwolf Exp $
+ * $Id: irc.c,v 1.69 2001/10/13 15:55:33 tothwolf Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -225,12 +225,15 @@
     add_mode(chan, '-', 'o', badnick);
   /* Ban. Should be done before kicking. */
   if (chan->revenge_mode > 2) {
-    char s[UHOSTLEN], s1[UHOSTLEN];
+    char *baduhost, s[UHOSTLEN], s1[UHOSTLEN], s2[UHOSTLEN];
 
-    splitnick(&whobad);
-    maskhost(whobad, s1);
-    simple_sprintf(s, "(%s) %s", ct, reason);
-    u_addban(chan, s1, origbotname, s, now + (60 * ban_time), 0);
+    /* FIXME: clean this mess up */
+    strncpyz(s, whobad, sizeof s);
+    strtok(s, "!");
+    baduhost = strtok(NULL, "!");
+    maskhost(baduhost, s1);
+    simple_sprintf(s2, "(%s) %s", ct, reason);
+    u_addban(chan, s1, origbotname, s2, now + (60 * ban_time), 0);
     if (!mevictim && me_op(chan)) {
       add_mode(chan, '+', 'b', s1);
       flush_mode(chan, QUICK);
@@ -256,7 +259,7 @@
 static void maybe_revenge(struct chanset_t *chan, char *whobad,
 			  char *whovictim, int type)
 {
-  char *badnick, *victim;
+  char buf[UHOSTLEN], buf2[UHOSTLEN], *badnick, *victim;
   int mevictim;
   struct userrec *u, *u2;
 
@@ -265,11 +268,13 @@
 
   /* Get info about offender */
   u = get_user_by_host(whobad);
-  badnick = splitnick(&whobad);
+  strncpyz(buf, whobad, sizeof buf);
+  badnick = strtok(buf, "!");
 
   /* Get info about victim */
   u2 = get_user_by_host(whovictim);
-  victim = splitnick(&whovictim);
+  strncpyz(buf2, whovictim, sizeof buf2);
+  victim = strtok(buf2, "!");
   mevictim = match_my_nick(victim);
 
   /* Do we want to revenge? */
Index: eggdrop1.7/src/mod/irc.mod/mode.c
diff -u eggdrop1.7/src/mod/irc.mod/mode.c:1.53 eggdrop1.7/src/mod/irc.mod/mode.c:1.54
--- eggdrop1.7/src/mod/irc.mod/mode.c:1.53	Thu Oct 11 13:24:02 2001
+++ eggdrop1.7/src/mod/irc.mod/mode.c	Sat Oct 13 10:55:33 2001
@@ -4,7 +4,7 @@
  *   channel mode changes and the bot's reaction to them
  *   setting and getting the current wanted channel modes
  *
- * $Id: mode.c,v 1.53 2001/10/11 18:24:02 tothwolf Exp $
+ * $Id: mode.c,v 1.54 2001/10/13 15:55:33 tothwolf Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -856,17 +856,15 @@
 
 static int gotmode(char *from, char *ignore, char *origmsg)
 {
-  char *nick, *ch, *op, *chg, *msg;
-  char s[UHOSTLEN], buf[511];
+  char buf[UHOSTLEN], *nick, *uhost, *ch, *op, *chg, *msg;
+  char s[256], buf2[512];
   char ms2[3];
   int z;
   struct userrec *u;
   memberlist *m;
   struct chanset_t *chan;
 
-  strncpy(buf, origmsg, 510);
-  buf[510] = 0;
-  msg = buf;
+  strncpyz(buf2, origmsg, sizeof buf2);
   /* Usermode changes? */
   if (msg[0] && (strchr(CHANMETA, msg[0]) != NULL)) {
     ch = newsplit(&msg);
@@ -884,7 +882,9 @@
 	     ch, chg, msg, from);
       u = get_user_by_host(from);
       get_user_flagrec(u, &user, ch);
-      nick = splitnick(&from);
+      strncpyz(buf, from, sizeof buf);
+      nick = strtok(buf, "!");
+      uhost = strtok(NULL, "!");
       m = ismember(chan, nick);
       if (m)
 	m->last = now;
@@ -972,7 +972,7 @@
 	  if ((!nick[0]) && (bounce_modes))
 	    reversing = 1;
 	  if (ms2[0] == '-') {
-	    check_tcl_mode(nick, from, u, chan->dname, ms2, "");
+	    check_tcl_mode(nick, uhost, u, chan->dname, ms2, "");
 	    if (channel_active(chan)) {
 	      if ((reversing) && (chan->channel.maxmembers != 0)) {
 		simple_sprintf(s, "%d", chan->channel.maxmembers);
@@ -990,7 +990,7 @@
 	    if (op == '\0')
 	      break;
 	    chan->channel.maxmembers = atoi(op);
-	    check_tcl_mode(nick, from, u, chan->dname, ms2,
+	    check_tcl_mode(nick, uhost, u, chan->dname, ms2,
 			   int_to_base10(chan->channel.maxmembers));
 	    if (channel_pending(chan))
 	      break;
@@ -1018,11 +1018,11 @@
 	  if (op == '\0') {
 	    break;
 	  }
-	  check_tcl_mode(nick, from, u, chan->dname, ms2, op);
+	  check_tcl_mode(nick, uhost, u, chan->dname, ms2, op);
 	  if (ms2[0] == '+') {
 	    set_key(chan, op);
 	    if (channel_active(chan))
-	      got_key(chan, nick, from, op);
+	      got_key(chan, nick, uhost, op);
 	  } else {
 	    if (channel_active(chan)) {
 	      if ((reversing) && (chan->channel.key[0]))
@@ -1038,9 +1038,9 @@
 	  op = newsplit(&msg);
 	  fixcolon(op);
 	  if (ms2[0] == '+')
-	    got_op(chan, nick, from, op, u, &user);
+	    got_op(chan, nick, uhost, op, u, &user);
 	  else
-	    got_deop(chan, nick, from, op, u);
+	    got_deop(chan, nick, uhost, op, u);
 	  break;
 	case 'v':
 	  op = newsplit(&msg);
@@ -1059,7 +1059,7 @@
 	    if (ms2[0] == '+') {
 	      m->flags &= ~SENTVOICE;
 	      m->flags |= CHANVOICE;
-	      check_tcl_mode(nick, from, u, chan->dname, ms2, op);
+	      check_tcl_mode(nick, uhost, u, chan->dname, ms2, op);
 	      if (channel_active(chan) &&
 		  !glob_master(user) && !chan_master(user)) {
 		if (channel_autovoice(chan) &&
@@ -1072,7 +1072,7 @@
 	    } else {
 	      m->flags &= ~SENTDEVOICE;
 	      m->flags &= ~CHANVOICE;
-	      check_tcl_mode(nick, from, u, chan->dname, ms2, op);
+	      check_tcl_mode(nick, uhost, u, chan->dname, ms2, op);
 	      if (channel_active(chan) &&
 		  !glob_master(user) && !chan_master(user)) {
 		if ((channel_autovoice(chan) && !chan_quiet(victim) &&
@@ -1089,33 +1089,33 @@
 	case 'b':
 	  op = newsplit(&msg);
 	  fixcolon(op);
-	  check_tcl_mode(nick, from, u, chan->dname, ms2, op);
+	  check_tcl_mode(nick, uhost, u, chan->dname, ms2, op);
 	  if (ms2[0] == '+')
-	    got_ban(chan, nick, from, op);
+	    got_ban(chan, nick, uhost, op);
 	  else
-	    got_unban(chan, nick, from, op, u);
+	    got_unban(chan, nick, uhost, op, u);
 	  break;
 	case 'e':
 	  op = newsplit(&msg);
 	  fixcolon(op);
-	  check_tcl_mode(nick, from, u, chan->dname, ms2, op);
+	  check_tcl_mode(nick, uhost, u, chan->dname, ms2, op);
 	  if (ms2[0] == '+')
-	    got_exempt(chan, nick, from, op);
+	    got_exempt(chan, nick, uhost, op);
 	  else
-	    got_unexempt(chan, nick, from, op, u);
+	    got_unexempt(chan, nick, uhost, op, u);
 	  break;
 	case 'I':
 	  op = newsplit(&msg);
 	  fixcolon(op);
-	  check_tcl_mode(nick, from, u, chan->dname, ms2, op);
+	  check_tcl_mode(nick, uhost, u, chan->dname, ms2, op);
 	  if (ms2[0] == '+')
-	    got_invite(chan, nick, from, op);
+	    got_invite(chan, nick, uhost, op);
 	  else
-	    got_uninvite(chan, nick, from, op, u);
+	    got_uninvite(chan, nick, uhost, op, u);
 	  break;
 	}
 	if (todo) {
-	  check_tcl_mode(nick, from, u, chan->dname, ms2, "");
+	  check_tcl_mode(nick, uhost, u, chan->dname, ms2, "");
 	  if (ms2[0] == '+')
 	    chan->channel.mode |= todo;
 	  else
Index: eggdrop1.7/src/mod/module.h
diff -u eggdrop1.7/src/mod/module.h:1.63 eggdrop1.7/src/mod/module.h:1.64
--- eggdrop1.7/src/mod/module.h:1.63	Fri Oct 12 10:50:26 2001
+++ eggdrop1.7/src/mod/module.h	Sat Oct 13 10:55:33 2001
@@ -1,7 +1,7 @@
 /*
  * module.h
  *
- * $Id: module.h,v 1.63 2001/10/12 15:50:26 tothwolf Exp $
+ * $Id: module.h,v 1.64 2001/10/13 15:55:33 tothwolf Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -253,7 +253,7 @@
 /* 136 - 139 */
 #define ismember ((memberlist * (*) (struct chanset_t *, char *))global[136])
 #define newsplit ((char *(*)(char **))global[137])
-#define splitnick ((char *(*)(char **))global[138])
+/* 138: splitnick -- UNUSED (Tothwolf) */
 #define splitc ((void (*)(char *,char *,char))global[139])
 /* 140 - 143 */
 #define addignore ((void (*) (char *, char *, char *,time_t))global[140])
Index: eggdrop1.7/src/mod/server.mod/server.c
diff -u eggdrop1.7/src/mod/server.mod/server.c:1.87 eggdrop1.7/src/mod/server.mod/server.c:1.88
--- eggdrop1.7/src/mod/server.mod/server.c:1.87	Fri Oct 12 12:40:46 2001
+++ eggdrop1.7/src/mod/server.mod/server.c	Sat Oct 13 10:55:34 2001
@@ -2,7 +2,7 @@
  * server.c -- part of server.mod
  *   basic irc server support
  *
- * $Id: server.c,v 1.87 2001/10/12 17:40:46 tothwolf Exp $
+ * $Id: server.c,v 1.88 2001/10/13 15:55:34 tothwolf Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -237,7 +237,7 @@
 
 static int calc_penalty(char * msg)
 {
-  char *cmd, *par1, *par2;
+  char *cmd, *par1, *par2, *par3;
   register int penalty, i, ii;
 
   if (!use_penalties &&
@@ -259,14 +259,17 @@
   if (!egg_strcasecmp(cmd, "KICK")) {
     par1 = newsplit(&msg); /* channel */
     par2 = newsplit(&msg); /* victim(s) */
-    strtok(par2, ",");
-    penalty++;
-    while (strtok(NULL, ",") != NULL)
+    par3 = strtok(par2, ",");
+    while (par3) {
       penalty++;
+      par3 = strtok(NULL, ",");
+    }
     ii = penalty;
-    strtok(par1, " ");
-    while (strtok(NULL, ",") != NULL)
+    par3 = strtok(par1, " ");
+    while (par3) {
       penalty += ii;
+      par3 = strtok(NULL, ",");
+    }
   } else if (!egg_strcasecmp(cmd, "MODE")) {
     i = 0;
     par1 = newsplit(&msg); /* channel */
@@ -285,11 +288,10 @@
       i += 2;
     }
     ii = 0;
-    if (strlen(par1)) {
-      strtok(par1, ",");
+    par3 = strtok(par1, ",");
+    while (par3) {
       ii++;
-      while (strtok(NULL, ",") != NULL)
-        ii++;
+      par3 = strtok(NULL, ",");
     }
     penalty += (ii * i);
   } else if (!egg_strcasecmp(cmd, "TOPIC")) {
@@ -297,35 +299,30 @@
     par1 = newsplit(&msg); /* channel */
     par2 = newsplit(&msg); /* topic */
     if (strlen(par2) > 0) {  /* topic manipulation => 2 penalty points */
-      strtok(par1, ",");
-      penalty += 2;
-      while (strtok(NULL, ",") != NULL)
+      par3 = strtok(par1, ",");
+      while (par3) {
         penalty += 2;
+        strtok(NULL, ",");
+      }
     }
   } else if (!egg_strcasecmp(cmd, "PRIVMSG") ||
 	     !egg_strcasecmp(cmd, "NOTICE")) {
     par1 = newsplit(&msg); /* channel(s)/nick(s) */
     /* Add one sec penalty for each recipient */
-    if (strlen(par1)) {
-      strtok(par1, ",");
+    par3 = strtok(par1, ",");
+    while (par3) {
       penalty++;
-      while (strtok(NULL, ",") != NULL)
-        penalty++;
+      par3 = strtok(NULL, ",");
     }
   } else if (!egg_strcasecmp(cmd, "WHO")) {
     par1 = newsplit(&msg); /* masks */
-    if (strlen(par1)) {
-      par2 = strtok(par1, ",");
+    par2 = strtok(par1, ",");
+    while (par2) {
       if (strlen(par2) > 4)   /* long WHO-masks receive less penalty */
 	penalty += 3;
       else
 	penalty += 5;
-      while ((par2 = strtok(NULL, ",")) != NULL) {
-	if (strlen(par2) > 4)   /* long WHO-masks receive less penalty */
-	  penalty += 3;
-	else
-	  penalty += 5;
-      }
+      par2 = strtok(NULL, ",");
     }
   } else if (!egg_strcasecmp(cmd, "AWAY")) {
     if (strlen(msg) > 0)
Index: eggdrop1.7/src/mod/server.mod/servmsg.c
diff -u eggdrop1.7/src/mod/server.mod/servmsg.c:1.71 eggdrop1.7/src/mod/server.mod/servmsg.c:1.72
--- eggdrop1.7/src/mod/server.mod/servmsg.c:1.71	Fri Oct 12 12:40:46 2001
+++ eggdrop1.7/src/mod/server.mod/servmsg.c	Sat Oct 13 10:55:34 2001
@@ -1,7 +1,7 @@
 /*
  * servmsg.c -- part of server.mod
  *
- * $Id: servmsg.c,v 1.71 2001/10/12 17:40:46 tothwolf Exp $
+ * $Id: servmsg.c,v 1.72 2001/10/13 15:55:34 tothwolf Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -367,8 +367,8 @@
  */
 static int gotmsg(char *from, char *ignore, char *msg)
 {
-  char *to, buf[UHOSTLEN], *nick, ctcpbuf[512], *uhost = buf, *ctcp;
-  char *p, *p1, *code;
+  char *to, buf[UHOSTLEN], *nick, *uhost, ctcpbuf[512], *ctcp, *p, *p1;
+  char *code;
   struct userrec *u;
   int ctcp_count = 0;
   int ignoring;
@@ -379,12 +379,14 @@
   ignoring = match_ignore(from);
   to = newsplit(&msg);
   fixcolon(msg);
+  strncpyz(buf, from, sizeof buf);
+  nick = strtok(buf, "!");
+  uhost = strtok(NULL, "!");
   /* Only check if flood-ctcp is active */
-  strcpy(uhost, from);
-  nick = splitnick(&uhost);
   if (flud_ctcp_thr && detect_avalanche(msg)) {
     if (!ignoring) {
       putlog(LOG_MODES, "*", "Avalanche from %s - ignoring", from);
+      /* FIXME: get rid of this mess */
       p = strchr(uhost, '@');
       if (p != NULL)
 	p++;
@@ -505,7 +507,8 @@
  */
 static int gotnotice(char *from, char *ignore, char *msg)
 {
-  char *to, *nick, ctcpbuf[512], *p, *p1, buf[512], *uhost = buf, *ctcp;
+  char *to, buf[UHOSTLEN], *nick, *uhost, ctcpbuf[512], *ctcp, *p, *p1;
+  char *code;
   struct userrec *u;
   int ignoring;
 
@@ -515,8 +518,9 @@
   ignoring = match_ignore(from);
   to = newsplit(&msg);
   fixcolon(msg);
-  strcpy(uhost, from);
-  nick = splitnick(&uhost);
+  strncpyz(buf, from, sizeof buf);
+  nick = strtok(buf, "!");
+  uhost = strtok(NULL, "!");
   if (flud_ctcp_thr && detect_avalanche(msg)) {
     /* Discard -- kick user if it was to the channel */
     if (!ignoring)
@@ -538,8 +542,7 @@
 	detect_flood(nick, uhost, from, FLOOD_CTCP);
       p = strchr(msg, 1);
       if (ctcp[0] != ' ') {
-	char *code = newsplit(&ctcp);
-
+	code = newsplit(&ctcp);
 	if ((to[0] == '$') || strchr(to, '.')) {
 	  if (!ignoring)
 	    putlog(LOG_PUBLIC, "*",
@@ -587,17 +590,18 @@
  */
 static int gotwall(char *from, char *ignore, char *msg)
 {
-  char *nick;
-  char *p;
+  char *p, buf[UHOSTLEN], *nick, *uhost;
   int r;
 
   fixcolon(msg);
   p = strchr(from, '!');
   if (p && (p == strrchr(from, '!'))) {
-    nick = splitnick(&from);
+    strncpyz(buf, from, sizeof buf);
+    nick = strtok(buf, "!");
+    uhost = strtok(NULL, "!");
     r = check_tcl_wall(nick, msg);
     if (r == 0)
-      putlog(LOG_WALL, "*", "!%s(%s)! %s", nick, from, msg);
+      putlog(LOG_WALL, "*", "!%s(%s)! %s", nick, uhost, msg);
   } else {
     r = check_tcl_wall(from, msg);
     if (r == 0)
@@ -800,9 +804,9 @@
   char *nick, *alt = get_altbotnick();
   struct userrec *u;
 
-  u = get_user_by_host(from);
-  nick = splitnick(&from);
   fixcolon(msg);
+  u = get_user_by_host(from);
+  nick = strtok(from, "!");
   if (match_my_nick(nick)) {
     /* Regained nick! */
     strncpyz(botname, msg, NICKLEN);
Index: eggdrop1.7/src/modules.c
diff -u eggdrop1.7/src/modules.c:1.67 eggdrop1.7/src/modules.c:1.68
--- eggdrop1.7/src/modules.c:1.67	Fri Oct 12 10:50:26 2001
+++ eggdrop1.7/src/modules.c	Sat Oct 13 10:55:33 2001
@@ -4,7 +4,7 @@
  * 
  * by Darrin Smith (beldin at light.iinet.net.au)
  * 
- * $Id: modules.c,v 1.67 2001/10/12 15:50:26 tothwolf Exp $
+ * $Id: modules.c,v 1.68 2001/10/13 15:55:33 tothwolf Exp $
  */
 /* 
  * Copyright (C) 1997  Robey Pointer
@@ -328,7 +328,7 @@
   /* 136 - 139 */
   (Function) ismember,
   (Function) newsplit,
-  (Function) splitnick,
+  (Function) 0,
   (Function) splitc,
   /* 140 - 143 */
   (Function) addignore,
Index: eggdrop1.7/src/proto.h
diff -u eggdrop1.7/src/proto.h:1.55 eggdrop1.7/src/proto.h:1.56
--- eggdrop1.7/src/proto.h:1.55	Fri Oct 12 10:50:26 2001
+++ eggdrop1.7/src/proto.h	Sat Oct 13 10:55:33 2001
@@ -7,7 +7,7 @@
  * because they use structures in those
  * (saves including those .h files EVERY time) - Beldin
  *
- * $Id: proto.h,v 1.55 2001/10/12 15:50:26 tothwolf Exp $
+ * $Id: proto.h,v 1.56 2001/10/13 15:55:33 tothwolf Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -178,7 +178,6 @@
 void splitc(char *, char *, char);
 void splitcn(char *, char *, char, size_t);
 char *newsplit(char **);
-char *splitnick(char **);
 void stridx(char *, char *, int);
 void dumplots(int, const char *, char *);
 void daysago(time_t, time_t, char *);
----------------------- End of diff -----------------------



More information about the Changes mailing list