[cvslog] (2006-10-11 01:54:14 UTC) Module eggdrop1.9: Change committed!

cvslog cvs at tsss.org
Tue Oct 10 19:54:14 CST 2006


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.9
Commit time: 2006-10-11 01:54:14 UTC
Commited by: sven

Modified files:
     lib/eggdrop/eggdrop.c lib/eggdrop/partyline.c lib/eggdrop/timer.c
     modules/dccparty/events.c

Log message:

 * Fixed a crash on shutdown bug
 * Removed an incorrect use of the return value of strftime
 * Added /me CTCP ACTION handling to the partyline

Unlike eggdrop1.6 that does this in the input functions it's done in the
output functions to keep the partyline API clean.

---------------------- diff included ----------------------
Index: eggdrop1.9/lib/eggdrop/eggdrop.c
diff -u eggdrop1.9/lib/eggdrop/eggdrop.c:1.25 eggdrop1.9/lib/eggdrop/eggdrop.c:1.26
--- eggdrop1.9/lib/eggdrop/eggdrop.c:1.25	Sat May  7 23:40:12 2005
+++ eggdrop1.9/lib/eggdrop/eggdrop.c	Tue Oct 10 20:54:04 2006
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: eggdrop.c,v 1.25 2005-05-08 04:40:12 stdarg Exp $";
+static const char rcsid[] = "$Id: eggdrop.c,v 1.26 2006-10-11 01:54:04 sven Exp $";
 #endif
 
 #include <eggdrop/eggdrop.h>
@@ -50,7 +50,6 @@
 
 int eggdrop_shutdown(void)
 {
-	bind_table_del(BT_event);
 	module_shutdown();
 	partyline_shutdown();
 	script_shutdown();
@@ -59,6 +58,7 @@
 	egg_net_shutdown();
 	timer_shutdown();
 	config_shutdown();
+	bind_table_del(BT_event);
 	
 	return 1;
 }
Index: eggdrop1.9/lib/eggdrop/partyline.c
diff -u eggdrop1.9/lib/eggdrop/partyline.c:1.25 eggdrop1.9/lib/eggdrop/partyline.c:1.26
--- eggdrop1.9/lib/eggdrop/partyline.c:1.25	Sun Oct 17 03:38:11 2004
+++ eggdrop1.9/lib/eggdrop/partyline.c	Tue Oct 10 20:54:04 2006
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: partyline.c,v 1.25 2004-10-17 08:38:11 stdarg Exp $";
+static const char rcsid[] = "$Id: partyline.c,v 1.26 2006-10-11 01:54:04 sven Exp $";
 #endif
 
 #include <eggdrop/eggdrop.h>
@@ -232,8 +232,19 @@
 
 int partyline_idx_privmsg(int idx, partymember_t *dest, partymember_t *src, const char *text, int len)
 {
-	if (src) egg_iprintf(idx, "[%s] %s\r\n", src->nick, text);
-	else egg_iprintf(idx, "%s\r\n", text);
+	char *ts;
+
+	ts = timer_get_timestamp();
+
+	if (src) {
+		if (len >= 9 && !strncasecmp(text, "\1ACTION ", 8) && text[len - 1] == 1) {
+			egg_iprintf(idx, "%s* %s %.*s\r\n", ts, src->nick, len - 9, text + 8);
+		} else {
+			egg_iprintf(idx, "%s[%s] %s\r\n", ts, src->nick, text);
+		}
+	} else {
+		egg_iprintf(idx, "%s\r\n", text);
+	}
 	return 0;
 }
 
@@ -255,8 +266,15 @@
 
 	ts = timer_get_timestamp();
 
-	if (src) egg_iprintf(idx, "%s %s<%s> %s\r\n", chan->name, ts, src->nick, text);
-	else egg_iprintf(idx, "%s %s%s\r\n", chan->name, ts, text);
+	if (src) {
+		if (len >= 9 && !strncasecmp(text, "\1ACTION ", 8) && text[len - 1] == 1) {
+			egg_iprintf(idx, "%s %s* %s %.*s\r\n", chan->name, ts, src->nick, len - 9, text + 8);
+		} else {
+			egg_iprintf(idx, "%s %s<%s> %s\r\n", chan->name, ts, src->nick, text);
+		}
+	} else {
+		egg_iprintf(idx, "%s %s%s\r\n", chan->name, ts, text);
+	}
 	return 0;
 }
 
Index: eggdrop1.9/lib/eggdrop/timer.c
diff -u eggdrop1.9/lib/eggdrop/timer.c:1.13 eggdrop1.9/lib/eggdrop/timer.c:1.14
--- eggdrop1.9/lib/eggdrop/timer.c:1.13	Mon Oct  2 23:02:13 2006
+++ eggdrop1.9/lib/eggdrop/timer.c	Tue Oct 10 20:54:04 2006
@@ -18,15 +18,16 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: timer.c,v 1.13 2006-10-03 04:02:13 sven Exp $";
+static const char rcsid[] = "$Id: timer.c,v 1.14 2006-10-11 01:54:04 sven Exp $";
 #endif
 
 #include <eggdrop/eggdrop.h>
 
+#define TIMEBUFLEN 1024
+
 static egg_timeval_t now;
 static char *timestamp_format = NULL;
-static char *timestamp = NULL;
-static int timestamp_len = 0;
+static char timestamp[TIMEBUFLEN];
 
 /* We keep a sorted list of active timers. */
 static egg_timer_t *timer_list_head = NULL;
@@ -34,9 +35,7 @@
 
 int timer_init()
 {
-	timestamp_len = 32;
 	timestamp_format = strdup("[%H:%M] ");
-	timestamp = malloc(timestamp_len);
 	return(0);
 }
 
@@ -46,11 +45,6 @@
 		free(timestamp_format);
 		timestamp_format = NULL;
 	}
-	if (timestamp) {
-		free(timestamp);
-		timestamp = NULL;
-	}
-	timestamp_len = 0;
 	return(0);
 }
 
@@ -325,23 +319,9 @@
 	time_t now_secs = (time_t)now.sec;
 	int len;
 
-	while (1) {
-		len = strftime(timestamp, timestamp_len, timestamp_format, localtime(&now_secs));
-
-		/* Did it work and fit in the buffer? */
-		if (len > 0 && len < timestamp_len) break;
-		else if (len >= timestamp_len) {
-			/* Adjust buffer. */
-			timestamp_len = len+1;
-			free(timestamp);
-			timestamp = malloc(timestamp_len);
-		}
-		else {
-			/* Error with strftime, or empty timestamp. */
-			*timestamp = 0;
-			break;
-		}
-	}
+	len = strftime(timestamp, TIMEBUFLEN, timestamp_format, localtime(&now_secs));
+	/* Did it work and fit in the buffer? */
+	if (!len) *timestamp = 0;
 
 	return timestamp;
 }
Index: eggdrop1.9/modules/dccparty/events.c
diff -u eggdrop1.9/modules/dccparty/events.c:1.5 eggdrop1.9/modules/dccparty/events.c:1.6
--- eggdrop1.9/modules/dccparty/events.c:1.5	Wed Jun 23 06:19:52 2004
+++ eggdrop1.9/modules/dccparty/events.c	Tue Oct 10 20:54:04 2006
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: events.c,v 1.5 2004-06-23 11:19:52 wingman Exp $";
+static const char rcsid[] = "$Id: events.c,v 1.6 2006-10-11 01:54:04 sven Exp $";
 #endif
 
 #include <string.h>
@@ -47,8 +47,15 @@
 {
 	dcc_session_t *session = client_data;
 
-	if (src) egg_iprintf(session->idx, "[%s] %s\r\n", src->nick, text);
-	else egg_iprintf(session->idx, "%s\r\n", text);
+	if (src) {
+		if (len >= 9 && !strncasecmp(text, "\1ACTION ", 8) && text[len - 1] == 1) {
+			egg_iprintf(session->idx, "%s %.*s\r\n", src->nick, len - 9, text + 8);
+		} else {
+			egg_iprintf(session->idx, "[%s] %s\r\n", src->nick, text);
+		}
+	} else {
+		egg_iprintf(session->idx, "%s\r\n", text);
+	}
 	return(0);
 }
 
@@ -74,8 +81,15 @@
 {
 	dcc_session_t *session = client_data;
 
-	if (src) egg_iprintf(session->idx, "%s <%s> %s\r\n", chan->name, src->nick, text);
-	else egg_iprintf(session->idx, "%s %s\r\n", chan->name, text);
+	if (src) {
+		if (len >= 9 && !strncasecmp(text, "\1ACTION ", 8) && text[len - 1] == 1) {
+			egg_iprintf(session->idx, "%s %s %.*s\r\n", chan->name, src->nick, len - 9, text + 8);
+		} else {
+			egg_iprintf(session->idx, "%s <%s> %s\r\n", chan->name, src->nick, text);
+		}
+	} else {
+		egg_iprintf(session->idx, "%s %s\r\n", chan->name, text);
+	}
 	return(0);
 }
 
----------------------- End of diff -----------------------



More information about the Changes mailing list