[cvslog] (2005-03-03 18:44:57 UTC) Module eggdrop1.9: Change committed!

cvslog cvs at tsss.org
Thu Mar 3 12:44:57 CST 2005


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.9
Commit time: 2005-03-03 18:44:57 UTC
Commited by: stdarg <stdarg at techmonkeys.org>

Modified files:
     lib/eggdrop/hash_table.c lib/eggdrop/hash_table.h
     lib/eggdrop/ircmasks.c lib/eggdrop/ircmasks.h lib/eggdrop/timer.c
     lib/eggdrop/timer.h lib/eggdrop/xml.c

Log message:

* Changed time to use long instead of int
* Fixed hash table resize to use defined constant

---------------------- diff included ----------------------
Index: eggdrop1.9/lib/eggdrop/hash_table.c
diff -u eggdrop1.9/lib/eggdrop/hash_table.c:1.17 eggdrop1.9/lib/eggdrop/hash_table.c:1.18
--- eggdrop1.9/lib/eggdrop/hash_table.c:1.17	Thu Mar  3 11:12:13 2005
+++ eggdrop1.9/lib/eggdrop/hash_table.c	Thu Mar  3 12:44:47 2005
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: hash_table.c,v 1.17 2005/03/03 17:12:13 lordares Exp $";
+static const char rcsid[] = "$Id: hash_table.c,v 1.18 2005/03/03 18:44:47 stdarg Exp $";
 #endif
 
 #include <eggdrop/eggdrop.h>
@@ -76,14 +76,9 @@
 
 int hash_table_check_resize(hash_table_t *ht)
 {
-	if (!ht) return(-1);
+	if (!ht || (ht->flags & HASH_TABLE_NORESIZE)) return(-1);
 
-	/* This 100 allows (ht->max_rows) linked lists (collisions) each with an average of 100 elements in the list
-         * before actually resizing.
-         * This is done to avoid a relatively slow reorganization of the table by having to recalculate all the hash positions
-         * Having (ht->max_rows) linked lists (collisions) is still more effecient than one large linked list.
-         */
-	if (ht->cells_in_use / ht->max_rows > 100) {
+	if ((100 * ht->cells_in_use) / ht->max_rows > HASH_TABLE_RESIZE_BOUNDARY) {
 		hash_table_resize(ht, ht->max_rows * 3);
 	}
 	return(0);
Index: eggdrop1.9/lib/eggdrop/hash_table.h
diff -u eggdrop1.9/lib/eggdrop/hash_table.h:1.5 eggdrop1.9/lib/eggdrop/hash_table.h:1.6
--- eggdrop1.9/lib/eggdrop/hash_table.h:1.5	Wed Jun 23 15:19:45 2004
+++ eggdrop1.9/lib/eggdrop/hash_table.h	Thu Mar  3 12:44:47 2005
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: hash_table.h,v 1.5 2004/06/23 20:19:45 wingman Exp $
+ * $Id: hash_table.h,v 1.6 2005/03/03 18:44:47 stdarg Exp $
  */
 
 #ifndef _EGG_HASH_TABLE_H_
@@ -27,6 +27,10 @@
 #define HASH_TABLE_MIXED	4
 #define HASH_TABLE_NORESIZE	8
 
+/* We automatically resize the table when (100 * cells in use) / max rows
+ * exceeds this constant: */
+#define HASH_TABLE_RESIZE_BOUNDARY	150
+
 /* Turns a key into an unsigned int. */
 typedef unsigned int (*hash_table_hash_alg)(const void *key);
 
Index: eggdrop1.9/lib/eggdrop/ircmasks.c
diff -u eggdrop1.9/lib/eggdrop/ircmasks.c:1.9 eggdrop1.9/lib/eggdrop/ircmasks.c:1.10
--- eggdrop1.9/lib/eggdrop/ircmasks.c:1.9	Sun Oct 17 00:14:06 2004
+++ eggdrop1.9/lib/eggdrop/ircmasks.c	Thu Mar  3 12:44:47 2005
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: ircmasks.c,v 1.9 2004/10/17 05:14:06 stdarg Exp $";
+static const char rcsid[] = "$Id: ircmasks.c,v 1.10 2005/03/03 18:44:47 stdarg Exp $";
 #endif
 
 #include <eggdrop/eggdrop.h>
@@ -104,3 +104,80 @@
 	*(void **)dataptr = NULL;
 	return(-1);
 }
+
+/* Type corresponds to the mirc mask types. */
+char *ircmask_create_separate(int type, const char *nick, const char *user, const char *host)
+{
+	char *mask;
+	char ustar[2] = {0, 0};
+	char *domain;
+
+	if (type < 5) nick = "*";
+	if (type == 2 || type == 7) user = "*";
+	else if (type == 1 || type == 3 || type == 6 || type == 8) {
+		while (*user && !isalnum(*user)) user++;
+		ustar[0] = '*';
+	}
+	else {
+		user = "";
+		ustar[0] = '*';
+	}
+
+	domain = strdup(host);
+	if (type == 3 || type == 4 || type == 8 || type == 9) {
+		char *dot = strrchr(host, '.');
+		char *colon = strrchr(host, ':');
+		if (colon || (dot && isdigit(*(dot+1)))) {
+			/* ipv6 or dotted decimal. */
+			if (dot < colon) dot = colon;
+			domain[host-dot+1] = '*';
+			domain[host-dot+2] = 0;
+		}
+		else if (dot) {
+			char *dot2;
+			dot = strchr(host, '.');
+			if ((dot2 = strchr(dot+1, '.'))) {
+				if (strlen(dot2+1) > 2) {
+					free(domain);
+					domain = egg_mprintf("*%s", dot);
+				}
+			}
+		}
+	}
+	mask = egg_mprintf("%s!%s%s@%s", nick, ustar, user, domain);
+	free(domain);
+	return(mask);
+}
+
+char *ircmask_create(int type, const char *nick, const char *uhost)
+{
+	char *user = strdup(uhost);
+	char *at = strchr(uhost, '@');
+	char *mask;
+
+	if (at) {
+		user[at-uhost] = 0;
+		uhost = at+1;
+	}
+	else user[0] = 0;
+	mask = ircmask_create_separate(type, nick, user, uhost);
+	free(user);
+	return(mask);
+}
+
+char *ircmask_create_full(int type, const char *nuhost)
+{
+	char *nick, *user, *host, *buf, *mask;
+
+	buf = strdup(nuhost);
+	nick = buf;
+	user = strchr(nick, '!');
+	if (user) *user++ = 0;
+	else user = "";
+	host = strchr(user, '@');
+	if (host) *host++ = 0;
+	else host = "";
+	mask = ircmask_create_separate(type, nick, user, host);
+	free(buf);
+	return(mask);
+}
Index: eggdrop1.9/lib/eggdrop/ircmasks.h
diff -u eggdrop1.9/lib/eggdrop/ircmasks.h:1.4 eggdrop1.9/lib/eggdrop/ircmasks.h:1.5
--- eggdrop1.9/lib/eggdrop/ircmasks.h:1.4	Tue Jun 22 15:12:37 2004
+++ eggdrop1.9/lib/eggdrop/ircmasks.h	Thu Mar  3 12:44:47 2005
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: ircmasks.h,v 1.4 2004/06/22 20:12:37 wingman Exp $
+ * $Id: ircmasks.h,v 1.5 2005/03/03 18:44:47 stdarg Exp $
  */
 
 #ifndef _EGG_IRCMASKS_H_
@@ -37,5 +37,8 @@
 int ircmask_list_del(ircmask_list_t *list, const char *ircmask, void *data);
 int ircmask_list_find(ircmask_list_t *list, const char *irchost, void *dataptr);
 int ircmask_list_clear(ircmask_list_t *list);
+char *ircmask_create_separate(int type, const char *nick, const char *user, const char *host);
+char *ircmask_create(int type, const char *nick, const char *uhost);
+char *ircmask_create_full(int type, const char *nuhost);
 
 #endif /* _EGG_IRCMASKS_H_ */
Index: eggdrop1.9/lib/eggdrop/timer.c
diff -u eggdrop1.9/lib/eggdrop/timer.c:1.8 eggdrop1.9/lib/eggdrop/timer.c:1.9
--- eggdrop1.9/lib/eggdrop/timer.c:1.8	Thu Dec  9 00:43:32 2004
+++ eggdrop1.9/lib/eggdrop/timer.c	Thu Mar  3 12:44:47 2005
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: timer.c,v 1.8 2004/12/09 06:43:32 lordares Exp $";
+static const char rcsid[] = "$Id: timer.c,v 1.9 2005/03/03 18:44:47 stdarg Exp $";
 #endif
 
 #include <eggdrop/eggdrop.h>
@@ -65,7 +65,7 @@
 	return(0);
 }
 
-int timer_update_now(egg_timeval_t *_now)
+long timer_update_now(egg_timeval_t *_now)
 {
 	timer_get_time(&now);
 	if (_now) {
@@ -81,7 +81,7 @@
 	_now->usec = now.usec;
 }
 
-int timer_get_now_sec(int *sec)
+long timer_get_now_sec(long *sec)
 {
 	if (sec) *sec = now.sec;
 	return(now.sec);
@@ -135,7 +135,7 @@
 	return(0);
 }
 
-int timer_create_secs(int secs, const char *name, Function callback)
+int timer_create_secs(long secs, const char *name, Function callback)
 {
         egg_timeval_t howlong;
 
Index: eggdrop1.9/lib/eggdrop/timer.h
diff -u eggdrop1.9/lib/eggdrop/timer.h:1.3 eggdrop1.9/lib/eggdrop/timer.h:1.4
--- eggdrop1.9/lib/eggdrop/timer.h:1.3	Thu Dec  9 00:43:32 2004
+++ eggdrop1.9/lib/eggdrop/timer.h	Thu Mar  3 12:44:47 2005
@@ -16,15 +16,15 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Id: timer.h,v 1.3 2004/12/09 06:43:32 lordares Exp $
+ * $Id: timer.h,v 1.4 2005/03/03 18:44:47 stdarg Exp $
  */
 
 #ifndef _EGG_TIMER_H_
 #define _EGG_TIMER_H_
 
 typedef struct egg_timeval {
-	int sec;
-	int usec;
+	long sec;
+	long usec;
 } egg_timeval_t;
 
 typedef struct egg_timer {
@@ -50,10 +50,10 @@
 extern int timer_shutdown();
 extern int timer_get_time(egg_timeval_t *curtime);
 extern void timer_get_now(egg_timeval_t *_now);
-extern int timer_get_now_sec(int *sec);
-extern int timer_update_now(egg_timeval_t *_now);
+extern long timer_get_now_sec(long *sec);
+extern long 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_secs(int secs, const char *name, Function callback);
+extern int timer_create_secs(long secs, const char *name, Function callback);
 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();
Index: eggdrop1.9/lib/eggdrop/xml.c
diff -u eggdrop1.9/lib/eggdrop/xml.c:1.24 eggdrop1.9/lib/eggdrop/xml.c:1.25
--- eggdrop1.9/lib/eggdrop/xml.c:1.24	Sun Oct 17 00:14:06 2004
+++ eggdrop1.9/lib/eggdrop/xml.c	Thu Mar  3 12:44:47 2005
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: xml.c,v 1.24 2004/10/17 05:14:06 stdarg Exp $";
+static const char rcsid[] = "$Id: xml.c,v 1.25 2005/03/03 18:44:47 stdarg Exp $";
 #endif
 
 #include <eggdrop/eggdrop.h>
@@ -343,30 +343,32 @@
 		}
 		fmt++;
 	}
+	va_end(args);
 	return(0);
 }
 
 int xml_node_set_vars(xml_node_t *node, const char *fmt, ...)
 {
 	va_list args;
-	char *name, *strptr;
-	int intptr;
+	char *name, *strval;
+	int intval;
 
 	va_start(args, fmt);
 	while (*fmt) {
 		name = va_arg(args, char *);
 		switch (*fmt) {
 			case 's':
-				strptr = va_arg(args, char *);
-				xml_node_set_str(strptr, node, name, 0, 0);
+				strval = va_arg(args, char *);
+				xml_node_set_str(strval, node, name, 0, 0);
 				break;
 			case 'i':
-				intptr = va_arg(args, int);
-				xml_node_get_int(intptr, node, name, 0, 0);
+				intval = va_arg(args, int);
+				xml_node_set_int(intval, node, name, 0, 0);
 				break;
 		}
 		fmt++;
 	}
+	va_end(args);
 	return(0);
 }
 
----------------------- End of diff -----------------------



More information about the Changes mailing list