[cvslog] Module eggdrop1.7: Change committed

cvslog cvs at tsss.org
Sat Sep 22 01:39:00 CST 2001


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.7
Commit time: 2001-09-20 19:50:30 UTC
Commited by: stdarg

Modified files:
     src/main.c src/tcl.c src/tclhash.c src/tclhash.h

Log message:

STill removing tcl from the bind table.
Created first non-tcl bind entry ("event") and bind2/unbind2.

---------------------- diff included ----------------------
Index: eggdrop1.7/src/main.c
diff -u eggdrop1.7/src/main.c:1.76 eggdrop1.7/src/main.c:1.77
--- eggdrop1.7/src/main.c:1.76	Mon Aug 20 19:21:17 2001
+++ eggdrop1.7/src/main.c	Thu Sep 20 14:50:19 2001
@@ -5,7 +5,7 @@
  *   command line arguments
  *   context and assert debugging
  *
- * $Id: main.c,v 1.76 2001/08/21 00:21:17 ite Exp $
+ * $Id: main.c,v 1.77 2001/09/20 19:50:19 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -347,6 +347,7 @@
 {
   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);
@@ -358,6 +359,7 @@
 static void got_quit(int z)
 {
   check_tcl_event("sigquit");
+  check_event2("sigquit");
   putlog(LOG_MISC, "*", "RECEIVED QUIT SIGNAL (IGNORING)");
   return;
 }
@@ -366,6 +368,7 @@
 {
   write_userfile(-1);
   check_tcl_event("sighup");
+  check_event2("sighup");
   if (die_on_sighup) {
     fatal("HANGUP SIGNAL -- SIGNING OFF", 0);
   } else
@@ -388,6 +391,7 @@
 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] : "");
@@ -619,21 +623,25 @@
 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()
@@ -658,6 +666,7 @@
 static void event_loaded()
 {
   check_tcl_event("loaded");
+  check_event2("loaded");
 }
 
 void kill_tcl();
@@ -1036,7 +1045,8 @@
 	char xx[256];
 
  	/* oops, I guess we should call this event before tcl is restarted */
-   	check_tcl_event("prerestart");
+	check_tcl_event("prerestart");
+	check_event2("prerestart");
 
 	while (f) {
 	  f = 0;
Index: eggdrop1.7/src/tcl.c
diff -u eggdrop1.7/src/tcl.c:1.41 eggdrop1.7/src/tcl.c:1.42
--- eggdrop1.7/src/tcl.c:1.41	Sat Aug 18 21:36:23 2001
+++ eggdrop1.7/src/tcl.c	Thu Sep 20 14:50:19 2001
@@ -4,7 +4,7 @@
  *   Tcl initialization
  *   getting and setting Tcl/eggdrop variables
  *
- * $Id: tcl.c,v 1.41 2001/08/19 02:36:23 drummer Exp $
+ * $Id: tcl.c,v 1.42 2001/09/20 19:50:19 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -618,6 +618,7 @@
 #endif
 
   /* Initialize binds and traces */
+  init_bind2();
   init_bind();
   init_traces();
 
Index: eggdrop1.7/src/tclhash.c
diff -u eggdrop1.7/src/tclhash.c:1.34 eggdrop1.7/src/tclhash.c:1.35
--- eggdrop1.7/src/tclhash.c:1.34	Sat Aug 25 22:52:32 2001
+++ eggdrop1.7/src/tclhash.c	Thu Sep 20 14:50:19 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.34 2001/08/26 03:52:32 stdarg Exp $
+ * $Id: tclhash.c,v 1.35 2001/09/20 19:50:19 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -40,7 +40,8 @@
 extern time_t		 now;
 
 /* New bind table list */
-bind_table_t *bind_table_list_head;
+bind_table_t *bind_table_list_head = NULL;
+bind_table_t *BT_event = NULL;
 
 p_tcl_bind_list		bind_table_list;
 p_tcl_bind_list		H_chat, H_act, H_bcst, H_chon, H_chof,
@@ -219,6 +220,16 @@
 
 extern cmd_t C_dcc[];
 static int tcl_bind();
+static int tcl_bind2();
+static int tcl_unbind2();
+
+void init_bind2(void)
+{
+	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);
+}
 
 void init_bind(void)
 {
@@ -270,18 +281,18 @@
   bind_table_list = NULL;
 }
 
-bind_table_t *add_bind_table2(const char *name, int flags)
+bind_table_t *add_bind_table2(const char *name, const char *syntax, int flags)
 {
 	bind_table_t *table;
 
 	for (table = bind_table_list_head; table; table = table->next) {
-		/* If it already exists, and isn't marked for deletion, return it. */
 		if (!strcmp(table->name, name)) return(table);
 	}
 	/* Nope, we have to create a new one. */
 	table = (bind_table_t *)nmalloc(sizeof(*table));
 	table->chains = NULL;
 	table->name = my_strdup(name);
+	table->syntax = my_strdup(syntax);
 	table->flags = flags;
 	table->next = bind_table_list_head;
 	bind_table_list_head = table;
@@ -396,15 +407,6 @@
   return NULL;
 }
 
-static void dump_bind_tables2(Tcl_Interp *irp)
-{
-	bind_table_t *table;
-
-	for (table = bind_table_list_head; table; table = table->next) {
-		Tcl_AppendResult(irp, table->name, " ", NULL);
-	}
-}
-
 static void dump_bind_tables(Tcl_Interp *irp)
 {
   tcl_bind_list_t	*tl;
@@ -477,7 +479,7 @@
   return 0;			/* No match.	*/
 }
 
-static int add_bind_entry(bind_table_t *table, const char *flags, const char *mask, const char *function_name, Function callback, void *client_data)
+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)
 {
 	bind_chain_t *chain;
 	bind_entry_t *entry, *prev;
@@ -514,13 +516,14 @@
 	else {
 		entry = (bind_entry_t *)nmalloc(sizeof(*entry));
 		entry->next = chain->entries;
+		chain->entries = entry;
 	}
 
 	entry->function_name = my_strdup(function_name);
 	entry->callback = callback;
 	entry->client_data = client_data;
 	entry->hits = 0;
-	entry->bind_flags = 0;
+	entry->bind_flags = bind_flags;
 
 	entry->user_flags.match = FR_GLOBAL | FR_CHAN;
 	break_down_flags(flags, &(entry->user_flags), NULL);
@@ -617,6 +620,48 @@
   return TCL_OK;
 }
 
+/* Only needs to work for "event" right now */
+static int my_tcl_bind_callback(char *cmd, char *event)
+{
+	Tcl_VarEval(interp, cmd, " ", event, NULL);
+	return(0);
+}
+
+static int tcl_bind2 STDVAR
+{
+	bind_table_t *table;
+	char *cmd;
+
+	BADARGS(5, 5, " type flags cmd/mask procname");
+
+	table = find_bind_table2(argv[1]);
+	if (!table) {
+		Tcl_AppendResult(irp, "invalid table type", NULL);
+		return(TCL_ERROR);
+	}
+
+	/* We pass the callback cmd as our client data */
+	cmd = my_strdup(argv[4]);
+	add_bind_entry(table, argv[2], argv[3], argv[4], BIND_WANTS_CD, my_tcl_bind_callback, cmd);
+	Tcl_AppendResult(irp, "moooo", NULL);
+	return(TCL_OK);
+}
+
+static int tcl_unbind2 STDVAR
+{
+	bind_table_t *table;
+
+	BADARGS(5, 5, " type flags cmd/mask procname");
+	table = find_bind_table2(argv[1]);
+	if (!table) {
+		Tcl_AppendResult(irp, "invalid table type", NULL);
+		return(TCL_ERROR);
+	}
+	del_bind_entry(table, argv[2], argv[3], argv[4]);
+	Tcl_AppendResult(irp, "mooooo", NULL);
+	return(TCL_OK);
+}
+
 static int tcl_bind STDVAR
 {
   tcl_bind_list_t	*tl;
@@ -876,7 +921,7 @@
 			else cmp = egg_strncasecmp(match, chain->mask, len);
 		}
 		else if (match_type & MATCH_MASK) {
-			cmp = wild_match_per((unsigned char *)match, (unsigned char *)chain->mask);
+			cmp = !wild_match_per((unsigned char *)chain->mask, (unsigned char *)match);
 		}
 		else {
 			if (match_type & MATCH_CASE) cmp = strcmp(match, chain->mask);
@@ -912,8 +957,6 @@
 			}
 			if (entry->bind_flags & BIND_WANTS_CD) n_args--;
 			else al--;
-
-			/* Another break */
 		}
 	}
 	return(0);
@@ -1270,6 +1313,11 @@
   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)
Index: eggdrop1.7/src/tclhash.h
diff -u eggdrop1.7/src/tclhash.h:1.12 eggdrop1.7/src/tclhash.h:1.13
--- eggdrop1.7/src/tclhash.h:1.12	Sat Aug 25 22:52:32 2001
+++ eggdrop1.7/src/tclhash.h	Thu Sep 20 14:50:19 2001
@@ -1,7 +1,7 @@
 /*
  * tclhash.h
  *
- * $Id: tclhash.h,v 1.12 2001/08/26 03:52:32 stdarg Exp $
+ * $Id: tclhash.h,v 1.13 2001/09/20 19:50:19 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -90,6 +90,7 @@
 	struct bind_table_b *next;
 	bind_chain_t *chains;
 	char *name;
+	char *syntax;
 	int flags;
 } bind_table_t;
 
----------------------- End of diff -----------------------



More information about the Changes mailing list