[cvslog] (2003-04-15 08:18:14 UTC) Module eggdrop1.7: Change committed

cvslog cvs at tsss.org
Tue Apr 15 02:18:14 CST 2003


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

Modified files:
     lib/eggdrop/Makefile.am lib/eggdrop/eggdrop.c
     lib/eggdrop/eggdrop.h lib/eggdrop/eggtimer.c
     lib/eggdrop/eggtimer.h modules/blowfish/bf_tab.h
     modules/blowfish/blowfish.c modules/blowfish/blowfish.h
     modules/perlscript/mod_iface.c modules/script/scriptmisc.c
     modules/script/scriptmod.c modules/server/channels.c
     modules/server/dcc.c modules/server/input.c
     modules/server/nicklist.c modules/server/scriptcmds.c
     modules/server/server.c modules/server/serverlist.c
     modules/server/servsock.c modules/tclscript/tclscript.c
     src/Makefile.am src/core_binds.c src/core_binds.h
     src/core_config.c src/logfile.c src/main.c src/main.h

Added files:
     lib/eggdrop/eggmod.c lib/eggdrop/eggmod.h lib/eggdrop/eggowner.c
     lib/eggdrop/eggowner.h

Log message:

* Start of new module interface
* Global function table is gone

---------------------- diff included ----------------------
Index: eggdrop1.7/lib/eggdrop/Makefile.am
diff -u eggdrop1.7/lib/eggdrop/Makefile.am:1.19 eggdrop1.7/lib/eggdrop/Makefile.am:1.20
--- eggdrop1.7/lib/eggdrop/Makefile.am:1.19	Thu Apr  3 22:04:46 2003
+++ eggdrop1.7/lib/eggdrop/Makefile.am	Tue Apr 15 03:18:03 2003
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.19 2003/04/04 04:04:46 stdarg Exp $
+# $Id: Makefile.am,v 1.20 2003/04/15 08:18:03 stdarg Exp $
 
 MAINTAINERCLEANFILES	= Makefile.in
 
@@ -13,7 +13,9 @@
 			eggdrop.c eggdrop.h \
 			eggdns.c eggdns.h \
 			eggident.c eggident.h \
-			eggnet.h eggnet.c \
+			eggmod.c eggmod.h \
+			eggnet.c eggnet.h \
+			eggowner.c eggowner.h \
 			eggtimer.c eggtimer.h \
 			fileutil.c fileutil.h \
 			flags.c flags.h \
@@ -35,6 +37,7 @@
 			users.c users.h \
 			xml.c xmlread.c xmlwrite.c xml.h
 
-libeggdrop_la_LIBADD	= $(top_builddir)/lib/compat/libcompat.la \
+libeggdrop_la_LIBADD	= @LIBLTDL@ \
+			$(top_builddir)/lib/compat/libcompat.la \
 		   	$(top_builddir)/lib/egglib/libegg.la
 
Index: eggdrop1.7/lib/eggdrop/eggdrop.c
diff -u eggdrop1.7/lib/eggdrop/eggdrop.c:1.4 eggdrop1.7/lib/eggdrop/eggdrop.c:1.5
--- eggdrop1.7/lib/eggdrop/eggdrop.c:1.4	Thu Jan  2 15:33:13 2003
+++ eggdrop1.7/lib/eggdrop/eggdrop.c	Tue Apr 15 03:18:03 2003
@@ -22,7 +22,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: eggdrop.c,v 1.4 2003/01/02 21:33:13 wcc Exp $";
+static const char rcsid[] = "$Id: eggdrop.c,v 1.5 2003/04/15 08:18:03 stdarg Exp $";
 #endif
 
 #include <stdlib.h>
@@ -45,3 +45,4 @@
 
   return NULL;
 }
+
Index: eggdrop1.7/lib/eggdrop/eggdrop.h
diff -u eggdrop1.7/lib/eggdrop/eggdrop.h:1.18 eggdrop1.7/lib/eggdrop/eggdrop.h:1.19
--- eggdrop1.7/lib/eggdrop/eggdrop.h:1.18	Mon Feb 17 04:22:30 2003
+++ eggdrop1.7/lib/eggdrop/eggdrop.h	Tue Apr 15 03:18:03 2003
@@ -18,7 +18,9 @@
 #include <eggdrop/script.h>
 #include <eggdrop/my_socket.h>
 #include <eggdrop/sockbuf.h>
+#include <eggdrop/eggmod.h>
 #include <eggdrop/eggnet.h>
+#include <eggdrop/eggowner.h>
 #include <eggdrop/eggdns.h>
 #include <eggdrop/eggident.h>
 #include <eggdrop/linemode.h>
@@ -32,6 +34,18 @@
 #include <eggdrop/partyline.h>
 #include <eggdrop/egglog.h>
 #include <eggdrop/irccmp.h>
+
+/* Gettext macros */
+#ifdef ENABLE_NLS
+#include <libintl.h>
+#define _(x) gettext(x)
+#define N_(x) gettext_noop(x)
+#define P_(x1, x2, n) ngettext(x1, x2, n)
+#else
+#define _(x) (x)
+#define N_(x) (x)
+#define P_(x1, x2, n) ( ((n) == 1) ? (x1) : (x2) )
+#endif
 
 BEGIN_C_DECLS
 
Index: eggdrop1.7/lib/eggdrop/eggmod.c
diff -u /dev/null eggdrop1.7/lib/eggdrop/eggmod.c:1.1
--- /dev/null	Tue Apr 15 03:18:13 2003
+++ eggdrop1.7/lib/eggdrop/eggmod.c	Tue Apr 15 03:18:03 2003
@@ -0,0 +1,139 @@
+#include <eggdrop/eggdrop.h>
+#include <ltdl.h>
+#include <unistd.h>
+#include "eggmod.h"
+
+typedef struct module_list {
+	struct module_list *next;
+	egg_module_t modinfo;
+	lt_dlhandle hand;
+	int refcount;
+} module_list_t;
+
+static module_list_t *module_list_head = NULL;
+static bind_table_t *BT_load, *BT_unload;
+
+static module_list_t *find_module(const char *name)
+{
+	module_list_t *entry;
+
+	for (entry = module_list_head; entry; entry = entry->next) {
+		if (!strcasecmp(name, entry->modinfo.name)) return(entry);
+	}
+	return(NULL);
+}
+
+int module_init()
+{
+	BT_load = bind_table_add("load", 1, "s", MATCH_MASK, 0);
+	BT_unload = bind_table_add("unload", 1, "s", MATCH_MASK, 0);
+	return(0);
+}
+
+int module_add_dir(const char *moddir)
+{
+	char *fixed_moddir;
+
+	if (*moddir != '/') {
+		char cwd[1024];
+
+		cwd[0] = 0;
+		getcwd(cwd, sizeof(cwd));
+		cwd[sizeof(cwd)-1] = 0;
+		fixed_moddir = egg_mprintf("%s/%s", cwd, moddir);
+	}
+	else fixed_moddir = (char *)moddir;
+
+	lt_dladdsearchdir(fixed_moddir);
+	if (fixed_moddir != moddir) free(fixed_moddir);
+	return(0);
+}
+
+int module_load(const char *name)
+{
+	lt_dlhandle hand;
+	module_list_t *entry;
+	egg_start_func_t startfunc;
+
+	/* See if it's already loaded. */
+	entry = find_module(name);
+	if (entry) return(-1);
+
+	hand = lt_dlopenext(name);
+	if (!hand) {
+		const char *err = lt_dlerror();
+		putlog(LOG_MISC, "*", "Error loading module %s: %s", name, err);
+		return(-2);
+	}
+
+	startfunc = (egg_start_func_t)lt_dlsym(hand, "start");
+	if (!startfunc) {
+		lt_dlclose(hand);
+		return(-3);
+	}
+
+	/* Create an entry for it. */
+	entry = calloc(1, sizeof(*entry));
+	entry->next = module_list_head;
+	entry->refcount = 0;
+	module_list_head = entry;
+
+	if (startfunc(&entry->modinfo)) return(-4);
+
+	bind_check(BT_load, name, name);
+	putlog(LOG_MISC, "*", "Module loaded: %s", name);
+	return(0);
+}
+
+int module_unload(const char *name, int why)
+{
+	module_list_t *entry, *prev;
+	int retval;
+
+	for (entry = module_list_head; entry; entry = entry->next) {
+		if (!strcasecmp(entry->modinfo.name, name)) break;
+	}
+	if (!entry) return(-1);
+	if (entry->refcount > 0) return(-2);
+	if (entry->modinfo.close_func) {
+		retval = (entry->modinfo.close_func)(why);
+		if (retval) return(-3);
+	}
+
+	lt_dlclose(entry->hand);
+	if (prev) prev->next = entry->next;
+	else module_list_head = entry->next;
+	free(entry);
+	bind_check(BT_unload, name, name);
+	putlog(LOG_MISC, "*", "Module unloaded: %s", name);
+	return(0);
+}
+
+egg_module_t *module_lookup(const char *name)
+{
+	module_list_t *entry;
+
+	entry = find_module(name);
+	if (entry) return(&entry->modinfo);
+	return(NULL);
+}
+
+int module_addref(const char *name)
+{
+	module_list_t *entry;
+
+	entry = find_module(name);
+	if (!entry) return(-1);
+	entry->refcount++;
+	return(0);
+}
+
+int module_decref(const char *name)
+{
+	module_list_t *entry;
+
+	entry = find_module(name);
+	if (!entry) return(-1);
+	entry->refcount--;
+	return(0);
+}
Index: eggdrop1.7/lib/eggdrop/eggmod.h
diff -u /dev/null eggdrop1.7/lib/eggdrop/eggmod.h:1.1
--- /dev/null	Tue Apr 15 03:18:14 2003
+++ eggdrop1.7/lib/eggdrop/eggmod.h	Tue Apr 15 03:18:03 2003
@@ -0,0 +1,40 @@
+#ifndef _EGGMOD_H_
+#define _EGGMOD_H_
+
+/* Values for 'why' in module_unload() */
+#define EGGMOD_USER	0
+#define EGGMOD_SHUTDOWN	1
+#define EGGMOD_RESTART	2
+
+struct egg_module;
+typedef struct egg_module egg_module_t;
+
+typedef int (*egg_start_func_t)(egg_module_t *modinfo);
+typedef int (*egg_close_func_t)(int why);
+
+struct egg_module {
+	const char *name;
+	const char *author;
+	const char *version;
+	const char *description;
+
+	egg_close_func_t close_func;
+	void *module_data;
+};
+
+int module_init();
+int module_add_dir(const char *moddir);
+int module_load(const char *name);
+int module_unload(const char *name, int why);
+egg_module_t *module_lookup(const char *name);
+int module_addref(const char *name);
+int module_decref(const char *name);
+
+/* Windows hack to export functions from dlls. */
+#if defined (__CYGWIN__) 
+#  define EXPORT_SCOPE	__declspec(dllexport)
+#else
+#  define EXPORT_SCOPE
+#endif
+
+#endif
Index: eggdrop1.7/lib/eggdrop/eggowner.c
diff -u /dev/null eggdrop1.7/lib/eggdrop/eggowner.c:1.1
--- /dev/null	Tue Apr 15 03:18:14 2003
+++ eggdrop1.7/lib/eggdrop/eggowner.c	Tue Apr 15 03:18:03 2003
@@ -0,0 +1,32 @@
+#include <eggdrop/eggdrop.h>
+
+static char **owner = NULL;
+
+int egg_setowner(char **_owner)
+{
+	owner = _owner;
+	return(0);
+}
+
+int egg_isowner(const char *handle)
+{
+	int len;
+	char *powner;
+
+	if (!owner || !*owner) return(0);
+
+	len = strlen(handle);
+	if (!len) return(0);
+
+	powner = *owner;
+	while (*powner) {
+		while (*powner && !isalnum(*powner)) powner++;
+		if (!*powner) break;
+		if (!strncasecmp(powner, handle, len)) {
+			powner += len;
+			if (!*powner || !isalnum(*powner)) return(1);
+		}
+		while (*powner && isalnum(*powner)) powner++;
+	}
+	return(0);
+}
Index: eggdrop1.7/lib/eggdrop/eggowner.h
diff -u /dev/null eggdrop1.7/lib/eggdrop/eggowner.h:1.1
--- /dev/null	Tue Apr 15 03:18:14 2003
+++ eggdrop1.7/lib/eggdrop/eggowner.h	Tue Apr 15 03:18:03 2003
@@ -0,0 +1,7 @@
+#ifndef _EGGOWNER_H_
+#define _EGGOWNER_H_
+
+int egg_setowner(char **_owner);
+int egg_isowner(const char *handle);
+
+#endif
Index: eggdrop1.7/lib/eggdrop/eggtimer.c
diff -u eggdrop1.7/lib/eggdrop/eggtimer.c:1.5 eggdrop1.7/lib/eggdrop/eggtimer.c:1.6
--- eggdrop1.7/lib/eggdrop/eggtimer.c:1.5	Thu Apr  3 22:04:46 2003
+++ eggdrop1.7/lib/eggdrop/eggtimer.c	Tue Apr 15 03:18:03 2003
@@ -21,7 +21,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: eggtimer.c,v 1.5 2003/04/04 04:04:46 stdarg Exp $";
+static const char rcsid[] = "$Id: eggtimer.c,v 1.6 2003/04/15 08:18:03 stdarg Exp $";
 #endif
 
 #include <stdio.h> /* NULL */
@@ -74,6 +74,12 @@
 {
 	_now->sec = now.sec;
 	_now->usec = now.usec;
+}
+
+int timer_get_now_sec(int *sec)
+{
+	if (sec) *sec = now.sec;
+	return(now.sec);
 }
 
 /* Find difference between two timers. */
Index: eggdrop1.7/lib/eggdrop/eggtimer.h
diff -u eggdrop1.7/lib/eggdrop/eggtimer.h:1.4 eggdrop1.7/lib/eggdrop/eggtimer.h:1.5
--- eggdrop1.7/lib/eggdrop/eggtimer.h:1.4	Thu Apr  3 22:04:46 2003
+++ eggdrop1.7/lib/eggdrop/eggtimer.h	Tue Apr 15 03:18:03 2003
@@ -19,7 +19,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 /*
- * $Id: eggtimer.h,v 1.4 2003/04/04 04:04:46 stdarg Exp $
+ * $Id: eggtimer.h,v 1.5 2003/04/15 08:18:03 stdarg Exp $
  */
 
 #ifndef _EGG_TIMER_H
@@ -41,6 +41,7 @@
 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_get_now_sec(int *sec);
 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, const char *name, Function callback, void *client_data, int flags);
Index: eggdrop1.7/modules/blowfish/bf_tab.h
diff -u eggdrop1.7/modules/blowfish/bf_tab.h:1.4 eggdrop1.7/modules/blowfish/bf_tab.h:1.5
--- eggdrop1.7/modules/blowfish/bf_tab.h:1.4	Thu Jan  2 15:33:14 2003
+++ eggdrop1.7/modules/blowfish/bf_tab.h	Tue Apr 15 03:18:03 2003
@@ -21,13 +21,13 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 /*
- * $Id: bf_tab.h,v 1.4 2003/01/02 21:33:14 wcc Exp $
+ * $Id: bf_tab.h,v 1.5 2003/04/15 08:18:03 stdarg Exp $
  */
 
 #ifndef _EGG_MOD_BLOWFISH_BF_TAB_H
 #define _EGG_MOD_BLOWFISH_BF_TAB_H
 
-static u_32int_t initbf_P[bf_N + 2] =
+static u_int32_t initbf_P[bf_N + 2] =
 {
   0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344,
   0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,
@@ -35,7 +35,7 @@
   0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,
   0x9216d5d9, 0x8979fb1b,
 };
-static u_32int_t initbf_S[4][256] =
+static u_int32_t initbf_S[4][256] =
 {
   {
     0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,
Index: eggdrop1.7/modules/blowfish/blowfish.c
diff -u eggdrop1.7/modules/blowfish/blowfish.c:1.10 eggdrop1.7/modules/blowfish/blowfish.c:1.11
--- eggdrop1.7/modules/blowfish/blowfish.c:1.10	Thu Mar  6 06:08:14 2003
+++ eggdrop1.7/modules/blowfish/blowfish.c	Tue Apr 15 03:18:03 2003
@@ -26,20 +26,19 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: blowfish.c,v 1.10 2003/03/06 12:08:14 tothwolf Exp $";
+static const char rcsid[] = "$Id: blowfish.c,v 1.11 2003/04/15 08:18:03 stdarg Exp $";
 #endif
 
 #define MODULE_NAME "encryption"
 #define MAKING_ENCRYPTION
 
-#include "lib/eggdrop/module.h"
+#include <sys/types.h>
+#include <eggdrop/eggdrop.h>
 #include "blowfish.h"
 #include "bf_tab.h"		/* P-box P-array, S-box */
 
 #define start blowfish_LTX_start
 
-static eggdrop_t *egg = NULL;
-
 /* Each box takes up 4k so be very careful here */
 #define BOXES 3
 
@@ -53,19 +52,19 @@
 
 /* Keep a set of rotating P & S boxes */
 static struct box_t {
-  u_32int_t *P;
-  u_32int_t **S;
+  u_int32_t *P;
+  u_int32_t **S;
   char key[81];
   char keybytes;
-  time_t lastuse;
+  int lastuse;
 } box[BOXES];
 
-/* static u_32int_t bf_P[bf_N+2]; */
-/* static u_32int_t bf_S[4][256]; */
-static u_32int_t *bf_P;
-static u_32int_t **bf_S;
+/* static u_int32_t bf_P[bf_N+2]; */
+/* static u_int32_t bf_S[4][256]; */
+static u_int32_t *bf_P;
+static u_int32_t **bf_S;
 
-static void blowfish_encipher(u_32int_t * xl, u_32int_t * xr)
+static void blowfish_encipher(u_int32_t * xl, u_int32_t * xr)
 {
   union aword Xl;
   union aword Xr;
@@ -96,7 +95,7 @@
   *xl = Xr.word;
 }
 
-static void blowfish_decipher(u_32int_t * xl, u_32int_t * xr)
+static void blowfish_decipher(u_int32_t * xl, u_int32_t * xr)
 {
   union aword Xl;
   union aword Xr;
@@ -132,13 +131,13 @@
 {
 }
 
-static void blowfish_init(u_8bit_t * key, int keybytes)
+static void blowfish_init(u_int8_t * key, int keybytes)
 {
   int i, j, bx;
-  time_t lowest = 0;
-  u_32int_t data;
-  u_32int_t datal;
-  u_32int_t datar;
+  int lowest = 0;
+  u_int32_t data;
+  u_int32_t datal;
+  u_int32_t datar;
   union aword temp;
 
   /* drummer: Fixes crash if key is longer than 80 char. This may cause the key
@@ -153,7 +152,7 @@
       if ((box[i].keybytes == keybytes) &&
 	  (!strncmp((char *) (box[i].key), (char *) key, keybytes))) {
 	/* Match! */
-	box[i].lastuse = egg_timeval_now.sec;
+	timer_get_now_sec(&box[i].lastuse);
 	bf_P = box[i].P;
 	bf_S = box[i].S;
 	return;
@@ -170,7 +169,7 @@
   }
   if (bx < 0) {
     /* Find oldest */
-    lowest = egg_timeval_now.sec;
+    timer_get_now_sec(&lowest);
     for (i = 0; i < BOXES; i++)
       if (box[i].lastuse <= lowest) {
 	lowest = box[i].lastuse;
@@ -183,15 +182,15 @@
   }
   /* Initialize new buffer */
   /* uh... this is over 4k */
-  box[bx].P = (u_32int_t *) malloc((bf_N + 2) * sizeof(u_32int_t));
-  box[bx].S = (u_32int_t **) malloc(4 * sizeof(u_32int_t *));
+  box[bx].P = (u_int32_t *) malloc((bf_N + 2) * sizeof(u_int32_t));
+  box[bx].S = (u_int32_t **) malloc(4 * sizeof(u_int32_t *));
   for (i = 0; i < 4; i++)
-    box[bx].S[i] = (u_32int_t *) malloc(256 * sizeof(u_32int_t));
+    box[bx].S[i] = (u_int32_t *) malloc(256 * sizeof(u_int32_t));
   bf_P = box[bx].P;
   bf_S = box[bx].S;
   box[bx].keybytes = keybytes;
   strlcpy(box[bx].key, key, keybytes + 1);	/* + 1 for NULL */
-  box[bx].lastuse = egg_timeval_now.sec;
+  timer_get_now_sec(&box[bx].lastuse);
   /* Robey: Reset blowfish boxes to initial state
    * (I guess normally it just keeps scrambling them, but here it's
    * important to get the same encrypted result each time)
@@ -249,7 +248,7 @@
 
 static void blowfish_encrypt_pass(char *text, char *new)
 {
-  u_32int_t left, right;
+  u_int32_t left, right;
   int n;
   char *p;
 
@@ -278,7 +277,7 @@
  */
 static char *encrypt_string(char *key, char *str)
 {
-  u_32int_t left, right;
+  u_int32_t left, right;
   unsigned char *p;
   char *s, *dest, *d;
   int i;
@@ -325,7 +324,7 @@
  */
 static char *decrypt_string(char *key, char *str)
 {
-  u_32int_t left, right;
+  u_int32_t left, right;
   char *p, *s, *dest, *d;
   int i;
 
@@ -377,58 +376,31 @@
 	{0}
 };
 
-/* You CANT -module an encryption module , so -module just resets it.
- */
-static char *blowfish_close()
+static int blowfish_close(int why)
 {
-  return _("You can't unload an encryption module");
+	return(-1);
 }
 
-EXPORT_SCOPE char *start(eggdrop_t *);
-
-static Function blowfish_table[] =
-{
-  /* 0 - 3 */
-  (Function) start,
-  (Function) blowfish_close,
-  (Function) 0,
-  (Function) blowfish_report,
-  /* 4 - 7 */
-  (Function) encrypt_string,
-  (Function) decrypt_string,
-};
+EXPORT_SCOPE int start(egg_module_t *modinfo);
 
-char *start(eggdrop_t *eggdrop)
+int start(egg_module_t *modinfo)
 {
   int i;
 
-  /* `global_funcs' is NULL if eggdrop is recovering from a restart.
-   *
-   * As the encryption module is never unloaded, only initialise stuff
-   * that got reset during restart, e.g. the tcl bindings.
-   */
-  if (eggdrop) {
-    egg = eggdrop;
+  modinfo->name = "blowfish";
+  modinfo->author = "eggdev";
+  modinfo->version = "1.7.0";
+  modinfo->description = "provides blowfish encryption/decryption";
+  modinfo->close_func = blowfish_close;
 
-    if (!module_rename("blowfish", MODULE_NAME))
-      return _("Already loaded.");
-    /* Initialize buffered boxes */
-    for (i = 0; i < BOXES; i++) {
-      box[i].P = NULL;
-      box[i].S = NULL;
-      box[i].key[0] = 0;
-      box[i].lastuse = 0L;
-    }
-    module_register(MODULE_NAME, blowfish_table, 2, 1);
-    if (!module_depend(MODULE_NAME, "eggdrop", 107, 0)) {
-      module_undepend(MODULE_NAME);
-      return _("This module requires eggdrop1.7.0 or later");
-    }
-    add_hook(HOOK_ENCRYPT_PASS, (Function) blowfish_encrypt_pass);
-    add_hook(HOOK_ENCRYPT_STRING, (Function) encrypt_string);
-    add_hook(HOOK_DECRYPT_STRING, (Function) decrypt_string);
+  /* Initialize buffered boxes */
+  for (i = 0; i < BOXES; i++) {
+    box[i].P = NULL;
+    box[i].S = NULL;
+    box[i].key[0] = 0;
+    box[i].lastuse = 0L;
   }
   script_create_commands(blowfish_script_cmds);
-  return NULL;
+  return(0);
 }
 
Index: eggdrop1.7/modules/blowfish/blowfish.h
diff -u eggdrop1.7/modules/blowfish/blowfish.h:1.4 eggdrop1.7/modules/blowfish/blowfish.h:1.5
--- eggdrop1.7/modules/blowfish/blowfish.h:1.4	Thu Jan  2 15:33:14 2003
+++ eggdrop1.7/modules/blowfish/blowfish.h	Tue Apr 15 03:18:03 2003
@@ -20,7 +20,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 /*
- * $Id: blowfish.h,v 1.4 2003/01/02 21:33:14 wcc Exp $
+ * $Id: blowfish.h,v 1.5 2003/04/15 08:18:03 stdarg Exp $
  */
 
 #ifndef _EGG_MOD_BLOWFISH_BLOWFISH_H
@@ -33,8 +33,8 @@
 #define KEYBYTES	 8
 
 union aword {
-  u_32int_t word;
-  u_8bit_t byte[4];
+  u_int32_t word;
+  u_int8_t byte[4];
   struct {
 #ifdef WORDS_BIGENDIAN
     unsigned int byte0:8;
Index: eggdrop1.7/modules/perlscript/mod_iface.c
diff -u eggdrop1.7/modules/perlscript/mod_iface.c:1.12 eggdrop1.7/modules/perlscript/mod_iface.c:1.13
--- eggdrop1.7/modules/perlscript/mod_iface.c:1.12	Tue Feb 25 04:28:22 2003
+++ eggdrop1.7/modules/perlscript/mod_iface.c	Tue Apr 15 03:18:03 2003
@@ -1,37 +1,13 @@
 /*
  * mod_iface.c --
  */
-/*
- * Copyright (C) 2002, 2003 Eggheads Development Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: mod_iface.c,v 1.12 2003/02/25 10:28:22 stdarg Exp $";
-#endif
 
 #include <stdio.h>
 #include <stdlib.h>
-#include "lib/eggdrop/module.h"
 #include <eggdrop/eggdrop.h>
 
 #define MODULE_NAME "perlscript"
 
-static eggdrop_t *egg = NULL;
-
 /* Stuff from perlscript.c. */
 extern int perlscript_init();
 extern int perlscript_destroy();
@@ -46,12 +22,12 @@
 }
 
 /* A stub for the .perl command. */
-static int party_perl(int pid, const char *nick, user_t *u, const char *cmd, const char *text)
+static int party_perl(int pid, char *nick, user_t *u, char *cmd, char *text)
 {
 	char *retval;
 
 	/* You must be owner to use this command. */
-	if (!u || owner_check(u->handle)) {
+	if (!u || !egg_isowner(u->handle)) {
 		partyline_printf(pid, "Sorry, you must be a permanent owner to use this command.");
 		return(0);
 	}
@@ -67,25 +43,27 @@
 	{0}
 };
 
-EXPORT_SCOPE char *perlscript_LTX_start();
-static char *perlscript_close();
+static int perlscript_close(int why)
+{
+	bind_rem_list("party", my_party_cmds);
 
-static Function perlscript_table[] = {
-	(Function) perlscript_LTX_start,
-	(Function) perlscript_close,
-	(Function) 0,
-	(Function) 0
-};
+	/* Destroy interpreter. */
+	perlscript_destroy();
 
-char *perlscript_LTX_start(eggdrop_t *eggdrop)
-{
-	egg = eggdrop;
+	script_unregister_module(&my_script_interface);
 
-	module_register("perlscript", perlscript_table, 1, 2);
-	if (!module_depend("perlscript", "eggdrop", 107, 0)) {
-		module_undepend("perlscript");
-		return "This module requires eggdrop1.7.0 of later";
-	}
+	return(0);
+}
+
+EXPORT_SCOPE int perlscript_LTX_start(egg_module_t *modinfo);
+
+int perlscript_LTX_start(egg_module_t *modinfo)
+{
+	modinfo->name = "perlscript";
+	modinfo->author = "eggdev";
+	modinfo->version = "1.7.0";
+	modinfo->description = "provides perl scripting support";
+	modinfo->close_func = perlscript_close;
 
 	/* Initialize interpreter. */
 	perlscript_init();
@@ -94,19 +72,5 @@
 	script_playback(&my_script_interface);
 
 	bind_add_list("party", my_party_cmds);
-	return(NULL);
-}
-
-static char *perlscript_close()
-{
-	bind_rem_list("party", my_party_cmds);
-
-	/* Destroy interpreter. */
-	perlscript_destroy();
-
-	script_unregister_module(&my_script_interface);
-
-	module_undepend("perlscript");
-	return(NULL);
+	return(0);
 }
-
Index: eggdrop1.7/modules/script/scriptmisc.c
diff -u eggdrop1.7/modules/script/scriptmisc.c:1.2 eggdrop1.7/modules/script/scriptmisc.c:1.3
--- eggdrop1.7/modules/script/scriptmisc.c:1.2	Fri Feb 14 18:23:51 2003
+++ eggdrop1.7/modules/script/scriptmisc.c	Tue Apr 15 03:18:03 2003
@@ -3,27 +3,8 @@
  *
  *	Misc script commands
  */
-/*
- * Copyright (C) 1997 Robey Pointer
- * Copyright (C) 1999, 2000, 2001, 2002, 2003 Eggheads Development Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
 
 #include <eggdrop/eggdrop.h>
-#include <eggdrop/module.h>
 #ifdef TIME_WITH_SYS_TIME
 # include <sys/time.h>
 # include <time.h>
Index: eggdrop1.7/modules/script/scriptmod.c
diff -u eggdrop1.7/modules/script/scriptmod.c:1.4 eggdrop1.7/modules/script/scriptmod.c:1.5
--- eggdrop1.7/modules/script/scriptmod.c:1.4	Fri Feb 14 14:55:02 2003
+++ eggdrop1.7/modules/script/scriptmod.c	Tue Apr 15 03:18:03 2003
@@ -1,4 +1,3 @@
-#include "lib/eggdrop/module.h"
 #include <eggdrop/eggdrop.h>
 
 #define MODULE_NAME "script"
@@ -12,25 +11,14 @@
 {
 }
 
-EXPORT_SCOPE char *script_LTX_start();
-static char *script_close();
+EXPORT_SCOPE int script_LTX_start(egg_module_t *modinfo);
 
-static Function script_table[] = {
-	(Function) script_LTX_start,
-	(Function) script_close,
-	(Function) 0,
-	(Function) script_report
-};
-
-char *script_LTX_start(eggdrop_t *eggdrop)
+int script_LTX_start(egg_module_t *modinfo)
 {
-	egg = eggdrop;
-
-	module_register("script", script_table, 1, 2);
-	if (!module_depend("script", "eggdrop", 107, 0)) {
-		module_undepend("script");
-		return "This module requires eggdrop1.7.0 or later";
-	}
+	modinfo->name = "script";
+	modinfo->author = "eggdev";
+	modinfo->version = "1.7.0";
+	modinfo->description = "provides core scripting functions";
 
 	script_create_commands(script_config_cmds);
 	script_create_commands(script_log_cmds);
@@ -41,11 +29,5 @@
 	script_create_commands(script_timer_cmds);
 	script_create_commands(script_misc_cmds);
 
-	return(NULL);
-}
-
-static char *script_close()
-{
-	module_undepend("script");
 	return(NULL);
 }
Index: eggdrop1.7/modules/server/channels.c
diff -u eggdrop1.7/modules/server/channels.c:1.8 eggdrop1.7/modules/server/channels.c:1.9
--- eggdrop1.7/modules/server/channels.c:1.8	Tue Mar 25 13:20:32 2003
+++ eggdrop1.7/modules/server/channels.c	Tue Apr 15 03:18:03 2003
@@ -1,7 +1,6 @@
 /* Some channel-specific stuff. */
 
 #include <eggdrop/eggdrop.h>
-#include <eggdrop/module.h>
 #include <ctype.h>
 #include "server.h"
 #include "binds.h"
@@ -181,7 +180,7 @@
 	m = calloc(1, sizeof(*m));
 	m->nick = strdup(nick);
 	m->uhost = strdup(uhost);
-	m->join_time = egg_timeval_now.sec;
+	timer_get_now_sec(&m->join_time);
 
 	m->next = chan->member_head;
 	chan->member_head = m;
@@ -384,7 +383,7 @@
 	if (chan->topic_nick) free(chan->topic_nick);
 	if (from_uhost) chan->topic_nick = egg_mprintf("%s!%s", from_nick, from_uhost);
 	else chan->topic_nick = strdup(from_nick);
-	chan->topic_time = egg_timeval_now.sec;
+	timer_get_now_sec(&chan->topic_time);
 
 	return(0);
 }
@@ -683,7 +682,7 @@
 		else if (changestr[0] == '+') {
 			switch (*change) {
 				case 'b':
-					add_ban(chan, arg, set_by, egg_timeval_now.sec);
+					add_ban(chan, arg, set_by, timer_get_now_sec(NULL));
 					break;
 				case 'k':
 					str_redup(&chan->key, arg);
Index: eggdrop1.7/modules/server/dcc.c
diff -u eggdrop1.7/modules/server/dcc.c:1.11 eggdrop1.7/modules/server/dcc.c:1.12
--- eggdrop1.7/modules/server/dcc.c:1.11	Fri Apr  4 09:51:39 2003
+++ eggdrop1.7/modules/server/dcc.c	Tue Apr 15 03:18:03 2003
@@ -2,7 +2,9 @@
  * dcc.c -- take care of dcc stuff
  */
 
-#include "lib/eggdrop/module.h"
+#include <stdio.h>
+#include <unistd.h>
+#include <eggdrop/eggdrop.h>
 #include "server.h"
 #include "output.h"
 #include "parse.h"
@@ -13,8 +15,6 @@
 
 #include "dcc.h"
 
-#define now egg_timeval_now.sec
-
 typedef struct dcc_listen {
 	int serv, client;
 	int timer_id, timeout;
@@ -269,7 +269,7 @@
 	send->size = size;
 	send->bytes_sent = 0;
 	send->bytes_left = size;
-	send->request_time = now;
+	timer_get_now_sec(&send->request_time);
 	send->fname = strdup(fname);
 	send->nick = strdup(nick);
 
@@ -317,7 +317,7 @@
 	dcc_send_t *send = client_data;
 	int n;
 
-	send->connect_time = now;
+	timer_get_now_sec(&send->connect_time);
 	send->serv = -1;
 	send->ip = strdup(peer_ip);
 	sockbuf_on_connect(idx, DCC_FILTER_LEVEL, peer_ip, peer_port);
@@ -412,13 +412,14 @@
 int dcc_send_info(int idx, int field, void *valueptr)
 {
 	dcc_send_t *send;
-	int i, n;
+	int i, n, now;
 
 	if (!valueptr) return(-1);
 	if (sockbuf_get_filter_data(idx, &dcc_send_filter, &send) < 0) {
 		if (sockbuf_get_filter_data(idx, &dcc_recv_filter, &send) < 0) return(-1);
 	}
 
+	timer_get_now_sec(&now);
 	switch (field) {
 		case DCC_SEND_SENT:
 			*(int *)valueptr = send->bytes_sent;
@@ -483,7 +484,7 @@
 	send->size = size;
 	send->bytes_sent = 0;
 	send->bytes_left = size;
-	send->request_time = now;
+	timer_get_now_sec(&send->request_time);
 
 	if (resume < 0) {
 		send->fd = open(localfname, O_RDWR | O_CREAT, 0640);
@@ -529,7 +530,7 @@
 
 	/* send->connect_time holds our connect timer if there was one */
 	if (send->timer_id >= 0) timer_destroy(send->timer_id);
-	send->connect_time = now;
+	timer_get_now_sec(&send->connect_time);
 	sockbuf_on_connect(idx, DCC_FILTER_LEVEL, peer_ip, peer_port);
 	return(0);
 }
@@ -583,8 +584,8 @@
 	int i;
 
 	/* Get time diff. */
-	diff = now - send->last_snapshot;
-	send->last_snapshot = now;
+	diff = timer_get_now_sec(NULL) - send->last_snapshot;
+	timer_get_now_sec(&send->last_snapshot);
 	if (diff > 5) diff = 5;
 
 	/* Reset counter for seconds that were skipped. */
Index: eggdrop1.7/modules/server/input.c
diff -u eggdrop1.7/modules/server/input.c:1.18 eggdrop1.7/modules/server/input.c:1.19
--- eggdrop1.7/modules/server/input.c:1.18	Mon Apr  7 02:20:11 2003
+++ eggdrop1.7/modules/server/input.c	Tue Apr 15 03:18:03 2003
@@ -3,7 +3,6 @@
  */
 
 #include <eggdrop/eggdrop.h>
-#include "lib/eggdrop/module.h"
 #include "server.h"
 #include "parse.h"
 #include "channels.h"
Index: eggdrop1.7/modules/server/nicklist.c
diff -u eggdrop1.7/modules/server/nicklist.c:1.2 eggdrop1.7/modules/server/nicklist.c:1.3
--- eggdrop1.7/modules/server/nicklist.c:1.2	Mon Mar 10 03:11:50 2003
+++ eggdrop1.7/modules/server/nicklist.c	Tue Apr 15 03:18:03 2003
@@ -1,7 +1,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "lib/eggdrop/module.h"
+#include <eggdrop/eggdrop.h>
 #include "nicklist.h"
 #include "output.h"
 
Index: eggdrop1.7/modules/server/scriptcmds.c
diff -u eggdrop1.7/modules/server/scriptcmds.c:1.27 eggdrop1.7/modules/server/scriptcmds.c:1.28
--- eggdrop1.7/modules/server/scriptcmds.c:1.27	Mon Apr  7 02:20:11 2003
+++ eggdrop1.7/modules/server/scriptcmds.c	Tue Apr 15 03:18:03 2003
@@ -22,11 +22,11 @@
 
 /* FIXME: #include mess
 #ifndef lint
-static const char rcsid[] = "$Id: scriptcmds.c,v 1.27 2003/04/07 07:20:11 stdarg Exp $";
+static const char rcsid[] = "$Id: scriptcmds.c,v 1.28 2003/04/15 08:18:03 stdarg Exp $";
 #endif
 */
 
-#include "lib/eggdrop/module.h"
+#include <eggdrop/eggdrop.h>
 
 #include "server.h"
 #include "serverlist.h"
Index: eggdrop1.7/modules/server/server.c
diff -u eggdrop1.7/modules/server/server.c:1.44 eggdrop1.7/modules/server/server.c:1.45
--- eggdrop1.7/modules/server/server.c:1.44	Thu Mar  6 03:15:33 2003
+++ eggdrop1.7/modules/server/server.c	Tue Apr 15 03:18:03 2003
@@ -4,7 +4,7 @@
 
 #define MODULE_NAME "server"
 #define MAKING_SERVER
-#include "lib/eggdrop/module.h"
+#include <eggdrop/eggdrop.h>
 #include "server.h"
 #include "servsock.h"
 #include "serverlist.h"
@@ -54,7 +54,7 @@
  * 1. See if we're ready to connect to the next server (cycle_delay == 0)
  * 2. Dequeue some messages if we're connected. */
 
-static void server_secondly()
+static int server_secondly()
 {
 	if (current_server.idx < 0 && cycle_delay >= 0) {
 		/* If there's no idx, see if it's time to jump to the next
@@ -64,11 +64,12 @@
 			cycle_delay = -1;
 			connect_to_next_server();
 		}
-		return;
+		return(0);
 	}
 
 	/* Try to dequeue some stuff. */
 	dequeue_messages();
+	return(0);
 }
 
 /* A report on the module status.  */
@@ -101,12 +102,19 @@
 	}
 }
 
-static char *server_close()
+static bind_list_t server_secondly_binds[] = {
+	{NULL, server_secondly},
+	{0}
+};
+
+static int server_close(int why)
 {
 	kill_server("Server module unloading");
 	cycle_delay = 100;
 
 	bind_rem_list("raw", server_raw_binds);
+	bind_rem_list("party", server_party_commands);
+	bind_rem_list("secondly", server_secondly_binds);
 
 	server_binds_destroy();
 
@@ -114,20 +122,9 @@
 
 	server_script_destroy();
 
-	del_hook(HOOK_SECONDLY, (Function) server_secondly);
-	return(NULL);
+	return(0);
 }
 
-EXPORT_SCOPE char *start();
-
-static Function server_table[] =
-{
-  (Function) start,
-  (Function) server_close,
-  (Function) 0,
-  (Function) server_report,
-};
-
 static config_var_t server_config_vars[] = {
 	/* Registration information. */
 	{"user", &server_config.user, CONFIG_STRING},
@@ -193,26 +190,27 @@
 	}
 }
 
-char *start(eggdrop_t *eggdrop)
+EXPORT_SCOPE int start(egg_module_t *modinfo);
+
+int start(egg_module_t *modinfo)
 {
-	egg = eggdrop;
+	modinfo->name = "server";
+	modinfo->author = "eggdev";
+	modinfo->version = "1.7.0";
+	modinfo->description = "normal irc server support";
+	modinfo->close_func = server_close;
 
 	memset(&current_server, 0, sizeof(current_server));
 	current_server.idx = -1;
 	cycle_delay = 0;
 
-	module_register(MODULE_NAME, server_table, 1, 2);
-	if (!module_depend(MODULE_NAME, "eggdrop", 107, 0)) {
-		module_undepend(MODULE_NAME);
-		return "This module requires eggdrop1.7.0 or later";
-	}
-
 	server_config_init();
 
 	/* Create our bind tables. */
 	server_binds_init();
 	bind_add_list("raw", server_raw_binds);
 	bind_add_list("party", server_party_commands);
+	bind_add_list("secondly", server_secondly_binds);
 
 	/* Initialize channels. */
 	server_channel_init();
@@ -220,7 +218,5 @@
 	/* Initialize script interface. */
 	server_script_init();
 
-	add_hook(HOOK_SECONDLY, (Function) server_secondly);
-
-	return(NULL);
+	return(0);
 }
Index: eggdrop1.7/modules/server/serverlist.c
diff -u eggdrop1.7/modules/server/serverlist.c:1.2 eggdrop1.7/modules/server/serverlist.c:1.3
--- eggdrop1.7/modules/server/serverlist.c:1.2	Sun Feb 16 05:15:06 2003
+++ eggdrop1.7/modules/server/serverlist.c	Tue Apr 15 03:18:03 2003
@@ -1,7 +1,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "lib/eggdrop/module.h"
 #include "serverlist.h"
 
 /*
Index: eggdrop1.7/modules/server/servsock.c
diff -u eggdrop1.7/modules/server/servsock.c:1.12 eggdrop1.7/modules/server/servsock.c:1.13
--- eggdrop1.7/modules/server/servsock.c:1.12	Mon Apr  7 02:20:11 2003
+++ eggdrop1.7/modules/server/servsock.c	Tue Apr 15 03:18:03 2003
@@ -1,5 +1,4 @@
-#include "lib/eggdrop/module.h"
-#include "lib/eggdrop/eggdrop.h"
+#include <eggdrop/eggdrop.h>
 
 #include "server.h"
 #include "servsock.h"
Index: eggdrop1.7/modules/tclscript/tclscript.c
diff -u eggdrop1.7/modules/tclscript/tclscript.c:1.31 eggdrop1.7/modules/tclscript/tclscript.c:1.32
--- eggdrop1.7/modules/tclscript/tclscript.c:1.31	Sat Mar  8 03:20:35 2003
+++ eggdrop1.7/modules/tclscript/tclscript.c	Tue Apr 15 03:18:03 2003
@@ -1,36 +1,12 @@
 /*
  * tclscript.c --
  */
-/*
- * Copyright (C) 2002, 2003 Eggheads Development Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id: tclscript.c,v 1.31 2003/03/08 09:20:35 stdarg Exp $";
-#endif
 
 #include <tcl.h>
-#include "lib/eggdrop/module.h"
 #include <eggdrop/eggdrop.h>
 
 #define MODULE_NAME "tclscript"
 
-static eggdrop_t *egg = NULL;
-
 #if (((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 1)) || (TCL_MAJOR_VERSION > 8))
 #  define USE_TCL_BYTE_ARRAYS
 #endif
@@ -581,8 +557,8 @@
 {
 	char *str;
 
-	if (!u || owner_check(u->handle)) {
-		partyline_write(pid, _("You must be a permanent owner (defined in the config file) to use this command.\n"));
+	if (!u || !egg_isowner(u->handle)) {
+		partyline_write(pid, "You must be a permanent owner (defined in the config file) to use this command.\n");
 		return(BIND_RET_LOG);
 	}
 
@@ -617,7 +593,7 @@
 	*/
 }
 
-static int hook_secondly()
+static int tclscript_secondly()
 {
 	Tcl_DoOneEvent(TCL_ALL_EVENTS | TCL_DONT_WAIT);
 	return(0);
@@ -628,27 +604,33 @@
 	{0}
 };
 
-EXPORT_SCOPE char *tclscript_LTX_start();
-static char *tclscript_close();
-
-static Function tclscript_table[] = {
-	(Function) tclscript_LTX_start,
-	(Function) tclscript_close,
-	(Function) 0,
-	(Function) tclscript_report
+static bind_list_t secondly_binds[] = {
+	{NULL, tclscript_secondly},
+	{0}
 };
 
-char *tclscript_LTX_start(eggdrop_t *eggdrop)
+static int tclscript_close(int why)
 {
-	egg = eggdrop;
+	Tcl_DeleteInterp(ginterp);
 
-	ginterp = Tcl_CreateInterp();
+	bind_rem_list("party", party_commands);
+	bind_add_list("secondly", secondly_binds);
 
-	module_register("tclscript", tclscript_table, 1, 2);
-	if (!module_depend("tclscript", "eggdrop", 107, 0)) {
-		module_undepend("tclscript");
-		return "This module requires eggdrop1.7.0 or later";
-	}
+	script_unregister_module(&my_script_interface);
+	return(0);
+}
+
+EXPORT_SCOPE int tclscript_LTX_start(egg_module_t *modinfo);
+
+int tclscript_LTX_start(egg_module_t *modinfo)
+{
+	modinfo->name = "tclscript";
+	modinfo->author = "eggdev";
+	modinfo->version = "1.7.0";
+	modinfo->description = "provides tcl scripting support";
+	modinfo->close_func = tclscript_close;
+
+	ginterp = Tcl_CreateInterp();
 
 	error_logfile = strdup("logs/tcl_errors.log");
 	Tcl_LinkVar(ginterp, "error_logfile", (char *)&error_logfile, TCL_LINK_STRING);
@@ -657,18 +639,7 @@
 	script_playback(&my_script_interface);
 
 	bind_add_list("party", party_commands);
-
-	add_hook(HOOK_SECONDLY, hook_secondly);
-	return(NULL);
+	bind_add_list("secondly", secondly_binds);
+	return(0);
 }
 
-static char *tclscript_close()
-{
-	Tcl_DeleteInterp(ginterp);
-
-	bind_rem_list("party", party_commands);
-
-	module_undepend("tclscript");
-	script_unregister_module(&my_script_interface);
-	return(NULL);
-}
Index: eggdrop1.7/src/Makefile.am
diff -u eggdrop1.7/src/Makefile.am:1.40 eggdrop1.7/src/Makefile.am:1.41
--- eggdrop1.7/src/Makefile.am:1.40	Sun Mar 23 20:42:39 2003
+++ eggdrop1.7/src/Makefile.am	Tue Apr 15 03:18:03 2003
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.40 2003/03/24 02:42:39 wcc Exp $
+# $Id: Makefile.am,v 1.41 2003/04/15 08:18:03 stdarg Exp $
 
 # FIXME: optionally allow a system wide install by ignoring the line below.
 bindir			= $(exec_prefix)
@@ -29,7 +29,6 @@
 			egg.h \
 			logfile.c logfile.h \
 			main.c main.h \
-			modules.c modules.h \
 			telnet.c
 
 eggdrop_LDFLAGS		= -no-undefined
Index: eggdrop1.7/src/core_binds.c
diff -u eggdrop1.7/src/core_binds.c:1.9 eggdrop1.7/src/core_binds.c:1.10
--- eggdrop1.7/src/core_binds.c:1.9	Tue Feb 25 00:52:19 2003
+++ eggdrop1.7/src/core_binds.c	Tue Apr 15 03:18:03 2003
@@ -2,12 +2,13 @@
 #include "main.h"
 #include "logfile.h"
 
-static bind_table_t *BT_time, *BT_event;
+static bind_table_t *BT_time = NULL, *BT_event = NULL, *BT_secondly = NULL;
 
 void core_binds_init()
 {
 	BT_time = bind_table_add("time", 5, "iiiii", MATCH_MASK, BIND_STACKABLE);
 	BT_event = bind_table_add("event", 1, "s", MATCH_MASK, BIND_STACKABLE);
+	BT_secondly = bind_table_add("secondly", 0, "", MATCH_NONE, BIND_STACKABLE);
 }
 
 void check_bind_time(struct tm *tm)
@@ -20,4 +21,9 @@
 void check_bind_event(char *event)
 {
 	bind_check(BT_event, event, NULL, event);
+}
+
+void check_bind_secondly()
+{
+	bind_check(BT_secondly, NULL);
 }
Index: eggdrop1.7/src/core_binds.h
diff -u eggdrop1.7/src/core_binds.h:1.5 eggdrop1.7/src/core_binds.h:1.6
--- eggdrop1.7/src/core_binds.h:1.5	Sun Feb  2 19:01:07 2003
+++ eggdrop1.7/src/core_binds.h	Tue Apr 15 03:18:03 2003
@@ -1,46 +1,9 @@
-/*
- * core_binds.h --
- */
-/*
- * Copyright (C) 2002, 2003 Eggheads Development Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-
 #ifndef _CORE_BINDS_H_
 #define _CORE_BINDS_H_
 
 void core_binds_init();
 void check_bind_time(struct tm *tm);
 void check_bind_event(char *event);
-void check_bind_dcc(const char *, int, const char *);
-void check_bind_chjn(const char *, const char *, int, char, int, const char *);
-void check_bind_chpt(const char *, const char *, int, int);
-void check_bind_bot(const char *, const char *, const char *);
-void check_bind_link(const char *, const char *);
-void check_bind_disc(const char *);
-const char *check_bind_filt(int, const char *);
-int check_bind_note(const char *, const char *, const char *);
-void check_bind_listen(const char *, int);
-void check_bind_time(struct tm *);
-void check_bind_nkch(const char *, const char *);
-void check_bind_away(const char *, int, const char *);
-int check_bind_chat(const char *, int, const char *);
-void check_bind_act(const char *, int, const char *);
-void check_bind_bcst(const char *, int, const char *);
-void check_bind_chon(char *, int);
-void check_bind_chof(char *, int);
+void check_bind_secondly();
 
 #endif				/* !_CORE_BINDS_H_ */
Index: eggdrop1.7/src/core_config.c
diff -u eggdrop1.7/src/core_config.c:1.5 eggdrop1.7/src/core_config.c:1.6
--- eggdrop1.7/src/core_config.c:1.5	Sun Feb 16 05:15:06 2003
+++ eggdrop1.7/src/core_config.c	Tue Apr 15 03:18:03 2003
@@ -1,5 +1,4 @@
 #include <eggdrop/eggdrop.h>
-#include <eggdrop/eggconfig.h>
 #include "core_config.h"
 
 core_config_t core_config = {0};
@@ -40,6 +39,9 @@
 {
 	/* Set default vals. */
 	memset(&core_config, 0, sizeof(core_config));
+
+	/* Hook the owner variable into libeggdrop. */
+	egg_setowner(&core_config.owner);
 
 	core_config.botname = strdup("eggdrop");
 	core_config.userfile = strdup("users.xml");
Index: eggdrop1.7/src/logfile.c
diff -u eggdrop1.7/src/logfile.c:1.30 eggdrop1.7/src/logfile.c:1.31
--- eggdrop1.7/src/logfile.c:1.30	Tue Feb 25 04:28:22 2003
+++ eggdrop1.7/src/logfile.c	Tue Apr 15 03:18:03 2003
@@ -3,11 +3,10 @@
  *
  */
 
+#include <unistd.h>
 #include "main.h"
 #include "core_config.h"
-#include "modules.h" 			/* add_hook() 			*/
 #include "logfile.h"			/* prototypes			*/
-#include "chanprog.h"	/* logmodes */
 #include <eggdrop/eggdrop.h>
 #include <stdio.h>
 
@@ -50,12 +49,17 @@
 	{0}
 };
 
+static bind_list_t log_events[] = {
+	{"minutely", logfile_minutely},
+	{"5minutely", logfile_5minutely},
+	{0}
+};
+
 void logfile_init()
 {
 	script_create_commands(log_script_cmds);
-	add_hook(HOOK_MINUTELY, logfile_minutely);
-	add_hook(HOOK_5MINUTELY, logfile_5minutely);
 	bind_add_list("log", log_binds);
+	bind_add_list("event", log_events);
 }
 
 static int get_timestamp(char *t)
Index: eggdrop1.7/src/main.c
diff -u eggdrop1.7/src/main.c:1.144 eggdrop1.7/src/main.c:1.145
--- eggdrop1.7/src/main.c:1.144	Thu Apr  3 22:04:46 2003
+++ eggdrop1.7/src/main.c	Tue Apr 15 03:18:03 2003
@@ -30,9 +30,10 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: main.c,v 1.144 2003/04/04 04:04:46 stdarg Exp $";
+static const char rcsid[] = "$Id: main.c,v 1.145 2003/04/15 08:18:03 stdarg Exp $";
 #endif
 
+#include <unistd.h>
 #include <eggdrop/eggdrop.h>
 #include "main.h"
 #include "core_config.h"
@@ -54,6 +55,7 @@
 #include <setjmp.h>
 #include <locale.h>
 #include <ctype.h>
+#include <ltdl.h>
 
 #ifdef STOP_UAC				/* osf/1 complains a lot */
 #include <sys/sysinfo.h>
@@ -63,13 +65,9 @@
  * decide it's not bsd compatable.  Oh well.
  */
 
-#include "chan.h"
-#include "modules.h"
 #include "bg.h"
 #include "core_binds.h"
 #include "logfile.h"
-#include "misc.h"
-#include "traffic.h"
 
 #ifdef CYGWIN_HACKS
 #include <windows.h>
@@ -80,14 +78,6 @@
 #define _POSIX_SOURCE 1
 #endif
 
-extern int conmask;
-extern struct dcc_t *dcc;
-extern struct userrec *userlist;
-
-#ifndef MAKING_MODS
-extern struct dcc_table DCC_CHAT;
-#endif /* MAKING_MODS   */
-
 char	egg_version[1024] = VERSION;
 int	egg_numver = VERSION_NUM;
 
@@ -109,7 +99,6 @@
 time_t	online_since;		/* Unix-time that the bot loaded up */
 int	make_userfile = 0;	/* Using bot in make-userfile mode? (first
 				   user to 'hello' becomes master) */
-char	owner[121] = "";	/* Permanent owner(s) of the bot */
 char	pid_file[120];		/* Name of the file for the pid to be
 				   stored in */
 int	save_users_at = 0;	/* How many minutes past the hour to
@@ -310,7 +299,7 @@
   static int cnt = 0;
   int miltime;
 
-  call_hook(HOOK_SECONDLY);	/* Will be removed later */
+  check_bind_secondly();
   cnt++;
   memcpy(&nowtm, localtime(&now), sizeof(struct tm));
   if (nowtm.tm_min != lastmin) {
@@ -318,7 +307,8 @@
 
     /* Once a minute */
     lastmin = (lastmin + 1) % 60;
-    call_hook(HOOK_MINUTELY);
+    check_bind_event("minutely");
+    check_bind_time(&nowtm);
     /* In case for some reason more than 1 min has passed: */
     while (nowtm.tm_min != lastmin) {
       /* Timer drift, dammit */
@@ -326,80 +316,30 @@
              nowtm.tm_min);
       i++;
       lastmin = (lastmin + 1) % 60;
-      call_hook(HOOK_MINUTELY);
+      check_bind_event("minutely");
     }
     if (i > 1)
       putlog(LOG_MISC, "*", "(!) timer drift -- spun %d minutes", i);
     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_bind_event("5minutely");
       if (!miltime) {	/* At midnight */
 	char s[25];
 
 	strlcpy(s, ctime(&now), sizeof s);
 	putlog(LOG_ALL, "*", "--- %.11s%s", s, s + 20);
-	call_hook(HOOK_BACKUP);
-	call_hook(HOOK_DAILY);
+	check_bind_event("backup");
+	check_bind_event("daily");
       }
     }
-    if (nowtm.tm_min == notify_users_at)
-      call_hook(HOOK_HOURLY);
+    if (nowtm.tm_min == notify_users_at) check_bind_event("hourly");
   }
   return(0);
 }
 
-static void core_minutely()
-{
-  check_bind_time(&nowtm);
-}
-
-static void core_hourly()
-{
-}
-
-static void event_rehash()
-{
-  check_bind_event("rehash");
-}
-
-static void event_prerehash()
-{
-  check_bind_event("prerehash");
-}
-
-static void event_save()
-{
-  check_bind_event("save");
-}
-
-static void event_logfile()
-{
-  check_bind_event("logfile");
-}
-
-static void event_loaded()
-{
-  check_bind_event("loaded");
-}
-
-extern module_entry *module_list;
-
 void core_party_init();
 void core_config_init();
 void telnet_init();
-void binds_init();
-
-/*
-static inline void garbage_collect(void)
-{
-  static u_8bit_t	run_cnt = 0;
-
-  if (run_cnt == 3)
-    garbage_collect_tclhash();
-  else
-    run_cnt++;
-}
-*/
 
 int owner_check(const char *handle)
 {
@@ -465,6 +405,13 @@
   textdomain(PACKAGE);
 #endif
 
+	/* Initialize ltdl. */
+	LTDL_SET_PRELOADED_SYMBOLS();
+	if (lt_dlinit()) {
+		printf("Fatal error initializing ltdl: %s\n", lt_dlerror());
+		return(-1);
+	}
+
   /* Version info! */
   snprintf(ver, sizeof ver, "%s v%s", PACKAGE, egg_version);
   snprintf(version, sizeof version, "Eggdrop v%s (C) 1997 Robey Pointer (C) 2003 Eggheads",
@@ -541,7 +488,7 @@
   partyline_init();
   core_party_init();
   telnet_init();
-  modules_init();
+  module_init();
   egg_net_init();
   core_binds_init();
 
@@ -552,6 +499,9 @@
   strcpy(&s[11], &s[20]);
   putlog(LOG_ALL, "*", "--- Loading %s (%s)", ver, s);
 
+	/* Put the module directory in the ltdl search path. */
+	if (core_config.module_path) module_add_dir(core_config.module_path);
+
 	/* Scan the autoload section of config. */
 	config_root = config_get_root("eggdrop");
 	for (i = 0; (entry = config_exists(config_root, "eggdrop", 0, "autoload", 0, "module", i, NULL)); i++) {
@@ -634,17 +584,6 @@
   howlong.sec = 1;
   howlong.usec = 0;
   timer_create_repeater(&howlong, "main loop", core_secondly);
-
-  /* init time'd hooks */
-  add_hook(HOOK_MINUTELY, (Function) core_minutely);
-  add_hook(HOOK_HOURLY, (Function) core_hourly);
-  add_hook(HOOK_REHASH, (Function) event_rehash);
-  add_hook(HOOK_PRE_REHASH, (Function) event_prerehash);
-  add_hook(HOOK_USERFILE, (Function) event_save);
-  add_hook(HOOK_DAILY, (Function) event_logfile);
-  add_hook(HOOK_LOADED, (Function) event_loaded);
-
-  call_hook(HOOK_LOADED);
 
   putlog(LOG_DEBUG, "*", "main: entering loop");
 	while (1) {
Index: eggdrop1.7/src/main.h
diff -u eggdrop1.7/src/main.h:1.33 eggdrop1.7/src/main.h:1.34
--- eggdrop1.7/src/main.h:1.33	Sun Mar 23 20:42:39 2003
+++ eggdrop1.7/src/main.h	Tue Apr 15 03:18:03 2003
@@ -22,7 +22,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 /*
- * $Id: main.h,v 1.33 2003/03/24 02:42:39 wcc Exp $
+ * $Id: main.h,v 1.34 2003/04/15 08:18:03 stdarg Exp $
  */
 
 #ifndef _EGG_MAIN_H
@@ -33,7 +33,6 @@
 #endif
 
 #include "debug.h"
-#include "egg.h"
 #include <eggdrop/eggdrop.h>
 #include "lib/compat/compat.h"
 
----------------------- End of diff -----------------------


More information about the Changes mailing list