[cvslog] Module eggdrop1.7: Change committed

cvslog cvs at tsss.org
Sat Oct 20 22:45:01 CST 2001


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.7
Commit time: 2001-10-21 03:44:41 UTC
Commited by: stdarg <stdarg at techmonkeys.org>

Modified files:
     src/botnet.c src/cmds.c src/logfile.c src/modules.c src/tcl.c
     src/tclhash.c src/tclhash.h src/mod/module.h
     src/mod/assoc.mod/assoc.c src/mod/channels.mod/channels.c
     src/mod/console.mod/console.c src/mod/notes.mod/notes.c
     src/mod/tclscript.mod/tclscript.c

Log message:

* Applied Oskar Liljeblad's patch to convert more bind tables.
* Fixed bug in putlog which causes an infinite loop.
* Added console error logging into tclscript.mod.
* Added external error logging via "error_logfile" variable, for more detailed information. Default filename is logs/tcl_errors.log.

---------------------- diff included ----------------------
Index: eggdrop1.7/src/botnet.c
diff -u eggdrop1.7/src/botnet.c:1.45 eggdrop1.7/src/botnet.c:1.46
--- eggdrop1.7/src/botnet.c:1.45	Thu Oct 18 20:55:04 2001
+++ eggdrop1.7/src/botnet.c	Sat Oct 20 22:44:30 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.45 2001/10/19 01:55:04 tothwolf Exp $
+ * $Id: botnet.c,v 1.46 2001/10/21 03:44:30 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -55,9 +55,6 @@
 extern int die_on_sigterm;
 extern int die_on_sighup;
 
-/* The bind tables we create. */
-static bind_table_t *BT_chjn, *BT_chpt;
-
 static void botnet_sigterm(char *);
 static void botnet_sighup(char *);
 
@@ -75,10 +72,6 @@
 	bind_table_t *BT_event;
 
 	init_bots();
-
-	/* Create botnet bind tables. */
-	BT_chjn = add_bind_table2("chjn", 4, "ssdd", MATCH_MASK, BIND_STACKABLE);
-	BT_chpt = add_bind_table2("chpt", 4, "ssdd", MATCH_MASK, BIND_STACKABLE);
 
 	/* Add our event handlers */
 	add_hook(HOOK_5MINUTELY, (Function) check_botnet_pings);
Index: eggdrop1.7/src/cmds.c
diff -u eggdrop1.7/src/cmds.c:1.74 eggdrop1.7/src/cmds.c:1.75
--- eggdrop1.7/src/cmds.c:1.74	Thu Oct 18 20:55:04 2001
+++ eggdrop1.7/src/cmds.c	Sat Oct 20 22:44:30 2001
@@ -3,7 +3,7 @@
  *   commands from a user via dcc
  *   (split in 2, this portion contains no-irc commands)
  *
- * $Id: cmds.c,v 1.74 2001/10/19 01:55:04 tothwolf Exp $
+ * $Id: cmds.c,v 1.75 2001/10/21 03:44:30 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -877,11 +877,13 @@
   }
 }
 
-static void cmd_handle(struct userrec *u, int idx, char *par)
+static int cmd_handle(struct userrec *u, int idx, char *par)
 {
   char oldhandle[HANDLEN + 1], newhandle[HANDLEN + 1];
   int i;
 
+  putlog(LOG_MISC, "*", "boogaboo!");
+  return(0);
   strncpyz(newhandle, newsplit(&par), sizeof newhandle);
 
   if (!newhandle[0]) {
Index: eggdrop1.7/src/logfile.c
diff -u eggdrop1.7/src/logfile.c:1.4 eggdrop1.7/src/logfile.c:1.5
--- eggdrop1.7/src/logfile.c:1.4	Thu Oct 18 20:55:05 2001
+++ eggdrop1.7/src/logfile.c	Sat Oct 20 22:44:30 2001
@@ -243,9 +243,9 @@
 		chname = va_arg(va, char *);
 		format = va_arg(va, char *);
 		i = vsnprintf(out, len, format, va);
-		if (i > -1 && i < len) break;
-		if (i > len) i = len+1;
-		else len *= 2;
+		if (i > -1 && i < len) break; /* Done. */
+		if (i > len) len = i+1; /* Exact amount. */
+		else len *= 2; /* Just guessing. */
 		out = (char *)realloc(out, len);
 	}
 	len = i;
Index: eggdrop1.7/src/mod/assoc.mod/assoc.c
diff -u eggdrop1.7/src/mod/assoc.mod/assoc.c:1.26 eggdrop1.7/src/mod/assoc.mod/assoc.c:1.27
--- eggdrop1.7/src/mod/assoc.mod/assoc.c:1.26	Thu Oct 18 20:55:06 2001
+++ eggdrop1.7/src/mod/assoc.mod/assoc.c	Sat Oct 20 22:44:30 2001
@@ -2,7 +2,7 @@
  * assoc.c -- part of assoc.mod
  *   the assoc code, moved here mainly from botnet.c for module work
  *
- * $Id: assoc.c,v 1.26 2001/10/19 01:55:06 tothwolf Exp $
+ * $Id: assoc.c,v 1.27 2001/10/21 03:44:30 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -45,7 +45,7 @@
 /* Channel name-number associations */
 static assoc_t *assoc;
 
-static bind_table_t *BT_dcc;
+static bind_table_t *BT_dcc, *BT_bot, *BT_link;
 
 static void botnet_send_assoc(int idx, int chan, char *nick,
 			      char *buf)
@@ -379,8 +379,8 @@
 {
   kill_all_assoc();
   if (BT_dcc) rem_builtins2(BT_dcc, mydcc);
-  rem_builtins(H_bot, mybot);
-  rem_builtins(H_link, mylink);
+  if (BT_bot) rem_builtins2(BT_bot, mybot);
+  if (BT_link) rem_builtins2(BT_link, mylink);
   rem_tcl_commands(mytcl);
   module_undepend(MODULE_NAME);
   return NULL;
@@ -408,8 +408,10 @@
   assoc = NULL;
   BT_dcc = find_bind_table2("dcc");
   if (BT_dcc) add_builtins2(BT_dcc, mydcc);
-  add_builtins(H_bot, mybot);
-  add_builtins(H_link, mylink);
+  BT_bot = find_bind_table2("bot");
+  if (BT_bot) add_builtins2(BT_bot, mybot);
+  BT_link = find_bind_table2("link");
+  if (BT_link) add_builtins2(BT_link, mylink);
   add_tcl_commands(mytcl);
 
   return NULL;
Index: eggdrop1.7/src/mod/channels.mod/channels.c
diff -u eggdrop1.7/src/mod/channels.mod/channels.c:1.65 eggdrop1.7/src/mod/channels.mod/channels.c:1.66
--- eggdrop1.7/src/mod/channels.mod/channels.c:1.65	Thu Oct 18 20:55:07 2001
+++ eggdrop1.7/src/mod/channels.mod/channels.c	Sat Oct 20 22:44:31 2001
@@ -2,7 +2,7 @@
  * channels.c -- part of channels.mod
  *   support for channels within the bot
  *
- * $Id: channels.c,v 1.65 2001/10/19 01:55:07 tothwolf Exp $
+ * $Id: channels.c,v 1.66 2001/10/21 03:44:31 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -67,7 +67,7 @@
 static int gfld_nick_thr;
 static int gfld_nick_time;
 
-static bind_table_t *BT_dcc;
+static bind_table_t *BT_dcc, *BT_chon;
 
 #include "channels.h"
 #include "cmdschan.c"
@@ -718,7 +718,7 @@
 {
   write_channels();
   free_udef(udef);
-  rem_builtins(H_chon, my_chon);
+  if (BT_chon) rem_builtins2(BT_chon, my_chon);
   if (BT_dcc) rem_builtins2(BT_dcc, C_dcc_irc);
   rem_tcl_commands(channels_cmds);
   rem_tcl_strings(my_tcl_strings);
@@ -854,7 +854,8 @@
   Tcl_TraceVar(interp, "global-chanset",
 	       TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
 	       traced_globchanset, NULL);
-  add_builtins(H_chon, my_chon);
+  BT_chon = find_bind_table2("chon");
+  if (BT_chon) add_builtins2(BT_chon, my_chon);
   BT_dcc = find_bind_table2("dcc");
   if (BT_dcc) add_builtins2(BT_dcc, C_dcc_irc);
   add_tcl_commands(channels_cmds);
Index: eggdrop1.7/src/mod/console.mod/console.c
diff -u eggdrop1.7/src/mod/console.mod/console.c:1.27 eggdrop1.7/src/mod/console.mod/console.c:1.28
--- eggdrop1.7/src/mod/console.mod/console.c:1.27	Thu Oct 11 06:34:20 2001
+++ eggdrop1.7/src/mod/console.mod/console.c	Sat Oct 20 22:44:31 2001
@@ -3,7 +3,7 @@
  *   saved console settings based on console.tcl
  *   by cmwagner/billyjoe/D. Senso
  *
- * $Id: console.c,v 1.27 2001/10/11 11:34:20 tothwolf Exp $
+ * $Id: console.c,v 1.28 2001/10/21 03:44:31 stdarg Exp $
  */
 /*
  * Copyright (C) 1999, 2000, 2001 Eggheads Development Team
@@ -36,7 +36,7 @@
 static int force_channel = 0;
 static int info_party = 0;
 
-static bind_table_t *BT_dcc;
+static bind_table_t *BT_dcc, *BT_chon;
 
 struct console_info {
   char *channel;
@@ -340,7 +340,7 @@
 
 static char *console_close()
 {
-  rem_builtins(H_chon, mychon);
+  if (BT_chon) rem_builtins2(BT_chon, mychon);
   if (BT_dcc) rem_builtins2(BT_dcc, mydcc);
   rem_tcl_ints(myints);
   rem_help_reference("console.help");
@@ -371,9 +371,10 @@
   }
 
   BT_dcc = find_bind_table2("dcc");
+  BT_chon = find_bind_table2("chon");
 
   if (BT_dcc) add_builtins2(BT_dcc, mydcc);
-  add_builtins(H_chon, mychon);
+  if (BT_chon) add_builtins2(BT_chon, mychon);
   add_tcl_ints(myints);
   add_help_reference("console.help");
   USERENTRY_CONSOLE.get = def_get;
Index: eggdrop1.7/src/mod/module.h
diff -u eggdrop1.7/src/mod/module.h:1.72 eggdrop1.7/src/mod/module.h:1.73
--- eggdrop1.7/src/mod/module.h:1.72	Sat Oct 20 16:57:15 2001
+++ eggdrop1.7/src/mod/module.h	Sat Oct 20 22:44:30 2001
@@ -1,7 +1,7 @@
 /*
  * module.h
  *
- * $Id: module.h,v 1.72 2001/10/20 21:57:15 stdarg Exp $
+ * $Id: module.h,v 1.73 2001/10/21 03:44:30 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -285,22 +285,22 @@
 #define add_hook(a,b) (((void (*) (int, Function))global[172])(a,b))
 #define del_hook(a,b) (((void (*) (int, Function))global[173])(a,b))
 /* 174: H_dcc -- UNUSED (stdarg) */
-#define H_filt (*(p_tcl_bind_list *)(global[175]))
+/* 175: H_filt -- UNUSED (oskar) */
 /* 176 - 179 */
-#define H_chon (*(p_tcl_bind_list *)(global[176]))
-#define H_chof (*(p_tcl_bind_list *)(global[177]))
+/* 176: H_chon -- UNUSED (oskar) */
+/* 177: H_chof -- UNUSED (oskar) */
 /*#define H_load (*(p_tcl_bind_list *)(global[178])) */
 /*#define H_unld (*(p_tcl_bind_list *)(global[179])) */
 /* 180 - 183 */
 /* 180: H_chat -- UNUSED (oskar) */
 /* 181: H_act -- UNUSED (oskar) */
 /* 182: H_bcst -- UNUSED (oskar) */
-#define H_bot (*(p_tcl_bind_list *)(global[183]))
+/* 183: H_bot -- UNUSED (oskar) */
 /* 184 - 187 */
-#define H_link (*(p_tcl_bind_list *)(global[184]))
-#define H_disc (*(p_tcl_bind_list *)(global[185]))
+/* 184: H_link -- UNUSED (oskar) */
+/* 185: H_disc -- UNUSED (oskar) */
 /* 186: H_away -- UNUSED (oskar) */
-#define H_nkch (*(p_tcl_bind_list *)(global[187]))
+/* 187: H_nkch -- UNUSED (oskar) */
 /* 188 - 191 */
 #define USERENTRY_BOTADDR (*(struct user_entry_type *)(global[188]))
 #define USERENTRY_BOTFL (*(struct user_entry_type *)(global[189]))
Index: eggdrop1.7/src/mod/notes.mod/notes.c
diff -u eggdrop1.7/src/mod/notes.mod/notes.c:1.41 eggdrop1.7/src/mod/notes.mod/notes.c:1.42
--- eggdrop1.7/src/mod/notes.mod/notes.c:1.41	Sat Oct 20 05:22:14 2001
+++ eggdrop1.7/src/mod/notes.mod/notes.c	Sat Oct 20 22:44:31 2001
@@ -5,7 +5,7 @@
  *   note cmds
  *   note ignores
  *
- * $Id: notes.c,v 1.41 2001/10/20 10:22:14 stdarg Exp $
+ * $Id: notes.c,v 1.42 2001/10/21 03:44:31 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -47,7 +47,7 @@
 				   drummer */
 static Function *global = NULL;	/* DAMN fcntl.h */
 
-static bind_table_t *BT_dcc, *BT_load, *BT_away;
+static bind_table_t *BT_dcc, *BT_load, *BT_away, *BT_nkch, *BT_chon;
 
 static struct user_entry_type USERENTRY_FWD =
 {
@@ -1175,9 +1175,9 @@
   if ((H_temp = find_bind_table("join")))
     rem_builtins(H_temp, notes_join);
   if (BT_dcc) rem_builtins2(BT_dcc, notes_cmds);
-  rem_builtins(H_chon, notes_chon);
+  if (BT_chon) rem_builtins2(BT_chon, notes_chon);
   if (BT_away) rem_builtins2(BT_away, notes_away);
-  rem_builtins(H_nkch, notes_nkch);
+  if (BT_nkch) rem_builtins2(BT_nkch, notes_nkch);
   if (BT_load) rem_builtins2(BT_load, notes_load);
   rem_help_reference("notes.help");
   del_hook(HOOK_MATCH_NOTEREJ, (Function) match_note_ignore);
@@ -1228,12 +1228,14 @@
   BT_dcc = find_bind_table2("dcc");
   BT_load = find_bind_table2("load");
   BT_away = find_bind_table2("away");
+  BT_nkch = find_bind_table2("nkch");
+  BT_chon = find_bind_table2("chon");
   if (BT_dcc) add_builtins2(BT_dcc, notes_cmds);
   if (BT_load) add_builtins2(BT_load, notes_load);
 
-  add_builtins(H_chon, notes_chon);
+  if (BT_chon) add_builtins2(BT_chon, notes_chon);
   if (BT_away) add_builtins2(BT_away, notes_away);
-  add_builtins(H_nkch, notes_nkch);
+  if (BT_nkch) add_builtins2(BT_nkch, notes_nkch);
   add_help_reference("notes.help");
   notes_server_setup(0);
   notes_irc_setup(0);
Index: eggdrop1.7/src/mod/tclscript.mod/tclscript.c
diff -u eggdrop1.7/src/mod/tclscript.mod/tclscript.c:1.9 eggdrop1.7/src/mod/tclscript.mod/tclscript.c:1.10
--- eggdrop1.7/src/mod/tclscript.mod/tclscript.c:1.9	Thu Oct 18 04:06:44 2001
+++ eggdrop1.7/src/mod/tclscript.mod/tclscript.c	Sat Oct 20 22:44:31 2001
@@ -29,6 +29,8 @@
 static Tcl_Interp *ginterp; /* Our global interpreter. */
 static char *my_syntax_error = "syntax error";
 
+static char *error_logfile = NULL;
+
 static int my_load_script(registry_entry_t *entry, char *fname)
 {
 	int result;
@@ -134,9 +136,35 @@
 		Tcl_ListObjAppendElement(cd->myinterp, final_command, arg);
 	}
 
-	Tcl_EvalObjEx(cd->myinterp, final_command, TCL_EVAL_GLOBAL);
-	result = Tcl_GetObjResult(cd->myinterp);
-	Tcl_GetIntFromObj(cd->myinterp, result, &retval);
+	n = Tcl_EvalObjEx(cd->myinterp, final_command, TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT);
+	if (n == TCL_OK) {
+		result = Tcl_GetObjResult(cd->myinterp);
+		Tcl_GetIntFromObj(cd->myinterp, result, &retval);
+	}
+	else {
+		FILE *fp;
+		char *errmsg;
+
+		errmsg = Tcl_GetStringResult(cd->myinterp);
+		putlog(LOG_MISC, "*", "TCL Error: %s", errmsg);
+
+		if (error_logfile && error_logfile[0]) {
+			time_t timenow = time(NULL);
+			fp = fopen(error_logfile, "a");
+			if (fp) {
+				errmsg = Tcl_GetVar(cd->myinterp, "errorInfo", TCL_GLOBAL_ONLY);
+				fprintf(fp, "%s", asctime(localtime(&timenow)));
+				fprintf(fp, "%s\n\n", errmsg);
+				fclose(fp);
+			}
+			else {
+				putlog(LOG_MISC, "*", "Error opening TCL error log (%s)!", error_logfile);
+			}
+		}
+	}
+
+	/* Clear any errors or stray messages. */
+	Tcl_ResetResult(cd->myinterp);
 
 	/* If it's a one-time callback, delete it. */
 	if (me->flags & SCRIPT_CALLBACK_ONCE) me->delete(me);
@@ -481,6 +509,10 @@
 	/* When tcl is gone from the core, this will be uncommented. */
 	/* interp = Tcl_CreateInterp(); */
 	ginterp = interp;
+
+	malloc_strcpy(error_logfile, "logs/tcl_errors.log");
+	Tcl_LinkVar(ginterp, "error_logfile", (char *)&error_logfile, TCL_LINK_STRING);
+
 	registry_add_simple_chains(my_functions);
 	registry_lookup("script", "playback", &journal_playback, &journal_playback_h);
 	if (journal_playback) journal_playback(journal_playback_h, journal_table);
Index: eggdrop1.7/src/modules.c
diff -u eggdrop1.7/src/modules.c:1.80 eggdrop1.7/src/modules.c:1.81
--- eggdrop1.7/src/modules.c:1.80	Sat Oct 20 16:57:15 2001
+++ eggdrop1.7/src/modules.c	Sat Oct 20 22:44:30 2001
@@ -4,7 +4,7 @@
  * 
  * by Darrin Smith (beldin at light.iinet.net.au)
  * 
- * $Id: modules.c,v 1.80 2001/10/20 21:57:15 stdarg Exp $
+ * $Id: modules.c,v 1.81 2001/10/21 03:44:30 stdarg Exp $
  */
 /* 
  * Copyright (C) 1997  Robey Pointer
@@ -362,22 +362,22 @@
   (Function) add_hook,
   (Function) del_hook,
   (Function) 0,
-  (Function) & H_filt,		/* p_tcl_bind_list *			*/
+  (Function) 0,		/* p_tcl_bind_list *			*/
   /* 176 - 179 */
-  (Function) & H_chon,		/* p_tcl_bind_list *			*/
-  (Function) & H_chof,		/* p_tcl_bind_list *			*/
+  (Function) 0,		/* p_tcl_bind_list *			*/
+  (Function) 0,		/* p_tcl_bind_list *			*/
   (Function) 0,		/* p_tcl_bind_list *			*/
   (Function) 0,		/* p_tcl_bind_list *			*/
   /* 180 - 183 */
   (Function) 0,		/* p_tcl_bind_list *			*/
   (Function) 0,		/* p_tcl_bind_list *			*/
   (Function) 0,		/* p_tcl_bind_list *			*/
-  (Function) & H_bot,		/* p_tcl_bind_list *			*/
+  (Function) 0,		/* p_tcl_bind_list *			*/
   /* 184 - 187 */
-  (Function) & H_link,		/* p_tcl_bind_list *			*/
-  (Function) & H_disc,		/* p_tcl_bind_list *			*/
   (Function) 0,		/* p_tcl_bind_list *			*/
-  (Function) & H_nkch,		/* p_tcl_bind_list *			*/
+  (Function) 0,		/* p_tcl_bind_list *			*/
+  (Function) 0,		/* p_tcl_bind_list *			*/
+  (Function) 0,		/* p_tcl_bind_list *			*/
   /* 188 - 191 */
   (Function) & USERENTRY_BOTADDR,	/* struct user_entry_type *	*/
   (Function) & USERENTRY_BOTFL,		/* struct user_entry_type *	*/
Index: eggdrop1.7/src/tcl.c
diff -u eggdrop1.7/src/tcl.c:1.50 eggdrop1.7/src/tcl.c:1.51
--- eggdrop1.7/src/tcl.c:1.50	Fri Oct 19 00:26:32 2001
+++ eggdrop1.7/src/tcl.c	Sat Oct 20 22:44:30 2001
@@ -4,7 +4,7 @@
  *   Tcl initialization
  *   getting and setting Tcl/eggdrop variables
  *
- * $Id: tcl.c,v 1.50 2001/10/19 05:26:32 guppy Exp $
+ * $Id: tcl.c,v 1.51 2001/10/21 03:44:30 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -441,8 +441,7 @@
   Tcl_PkgProvide(interp, "eggdrop", pver);
 #endif
 
-  /* Initialize old binds and traces */
-  init_old_binds();
+  /* Initialize traces */
   init_traces();
 
   /* Add new commands */
Index: eggdrop1.7/src/tclhash.c
diff -u eggdrop1.7/src/tclhash.c:1.51 eggdrop1.7/src/tclhash.c:1.52
--- eggdrop1.7/src/tclhash.c:1.51	Sat Oct 20 16:57:15 2001
+++ eggdrop1.7/src/tclhash.c	Sat Oct 20 22:44:30 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.51 2001/10/20 21:57:15 stdarg Exp $
+ * $Id: tclhash.c,v 1.52 2001/10/21 03:44:30 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -49,21 +49,19 @@
 static bind_table_t *BT_chat;
 static bind_table_t *BT_act;
 static bind_table_t *BT_bcst;
+static bind_table_t *BT_note;
+static bind_table_t *BT_bot;
+static bind_table_t *BT_nkch;
+static bind_table_t *BT_chon;
+static bind_table_t *BT_chof;
+static bind_table_t *BT_chpt;
+static bind_table_t *BT_chjn;
+static bind_table_t *BT_filt;
 
 p_tcl_bind_list		bind_table_list;
-p_tcl_bind_list		H_chon, H_chof,
-			H_link, H_disc, H_chjn, H_chpt,
-			H_bot, H_time, H_nkch, H_note, H_filt;
 
-static int builtin_2char();
-static int builtin_3char();
 static int builtin_5int();
-static int builtin_char();
-static int builtin_chpt();
-static int builtin_chjn();
-static int builtin_idxchar();
 static int builtin_charidx();
-static int builtin_dcc();
 
 /* Delete trigger/command.
  */
@@ -167,6 +165,7 @@
 	bind_table_list_head = NULL;
 	script_create_simple_cmd_table(script_commands);
 	BT_link = add_bind_table2("link", 2, "ss", MATCH_MASK, BIND_STACKABLE);
+	BT_nkch = add_bind_table2("nkch", 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_dcc = add_bind_table2("dcc", 3, "Uis", MATCH_MASK, BIND_USE_ATTR);
@@ -174,23 +173,13 @@
 	BT_chat = add_bind_table2("chat", 3, "Uis", MATCH_MASK, BIND_STACKABLE | BIND_BREAKABLE);
 	BT_act = add_bind_table2("act", 3, "sis", MATCH_MASK, BIND_STACKABLE);
 	BT_bcst = add_bind_table2("bcst", 3, "sis", MATCH_MASK, BIND_STACKABLE);
-}
-
-void init_old_binds(void)
-{
-  bind_table_list = NULL;
-  Context;
-  H_note = add_bind_table("note", 0, builtin_3char);
-  H_nkch = add_bind_table("nkch", HT_STACKABLE, builtin_2char);
-  H_link = add_bind_table("link", HT_STACKABLE, builtin_2char);
-  H_filt = add_bind_table("filt", HT_STACKABLE, builtin_idxchar);
-  H_disc = add_bind_table("disc", HT_STACKABLE, builtin_char);
-  H_chpt = add_bind_table("chpt", HT_STACKABLE, builtin_chpt);
-  H_chon = add_bind_table("chon", HT_STACKABLE, builtin_charidx);
-  H_chof = add_bind_table("chof", HT_STACKABLE, builtin_charidx);
-  H_chjn = add_bind_table("chjn", HT_STACKABLE, builtin_chjn);
-  H_bot = add_bind_table("bot", 0, builtin_3char);
-  Context;
+	BT_note = add_bind_table2("note", 3 , "sss", MATCH_EXACT, 0);
+	BT_bot = add_bind_table2("bot", 3, "sss", MATCH_EXACT, 0);
+	BT_chon = add_bind_table2("chon", 2, "si", MATCH_MASK, BIND_USE_ATTR | BIND_STACKABLE | BIND_WANTRET);
+	BT_chof = add_bind_table2("chof", 2, "si", MATCH_MASK, BIND_USE_ATTR | BIND_STACKABLE | BIND_WANTRET);
+	BT_chpt = add_bind_table2("chpt", 4, "ssii", MATCH_MASK, BIND_STACKABLE);
+	BT_chjn = add_bind_table2("chjn", 6, "ssisis", MATCH_MASK, BIND_STACKABLE);
+	BT_filt = add_bind_table2("filt", 2, "is", MATCH_MASK, BIND_USE_ATTR | BIND_STACKABLE | BIND_WANTRET | BIND_ALTER_ARGS);
 }
 
 void kill_bind2(void)
@@ -583,26 +572,6 @@
   return 1;
 }
 
-static int builtin_3char STDVAR
-{
-  Function F = (Function) cd;
-
-  BADARGS(4, 4, " from to args");
-  CHECKVALIDITY(builtin_3char);
-  F(argv[1], argv[2], argv[3]);
-  return TCL_OK;
-}
-
-static int builtin_2char STDVAR
-{
-  Function F = (Function) cd;
-
-  BADARGS(3, 3, " nick msg");
-  CHECKVALIDITY(builtin_2char);
-  F(argv[1], argv[2]);
-  return TCL_OK;
-}
-
 static int builtin_5int STDVAR
 {
   Function F = (Function) cd;
@@ -613,57 +582,6 @@
   return TCL_OK;
 }
 
-static int builtin_char STDVAR
-{
-  Function F = (Function) cd;
-
-  BADARGS(2, 2, " handle");
-  CHECKVALIDITY(builtin_char);
-  F(argv[1]);
-  return TCL_OK;
-}
-
-static int builtin_chpt STDVAR
-{
-  Function F = (Function) cd;
-
-  BADARGS(3, 3, " bot nick sock");
-  CHECKVALIDITY(builtin_chpt);
-  F(argv[1], argv[2], atoi(argv[3]));
-  return TCL_OK;
-}
-
-static int builtin_chjn STDVAR
-{
-  Function F = (Function) cd;
-
-  BADARGS(6, 6, " bot nick chan# flag&sock host");
-  CHECKVALIDITY(builtin_chjn);
-  F(argv[1], argv[2], atoi(argv[3]), argv[4][0],
-    argv[4][0] ? atoi(argv[4] + 1) : 0, argv[5]);
-  return TCL_OK;
-}
-
-static int builtin_idxchar STDVAR
-{
-  Function F = (Function) cd;
-  int idx;
-  char *r;
-
-  BADARGS(3, 3, " idx args");
-  CHECKVALIDITY(builtin_idxchar);
-  idx = findidx(atoi(argv[1]));
-  if (idx < 0) {
-    Tcl_AppendResult(irp, "invalid idx", NULL);
-    return TCL_ERROR;
-  }
-  r = (((char *(*)()) F) (idx, argv[2]));
-
-  Tcl_ResetResult(irp);
-  Tcl_AppendResult(irp, r, NULL);
-  return TCL_OK;
-}
-
 int findanyidx(register int z)
 {
   register int j;
@@ -766,8 +684,8 @@
 		/* If it's not stackable, There Can Be Only One. */
 		for (entry = chain->entries; entry; entry = entry->next) {
 			/* Check flags. */
-			if (table->match_type & BIND_USE_ATTR) {
-				if (table->match_type & BIND_STRICT_ATTR) cmp = flagrec_eq(&entry->user_flags, flags);
+			if (table->flags & BIND_USE_ATTR) {
+				if (table->flags & BIND_STRICT_ATTR) cmp = flagrec_eq(&entry->user_flags, flags);
 				else cmp = flagrec_ok(&entry->user_flags, flags);
 				if (!cmp) continue;
 			}
@@ -956,31 +874,34 @@
 
 void check_tcl_bot(const char *nick, const char *code, const char *param)
 {
-  Tcl_SetVar(interp, "_bot1", (char *) nick, 0);
-  Tcl_SetVar(interp, "_bot2", (char *) code, 0);
-  Tcl_SetVar(interp, "_bot3", (char *) param, 0);
-  check_tcl_bind(H_bot, code, 0, " $_bot1 $_bot2 $_bot3", MATCH_EXACT);
+  check_bind(BT_bot, code, NULL, nick, code, param);
+}
+
+void check_tcl_chon(char *hand, int idx)
+{
+  struct flag_record	 fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
+  struct userrec	*u;
+
+  u = get_user_by_handle(userlist, hand);
+  touch_laston(u, "partyline", now);
+  get_user_flagrec(u, &fr, NULL);
+  check_bind(BT_chon, hand, &fr, hand, idx);
 }
 
-void check_tcl_chonof(char *hand, int sock, tcl_bind_list_t *tl)
+void check_tcl_chof(char *hand, int idx)
 {
   struct flag_record	 fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
-  char			 s[11];
   struct userrec	*u;
 
   u = get_user_by_handle(userlist, hand);
   touch_laston(u, "partyline", now);
   get_user_flagrec(u, &fr, NULL);
-  Tcl_SetVar(interp, "_chonof1", (char *) hand, 0);
-  snprintf(s, sizeof s, "%d", sock);
-  Tcl_SetVar(interp, "_chonof2", (char *) s, 0);
-  check_tcl_bind(tl, hand, &fr, " $_chonof1 $_chonof2", MATCH_MASK |
-		 BIND_USE_ATTR | BIND_STACKABLE | BIND_WANTRET);
+  check_bind(BT_chof, hand, &fr, hand, idx);
 }
 
-int check_tcl_chat(struct userrec *u, int chan, const char *text)
+int check_tcl_chat(const char *from, int chan, const char *text)
 {
-  return check_bind(BT_chat, text, NULL, u, chan, text);
+  return check_bind(BT_chat, text, NULL, from, chan, text);
 }
 
 void check_tcl_act(const char *from, int chan, const char *text)
@@ -995,43 +916,26 @@
 
 void check_tcl_nkch(const char *ohand, const char *nhand)
 {
-  Tcl_SetVar(interp, "_nkch1", (char *) ohand, 0);
-  Tcl_SetVar(interp, "_nkch2", (char *) nhand, 0);
-  check_tcl_bind(H_nkch, ohand, 0, " $_nkch1 $_nkch2",
-		 MATCH_MASK | BIND_STACKABLE);
+  check_bind(BT_nkch, ohand, NULL, ohand, nhand);
 }
 
 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",
-		 MATCH_MASK | BIND_STACKABLE);
 }
 
 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);
 }
 
 const char *check_tcl_filt(int idx, const char *text)
 {
-  char			s[11];
   int			x;
   struct flag_record	fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
 
-  snprintf(s, sizeof s, "%ld", dcc[idx].sock);
   get_user_flagrec(dcc[idx].user, &fr, dcc[idx].u.chat->con_chan);
-  Tcl_SetVar(interp, "_filt1", (char *) s, 0);
-  Tcl_SetVar(interp, "_filt2", (char *) text, 0);
-  x = check_tcl_bind(H_filt, text, &fr, " $_filt1 $_filt2",
-		     MATCH_MASK | BIND_USE_ATTR | BIND_STACKABLE |
-		     BIND_WANTRET | BIND_ALTER_ARGS);
+  x = check_bind(BT_filt, text, &fr, dcc[idx].sock, text);
   if (x == BIND_EXECUTED || x == BIND_EXEC_LOG) {
     if (interp->result == NULL || !interp->result[0])
       return "";
@@ -1045,10 +949,7 @@
 {
   int	x;
 
-  Tcl_SetVar(interp, "_note1", (char *) from, 0);
-  Tcl_SetVar(interp, "_note2", (char *) to, 0);
-  Tcl_SetVar(interp, "_note3", (char *) text, 0);
-  x = check_tcl_bind(H_note, to, 0, " $_note1 $_note2 $_note3", MATCH_EXACT);
+  check_bind(BT_note, to, NULL, from, to, text);
   return (x == BIND_MATCHED || x == BIND_EXECUTED || x == BIND_EXEC_LOG);
 }
 
@@ -1086,30 +987,15 @@
     fr.global = USER_BOTMAST;
   }
   snprintf(s, sizeof s, "%d", chan);
-  snprintf(u, sizeof u, "%d", sock);
-  Tcl_SetVar(interp, "_chjn1", (char *) bot, 0);
-  Tcl_SetVar(interp, "_chjn2", (char *) nick, 0);
-  Tcl_SetVar(interp, "_chjn3", (char *) s, 0);
-  Tcl_SetVar(interp, "_chjn4", (char *) t, 0);
-  Tcl_SetVar(interp, "_chjn5", (char *) u, 0);
-  Tcl_SetVar(interp, "_chjn6", (char *) host, 0);
-  check_tcl_bind(H_chjn, s, &fr,
-		 " $_chjn1 $_chjn2 $_chjn3 $_chjn4 $_chjn5 $_chjn6",
-		 MATCH_MASK | BIND_STACKABLE);
+  check_bind(BT_chjn, s, &fr, bot, nick, chan, t, sock, host);
 }
 
 void check_tcl_chpt(const char *bot, const char *hand, int sock, int chan)
 {
-  char	u[11], v[11];
+  char	v[11];
 
-  snprintf(u, sizeof u, "%d", sock);
   snprintf(v, sizeof v, "%d", chan);
-  Tcl_SetVar(interp, "_chpt1", (char *) bot, 0);
-  Tcl_SetVar(interp, "_chpt2", (char *) hand, 0);
-  Tcl_SetVar(interp, "_chpt3", (char *) u, 0);
-  Tcl_SetVar(interp, "_chpt4", (char *) v, 0);
-  check_tcl_bind(H_chpt, v, 0, " $_chpt1 $_chpt2 $_chpt3 $_chpt4",
-		 MATCH_MASK | BIND_STACKABLE);
+  check_bind(BT_chpt, v, NULL, bot, hand, sock, chan);
 }
 
 void check_tcl_away(const char *bot, int idx, const char *msg)
Index: eggdrop1.7/src/tclhash.h
diff -u eggdrop1.7/src/tclhash.h:1.23 eggdrop1.7/src/tclhash.h:1.24
--- eggdrop1.7/src/tclhash.h:1.23	Sat Oct 20 16:57:15 2001
+++ eggdrop1.7/src/tclhash.h	Sat Oct 20 22:44:30 2001
@@ -1,7 +1,7 @@
 /*
  * tclhash.h
  *
- * $Id: tclhash.h,v 1.23 2001/10/20 21:57:15 stdarg Exp $
+ * $Id: tclhash.h,v 1.24 2001/10/21 03:44:30 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -156,22 +156,18 @@
 void check_tcl_away(const char *, int, const char *);
 void check_tcl_event(const char *);
 
-int check_tcl_chat(struct userrec *, int, const char *);
+int check_tcl_chat(const char *, int, const char *);
 void check_tcl_act(const char *, int, const char *);
 void check_tcl_bcst(const char *, int, const char *);
-void check_tcl_chonof(char *, int, tcl_bind_list_t *);
+void check_tcl_chon(char *, int);
+void check_tcl_chof(char *, int);
 
-#define check_tcl_chon(a, b) check_tcl_chonof(a, b, H_chon)
-#define check_tcl_chof(a, b) check_tcl_chonof(a, b, H_chof)
 void check_tcl_loadunld(const char *, tcl_bind_list_t *);
 
 void rem_builtins(tcl_bind_list_t *, cmd_t *);
 void add_builtins(tcl_bind_list_t *, cmd_t *);
 
 int check_validity(char *, Function);
-extern p_tcl_bind_list H_chon, H_chof;
-extern p_tcl_bind_list H_bot, H_link;
-extern p_tcl_bind_list H_nkch, H_filt, H_disc;
 
 int check_bind(bind_table_t *table, const char *match, struct flag_record *_flags, ...);
 
----------------------- End of diff -----------------------



More information about the Changes mailing list