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

cvslog cvs at tsss.org
Tue Apr 15 12:05:11 CST 2003


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

Modified files:
     doc/SCRIPTING-COMMANDS modules/tclscript/tclscript.c src/main.c

Log message:

* guppy's bugfix
* tcl command to add tcl channels to our event loop (speeds up async tcl sockets)

---------------------- diff included ----------------------
Index: eggdrop1.7/doc/SCRIPTING-COMMANDS
diff -u eggdrop1.7/doc/SCRIPTING-COMMANDS:1.7 eggdrop1.7/doc/SCRIPTING-COMMANDS:1.8
--- eggdrop1.7/doc/SCRIPTING-COMMANDS:1.7	Mon Apr  7 02:20:11 2003
+++ eggdrop1.7/doc/SCRIPTING-COMMANDS	Tue Apr 15 13:05:01 2003
@@ -469,3 +469,15 @@
 
   net_throttle_off <idx>
     Description: Removes throttling from an idx.
+
+*** TCL ONLY ***
+
+  net_add_tcl <channel>
+    Description: Adds a tcl channel to eggdrop's event loop so that its events
+      can be serviced quickly.
+    Returns: Nothing.
+
+  net_rem_tcl <channel>
+    Description: Removes a previously added tcl channel from eggdrop's event
+      loop.
+    Returns: Nothing.
Index: eggdrop1.7/modules/tclscript/tclscript.c
diff -u eggdrop1.7/modules/tclscript/tclscript.c:1.32 eggdrop1.7/modules/tclscript/tclscript.c:1.33
--- eggdrop1.7/modules/tclscript/tclscript.c:1.32	Tue Apr 15 03:18:03 2003
+++ eggdrop1.7/modules/tclscript/tclscript.c	Tue Apr 15 13:05:01 2003
@@ -593,6 +593,70 @@
 	*/
 }
 
+typedef struct tcl_listener {
+	struct tcl_listener *next;
+	char *name;
+	int fd;
+} tcl_listener_t;
+
+static tcl_listener_t *listener_list_head = NULL;
+
+/* Two Tcl-only commands to add/remove sockbuf listeners. */
+static int add_tcl_chan(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
+{
+	Tcl_Channel chan;
+	char *chan_name;
+	int modes;
+	void *fd;
+	tcl_listener_t *listener;
+
+	if (objc != 2) {
+		Tcl_WrongNumArgs(interp, 0, NULL, "channel-name");
+		return(TCL_ERROR);
+	}
+
+	chan_name = Tcl_GetStringFromObj(objv[1], NULL);
+	if (!chan_name) return(TCL_ERROR);
+	chan = Tcl_GetChannel(interp, chan_name, &modes);
+	if (!chan) return(TCL_ERROR);
+	if (Tcl_GetChannelHandle(chan, TCL_READABLE, &fd)) return(TCL_ERROR);
+	listener = malloc(sizeof(*listener));
+	listener->next = listener_list_head;
+	listener->name = strdup(chan_name);
+	listener->fd = (int) fd;
+	listener_list_head = listener;
+	sockbuf_attach_listener((int) fd);
+	return(0);
+}
+
+static int rem_tcl_chan(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
+{
+	char *chan_name;
+	tcl_listener_t *listener, *prev;
+
+	if (objc != 2) {
+		Tcl_WrongNumArgs(interp, 0, NULL, "channel-name");
+		return(TCL_ERROR);
+	}
+
+	chan_name = Tcl_GetStringFromObj(objv[1], NULL);
+	if (!chan_name) return(TCL_ERROR);
+
+	prev = NULL;
+	for (listener = listener_list_head; listener; listener = listener->next) {
+		if (!strcasecmp(listener->name, chan_name)) break;
+		prev = listener;
+	}
+	if (!listener) return(TCL_ERROR);
+
+	if (prev) prev->next = listener->next;
+	else listener_list_head = listener->next;
+	sockbuf_detach_listener(listener->fd);
+	free(listener->name);
+	free(listener);
+	return(0);
+}
+
 static int tclscript_secondly()
 {
 	Tcl_DoOneEvent(TCL_ALL_EVENTS | TCL_DONT_WAIT);
@@ -614,7 +678,7 @@
 	Tcl_DeleteInterp(ginterp);
 
 	bind_rem_list("party", party_commands);
-	bind_add_list("secondly", secondly_binds);
+	bind_rem_list("secondly", secondly_binds);
 
 	script_unregister_module(&my_script_interface);
 	return(0);
@@ -640,6 +704,9 @@
 
 	bind_add_list("party", party_commands);
 	bind_add_list("secondly", secondly_binds);
+
+	Tcl_CreateObjCommand(ginterp, "net_add_tcl", add_tcl_chan, NULL, NULL);
+	Tcl_CreateObjCommand(ginterp, "net_rem_tcl", rem_tcl_chan, NULL, NULL);
 	return(0);
 }
 
Index: eggdrop1.7/src/main.c
diff -u eggdrop1.7/src/main.c:1.145 eggdrop1.7/src/main.c:1.146
--- eggdrop1.7/src/main.c:1.145	Tue Apr 15 03:18:03 2003
+++ eggdrop1.7/src/main.c	Tue Apr 15 13:05:01 2003
@@ -30,7 +30,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: main.c,v 1.145 2003/04/15 08:18:03 stdarg Exp $";
+static const char rcsid[] = "$Id: main.c,v 1.146 2003/04/15 18:05:01 stdarg Exp $";
 #endif
 
 #include <unistd.h>
@@ -340,27 +340,6 @@
 void core_party_init();
 void core_config_init();
 void telnet_init();
-
-int owner_check(const char *handle)
-{
-	int len;
-	char *powner;
-
-	len = strlen(handle);
-	if (!len) return(-1);
-
-	powner = core_config.owner;
-	while (powner) {
-		while (*powner && !isalnum(*powner)) powner++;
-		if (!*powner) break;
-		if (!strncasecmp(powner, handle, len)) {
-			powner += len;
-			if (!*powner || isalnum(*powner)) return(0);
-		}
-		while (*powner && isalnum(*powner)) powner++;
-	}
-	return(-1);
-}
 
 int file_check(const char *filename)
 {
----------------------- End of diff -----------------------


More information about the Changes mailing list