[cvslog] Module eggdrop1.7: Change committed

cvslog cvs at tsss.org
Thu Oct 11 21:28:00 CST 2001


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.7
Commit time: 2001-10-12 02:27:56 UTC
Commited by: stdarg <stdarg at techmonkeys.org>

Modified files:
     src/botnet.c src/main.c src/match.c src/net.c src/tcl.c
     src/tclhash.c

Log message:

Moved some stuff from main.c to botnet.c (for modularizing botnet)
Changed irctoupper to _irctoupper in match.c (temporary fix, cuz something is making it crash (I think irctoupper isn't initialized or exported or something))
Added code to expand the socket table when it's full.

---------------------- diff included ----------------------
Index: eggdrop1.7/src/botnet.c
diff -u eggdrop1.7/src/botnet.c:1.42 eggdrop1.7/src/botnet.c:1.43
--- eggdrop1.7/src/botnet.c:1.42	Thu Oct 11 06:34:19 2001
+++ eggdrop1.7/src/botnet.c	Thu Oct 11 21:27:45 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.42 2001/10/11 11:34:19 tothwolf Exp $
+ * $Id: botnet.c,v 1.43 2001/10/12 02:27:45 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -30,6 +30,7 @@
 
 #include "main.h"
 #include "tandem.h"
+#include "modules.h"
 
 extern char		 spaces[], spaces2[];
 extern int		 dcc_total, backgrd, connect_timeout, max_dcc,
@@ -50,19 +51,50 @@
 int		 share_unlinks = 0;	/* Allow remote unlinks of my
 					   sharebots? */
 
+/* From main.c */
+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 *);
 
-static bind_table_t *BT_chjn = NULL;
-static bind_table_t *BT_chpt = NULL;
+/* We want to listen to the sigterm event. */
+static cmd_t botnet_events[] = {
+	{"botnet_sigterm", "", (Function) botnet_sigterm, NULL},
+	{"botnet_sighup", "", (Function) botnet_sighup, NULL},
+	0
+};
 
 static void init_bots();
 
 void botnet_init()
 {
+	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);
+	BT_event = find_bind_table2("event");
+	if (BT_event) add_builtins2(BT_event, botnet_events);
+}
+
+/* Handle TERM signal */
+static void botnet_sigterm(char *event)
+{
+	if (die_on_sigterm) botnet_send_chat(-1, botnetnick, "ACK, I've been terminated! (SIGTERM)");
+}
+
+static void botnet_sighup(char *event)
+{
+	if (die_on_sighup) botnet_send_chat(-1, botnetnick, "ACK, I've been terminated! (SIGHUP)");
 }
 
 static void init_bots()
Index: eggdrop1.7/src/main.c
diff -u eggdrop1.7/src/main.c:1.79 eggdrop1.7/src/main.c:1.80
--- eggdrop1.7/src/main.c:1.79	Wed Oct 10 05:44:04 2001
+++ eggdrop1.7/src/main.c	Thu Oct 11 21:27:45 2001
@@ -5,7 +5,7 @@
  *   command line arguments
  *   context and assert debugging
  *
- * $Id: main.c,v 1.79 2001/10/10 10:44:04 tothwolf Exp $
+ * $Id: main.c,v 1.80 2001/10/12 02:27:45 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -331,7 +331,6 @@
   write_userfile(-1);
   check_tcl_event("sigterm");
   if (die_on_sigterm) {
-    botnet_send_chat(-1, botnetnick, "ACK, I've been terminated!");
     fatal("TERMINATE SIGNAL -- SIGNING OFF", 0);
   } else {
     putlog(LOG_MISC, "*", "RECEIVED TERMINATE SIGNAL (IGNORING)");
@@ -537,7 +536,6 @@
     miltime = (nowtm.tm_hour * 100) + (nowtm.tm_min);
     if (((int) (nowtm.tm_min / 5) * 5) == (nowtm.tm_min)) {	/* 5 min */
       call_hook(HOOK_5MINUTELY);
-      check_botnet_pings();
       if (!quick_logs) {
 	flushlogs();
 	check_logsize();
@@ -654,6 +652,7 @@
 int init_dcc_max(), init_userent(), init_misc(), init_net(),
  init_modules(), init_tcl(int, char **);
 void botnet_init();
+void init_binds();
 
 void patch(const char *str)
 {
@@ -768,15 +767,19 @@
   if (((int) getuid() == 0) || ((int) geteuid() == 0))
     fatal(_("ERROR: Eggdrop will not run as root!"), 0);
 
+  init_binds();
   init_dcc_max();
   init_userent();
   init_misc();
   botnet_init();
   init_net();
   init_modules();
+
   if (backgrd)
     bg_prepare_split();
+
   init_tcl(argc, argv);
+
 #ifdef STATIC
   link_statics();
 #endif
Index: eggdrop1.7/src/match.c
diff -u eggdrop1.7/src/match.c:1.7 eggdrop1.7/src/match.c:1.8
--- eggdrop1.7/src/match.c:1.7	Thu Oct 11 13:24:01 2001
+++ eggdrop1.7/src/match.c	Thu Oct 11 21:27:45 2001
@@ -2,7 +2,7 @@
  * match.c
  *   wildcard matching functions
  *
- * $Id: match.c,v 1.7 2001/10/11 18:24:01 tothwolf Exp $
+ * $Id: match.c,v 1.8 2001/10/12 02:27:45 stdarg Exp $
  */
 /*
  * Once this code was working, I added support for % so that I could
@@ -102,7 +102,7 @@
       sofar &= UNQUOTED;	/* Remember not quoted */
     } else
       sofar |= QUOTED;		/* Remember quoted */
-    if (irctoupper(*m) == irctoupper(*n)) {	/* If matching char */
+    if (_irctoupper(*m) == _irctoupper(*n)) {	/* If matching char */
       m--;
       n--;
       sofar++;			/* Tally the match */
@@ -204,7 +204,7 @@
       case QUOTE:
 	m++;			/* Handle quoting */
       }
-      if (irctoupper(*m) == irctoupper(*n)) {		/* If matching */
+      if (_irctoupper(*m) == _irctoupper(*n)) {		/* If matching */
 	m++;
 	n++;
 	sofar++;
Index: eggdrop1.7/src/net.c
diff -u eggdrop1.7/src/net.c:1.43 eggdrop1.7/src/net.c:1.44
--- eggdrop1.7/src/net.c:1.43	Thu Oct 11 08:01:35 2001
+++ eggdrop1.7/src/net.c	Thu Oct 11 21:27:45 2001
@@ -2,7 +2,7 @@
  * net.c -- handles:
  *   all raw network i/o
  * 
- * $Id: net.c,v 1.43 2001/10/11 13:01:35 tothwolf Exp $
+ * $Id: net.c,v 1.44 2001/10/12 02:27:45 stdarg Exp $
  */
 /* 
  * This is hereby released into the public domain.
@@ -88,6 +88,7 @@
   char s[256];
   struct hostent *hp;
 
+  socklist = (sock_list *)calloc(MAXSOCKS, sizeof(sock_list));
   for (i = 0; i < MAXSOCKS; i++) {
     socklist[i].flags = SOCK_UNUSED;
   }
@@ -251,17 +252,20 @@
   int i;
 
   for (i = 0; i < MAXSOCKS; i++) {
-    if (socklist[i].flags & SOCK_UNUSED) {
-      /* yay!  there is table space */
-      socklist[i].inbuf = socklist[i].outbuf = NULL;
-      socklist[i].inbuflen = socklist[i].outbuflen = 0;
-      socklist[i].flags = options;
-      socklist[i].sock = sock;
-      return i;
-    }
+    if (socklist[i].flags & SOCK_UNUSED) break;
+  }
+
+  if (i == MAXSOCKS) {
+    /* Expand table by 5 */
+    socklist = (sock_list *)realloc(socklist, (MAXSOCKS+5) * sizeof(sock_list));
+    memset(socklist+MAXSOCKS, 0, 5 * sizeof(sock_list));
+    MAXSOCKS += 5;
   }
-  fatal("Socket table is full!", 0);
-  return -1; /* Never reached */
+
+  memset(socklist+i, 0, sizeof(sock_list));
+  socklist[i].flags = options;
+  socklist[i].sock = sock;
+  return(i);
 }
 
 /* Request a normal socket for i/o
Index: eggdrop1.7/src/tcl.c
diff -u eggdrop1.7/src/tcl.c:1.43 eggdrop1.7/src/tcl.c:1.44
--- eggdrop1.7/src/tcl.c:1.43	Wed Oct 10 05:44:04 2001
+++ eggdrop1.7/src/tcl.c	Thu Oct 11 21:27:45 2001
@@ -4,7 +4,7 @@
  *   Tcl initialization
  *   getting and setting Tcl/eggdrop variables
  *
- * $Id: tcl.c,v 1.43 2001/10/10 10:44:04 tothwolf Exp $
+ * $Id: tcl.c,v 1.44 2001/10/12 02:27:45 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -597,9 +597,8 @@
   Tcl_PkgProvide(interp, "eggdrop", pver);
 #endif
 
-  /* Initialize binds and traces */
-  init_bind2();
-  init_bind();
+  /* Initialize old binds and traces */
+  init_old_binds();
   init_traces();
 
   /* Add new commands */
Index: eggdrop1.7/src/tclhash.c
diff -u eggdrop1.7/src/tclhash.c:1.42 eggdrop1.7/src/tclhash.c:1.43
--- eggdrop1.7/src/tclhash.c:1.42	Thu Oct 11 06:34:19 2001
+++ eggdrop1.7/src/tclhash.c	Thu Oct 11 21:27:45 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.42 2001/10/11 11:34:19 tothwolf Exp $
+ * $Id: tclhash.c,v 1.43 2001/10/12 02:27:45 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -154,11 +154,9 @@
 static int tcl_bind2();
 static int tcl_unbind2();
 
-void init_bind2(void)
+void init_binds(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", 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);
@@ -168,7 +166,7 @@
 	add_builtins2(BT_dcc, C_dcc);
 }
 
-void init_bind(void)
+void init_old_binds(void)
 {
   bind_table_list = NULL;
   Context;
----------------------- End of diff -----------------------



More information about the Changes mailing list