[cvslog] Module eggdrop1.7: Change committed

cvslog cvs at tsss.org
Thu Sep 27 22:16:01 CST 2001


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.7
Commit time: 2001-09-28 03:15:45 UTC
Commited by: stdarg

Modified files:
     src/botcmd.c src/botnet.c src/dcc.c src/dccutil.c src/main.c
     src/modules.c src/tcldcc.c src/tclhash.c src/tclhash.h
     src/mod/module.h src/mod/irc.mod/chan.c src/mod/irc.mod/irc.c
     src/mod/server.mod/server.c src/mod/server.mod/servmsg.c

Log message:

This is a big patch!
Created several new bind tables (raw, msg, msgm, pub, pubm) to see how it
would work. Seems to work well so far, although there could be bugs.
Added most of the new important bind table functions to the global table.

---------------------- diff included ----------------------
Index: eggdrop1.7/src/botcmd.c
diff -u eggdrop1.7/src/botcmd.c:1.22 eggdrop1.7/src/botcmd.c:1.23
--- eggdrop1.7/src/botcmd.c:1.22	Fri Aug 10 18:51:20 2001
+++ eggdrop1.7/src/botcmd.c	Thu Sep 27 22:15:34 2001
@@ -3,7 +3,7 @@
  *   commands that comes across the botnet
  *   userfile transfer and update commands from sharebots
  *
- * $Id: botcmd.c,v 1.22 2001/08/10 23:51:20 ite Exp $
+ * $Id: botcmd.c,v 1.23 2001/09/28 03:15:34 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -1252,11 +1252,13 @@
 	chanout_but(-1, i, "*** (%s) %s %s %s.\n", bot, nick, _("has left the"),
 		    i ? "channel" : "party line");
       check_tcl_chpt(bot, nick, sock, i);
+      check_chpt(bot, nick, sock, i);
     }
     if ((b_numver(idx) >= NEAT_BOTNET) && !linking)
       chanout_but(-1, chan, "*** (%s) %s %s %s.\n", bot, nick, _("has joined the"),
 		  chan ? "channel" : "party line");
     check_tcl_chjn(bot, nick, chan, y[0], sock, par);
+    check_chjn(bot, nick, chan, y[0], sock, par);
   }
 }
 
@@ -1293,8 +1295,10 @@
     touch_laston(u, TBUF, now);
   }
   if ((partyidx = getparty(bot, sock)) != -1) {
-    if (party[partyidx].chan >= 0)
+    if (party[partyidx].chan >= 0) {
       check_tcl_chpt(bot, nick, sock, party[partyidx].chan);
+      check_chpt(bot, nick, sock, party[partyidx].chan);
+    }
     if ((b_numver(idx) >= NEAT_BOTNET) && !silent) {
       register int chan = party[partyidx].chan;
 
Index: eggdrop1.7/src/botnet.c
diff -u eggdrop1.7/src/botnet.c:1.38 eggdrop1.7/src/botnet.c:1.39
--- eggdrop1.7/src/botnet.c:1.38	Fri Aug 10 18:51:20 2001
+++ eggdrop1.7/src/botnet.c	Thu Sep 27 22:15:34 2001
@@ -7,7 +7,7 @@
  *   linking, unlinking, and relaying to another bot
  *   pinging the bots periodically and checking leaf status
  *
- * $Id: botnet.c,v 1.38 2001/08/10 23:51:20 ite Exp $
+ * $Id: botnet.c,v 1.39 2001/09/28 03:15:34 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -50,6 +50,10 @@
 int		 share_unlinks = 0;	/* Allow remote unlinks of my
 					   sharebots? */
 
+/* The bind tables we create. */
+
+static bind_table_t *BT_chjn = NULL;
+static bind_table_t *BT_chpt = NULL;
 
 int expmem_botnet()
 {
@@ -68,7 +72,17 @@
   return size;
 }
 
-void init_bots()
+static void init_bots();
+
+void botnet_init()
+{
+	init_bots();
+
+	BT_chjn = add_bind_table2("chjn", 4, "ssdd", MATCH_MASK, BIND_STACKABLE);
+	BT_chpt = add_bind_table2("chpt", 4, "ssdd", MATCH_MASK, BIND_STACKABLE);
+}
+
+static void init_bots()
 {
   tandbot = NULL;
   /* Grab space for 50 bots for now -- expand later as needed */
@@ -356,8 +370,10 @@
 
   for (i = 0; i < parties; i++)
     if (!egg_strcasecmp(party[i].bot, bot)) {
-      if (party[i].chan >= 0)
+      if (party[i].chan >= 0) {
         check_tcl_chpt(bot, party[i].nick, party[i].sock, party[i].chan);
+        check_chpt(bot, party[i].nick, party[i].sock, party[i].chan);
+      }
       remparty(bot, party[i].sock);
       i--;
     }
@@ -961,9 +977,11 @@
     while (parties) {
       parties--;
       /* Assert? */
-      if (party[i].chan >= 0)
+      if (party[i].chan >= 0) {
         check_tcl_chpt(party[i].bot, party[i].nick, party[i].sock,
 		       party[i].chan);
+        check_chpt(party[i].bot, party[i].nick, party[i].sock, party[i].chan);
+      }
     }
     strcpy(s, "killassoc &");
     Tcl_Eval(interp, s);
@@ -1353,6 +1371,7 @@
       botnet_send_part_idx(uidx, NULL);
     check_tcl_chpt(botnetnick, dcc[uidx].nick, dcc[uidx].sock,
 		   dcc[uidx].u.chat->channel);
+    check_chpt(botnetnick, dcc[uidx].nick, dcc[uidx].sock, dcc[uidx].u.chat->channel);
   }
   check_tcl_chof(dcc[uidx].nick, dcc[uidx].sock);
   dcc[uidx].type = &DCC_RELAYING;
@@ -1392,6 +1411,7 @@
   check_tcl_chon(dcc[j].nick, dcc[j].sock);
   check_tcl_chjn(botnetnick, dcc[j].nick, dcc[j].u.chat->channel,
 		 geticon(j), dcc[j].sock, dcc[j].host);
+  check_chjn(botnetnick, dcc[j].nick, dcc[j].u.chat->channel, geticon(j), dcc[j].sock, dcc[j].host);
   killsock(dcc[idx].sock);
   lostdcc(idx);
 }
@@ -1485,9 +1505,11 @@
   dcc[idx].u.chat = ci;
   dcc[idx].type = &DCC_CHAT;
   check_tcl_chon(dcc[idx].nick, dcc[idx].sock);
-  if (dcc[idx].u.chat->channel >= 0)
+  if (dcc[idx].u.chat->channel >= 0) {
     check_tcl_chjn(botnetnick, dcc[idx].nick, dcc[idx].u.chat->channel,
 		   geticon(idx), dcc[idx].sock, dcc[idx].host);
+    check_chjn(botnetnick, dcc[idx].nick, dcc[idx].u.chat->channel, geticon(idx), dcc[idx].sock, dcc[idx].host);
+  }
   killsock(dcc[j].sock);
   lostdcc(j);
 }
@@ -1690,10 +1712,40 @@
       check_tcl_chon(dcc[i].nick, dcc[i].sock);
       check_tcl_chjn(botnetnick, dcc[i].nick, dcc[i].u.chat->channel,
 		     geticon(i), dcc[i].sock, dcc[i].host);
+      check_chjn(botnetnick, dcc[i].nick, dcc[i].u.chat->channel, geticon(i), dcc[i].sock, dcc[i].host);
+      check_chjn(botnetnick, dcc[i].nick, dcc[i].u.chat->channel, geticon(i),
+		     dcc[i].sock, dcc[i].host);
     }
   }
   for (i = 0; i < parties; i++) {
     check_tcl_chjn(party[i].bot, party[i].nick, party[i].chan,
 		   party[i].flag, party[i].sock, party[i].from);
+    check_chjn(party[i].bot, party[i].nick, party[i].chan, party[i].flag, party[i].sock, party[i].from);
   }
+}
+
+void check_chjn(const char *bot, const char *nick, int chan, const char type, int sock, const char *host)
+{
+	char buf[32];
+	char stype[2];
+	struct flag_record fr = {FR_GLOBAL, 0, 0, 0, 0, 0};
+
+	sprintf(buf, "%d", chan);
+	stype[0] = type;
+	stype[1] = (char) 0;
+	switch (type) {
+		case '*': fr.global = USER_OWNER; break;
+		case '+': fr.global = USER_MASTER; break;
+		case '@': fr.global = USER_OP; break;
+		case '%': fr.global = USER_BOTMAST; break;
+	}
+	check_bind(BT_chjn, buf, NULL, bot, nick, chan, stype, sock, host);
+}
+
+void check_chpt(const char *bot, const char *hand, int sock, int chan)
+{
+	char buf[32];
+
+	sprintf(buf, "%d", chan);
+	check_bind(BT_chpt, buf, NULL, bot, hand, sock, chan);
 }
Index: eggdrop1.7/src/dcc.c
diff -u eggdrop1.7/src/dcc.c:1.52 eggdrop1.7/src/dcc.c:1.53
--- eggdrop1.7/src/dcc.c:1.52	Fri Aug 17 00:35:48 2001
+++ eggdrop1.7/src/dcc.c	Thu Sep 27 22:15:34 2001
@@ -4,7 +4,7 @@
  *   disconnect on a dcc socket
  *   ...and that's it!  (but it's a LOT)
  *
- * $Id: dcc.c,v 1.52 2001/08/17 05:35:48 guppy Exp $
+ * $Id: dcc.c,v 1.53 2001/09/28 03:15:34 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -914,9 +914,10 @@
 	v = newsplit(&buf);
 	rmspace(buf);
 	if (check_tcl_dcc(v, idx, buf)) {
-	  if (dcc[idx].u.chat->channel >= 0)
+	  if (dcc[idx].u.chat->channel >= 0) {
 	    check_tcl_chpt(botnetnick, dcc[idx].nick, dcc[idx].sock,
 			   dcc[idx].u.chat->channel);
+	  }
 	  check_tcl_chof(dcc[idx].nick, dcc[idx].sock);
 	  dprintf(idx, "*** Ja mata!\n");
 	  flush_lines(idx, dcc[idx].u.chat);
Index: eggdrop1.7/src/dccutil.c
diff -u eggdrop1.7/src/dccutil.c:1.34 eggdrop1.7/src/dccutil.c:1.35
--- eggdrop1.7/src/dccutil.c:1.34	Fri Aug 10 18:51:20 2001
+++ eggdrop1.7/src/dccutil.c	Thu Sep 27 22:15:34 2001
@@ -6,7 +6,7 @@
  *   memory management for dcc structures
  *   timeout checking for dcc connections
  *
- * $Id: dccutil.c,v 1.34 2001/08/10 23:51:20 ite Exp $
+ * $Id: dccutil.c,v 1.35 2001/09/28 03:15:34 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -248,6 +248,7 @@
       }
       check_tcl_chjn(botnetnick, dcc[idx].nick, dcc[idx].u.chat->channel,
 		     geticon(idx), dcc[idx].sock, dcc[idx].host);
+      check_chjn(botnetnick, dcc[idx].nick, dcc[idx].u.chat->channel, geticon(idx), dcc[idx].sock, dcc[idx].host);
     }
     /* But *do* bother with sending it locally */
     if (!dcc[idx].u.chat->channel) {
Index: eggdrop1.7/src/main.c
diff -u eggdrop1.7/src/main.c:1.77 eggdrop1.7/src/main.c:1.78
--- eggdrop1.7/src/main.c:1.77	Thu Sep 20 14:50:19 2001
+++ eggdrop1.7/src/main.c	Thu Sep 27 22:15:34 2001
@@ -5,7 +5,7 @@
  *   command line arguments
  *   context and assert debugging
  *
- * $Id: main.c,v 1.77 2001/09/20 19:50:19 stdarg Exp $
+ * $Id: main.c,v 1.78 2001/09/28 03:15:34 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -347,7 +347,6 @@
 {
   write_userfile(-1);
   check_tcl_event("sigterm");
-  check_event2("sigterm");
   if (die_on_sigterm) {
     botnet_send_chat(-1, botnetnick, "ACK, I've been terminated!");
     fatal("TERMINATE SIGNAL -- SIGNING OFF", 0);
@@ -359,7 +358,6 @@
 static void got_quit(int z)
 {
   check_tcl_event("sigquit");
-  check_event2("sigquit");
   putlog(LOG_MISC, "*", "RECEIVED QUIT SIGNAL (IGNORING)");
   return;
 }
@@ -368,7 +366,6 @@
 {
   write_userfile(-1);
   check_tcl_event("sighup");
-  check_event2("sighup");
   if (die_on_sighup) {
     fatal("HANGUP SIGNAL -- SIGNING OFF", 0);
   } else
@@ -391,7 +388,6 @@
 static void got_ill(int z)
 {
   check_tcl_event("sigill");
-  check_event2("sigill");
 #ifdef DEBUG_CONTEXT
   putlog(LOG_MISC, "*", "* Context: %s/%d [%s]", cx_file[cx_ptr],
 	 cx_line[cx_ptr], (cx_note[cx_ptr][0]) ? cx_note[cx_ptr] : "");
@@ -623,25 +619,21 @@
 static void event_rehash()
 {
   check_tcl_event("rehash");
-  check_event2("rehash");
 }
 
 static void event_prerehash()
 {
   check_tcl_event("prerehash");
-  check_event2("prerehash");
 }
 
 static void event_save()
 {
   check_tcl_event("save");
-  check_event2("save");
 }
 
 static void event_logfile()
 {
   check_tcl_event("logfile");
-  check_event2("logfile");
 }
 
 static void event_resettraffic()
@@ -666,7 +658,6 @@
 static void event_loaded()
 {
   check_tcl_event("loaded");
-  check_event2("loaded");
 }
 
 void kill_tcl();
@@ -678,8 +669,9 @@
 
 #include "mod/static.h"
 #endif
-int init_mem(), init_dcc_max(), init_userent(), init_misc(), init_bots(),
+int init_mem(), init_dcc_max(), init_userent(), init_misc(),
  init_net(), init_modules(), init_tcl(int, char **);
+void botnet_init();
 
 void patch(const char *str)
 {
@@ -798,7 +790,7 @@
   init_dcc_max();
   init_userent();
   init_misc();
-  init_bots();
+  botnet_init();
   init_net();
   init_modules();
   if (backgrd)
@@ -1046,7 +1038,6 @@
 
  	/* oops, I guess we should call this event before tcl is restarted */
 	check_tcl_event("prerestart");
-	check_event2("prerestart");
 
 	while (f) {
 	  f = 0;
Index: eggdrop1.7/src/mod/irc.mod/chan.c
diff -u eggdrop1.7/src/mod/irc.mod/chan.c:1.72 eggdrop1.7/src/mod/irc.mod/chan.c:1.73
--- eggdrop1.7/src/mod/irc.mod/chan.c:1.72	Mon Aug 27 18:06:40 2001
+++ eggdrop1.7/src/mod/irc.mod/chan.c	Thu Sep 27 22:15:35 2001
@@ -6,7 +6,7 @@
  *   user kickban, kick, op, deop
  *   idle kicking
  *
- * $Id: chan.c,v 1.72 2001/08/27 23:06:40 poptix Exp $
+ * $Id: chan.c,v 1.73 2001/09/28 03:15:35 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -803,7 +803,7 @@
 /* got 324: mode status
  * <server> 324 <to> <channel> <mode>
  */
-static int got324(char *from, char *msg)
+static int got324(char *from, char *ignore, char *msg)
 {
   int i = 1, ok =0;
   char *p, *q, *chname;
@@ -923,7 +923,7 @@
 
 /* got a 352: who info!
  */
-static int got352(char *from, char *msg)
+static int got352(char *from, char *ignore, char *msg)
 {
   char *nick, *user, *host, *chname, *flags;
   struct chanset_t *chan;
@@ -944,7 +944,7 @@
 
 /* got a 354: who info! - iru style
  */
-static int got354(char *from, char *msg)
+static int got354(char *from, char *ignore, char *msg)
 {
   char *nick, *user, *host, *chname, *flags;
   struct chanset_t *chan;
@@ -969,7 +969,7 @@
 /* got 315: end of who
  * <server> 315 <to> <chan> :End of /who
  */
-static int got315(char *from, char *msg)
+static int got315(char *from, char *ignore, char *msg)
 {
   char *chname;
   struct chanset_t *chan;
@@ -1004,7 +1004,7 @@
 /* got 367: ban info
  * <server> 367 <to> <chan> <ban> [placed-by] [timestamp]
  */
-static int got367(char *from, char *origmsg)
+static int got367(char *from, char *ignore, char *origmsg)
 {
   char s[UHOSTLEN], *ban, *who, *chname, buf[511], *msg;
   struct chanset_t *chan;
@@ -1042,7 +1042,7 @@
 /* got 368: end of ban list
  * <server> 368 <to> <chan> :etc
  */
-static int got368(char *from, char *msg)
+static int got368(char *from, char *ignore, char *msg)
 {
   struct chanset_t *chan;
   char *chname;
@@ -1062,7 +1062,7 @@
 /* got 348: ban exemption info
  * <server> 348 <to> <chan> <exemption>
  */
-static int got348(char *from, char *origmsg)
+static int got348(char *from, char *ignore, char *origmsg)
 {
   char *exempt, *who, *chname, buf[511], *msg;
   struct chanset_t *chan;
@@ -1091,7 +1091,7 @@
 /* got 349: end of ban exemption list
  * <server> 349 <to> <chan> :etc
  */
-static int got349(char *from, char *msg)
+static int got349(char *from, char *ignore, char *msg)
 {
   struct chanset_t *chan;
   char *chname;
@@ -1109,7 +1109,7 @@
 /* got 346: invite exemption info
  * <server> 346 <to> <chan> <exemption>
  */
-static int got346(char *from, char *origmsg)
+static int got346(char *from, char *ignore, char *origmsg)
 {
   char *invite, *who, *chname, buf[511], *msg;
   struct chanset_t *chan;
@@ -1137,7 +1137,7 @@
 /* got 347: end of invite exemption list
  * <server> 347 <to> <chan> :etc
  */
-static int got347(char *from, char *msg)
+static int got347(char *from, char *ignore, char *msg)
 {
   struct chanset_t *chan;
   char *chname;
@@ -1154,7 +1154,7 @@
 
 /* Too many channels.
  */
-static int got405(char *from, char *msg)
+static int got405(char *from, char *ignore, char *msg)
 {
   char *chname;
 
@@ -1170,7 +1170,7 @@
  *
  * 403 - ERR_NOSUCHCHANNEL
  */
-static int got403(char *from, char *msg)
+static int got403(char *from, char *ignore, char *msg)
 {
   char *chname;
   struct chanset_t *chan;
@@ -1205,7 +1205,7 @@
 
 /* got 471: can't join channel, full
  */
-static int got471(char *from, char *msg)
+static int got471(char *from, char *ignore, char *msg)
 {
   char *chname;
   struct chanset_t *chan;
@@ -1233,7 +1233,7 @@
 
 /* got 473: can't join channel, invite only
  */
-static int got473(char *from, char *msg)
+static int got473(char *from, char *ignore, char *msg)
 {
   char *chname;
   struct chanset_t *chan;
@@ -1261,7 +1261,7 @@
 
 /* got 474: can't join channel, banned
  */
-static int got474(char *from, char *msg)
+static int got474(char *from, char *ignore, char *msg)
 {
   char *chname;
   struct chanset_t *chan;
@@ -1289,7 +1289,7 @@
 
 /* got 475: can't goin channel, bad key
  */
-static int got475(char *from, char *msg)
+static int got475(char *from, char *ignore, char *msg)
 {
   char *chname;
   struct chanset_t *chan;
@@ -1323,7 +1323,7 @@
 
 /* got invitation
  */
-static int gotinvite(char *from, char *msg)
+static int gotinvite(char *from, char *ignore, char *msg)
 {
   char *nick;
   struct chanset_t *chan;
@@ -1366,7 +1366,7 @@
 
 /* Topic change.
  */
-static int gottopic(char *from, char *msg)
+static int gottopic(char *from, char *ignore, char *msg)
 {
   char *nick, *chname;
   memberlist *m;
@@ -1393,7 +1393,7 @@
 /* 331: no current topic for this channel
  * <server> 331 <to> <chname> :etc
  */
-static int got331(char *from, char *msg)
+static int got331(char *from, char *ignore, char *msg)
 {
   char *chname;
   struct chanset_t *chan;
@@ -1411,7 +1411,7 @@
 /* 332: topic on a channel i've just joined
  * <server> 332 <to> <chname> :topic goes here
  */
-static int got332(char *from, char *msg)
+static int got332(char *from, char *ignore, char *msg)
 {
   struct chanset_t *chan;
   char *chname;
@@ -1457,7 +1457,7 @@
 
 /* Got a join
  */
-static int gotjoin(char *from, char *chname)
+static int gotjoin(char *from, char *ignore, char *chname)
 {
   char *nick, *p, buf[UHOSTLEN], *uhost = buf;
   char *ch_dname = NULL;
@@ -1708,7 +1708,7 @@
 
 /* Got a part
  */
-static int gotpart(char *from, char *msg)
+static int gotpart(char *from, char *ignore, char *msg)
 {
   char *nick, *chname;
   struct chanset_t *chan;
@@ -1758,7 +1758,7 @@
 
 /* Got a kick
  */
-static int gotkick(char *from, char *origmsg)
+static int gotkick(char *from, char *ignore, char *origmsg)
 {
   char *nick, *whodid, *chname, s1[UHOSTLEN], buf[UHOSTLEN], *uhost = buf;
   char buf2[511], *msg;
@@ -1814,7 +1814,7 @@
 
 /* Got a nick change
  */
-static int gotnick(char *from, char *msg)
+static int gotnick(char *from, char *ignore, char *msg)
 {
   char *nick, s1[UHOSTLEN], buf[UHOSTLEN], *uhost = buf;
   memberlist *m, *mm;
@@ -1872,7 +1872,7 @@
 
 /* Signoff, similar to part.
  */
-static int gotquit(char *from, char *msg)
+static int gotquit(char *from, char *ignore, char *msg)
 {
   char *nick, *p, *alt;
   char from2[NICKMAX + UHOSTMAX +1];
@@ -1948,7 +1948,7 @@
 
 /* Got a private message.
  */
-static int gotmsg(char *from, char *msg)
+static int gotmsg(char *from, char *ignore, char *msg)
 {
   char *to, *realto, buf[UHOSTLEN], *nick, buf2[512], *uhost = buf;
   char *p, *p1, *code, *ctcp;
@@ -2086,7 +2086,7 @@
 
 /* Got a private notice.
  */
-static int gotnotice(char *from, char *msg)
+static int gotnotice(char *from, char *ignore, char *msg)
 {
   char *to, *realto, *nick, buf2[512], *p, *p1, buf[512], *uhost = buf;
   char *ctcp, *code;
Index: eggdrop1.7/src/mod/irc.mod/irc.c
diff -u eggdrop1.7/src/mod/irc.mod/irc.c:1.61 eggdrop1.7/src/mod/irc.mod/irc.c:1.62
--- eggdrop1.7/src/mod/irc.mod/irc.c:1.61	Thu Sep 27 13:33:21 2001
+++ eggdrop1.7/src/mod/irc.mod/irc.c	Thu Sep 27 22:15:35 2001
@@ -2,7 +2,7 @@
  * irc.c -- part of irc.mod
  *   support for channels within the bot
  *
- * $Id: irc.c,v 1.61 2001/09/27 18:33:21 sup Exp $
+ * $Id: irc.c,v 1.62 2001/09/28 03:15:35 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -33,6 +33,12 @@
 #include <sys/utsname.h>
 #endif
 
+/* We import some bind tables from server.mod */
+static bind_table_t *BT_raw, *BT_msg;
+
+/* We also create a few. */
+static bind_table_t *BT_pub, *BT_pubm;
+
 static p_tcl_bind_list H_topc, H_splt, H_sign, H_rejn, H_part, H_pub, H_pubm;
 static p_tcl_bind_list H_nick, H_mode, H_kick, H_join, H_need;
 static Function *global = NULL, *channels_funcs = NULL, *server_funcs = NULL;
@@ -776,6 +782,9 @@
   u = get_user_by_host(host);
   hand = u ? u->handle : "*";
   get_user_flagrec(u, &fr, chname);
+
+  check_bind(BT_pub, cmd, &fr, nick, from, hand, chname, args);
+
   Tcl_SetVar(interp, "_pub1", nick, 0);
   Tcl_SetVar(interp, "_pub2", from, 0);
   Tcl_SetVar(interp, "_pub3", hand, 0);
@@ -795,14 +804,20 @@
   struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
   char buf[1024], host[161];
   struct userrec *u;
+  char *hand;
 
   simple_sprintf(buf, "%s %s", chname, msg);
   simple_sprintf(host, "%s!%s", nick, from);
   u = get_user_by_host(host);
   get_user_flagrec(u, &fr, chname);
+  if (u) hand = u->handle;
+  else hand = "*";
+
+  check_bind(BT_pubm, buf, &fr, nick, from, hand, chname, msg);
+
   Tcl_SetVar(interp, "_pubm1", nick, 0);
   Tcl_SetVar(interp, "_pubm2", from, 0);
-  Tcl_SetVar(interp, "_pubm3", u ? u->handle : "*", 0);
+  Tcl_SetVar(interp, "_pubm3", hand, 0);
   Tcl_SetVar(interp, "_pubm4", chname, 0);
   Tcl_SetVar(interp, "_pubm5", msg, 0);
   check_tcl_bind(H_pubm, buf, &fr, " $_pubm1 $_pubm2 $_pubm3 $_pubm4 $_pubm5",
@@ -1018,7 +1033,11 @@
   rem_tcl_ints(myints);
   rem_builtins(H_dcc, irc_dcc);
   rem_builtins(H_msg, C_msg);
-  rem_builtins(H_raw, irc_raw);
+
+  /* rem_builtins(H_raw, irc_raw); */
+  if (BT_raw) rem_builtins2(BT_raw, irc_raw);
+  if (BT_msg) rem_builtins2(BT_msg, C_msg);
+
   rem_tcl_commands(tclchan_cmds);
   rem_help_reference("irc.help");
   del_hook(HOOK_MINUTELY, (Function) check_expired_chanstuff);
@@ -1106,8 +1125,22 @@
 	       traced_rfccompliant, NULL);
   add_tcl_ints(myints);
   add_builtins(H_dcc, irc_dcc);
+
+/*
   add_builtins(H_msg, C_msg);
   add_builtins(H_raw, irc_raw);
+*/
+
+  /* Import bind tables from other places. */
+  BT_raw = find_bind_table2("raw");
+  BT_msg = find_bind_table2("msg");
+  if (BT_raw) add_builtins2(BT_raw, irc_raw);
+  if (BT_msg) add_builtins2(BT_msg, C_msg);
+
+  /* Create our own bind tables. */
+  BT_pub = add_bind_table2("pub", 5, "sssss", MATCH_MASK, BIND_USE_ATTR);
+  BT_pubm = add_bind_table2("pubm", 5, "sssss", MATCH_MASK, BIND_STACKABLE | BIND_USE_ATTR);
+
   add_tcl_commands(tclchan_cmds);
   add_help_reference("irc.help");
   H_topc = add_bind_table("topc", HT_STACKABLE, channels_5char);
Index: eggdrop1.7/src/mod/module.h
diff -u eggdrop1.7/src/mod/module.h:1.57 eggdrop1.7/src/mod/module.h:1.58
--- eggdrop1.7/src/mod/module.h:1.57	Mon Aug 20 19:21:18 2001
+++ eggdrop1.7/src/mod/module.h	Thu Sep 27 22:15:34 2001
@@ -1,7 +1,7 @@
 /*
  * module.h
  *
- * $Id: module.h,v 1.57 2001/08/21 00:21:18 ite Exp $
+ * $Id: module.h,v 1.58 2001/09/28 03:15:34 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -451,6 +451,12 @@
 #define getlocaladdr ((char* (*) (int))global[272])
 #define kill_bot ((void (*)(char *, char *))global[273])
 #define quit_msg ((char *)(global[274]))
+#define add_bind_table2 ((bind_table_t *(*)(const char *, int, char *, int, int))global[275])
+#define del_bind_table2 ((void (*)(bind_table_t *))global[276])
+#define add_builtins2 ((void (*)(bind_table_t *, cmd_t *))global[277])
+#define rem_builtins2 ((void (*)(bind_table_t *, cmd_t *))global[278])
+#define find_bind_table2 ((bind_table_t *(*)(const char *))global[279])
+#define check_bind ((int (*)(bind_table_t *, const char *, struct flag_record *, ...))global[280])
 
 /* This is for blowfish module, couldnt be bothered making a whole new .h
  * file for it ;)
Index: eggdrop1.7/src/mod/server.mod/server.c
diff -u eggdrop1.7/src/mod/server.mod/server.c:1.78 eggdrop1.7/src/mod/server.mod/server.c:1.79
--- eggdrop1.7/src/mod/server.mod/server.c:1.78	Sat Aug 18 13:56:01 2001
+++ eggdrop1.7/src/mod/server.mod/server.c	Thu Sep 27 22:15:35 2001
@@ -2,7 +2,7 @@
  * server.c -- part of server.mod
  *   basic irc server support
  *
- * $Id: server.c,v 1.78 2001/08/18 18:56:01 drummer Exp $
+ * $Id: server.c,v 1.79 2001/09/28 03:15:35 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -108,6 +108,9 @@
 static int deq_kick(int);
 static void msgq_clear(struct msgq_head *qh);
 
+/* New bind tables. */
+static bind_table_t *BT_wall, *BT_raw, *BT_notc, *BT_msg, *BT_msgm;
+
 #include "servmsg.c"
 
 #define MAXPENALTY 10
@@ -1675,7 +1678,10 @@
   nuke_server("Connection reset by peer");
   clearq(serverlist);
   rem_builtins(H_dcc, C_dcc_serv);
-  rem_builtins(H_raw, my_raw_binds);
+
+  /* rem_builtins(H_raw, my_raw_binds); */
+  rem_builtins2(BT_raw, my_raw_binds);
+
   rem_builtins(H_ctcp, my_ctcps);
   /* Restore original commands. */
   del_bind_table(H_wall);
@@ -1864,6 +1870,12 @@
 	       TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
 	       traced_nicklen, NULL);
 
+	BT_wall = add_bind_table2("wall", 2, "ss", MATCH_MASK, BIND_STACKABLE);
+	BT_raw = add_bind_table2("raw", 3, "sss", MATCH_MASK, BIND_STACKABLE);
+	BT_notc = add_bind_table2("notc", 5, "sssss", MATCH_MASK, BIND_USE_ATTR | BIND_STACKABLE);
+	BT_msg = add_bind_table2("msg", 4, "ssss", 0, BIND_USE_ATTR);
+	BT_msgm = add_bind_table2("msgm", 4, "ssss", MATCH_MASK, BIND_USE_ATTR | BIND_STACKABLE);
+
   H_wall = add_bind_table("wall", HT_STACKABLE, server_2char);
   H_raw = add_bind_table("raw", HT_STACKABLE, server_raw);
   H_notc = add_bind_table("notc", HT_STACKABLE, server_6char);
@@ -1872,7 +1884,10 @@
   H_flud = add_bind_table("flud", HT_STACKABLE, server_5char);
   H_ctcr = add_bind_table("ctcr", HT_STACKABLE, server_6char);
   H_ctcp = add_bind_table("ctcp", HT_STACKABLE, server_6char);
-  add_builtins(H_raw, my_raw_binds);
+
+  /* add_builtins(H_raw, my_raw_binds); */
+  add_builtins2(BT_raw, my_raw_binds);
+
   add_builtins(H_dcc, C_dcc_serv);
   add_builtins(H_ctcp, my_ctcps);
   add_help_reference("server.help");
Index: eggdrop1.7/src/mod/server.mod/servmsg.c
diff -u eggdrop1.7/src/mod/server.mod/servmsg.c:1.64 eggdrop1.7/src/mod/server.mod/servmsg.c:1.65
--- eggdrop1.7/src/mod/server.mod/servmsg.c:1.64	Mon Aug 27 18:06:41 2001
+++ eggdrop1.7/src/mod/server.mod/servmsg.c	Thu Sep 27 22:15:35 2001
@@ -1,7 +1,7 @@
 /*
  * servmsg.c -- part of server.mod
  *
- * $Id: servmsg.c,v 1.64 2001/08/27 23:06:41 poptix Exp $
+ * $Id: servmsg.c,v 1.65 2001/09/28 03:15:35 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -101,6 +101,9 @@
   int x;
 
   get_user_flagrec(u, &fr, NULL);
+
+  check_bind(BT_msg, cmd, &fr, cmd, nick, uhost, hand, args);
+
   Tcl_SetVar(interp, "_msg1", nick, 0);
   Tcl_SetVar(interp, "_msg2", uhost, 0);
   Tcl_SetVar(interp, "_msg3", hand, 0);
@@ -117,33 +120,46 @@
 	       		   char *dest, char *arg)
 {
   struct flag_record fr = {FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0};
+  char *hand;
 
   get_user_flagrec(u, &fr, NULL);
+  if (u) hand = u->handle;
+  else hand = "*";
+
+  check_bind(BT_notc, arg, &fr, nick, uhost, hand, arg, dest);
+
   Tcl_SetVar(interp, "_notc1", nick, 0);
   Tcl_SetVar(interp, "_notc2", uhost, 0);
-  Tcl_SetVar(interp, "_notc3", u ? u->handle : "*", 0);
+  Tcl_SetVar(interp, "_notc3", hand, 0);
   Tcl_SetVar(interp, "_notc4", arg, 0);
   Tcl_SetVar(interp, "_notc5", dest, 0);
   check_tcl_bind(H_notc, arg, &fr, " $_notc1 $_notc2 $_notc3 $_notc4 $_notc5",
 		 MATCH_MASK | BIND_USE_ATTR | BIND_STACKABLE);
 }
 
-static void check_tcl_msgm(char *cmd, char *nick, char *uhost,
-			   struct userrec *u, char *arg)
+static void check_tcl_msgm(char *nick, char *uhost, struct userrec *u, char *arg)
 {
   struct flag_record fr = {FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0};
-  char args[1024];
+  char *hand;
 
+/*
   if (arg[0])
     simple_sprintf(args, "%s %s", cmd, arg);
   else
     strcpy(args, cmd);
+*/
+
   get_user_flagrec(u, &fr, NULL);
+  if (u) hand = u->handle;
+  else hand = "*";
+
+  check_bind(BT_msgm, arg, &fr, nick, uhost, hand, arg);
+
   Tcl_SetVar(interp, "_msgm1", nick, 0);
   Tcl_SetVar(interp, "_msgm2", uhost, 0);
-  Tcl_SetVar(interp, "_msgm3", u ? u->handle : "*", 0);
-  Tcl_SetVar(interp, "_msgm4", args, 0);
-  check_tcl_bind(H_msgm, args, &fr, " $_msgm1 $_msgm2 $_msgm3 $_msgm4",
+  Tcl_SetVar(interp, "_msgm3", hand, 0);
+  Tcl_SetVar(interp, "_msgm4", arg, 0);
+  check_tcl_bind(H_msgm, arg, &fr, " $_msgm1 $_msgm2 $_msgm3 $_msgm4",
 		 MATCH_MASK | BIND_USE_ATTR | BIND_STACKABLE);
 }
 
@@ -153,6 +169,8 @@
 {
   int x;
 
+  check_bind(BT_raw, code, NULL, from, code, msg);
+
   Tcl_SetVar(interp, "_raw1", from, 0);
   Tcl_SetVar(interp, "_raw2", code, 0);
   Tcl_SetVar(interp, "_raw3", msg, 0);
@@ -186,6 +204,8 @@
 {
   int x;
 
+  check_bind(BT_wall, msg, NULL, from, msg);
+
   Tcl_SetVar(interp, "_wall1", from, 0);
   Tcl_SetVar(interp, "_wall2", msg, 0);
   x = check_tcl_bind(H_wall, msg, 0, " $_wall1 $_wall2",
@@ -222,7 +242,7 @@
 
 /* 001: welcome to IRC (use it to fix the server name)
  */
-static int got001(char *from, char *msg)
+static int got001(char *from, char *ignore, char *msg)
 {
   struct server_list *x;
   int i, servidx = findanyidx(serv);
@@ -274,7 +294,7 @@
 
 /* Got 442: not on channel
  */
-static int got442(char *from, char *msg)
+static int got442(char *from, char *ignore, char *msg)
 {
   char			*chname;
   struct chanset_t	*chan;
@@ -414,7 +434,7 @@
 
 /* Got a private message.
  */
-static int gotmsg(char *from, char *msg)
+static int gotmsg(char *from, char *ignore, char *msg)
 {
   char *to, buf[UHOSTLEN], *nick, ctcpbuf[512], *uhost = buf, *ctcp;
   char *p, *p1, *code;
@@ -539,10 +559,9 @@
 
       detect_flood(nick, uhost, from, FLOOD_PRIVMSG);
       u = get_user_by_host(from);
+      if (!ignoring || trigger_on_ignore) check_tcl_msgm(nick, uhost, u, msg);
       code = newsplit(&msg);
       rmspace(msg);
-      if (!ignoring || trigger_on_ignore)
-	check_tcl_msgm(code, nick, uhost, u, msg);
       if (!ignoring)
 	if (!check_tcl_msg(code, nick, uhost, u, msg))
 	  putlog(LOG_MSGS, "*", "[%s] %s %s", from, code, msg);
@@ -553,7 +572,7 @@
 
 /* Got a private notice.
  */
-static int gotnotice(char *from, char *msg)
+static int gotnotice(char *from, char *ignore, char *msg)
 {
   char *to, *nick, ctcpbuf[512], *p, *p1, buf[512], *uhost = buf, *ctcp;
   struct userrec *u;
@@ -635,7 +654,7 @@
 
 /* WALLOPS: oper's nuisance
  */
-static int gotwall(char *from, char *msg)
+static int gotwall(char *from, char *ignore, char *msg)
 {
   char *nick;
   char *p;
@@ -683,7 +702,7 @@
 
 /* Pong from server.
  */
-static int gotpong(char *from, char *msg)
+static int gotpong(char *from, char *ignore, char *msg)
 {
   newsplit(&msg);
   fixcolon(msg);		/* Scrap server name */
@@ -698,7 +717,7 @@
 
 /* This is a reply on ISON :<current> <orig> [<alt>]
  */
-static void got303(char *from, char *msg)
+static void got303(char *from, char *ignore, char *msg)
 {
   char *tmp, *alt;
   int ison_orig = 0, ison_alt = 0;
@@ -731,7 +750,7 @@
 
 /* 432 : Bad nickname
  */
-static int got432(char *from, char *msg)
+static int got432(char *from, char *ignore, char *msg)
 {
   char *erroneus;
 
@@ -755,7 +774,7 @@
 /* 433 : Nickname in use
  * Change nicks till we're acceptable or we give up
  */
-static int got433(char *from, char *msg)
+static int got433(char *from, char *ignore, char *msg)
 {
   char *tmp;
 
@@ -773,7 +792,7 @@
 
 /* 437 : Nickname juped (IRCnet)
  */
-static int got437(char *from, char *msg)
+static int got437(char *from, char *ignore, char *msg)
 {
   char *s;
   struct chanset_t *chan;
@@ -806,7 +825,7 @@
 
 /* 438 : Nick change too fast
  */
-static int got438(char *from, char *msg)
+static int got438(char *from, char *ignore, char *msg)
 {
   newsplit(&msg);
   newsplit(&msg);
@@ -815,7 +834,7 @@
   return 0;
 }
 
-static int got451(char *from, char *msg)
+static int got451(char *from, char *ignore, char *msg)
 {
   /* Usually if we get this then we really messed up somewhere
    * or this is a non-standard server, so we log it and kill the socket
@@ -832,7 +851,7 @@
 
 /* Got error notice
  */
-static int goterror(char *from, char *msg)
+static int goterror(char *from, char *ignore, char *msg)
 {
   fixcolon(msg);
   putlog(LOG_SERV | LOG_MSGS, "*", "-ERROR from server- %s", msg);
@@ -845,7 +864,7 @@
 
 /* Got nick change.
  */
-static int gotnick(char *from, char *msg)
+static int gotnick(char *from, char *ignore, char *msg)
 {
   char *nick, *alt = get_altbotnick();
   struct userrec *u;
@@ -891,7 +910,7 @@
   return 0;
 }
 
-static int gotmode(char *from, char *msg)
+static int gotmode(char *from, char *ignore, char *msg)
 {
   char *ch;
 
@@ -1009,14 +1028,14 @@
   check_tcl_raw(from, code, msg);
 }
 
-static int gotping(char *from, char *msg)
+static int gotping(char *from, char *ignore, char *msg)
 {
   fixcolon(msg);
   dprintf(DP_MODE, "PONG :%s\n", msg);
   return 0;
 }
 
-static int gotkick(char *from, char *msg)
+static int gotkick(char *from, char *ignore, char *msg)
 {
   char *nick;
 
@@ -1062,7 +1081,7 @@
   return 0;
 }
 
-static int got311(char *from, char *msg)
+static int got311(char *from, char *ignore, char *msg)
 {
   char *n1, *n2, *u, *h;
   
Index: eggdrop1.7/src/modules.c
diff -u eggdrop1.7/src/modules.c:1.60 eggdrop1.7/src/modules.c:1.61
--- eggdrop1.7/src/modules.c:1.60	Sat Aug 18 21:36:23 2001
+++ eggdrop1.7/src/modules.c	Thu Sep 27 22:15:34 2001
@@ -4,7 +4,7 @@
  * 
  * by Darrin Smith (beldin at light.iinet.net.au)
  * 
- * $Id: modules.c,v 1.60 2001/08/19 02:36:23 drummer Exp $
+ * $Id: modules.c,v 1.61 2001/09/28 03:15:34 stdarg Exp $
  */
 /* 
  * Copyright (C) 1997  Robey Pointer
@@ -544,6 +544,13 @@
   (Function) getlocaladdr,
   (Function) kill_bot,
   (Function) quit_msg,                /* char *				  */
+  (Function) add_bind_table2,
+  /* 276 - 280 */
+  (Function) del_bind_table2,
+  (Function) add_builtins2,
+  (Function) rem_builtins2,
+  (Function) find_bind_table2,
+  (Function) check_bind
 };
 
 void init_modules(void)
Index: eggdrop1.7/src/tcldcc.c
diff -u eggdrop1.7/src/tcldcc.c:1.30 eggdrop1.7/src/tcldcc.c:1.31
--- eggdrop1.7/src/tcldcc.c:1.30	Fri Aug 10 18:51:20 2001
+++ eggdrop1.7/src/tcldcc.c	Thu Sep 27 22:15:34 2001
@@ -2,7 +2,7 @@
  * tcldcc.c -- handles:
  *   Tcl stubs for the dcc commands
  *
- * $Id: tcldcc.c,v 1.30 2001/08/10 23:51:20 ite Exp $
+ * $Id: tcldcc.c,v 1.31 2001/09/28 03:15:34 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -218,12 +218,14 @@
 	botnet_send_part_idx(idx, "*script*");
       check_tcl_chpt(botnetnick, dcc[idx].nick, dcc[idx].sock,
 		     dcc[idx].u.chat->channel);
+      check_chpt(botnetnick, dcc[idx].nick, dcc[idx].sock, dcc[idx].u.chat->channel);
     }
     dcc[idx].u.chat->channel = chan;
     if (chan < GLOBAL_CHANS)
       botnet_send_join_idx(idx, oldchan);
     check_tcl_chjn(botnetnick, dcc[idx].nick, chan, geticon(idx),
 		   dcc[idx].sock, dcc[idx].host);
+    check_chjn(botnetnick, dcc[idx].nick, chan, geticon(idx), dcc[idx].sock, dcc[idx].host);
   }
   /* Console autosave. */
   if ((me = module_find("console", 1, 1))) {
@@ -436,6 +438,7 @@
 		  dcc[idx].nick);
       check_tcl_chpt(botnetnick, dcc[idx].nick, dcc[idx].sock,
 		     dcc[idx].u.chat->channel);
+      check_chpt(botnetnick, dcc[idx].nick, dcc[idx].sock, dcc[idx].u.chat->channel);
       botnet_send_part_idx(idx, "gone");
     }
     check_tcl_chof(dcc[idx].nick, dcc[idx].sock);
@@ -484,10 +487,10 @@
 		dcc[idx].nick, dcc[idx].u.chat ? "channel" : "partyline",
 		argc == 3 ? ": " : "", argc == 3 ? argv[2] : "");
     botnet_send_part_idx(idx, argc == 3 ? argv[2] : "");
-    if ((dcc[idx].u.chat->channel >= 0) &&
-	(dcc[idx].u.chat->channel < GLOBAL_CHANS))
-      check_tcl_chpt(botnetnick, dcc[idx].nick, dcc[idx].sock,
-		     dcc[idx].u.chat->channel);
+    if ((dcc[idx].u.chat->channel >= 0) && (dcc[idx].u.chat->channel < GLOBAL_CHANS)) {
+      check_tcl_chpt(botnetnick, dcc[idx].nick, dcc[idx].sock, dcc[idx].u.chat->channel);
+      check_chpt(botnetnick, dcc[idx].nick, dcc[idx].sock, dcc[idx].u.chat->channel);
+    }
     check_tcl_chof(dcc[idx].nick, dcc[idx].sock);
     /* Notice is sent to the party line, the script can add a reason. */
   }
Index: eggdrop1.7/src/tclhash.c
diff -u eggdrop1.7/src/tclhash.c:1.35 eggdrop1.7/src/tclhash.c:1.36
--- eggdrop1.7/src/tclhash.c:1.35	Thu Sep 20 14:50:19 2001
+++ eggdrop1.7/src/tclhash.c	Thu Sep 27 22:15:34 2001
@@ -7,7 +7,7 @@
  *   (non-Tcl) procedure lookups for msg/dcc/file commands
  *   (Tcl) binding internal procedures to msg/dcc/file commands
  *
- * $Id: tclhash.c,v 1.35 2001/09/20 19:50:19 stdarg Exp $
+ * $Id: tclhash.c,v 1.36 2001/09/28 03:15:34 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -40,8 +40,12 @@
 extern time_t		 now;
 
 /* New bind table list */
-bind_table_t *bind_table_list_head = NULL;
-bind_table_t *BT_event = NULL;
+static bind_table_t *bind_table_list_head = NULL;
+static bind_table_t *BT_event;
+static bind_table_t *BT_link;
+static bind_table_t *BT_disc;
+static bind_table_t *BT_away;
+static bind_table_t *BT_time;
 
 p_tcl_bind_list		bind_table_list;
 p_tcl_bind_list		H_chat, H_act, H_bcst, H_chon, H_chof,
@@ -59,9 +63,6 @@
 static int builtin_chat();
 static int builtin_dcc();
 
-void del_bind_table2(bind_table_t *table);
-
-
 static char *my_strdup(const char *s)
 {
 	char *t;
@@ -228,7 +229,11 @@
 	bind_table_list_head = NULL;
 	Tcl_CreateCommand(interp, "bind2", tcl_bind2, NULL, NULL);
 	Tcl_CreateCommand(interp, "unbind2", tcl_unbind2, NULL, NULL);
-	BT_event = add_bind_table2("event", "s", 0);
+	BT_event = add_bind_table2("event", 1, "s", MATCH_MASK, BIND_STACKABLE);
+	BT_link = add_bind_table2("link", 2, "ss", MATCH_MASK, BIND_STACKABLE);
+	BT_disc = add_bind_table2("disc", 1, "s", MATCH_MASK, BIND_STACKABLE);
+	BT_away = add_bind_table2("away", 3, "sis", MATCH_MASK, BIND_STACKABLE);
+	BT_time = add_bind_table2("time", 5, "iiiii", MATCH_MASK, BIND_STACKABLE);
 }
 
 void init_bind(void)
@@ -281,7 +286,7 @@
   bind_table_list = NULL;
 }
 
-bind_table_t *add_bind_table2(const char *name, const char *syntax, int flags)
+bind_table_t *add_bind_table2(const char *name, int nargs, const char *syntax, int match_type, int flags)
 {
 	bind_table_t *table;
 
@@ -292,7 +297,9 @@
 	table = (bind_table_t *)nmalloc(sizeof(*table));
 	table->chains = NULL;
 	table->name = my_strdup(name);
+	table->nargs = nargs;
 	table->syntax = my_strdup(syntax);
+	table->match_type = match_type;
 	table->flags = flags;
 	table->next = bind_table_list_head;
 	bind_table_list_head = table;
@@ -385,9 +392,9 @@
 	bind_table_t *table;
 
 	for (table = bind_table_list_head; table; table = table->next) {
-		if (!strcmp(table->name, name)) return(table);
+		if (!strcmp(table->name, name)) break;
 	}
-	return(NULL);
+	return(table);
 }
 
 tcl_bind_list_t *find_bind_table(const char *nme)
@@ -423,7 +430,7 @@
   }
 }
 
-static int del_bind_entry(bind_table_t *table, const char *flags, const char *mask, const char *function_name)
+int del_bind_entry(bind_table_t *table, const char *flags, const char *mask, const char *function_name)
 {
 	bind_chain_t *chain;
 	bind_entry_t *entry, *prev;
@@ -479,10 +486,10 @@
   return 0;			/* No match.	*/
 }
 
-static int add_bind_entry(bind_table_t *table, const char *flags, const char *mask, const char *function_name, int bind_flags, Function callback, void *client_data)
+int add_bind_entry(bind_table_t *table, const char *flags, const char *mask, const char *function_name, int bind_flags, Function callback, void *client_data)
 {
 	bind_chain_t *chain;
-	bind_entry_t *entry, *prev;
+	bind_entry_t *entry;
 
 	/* Find the chain (mask) first. */
 	for (chain = table->chains; chain; chain = chain->next) {
@@ -499,9 +506,9 @@
 	}
 
 	/* If it's stackable */
-	if (chain->flags & BIND_STACKABLE) {
+	if (table->flags & BIND_STACKABLE) {
 		/* Search for specific entry. */
-		for (prev = NULL, entry = chain->entries; chain; prev = entry, entry = entry->next) {
+		for (entry = chain->entries; entry; entry = entry->next) {
 			if (!strcmp(entry->function_name, function_name)) break;
 		}
 	}
@@ -898,33 +905,37 @@
   }
 }
 
-int check_bind(bind_table_t *table, const char *match, struct flag_record *flags, int match_type, int nargs, ...)
+int check_bind(bind_table_t *table, const char *match, struct flag_record *_flags, ...)
 {
 	int *al; /* Argument list */
+	struct flag_record *flags;
 	bind_chain_t *chain;
 	bind_entry_t *entry;
-	int len, cmp, n_args, r;
+	int len, cmp, r, hits;
 	Function cb;
 
 	/* Experimental way to not use va_list... */
-	n_args = nargs;
-	al = (int *)&nargs;
+	flags = _flags;
+	al = (int *)&_flags;
 
 	/* Save the length for strncmp */
 	len = strlen(match);
 
+	/* Keep track of how many binds execute (or would) */
+	hits = 0;
+
 	/* For each chain in the table... */
 	for (chain = table->chains; chain; chain = chain->next) {
 		/* Test to see if it matches. */
-		if (match_type & MATCH_PARTIAL) {
-			if (match_type & MATCH_CASE) cmp = strncmp(match, chain->mask, len);
+		if (table->match_type & MATCH_PARTIAL) {
+			if (table->match_type & MATCH_CASE) cmp = strncmp(match, chain->mask, len);
 			else cmp = egg_strncasecmp(match, chain->mask, len);
 		}
-		else if (match_type & MATCH_MASK) {
+		else if (table->match_type & MATCH_MASK) {
 			cmp = !wild_match_per((unsigned char *)chain->mask, (unsigned char *)match);
 		}
 		else {
-			if (match_type & MATCH_CASE) cmp = strcmp(match, chain->mask);
+			if (table->match_type & MATCH_CASE) cmp = strcmp(match, chain->mask);
 			else cmp = egg_strcasecmp(match, chain->mask);
 		}
 		if (cmp) continue; /* Doesn't match. */
@@ -933,29 +944,34 @@
 		/* If it's not stackable, There Can Be Only One. */
 		for (entry = chain->entries; entry; entry = entry->next) {
 			/* Check flags. */
-			if (match_type & BIND_USE_ATTR) {
-				if (match_type & BIND_HAS_BUILTINS) cmp = flagrec_ok(&entry->user_flags, flags);
-				else cmp = flagrec_eq(&entry->user_flags, flags);
+			if (table->match_type & BIND_USE_ATTR) {
+				if (table->match_type & BIND_STRICT_ATTR) cmp = flagrec_eq(&entry->user_flags, flags);
+				else cmp = flagrec_ok(&entry->user_flags, flags);
 				if (!cmp) continue;
 			}
 
-			/* It's all good, now do the callback. */
+			/* This is a hit */
+			hits++;
+
+			/* Does the callback want client data? */
 			cb = entry->callback;
 			if (entry->bind_flags & BIND_WANTS_CD) {
 				al[0] = (int) entry->client_data;
-				n_args++;
+				table->nargs++;
 			}
 			else al++;
-			switch (n_args) {
+
+			switch (table->nargs) {
 				case 0: r = cb(); break;
 				case 1: r = cb(al[0]); break;
 				case 2: r = cb(al[0], al[1]); break;
 				case 3: r = cb(al[0], al[1], al[2]); break;
 				case 4: r = cb(al[0], al[1], al[2], al[3]); break;
 				case 5: r = cb(al[0], al[1], al[2], al[3], al[4]); break;
-				default: r = cb(al[0], al[1], al[2], al[3], al[4], al[5]); break;
+				case 6: r = cb(al[0], al[1], al[2], al[3], al[4], al[5]); break;
 			}
-			if (entry->bind_flags & BIND_WANTS_CD) n_args--;
+
+			if (entry->bind_flags & BIND_WANTS_CD) table->nargs--;
 			else al--;
 		}
 	}
@@ -1171,6 +1187,8 @@
 
 void check_tcl_link(const char *bot, const char *via)
 {
+  check_bind(BT_link, bot, NULL, bot, via);
+
   Tcl_SetVar(interp, "_link1", (char *) bot, 0);
   Tcl_SetVar(interp, "_link2", (char *) via, 0);
   check_tcl_bind(H_link, bot, 0, " $_link1 $_link2",
@@ -1179,6 +1197,8 @@
 
 void check_tcl_disc(const char *bot)
 {
+  check_bind(BT_disc, bot, NULL, bot);
+
   Tcl_SetVar(interp, "_disc1", (char *) bot, 0);
   check_tcl_bind(H_disc, bot, 0, " $_disc1", MATCH_MASK | BIND_STACKABLE);
 }
@@ -1286,6 +1306,8 @@
 {
   char	u[11];
 
+  check_bind(BT_away, bot, NULL, bot, idx, msg);
+
   egg_snprintf(u, sizeof u, "%d", idx);
   Tcl_SetVar(interp, "_away1", (char *) bot, 0);
   Tcl_SetVar(interp, "_away2", (char *) u, 0);
@@ -1310,18 +1332,18 @@
   Tcl_SetVar(interp, "_time5", (char *) y, 0);
   egg_snprintf(y, sizeof y, "%02d %02d %02d %02d %04d", tm->tm_min, tm->tm_hour,
 	       tm->tm_mday, tm->tm_mon, tm->tm_year + 1900);
+
+  check_bind(BT_time, y, NULL, tm->tm_min, tm->tm_hour, tm->tm_mday, tm->tm_mon, tm->tm_year + 1900);
+
   check_tcl_bind(H_time, y, 0,
 		 " $_time1 $_time2 $_time3 $_time4 $_time5",
 		 MATCH_MASK | BIND_STACKABLE);
 }
 
-void check_event2(const char *event)
-{
-	check_bind(BT_event, event, NULL, MATCH_MASK, 1, event);
-}
-
 void check_tcl_event(const char *event)
 {
+  check_bind(BT_event, event, NULL, event);
+
   Tcl_SetVar(interp, "_event1", (char *) event, 0);
   check_tcl_bind(H_event, event, 0, " $_event1", MATCH_EXACT | BIND_STACKABLE);
 }
@@ -1398,6 +1420,16 @@
   }
 }
 
+void add_builtins2(bind_table_t *table, cmd_t *cmds)
+{
+	char name[50];
+
+	for (; cmds->name; cmds++) {
+		snprintf(name, 50, "*%s:%s", table->name, cmds->funcname ? cmds->funcname : cmds->name);
+		add_bind_entry(table, cmds->flags, cmds->name, name, 0, cmds->func, NULL);
+	}
+}
+
 /* Bring the default msg/dcc/fil commands into the Tcl interpreter */
 void add_builtins(tcl_bind_list_t *tl, cmd_t *cc)
 {
@@ -1413,6 +1445,16 @@
     bind_bind_entry(tl, cc[i].flags, cc[i].name, l);
     nfree(l);
   }
+}
+
+void rem_builtins2(bind_table_t *table, cmd_t *cmds)
+{
+	char name[50];
+
+	for (; cmds->name; cmds++) {
+		sprintf(name, "*%s:%s", table->name, cmds->funcname ? cmds->funcname : cmds->name);
+		del_bind_entry(table, cmds->flags, cmds->name, name);
+	}
 }
 
 /* Remove the default msg/dcc/fil commands from the Tcl interpreter */
Index: eggdrop1.7/src/tclhash.h
diff -u eggdrop1.7/src/tclhash.h:1.13 eggdrop1.7/src/tclhash.h:1.14
--- eggdrop1.7/src/tclhash.h:1.13	Thu Sep 20 14:50:19 2001
+++ eggdrop1.7/src/tclhash.h	Thu Sep 27 22:15:34 2001
@@ -1,7 +1,7 @@
 /*
  * tclhash.h
  *
- * $Id: tclhash.h,v 1.13 2001/09/20 19:50:19 stdarg Exp $
+ * $Id: tclhash.h,v 1.14 2001/09/28 03:15:34 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -28,9 +28,13 @@
 
 #define TC_DELETED	0x0001	/* This command/trigger was deleted.	*/
 
+/* Flags for bind entries */
 /* Does the callback want their client_data inserted as the first argument? */
 #define BIND_WANTS_CD 1
 
+/* Flags for bind tables */
+#define BIND_STRICT_ATTR 0x80
+
 /* Will replace tcl_cmd_t */
 /* This holds the final information for a function listening on a bind
    table. */
@@ -91,6 +95,8 @@
 	bind_chain_t *chains;
 	char *name;
 	char *syntax;
+	int nargs;
+	int match_type;
 	int flags;
 } bind_table_t;
 
@@ -157,6 +163,22 @@
 extern p_tcl_bind_list H_chat, H_act, H_bcst, H_chon, H_chof;
 extern p_tcl_bind_list H_load, H_unld, H_dcc, H_bot, H_link;
 extern p_tcl_bind_list H_away, H_nkch, H_filt, H_disc, H_event;
+
+int check_bind(bind_table_t *table, const char *match, struct flag_record *_flags, ...);
+
+bind_table_t *add_bind_table2(const char *name, int nargs, const char *syntax, int match_type, int flags);
+
+void del_bind_table2(bind_table_t *table);
+
+bind_table_t *find_bind_table2(const char *name);
+
+int add_bind_entry(bind_table_t *table, const char *flags, const char *mask, const char *function_name, int bind_flags, Function callback, void *client_data);
+
+int del_bind_entry(bind_table_t *table, const char *flags, const char *mask, const char *function_name);
+
+void add_builtins2(bind_table_t *table, cmd_t *cmds);
+
+void rem_builtins2(bind_table_t *table, cmd_t *cmds);
 
 #endif
 
----------------------- End of diff -----------------------



More information about the Changes mailing list