[cvslog] Module eggdrop1.7: Change committed

cvslog cvs at tsss.org
Sat Sep 29 23:28:00 CST 2001


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.7
Commit time: 2001-09-30 04:27:49 UTC
Commited by: stdarg

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

Log message:

The new bind tables seem to be working pretty well. This patch mainly
creates a new dcc bind table and moves the core built-ins to that table.
The behavior of the new table is a little different than the old one (for now).

---------------------- diff included ----------------------
Index: eggdrop1.7/src/mod/server.mod/server.c
diff -u eggdrop1.7/src/mod/server.mod/server.c:1.79 eggdrop1.7/src/mod/server.mod/server.c:1.80
--- eggdrop1.7/src/mod/server.mod/server.c:1.79	Thu Sep 27 22:15:35 2001
+++ eggdrop1.7/src/mod/server.mod/server.c	Sat Sep 29 23:27:38 2001
@@ -2,7 +2,7 @@
  * server.c -- part of server.mod
  *   basic irc server support
  *
- * $Id: server.c,v 1.79 2001/09/28 03:15:35 stdarg Exp $
+ * $Id: server.c,v 1.80 2001/09/30 04:27:38 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -95,6 +95,8 @@
 static p_tcl_bind_list H_wall, H_raw, H_notc, H_msgm, H_msg, H_flud,
 		       H_ctcr, H_ctcp;
 
+static p_tcl_bind_list my_H_dcc; /* Imported from core */
+
 static void empty_msgq(void);
 static void next_server(int *, char *, unsigned int *, char *);
 static void disconnect_server(int);
@@ -109,7 +111,11 @@
 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;
+static bind_table_t *BT_wall, *BT_raw, *BT_notice, *BT_msg, *BT_msgm;
+static bind_table_t *BT_flood, *BT_ctcr, *BT_ctcp;
+
+/* Imported bind tables. */
+static bind_table_t *BT_dcc;
 
 #include "servmsg.c"
 
@@ -1677,12 +1683,15 @@
   cycle_time = 100;
   nuke_server("Connection reset by peer");
   clearq(serverlist);
-  rem_builtins(H_dcc, C_dcc_serv);
 
+  /* rem_builtins(my_H_dcc, C_dcc_serv); */
   /* rem_builtins(H_raw, my_raw_binds); */
+  /* rem_builtins(H_ctcp, my_ctcps); */
+
+  rem_builtins2(BT_dcc, C_dcc_serv);
   rem_builtins2(BT_raw, my_raw_binds);
+  rem_builtins2(BT_ctcp, my_ctcps);
 
-  rem_builtins(H_ctcp, my_ctcps);
   /* Restore original commands. */
   del_bind_table(H_wall);
   del_bind_table(H_raw);
@@ -1870,12 +1879,20 @@
 	       TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
 	       traced_nicklen, NULL);
 
+	/* Create our own bind tables. */
 	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_notice = add_bind_table2("notice", 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);
+	BT_flood = add_bind_table2("flood", 5, "sssss", MATCH_MASK, BIND_STACKABLE);
+	BT_ctcr = add_bind_table2("ctcr", 6, "ssssss", MATCH_MASK, BIND_USE_ATTR | BIND_STACKABLE);
+	BT_ctcp = add_bind_table2("ctcp", 6, "ssssss", MATCH_MASK, BIND_USE_ATTR | BIND_STACKABLE);
+
+	/* Import bind tables. */
+	BT_dcc = find_bind_table2("dcc");
 
+  /* Create the old tables for compatibility (temporary). */
   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);
@@ -1886,10 +1903,12 @@
   H_ctcp = add_bind_table("ctcp", HT_STACKABLE, server_6char);
 
   /* add_builtins(H_raw, my_raw_binds); */
+  /* add_builtins(H_ctcp, my_ctcps); */
+  /* add_builtins(H_dcc, C_dcc_serv); */
   add_builtins2(BT_raw, my_raw_binds);
+  add_builtins2(BT_ctcp, my_ctcps);
+  add_builtins2(BT_dcc, C_dcc_serv);
 
-  add_builtins(H_dcc, C_dcc_serv);
-  add_builtins(H_ctcp, my_ctcps);
   add_help_reference("server.help");
   my_tcl_strings[0].buf = botname;
   add_tcl_strings(my_tcl_strings);
Index: eggdrop1.7/src/mod/server.mod/servmsg.c
diff -u eggdrop1.7/src/mod/server.mod/servmsg.c:1.65 eggdrop1.7/src/mod/server.mod/servmsg.c:1.66
--- eggdrop1.7/src/mod/server.mod/servmsg.c:1.65	Thu Sep 27 22:15:35 2001
+++ eggdrop1.7/src/mod/server.mod/servmsg.c	Sat Sep 29 23:27:38 2001
@@ -1,7 +1,7 @@
 /*
  * servmsg.c -- part of server.mod
  *
- * $Id: servmsg.c,v 1.65 2001/09/28 03:15:35 stdarg Exp $
+ * $Id: servmsg.c,v 1.66 2001/09/30 04:27:38 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -126,7 +126,7 @@
   if (u) hand = u->handle;
   else hand = "*";
 
-  check_bind(BT_notc, arg, &fr, nick, uhost, hand, arg, dest);
+  check_bind(BT_notice, arg, &fr, nick, uhost, hand, arg, dest);
 
   Tcl_SetVar(interp, "_notc1", nick, 0);
   Tcl_SetVar(interp, "_notc2", uhost, 0);
@@ -183,13 +183,23 @@
 			   char *dest, char *keyword, char *args,
 			   p_tcl_bind_list table)
 {
+  bind_table_t *bt_table;
   struct flag_record fr = {FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0};
   int x;
+  char *hand;
 
   get_user_flagrec(u, &fr, NULL);
+  if (u) hand = u->handle;
+  else hand = "*";
+
+  if (table == H_ctcp) bt_table = BT_ctcp;
+  else bt_table = BT_ctcr;
+
+  check_bind(bt_table, keyword, &fr, nick, uhost, hand, dest, keyword, args);
+
   Tcl_SetVar(interp, "_ctcpr1", nick, 0);
   Tcl_SetVar(interp, "_ctcpr2", uhost, 0);
-  Tcl_SetVar(interp, "_ctcpr3", u ? u->handle : "*", 0);
+  Tcl_SetVar(interp, "_ctcpr3", hand, 0);
   Tcl_SetVar(interp, "_ctcpr4", dest, 0);
   Tcl_SetVar(interp, "_ctcpr5", keyword, 0);
   Tcl_SetVar(interp, "_ctcpr6", args, 0);
@@ -221,10 +231,16 @@
 			  char *ftype, char *chname)
 {
   int x;
+  char *hand;
+
+  if (u) hand = u->handle;
+  else hand = "*";
+
+  check_bind(BT_flood, ftype, NULL, nick, uhost, hand, ftype, chname);
 
   Tcl_SetVar(interp, "_flud1", nick, 0);
   Tcl_SetVar(interp, "_flud2", uhost, 0);
-  Tcl_SetVar(interp, "_flud3", u ? u->handle : "*", 0);
+  Tcl_SetVar(interp, "_flud3", hand, 0);
   Tcl_SetVar(interp, "_flud4", ftype, 0);
   Tcl_SetVar(interp, "_flud5", chname, 0);
   x = check_tcl_bind(H_flud, ftype, 0,
@@ -1249,7 +1265,7 @@
     if (pass[0])
       dprintf(DP_MODE, "PASS %s\n", pass);
     dprintf(DP_MODE, "NICK %s\n", botname);
-    dprintf(DP_MODE, "USER %s . . :%s\n", botuser, botrealname);
+    dprintf(DP_MODE, "USER %s localhost %s :%s\n", botuser, dcc[servidx].host, botrealname);
     /* Wait for async result now */
   }
 }
Index: eggdrop1.7/src/tclhash.c
diff -u eggdrop1.7/src/tclhash.c:1.36 eggdrop1.7/src/tclhash.c:1.37
--- eggdrop1.7/src/tclhash.c:1.36	Thu Sep 27 22:15:34 2001
+++ eggdrop1.7/src/tclhash.c	Sat Sep 29 23:27:38 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.36 2001/09/28 03:15:34 stdarg Exp $
+ * $Id: tclhash.c,v 1.37 2001/09/30 04:27:38 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -46,6 +46,7 @@
 static bind_table_t *BT_disc;
 static bind_table_t *BT_away;
 static bind_table_t *BT_time;
+static bind_table_t *BT_dcc;
 
 p_tcl_bind_list		bind_table_list;
 p_tcl_bind_list		H_chat, H_act, H_bcst, H_chon, H_chof,
@@ -234,6 +235,8 @@
 	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);
+	BT_dcc = add_bind_table2("dcc", 3, "sis", MATCH_MASK, BIND_USE_ATTR);
+	add_builtins2(BT_dcc, C_dcc);
 }
 
 void init_bind(void)
@@ -261,13 +264,12 @@
   H_away = add_bind_table("away", HT_STACKABLE, builtin_chat);
   H_act = add_bind_table("act", HT_STACKABLE, builtin_chat);
   H_event = add_bind_table("evnt", HT_STACKABLE, builtin_char);
-  add_builtins(H_dcc, C_dcc);
+  /* add_builtins(H_dcc, C_dcc); */
   Context;
 }
 
 void kill_bind2(void)
 {
-	rem_builtins(H_dcc, C_dcc);
 	while (bind_table_list_head) del_bind_table2(bind_table_list_head);
 }
 
@@ -275,7 +277,9 @@
 {
   tcl_bind_list_t	*tl, *tl_next;
 
-  rem_builtins(H_dcc, C_dcc);
+  /* rem_builtins(H_dcc, C_dcc); */
+  rem_builtins2(BT_dcc, C_dcc);
+
   for (tl = bind_table_list; tl; tl = tl_next) {
     tl_next = tl->next;
 
@@ -518,9 +522,9 @@
 	}
 
 	/* If we have an old entry, re-use it. */
-	/* Otherwise, create a new entry. */
 	if (entry) nfree(entry->function_name);
 	else {
+		/* Otherwise, create a new entry. */
 		entry = (bind_entry_t *)nmalloc(sizeof(*entry));
 		entry->next = chain->entries;
 		chain->entries = entry;
@@ -924,6 +928,9 @@
 	/* Keep track of how many binds execute (or would) */
 	hits = 0;
 
+	/* Default return value is 0 */
+	r = 0;
+
 	/* For each chain in the table... */
 	for (chain = table->chains; chain; chain = chain->next) {
 		/* Test to see if it matches. */
@@ -961,6 +968,9 @@
 			}
 			else al++;
 
+			/* Default return value is 0. */
+			r = 0;
+
 			switch (table->nargs) {
 				case 0: r = cb(); break;
 				case 1: r = cb(al[0]); break;
@@ -969,13 +979,18 @@
 				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;
 				case 6: r = cb(al[0], al[1], al[2], al[3], al[4], al[5]); break;
+				case 7: r = cb(al[0], al[1], al[2], al[3], al[4], al[5], al[6]);
+				case 8: r = cb(al[0], al[1], al[2], al[3], al[4], al[5], al[6], al[7]);
 			}
 
 			if (entry->bind_flags & BIND_WANTS_CD) table->nargs--;
 			else al--;
+
+			if (table->flags & BIND_BREAKABLE & r) break;
 		}
+		if (table->flags & BIND_BREAKABLE & r) break;
 	}
-	return(0);
+	return(r);
 }
 
 int check_tcl_bind(tcl_bind_list_t *tl, const char *match,
@@ -1119,6 +1134,7 @@
   char			s[11];
 
   get_user_flagrec(dcc[idx].user, &fr, dcc[idx].u.chat->con_chan);
+
   egg_snprintf(s, sizeof s, "%ld", dcc[idx].sock);
   Tcl_SetVar(interp, "_dcc1", (char *) dcc[idx].nick, 0);
   Tcl_SetVar(interp, "_dcc2", (char *) s, 0);
@@ -1130,7 +1146,11 @@
     return 0;
   }
   if (x == BIND_NOMATCH) {
-    dprintf(idx, _("What?  You need .help\n"));
+    /* Temporary fix for special-case quit command. */
+    /* Later I'll fix the real quit command so that it's not special. */
+    if (!strcmp(cmd, "quit")) return(1);
+    /* Check the new bind table. */
+    check_bind(BT_dcc, cmd, &fr, dcc[idx].user, idx, args);
     return 0;
   }
   if (x == BIND_EXEC_BRK)
Index: eggdrop1.7/src/tclhash.h
diff -u eggdrop1.7/src/tclhash.h:1.14 eggdrop1.7/src/tclhash.h:1.15
--- eggdrop1.7/src/tclhash.h:1.14	Thu Sep 27 22:15:34 2001
+++ eggdrop1.7/src/tclhash.h	Sat Sep 29 23:27:38 2001
@@ -1,7 +1,7 @@
 /*
  * tclhash.h
  *
- * $Id: tclhash.h,v 1.14 2001/09/28 03:15:34 stdarg Exp $
+ * $Id: tclhash.h,v 1.15 2001/09/30 04:27:38 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -34,6 +34,7 @@
 
 /* Flags for bind tables */
 #define BIND_STRICT_ATTR 0x80
+#define BIND_BREAKABLE 0x100
 
 /* Will replace tcl_cmd_t */
 /* This holds the final information for a function listening on a bind
----------------------- End of diff -----------------------



More information about the Changes mailing list