[cvslog] (2003-04-04 04:04:56 UTC) Module eggdrop1.7: Change committed

cvslog cvs at tsss.org
Thu Apr 3 22:04:56 CST 2003


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.7
Commit time: 2003-04-04 04:04:56 UTC
Commited by: stdarg <stdarg at techmonkeys.org>

Modified files:
     lib/eggdrop/Makefile.am lib/eggdrop/binds.c lib/eggdrop/eggnet.c
     lib/eggdrop/eggtimer.c lib/eggdrop/eggtimer.h
     lib/eggdrop/throttle.c modules/script/scripttimer.c
     modules/server/dcc.c src/main.c

Log message:

* Added a name field to timers

---------------------- diff included ----------------------
Index: eggdrop1.7/lib/eggdrop/Makefile.am
diff -u eggdrop1.7/lib/eggdrop/Makefile.am:1.18 eggdrop1.7/lib/eggdrop/Makefile.am:1.19
--- eggdrop1.7/lib/eggdrop/Makefile.am:1.18	Tue Feb 25 04:28:21 2003
+++ eggdrop1.7/lib/eggdrop/Makefile.am	Thu Apr  3 22:04:46 2003
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.18 2003/02/25 10:28:21 stdarg Exp $
+# $Id: Makefile.am,v 1.19 2003/04/04 04:04:46 stdarg Exp $
 
 MAINTAINERCLEANFILES	= Makefile.in
 
@@ -8,7 +8,6 @@
 
 libeggdrop_la_SOURCES	= base64.c base64.h \
 			binds.c binds.h \
-			botnetutil.c botnetutil.h \
 			common.h \
 			eggconfig.c eggconfig.h \
 			eggdrop.c eggdrop.h \
Index: eggdrop1.7/lib/eggdrop/binds.c
diff -u eggdrop1.7/lib/eggdrop/binds.c:1.3 eggdrop1.7/lib/eggdrop/binds.c:1.4
--- eggdrop1.7/lib/eggdrop/binds.c:1.3	Sun Feb 16 05:15:06 2003
+++ eggdrop1.7/lib/eggdrop/binds.c	Thu Apr  3 22:04:46 2003
@@ -42,7 +42,7 @@
 
 	when.sec = 0;
 	when.usec = 0;
-	timer_create(&when, internal_bind_cleanup);
+	timer_create(&when, "bind table cleanup", internal_bind_cleanup);
 }
 
 void kill_binds(void)
Index: eggdrop1.7/lib/eggdrop/eggnet.c
diff -u eggdrop1.7/lib/eggdrop/eggnet.c:1.4 eggdrop1.7/lib/eggdrop/eggnet.c:1.5
--- eggdrop1.7/lib/eggdrop/eggnet.c:1.4	Tue Feb 25 00:52:19 2003
+++ eggdrop1.7/lib/eggdrop/eggnet.c	Thu Apr  3 22:04:46 2003
@@ -117,9 +117,12 @@
 	connect_info->timer_id = -1;
 	connect_info->dns_id = egg_dns_lookup(host, DNS_IPV4, connect_host_resolved, connect_info);
 	if (timeout > 0) {
+		char buf[128];
+
+		snprintf(buf, sizeof(buf), "idx %d to %s/%d", idx, host, port);
 		howlong.sec = timeout;
 		howlong.usec = 0;
-		connect_info->timer_id = timer_create_complex(&howlong, egg_connect_timeout, connect_info, 0);
+		connect_info->timer_id = timer_create_complex(&howlong, buf, egg_connect_timeout, connect_info, 0);
 	}
 	return(connect_info->idx);
 }
Index: eggdrop1.7/lib/eggdrop/eggtimer.c
diff -u eggdrop1.7/lib/eggdrop/eggtimer.c:1.4 eggdrop1.7/lib/eggdrop/eggtimer.c:1.5
--- eggdrop1.7/lib/eggdrop/eggtimer.c:1.4	Thu Jan  2 15:33:13 2003
+++ eggdrop1.7/lib/eggdrop/eggtimer.c	Thu Apr  3 22:04:46 2003
@@ -21,7 +21,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: eggtimer.c,v 1.4 2003/01/02 21:33:13 wcc Exp $";
+static const char rcsid[] = "$Id: eggtimer.c,v 1.5 2003/04/04 04:04:46 stdarg Exp $";
 #endif
 
 #include <stdio.h> /* NULL */
@@ -37,6 +37,7 @@
 typedef struct egg_timer_b {
 	struct egg_timer_b *next;
 	int id;
+	char *name;
 	Function callback;
 	void *client_data;
 	egg_timeval_t howlong;
@@ -123,13 +124,15 @@
 	return(0);
 }
 
-int timer_create_complex(egg_timeval_t *howlong, Function callback, void *client_data, int flags)
+int timer_create_complex(egg_timeval_t *howlong, const char *name, Function callback, void *client_data, int flags)
 {
 	egg_timer_t *timer;
 
 	/* Fill out a new timer. */
 	timer = (egg_timer_t *)malloc(sizeof(*timer));
 	timer->id = timer_next_id++;
+	if (name) timer->name = strdup(name);
+	else timer->name = NULL;
 	timer->callback = callback;
 	timer->client_data = client_data;
 	timer->flags = flags;
@@ -160,6 +163,7 @@
 	if (prev) prev->next = timer->next;
 	else timer_list_head = timer->next;
 
+	if (timer->name) free(timer->name);
 	free(timer);
 	return(0);
 }
@@ -170,6 +174,7 @@
 
 	for (timer = timer_list_head; timer; timer = next) {
 		next = timer->next;
+		if (timer->name) free(timer->name);
 		free(timer);
 	}
 	timer_list_head = NULL;
@@ -216,6 +221,7 @@
 			timer_add_to_list(timer);
 		}
 		else {
+			if (timer->name) free(timer->name);
 			free(timer);
 		}
 
@@ -242,7 +248,7 @@
 	return(ntimers);
 }
 
-int timer_info(int id, egg_timeval_t *initial_len, egg_timeval_t *trigger_time)
+int timer_info(int id, char **name, egg_timeval_t *initial_len, egg_timeval_t *trigger_time)
 {
 	egg_timer_t *timer;
 
@@ -250,6 +256,7 @@
 		if (timer->id == id) break;
 	}
 	if (!timer) return(-1);
+	if (name) *name = timer->name;
 	if (initial_len) memcpy(initial_len, &timer->howlong, sizeof(*initial_len));
 	if (trigger_time) memcpy(trigger_time, &timer->trigger_time, sizeof(*trigger_time));
 	return(0);
Index: eggdrop1.7/lib/eggdrop/eggtimer.h
diff -u eggdrop1.7/lib/eggdrop/eggtimer.h:1.3 eggdrop1.7/lib/eggdrop/eggtimer.h:1.4
--- eggdrop1.7/lib/eggdrop/eggtimer.h:1.3	Thu Jan  2 15:33:13 2003
+++ eggdrop1.7/lib/eggdrop/eggtimer.h	Thu Apr  3 22:04:46 2003
@@ -19,7 +19,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 /*
- * $Id: eggtimer.h,v 1.3 2003/01/02 21:33:13 wcc Exp $
+ * $Id: eggtimer.h,v 1.4 2003/04/04 04:04:46 stdarg Exp $
  */
 
 #ifndef _EGG_TIMER_H
@@ -33,22 +33,22 @@
 #define TIMER_REPEAT 1
 
 /* Create a simple timer with no client data and no flags. */
-#define timer_create(howlong,callback) timer_create_complex(howlong, callback, NULL, 0)
+#define timer_create(howlong,name,callback) timer_create_complex(howlong, name, callback, NULL, 0)
 
 /* Create a simple timer with no client data, but it repeats. */
-#define timer_create_repeater(howlong,callback) timer_create_complex(howlong, callback, NULL, TIMER_REPEAT)
+#define timer_create_repeater(howlong,name,callback) timer_create_complex(howlong, name, callback, NULL, TIMER_REPEAT)
 
 extern void timer_init();
 extern int timer_get_time(egg_timeval_t *curtime);
 extern void timer_get_now(egg_timeval_t *_now);
 extern int timer_update_now(egg_timeval_t *_now);
 extern int timer_diff(egg_timeval_t *from_time, egg_timeval_t *to_time, egg_timeval_t *diff);
-extern int timer_create_complex(egg_timeval_t *howlong, Function callback, void *client_data, int flags);
+extern int timer_create_complex(egg_timeval_t *howlong, const char *name, Function callback, void *client_data, int flags);
 extern int timer_destroy(int timer_id);
 extern int timer_destroy_all();
 extern int timer_get_shortest(egg_timeval_t *howlong);
 extern int timer_run();
 extern int timer_list(int **ids);
-extern int timer_info(int id, egg_timeval_t *initial_len, egg_timeval_t *trigger_time);
+extern int timer_info(int id, char **name, egg_timeval_t *initial_len, egg_timeval_t *trigger_time);
 
 #endif				/* !_EGG_TIMER_H */
Index: eggdrop1.7/lib/eggdrop/throttle.c
diff -u eggdrop1.7/lib/eggdrop/throttle.c:1.1 eggdrop1.7/lib/eggdrop/throttle.c:1.2
--- eggdrop1.7/lib/eggdrop/throttle.c:1.1	Mon Oct  7 17:33:54 2002
+++ eggdrop1.7/lib/eggdrop/throttle.c	Thu Apr  3 22:04:46 2003
@@ -146,7 +146,7 @@
 	if (throttle_timer < 0) {
 		howlong.sec = 1;
 		howlong.usec = 0;
-		throttle_timer = timer_create_repeater(&howlong, throttle_secondly);
+		throttle_timer = timer_create_repeater(&howlong, "bandwidth throttler", throttle_secondly);
 	}
 	return(0);
 }
Index: eggdrop1.7/modules/script/scripttimer.c
diff -u eggdrop1.7/modules/script/scripttimer.c:1.1 eggdrop1.7/modules/script/scripttimer.c:1.2
--- eggdrop1.7/modules/script/scripttimer.c:1.1	Sun Nov  3 17:16:09 2002
+++ eggdrop1.7/modules/script/scripttimer.c	Thu Apr  3 22:04:46 2003
@@ -28,7 +28,7 @@
 	howlong.usec = usec;
 	callback->syntax = (char *)malloc(1);
 	callback->syntax[0] = 0;
-	id = timer_create_complex(&howlong, callback->callback, callback, flags);
+	id = timer_create_complex(&howlong, callback->name, callback->callback, callback, flags);
 	return(id);
 }
 
@@ -68,47 +68,39 @@
 
 static int script_timer_info(script_var_t *retval, int timer_id)
 {
-	int *info;
 	egg_timeval_t howlong, trigger_time, start_time, diff, now;
+	char *name;
 
-	if (timer_info(timer_id, &howlong, &trigger_time)) {
-		retval->type = SCRIPT_STRING | SCRIPT_ERROR;
-		retval->value = "Timer not found";
-		return(0);
-	}
+	retval->type = SCRIPT_VAR | SCRIPT_FREE | SCRIPT_ARRAY;
+	retval->len = 0;
 
-	timer_get_now(&now);
+	if (timer_info(timer_id, &name, &howlong, &trigger_time)) return(0);
 
-	/* We have 11 fields. */
-	info = (int *)malloc(sizeof(int) * 11);
+	timer_get_now(&now);
 
-	/* Timer id, when it started, initial timer length,
+	/* Name, when it started, initial timer length,
 		how long it's run already, how long until it triggers,
 		absolute time when it triggers. */
-	info[0] = timer_id;
+
+	script_list_append(retval, script_string(name, -1));
 
 	timer_diff(&howlong, &trigger_time, &start_time);
-	info[1] = start_time.sec;
-	info[2] = start_time.usec;
+	script_list_append(retval, script_int(start_time.sec));
+	script_list_append(retval, script_int(start_time.usec));
 
-	info[3] = howlong.sec;
-	info[4] = howlong.usec;
+	script_list_append(retval, script_int(howlong.sec));
+	script_list_append(retval, script_int(howlong.usec));
 
 	timer_diff(&start_time, &now, &diff);
-	info[5] = diff.sec;
-	info[6] = diff.usec;
+	script_list_append(retval, script_int(diff.sec));
+	script_list_append(retval, script_int(diff.usec));
 
 	timer_diff(&now, &trigger_time, &diff);
-	info[7] = diff.sec;
-	info[8] = diff.usec;
-
-	info[9] = trigger_time.sec;
-	info[10] = trigger_time.usec;
+	script_list_append(retval, script_int(diff.sec));
+	script_list_append(retval, script_int(diff.usec));
 
-	/* A malloc'd array of ints. */
-	retval->type = SCRIPT_FREE | SCRIPT_ARRAY | SCRIPT_INTEGER;
-	retval->value = info;
-	retval->len = 11;
+	script_list_append(retval, script_int(trigger_time.sec));
+	script_list_append(retval, script_int(trigger_time.usec));
 
 	return(0);
 }
Index: eggdrop1.7/modules/server/dcc.c
diff -u eggdrop1.7/modules/server/dcc.c:1.9 eggdrop1.7/modules/server/dcc.c:1.10
--- eggdrop1.7/modules/server/dcc.c:1.9	Mon Mar 10 03:11:50 2003
+++ eggdrop1.7/modules/server/dcc.c	Thu Apr  3 22:04:46 2003
@@ -128,9 +128,12 @@
 	if (!timeout) timeout = server_config.dcc_timeout;
 
 	if (timeout > 0) {
+		char buf[128];
+
+		snprintf(buf, "dcc listen port %d", port);
 		howlong.sec = timeout;
 		howlong.usec = 0;
-		listen->timer_id = timer_create_complex(&howlong, dcc_listen_timeout, listen, 0);
+		listen->timer_id = timer_create_complex(&howlong, buf, dcc_listen_timeout, listen, 0);
 	}
 
 	return(listen);
@@ -464,9 +467,12 @@
 	/* See if they want the default timeout. */
 	if (!timeout) timeout = server_config.dcc_timeout;
 	if (timeout > 0) {
+		char buf[128];
+
+		snprintf(buf, sizeof(buf), "dcc recv %s/%d", ip, port);
 		howlong.sec = timeout;
 		howlong.usec = 0;
-		send->timer_id = timer_create_complex(&howlong, dcc_recv_timeout, send, 0);
+		send->timer_id = timer_create_complex(&howlong, buf, dcc_recv_timeout, send, 0);
 	}
 	else send->connect_time = -1;
 
Index: eggdrop1.7/src/main.c
diff -u eggdrop1.7/src/main.c:1.143 eggdrop1.7/src/main.c:1.144
--- eggdrop1.7/src/main.c:1.143	Sun Mar 23 20:42:39 2003
+++ eggdrop1.7/src/main.c	Thu Apr  3 22:04:46 2003
@@ -30,7 +30,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: main.c,v 1.143 2003/03/24 02:42:39 wcc Exp $";
+static const char rcsid[] = "$Id: main.c,v 1.144 2003/04/04 04:04:46 stdarg Exp $";
 #endif
 
 #include <eggdrop/eggdrop.h>
@@ -633,7 +633,7 @@
   online_since = now;
   howlong.sec = 1;
   howlong.usec = 0;
-  timer_create_repeater(&howlong, core_secondly);
+  timer_create_repeater(&howlong, "main loop", core_secondly);
 
   /* init time'd hooks */
   add_hook(HOOK_MINUTELY, (Function) core_minutely);
----------------------- End of diff -----------------------


More information about the Changes mailing list