[cvslog] Module eggdrop1.7: Change committed

cvslog cvs at tsss.org
Tue Oct 23 03:49:00 CST 2001


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.7
Commit time: 2001-10-23 08:48:01 UTC
Commited by: stdarg <stdarg at techmonkeys.org>

Modified files:
     src/botmsg.c src/cmds.c src/script.c
     src/mod/perlscript.mod/perlscript.c

Log message:

* Added a "loadscript" script command.
* Fixed up perlscript.mod a little bit, so that it can do stuff.
* Wrote a test script in perl that uses timers, binds, and putlog successfully.

---------------------- diff included ----------------------
Index: eggdrop1.7/src/botmsg.c
diff -u eggdrop1.7/src/botmsg.c:1.25 eggdrop1.7/src/botmsg.c:1.26
--- eggdrop1.7/src/botmsg.c:1.25	Thu Oct 18 20:55:04 2001
+++ eggdrop1.7/src/botmsg.c	Tue Oct 23 03:47:51 2001
@@ -5,7 +5,7 @@
  *
  * by Darrin Smith (beldin at light.iinet.net.au)
  *
- * $Id: botmsg.c,v 1.25 2001/10/19 01:55:04 tothwolf Exp $
+ * $Id: botmsg.c,v 1.26 2001/10/23 08:47:51 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -848,7 +848,7 @@
   iaway = 0;
   /* Online right now? */
   for (i = 0; i < dcc_total; i++) {
-    if ((dcc[i].type->flags & DCT_GETNOTES) &&
+    if (dcc[i].type && (dcc[i].type->flags & DCT_GETNOTES) &&
 	((sock == (-1)) || (sock == dcc[i].sock)) &&
 	(!strcasecmp(dcc[i].nick, to))) {
       int aok = 1;
Index: eggdrop1.7/src/cmds.c
diff -u eggdrop1.7/src/cmds.c:1.75 eggdrop1.7/src/cmds.c:1.76
--- eggdrop1.7/src/cmds.c:1.75	Sat Oct 20 22:44:30 2001
+++ eggdrop1.7/src/cmds.c	Tue Oct 23 03:47:51 2001
@@ -3,7 +3,7 @@
  *   commands from a user via dcc
  *   (split in 2, this portion contains no-irc commands)
  *
- * $Id: cmds.c,v 1.75 2001/10/21 03:44:30 stdarg Exp $
+ * $Id: cmds.c,v 1.76 2001/10/23 08:47:51 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -1285,7 +1285,7 @@
     u->flags = sanity_check(u->flags | USER_OWNER);
   }
   for (i = 0; i < dcc_total; i++) {
-    if ((dcc[i].type->flags & DCT_MASTER) &&
+    if (dcc[i].type && (dcc[i].type->flags & DCT_MASTER) &&
 	(!strcasecmp(u->handle, dcc[i].nick))) {
       stat = dcc[i].status;
       if ((dcc[i].type == &DCC_CHAT) &&
Index: eggdrop1.7/src/mod/perlscript.mod/perlscript.c
diff -u eggdrop1.7/src/mod/perlscript.mod/perlscript.c:1.4 eggdrop1.7/src/mod/perlscript.mod/perlscript.c:1.5
--- eggdrop1.7/src/mod/perlscript.mod/perlscript.c:1.4	Sun Oct 21 20:49:25 2001
+++ eggdrop1.7/src/mod/perlscript.mod/perlscript.c	Tue Oct 23 03:47:51 2001
@@ -69,7 +69,7 @@
 	}
 	PUTBACK;
 
-	count = call_pv(me->name, G_SCALAR);
+	count = call_sv((SV *)me->callback_data, G_SCALAR);
 
 	SPAGAIN;
 
@@ -92,6 +92,7 @@
 {
 	if (me->syntax) free(me->syntax);
 	if (me->name) free(me->name);
+	sv_2mortal((SV *)me->callback_data);
 	free(me);
 	return(0);
 }
@@ -154,6 +155,19 @@
 			result = newSVpv(str, str_len);
 			break;
 		}
+		case SCRIPT_USER: {
+			char *handle;
+			struct userrec *u;
+			int str_len;
+
+			u = (struct userrec *)v->value;
+			if (u && u->handle) handle = u->handle;
+			else handle = "*";
+
+			str_len = strlen(handle);
+			result = newSVpv(handle, str_len);
+			break;
+		}
 		default:
 			result = &PL_sv_undef;
 	}
@@ -213,7 +227,7 @@
 				cback->delete = (Function) my_perl_cb_delete;
 				name = SvPV(ST(i), len);
 				malloc_strcpy(cback->name, name);
-				cback->callback_data = name;
+				cback->callback_data = (void *)newSVsv(ST(i));
 				mstack_push(args, cback);
 				break;
 			}
Index: eggdrop1.7/src/script.c
diff -u eggdrop1.7/src/script.c:1.8 eggdrop1.7/src/script.c:1.9
--- eggdrop1.7/src/script.c:1.8	Thu Oct 18 06:18:44 2001
+++ eggdrop1.7/src/script.c	Tue Oct 23 03:47:51 2001
@@ -5,11 +5,19 @@
 #include "script.h"
 #include "egglib/mstack.h"
 
-static Function link_int, unlink_int, link_str, unlink_str, create_cmd, delete_cmd;
-static void *link_int_h, *unlink_int_h, *link_str_h, *unlink_str_h, *create_cmd_h, *delete_cmd_h;
+static Function load_script, link_int, unlink_int, link_str, unlink_str, create_cmd, delete_cmd;
+static void *load_script_h, *link_int_h, *unlink_int_h, *link_str_h, *unlink_str_h, *create_cmd_h, *delete_cmd_h;
 
 static mstack_t *script_events;
 
+int script_load(char *fname);
+int script_create_cmd_table(script_command_t *table);
+
+static script_command_t my_script_cmds[] = {
+	{"", "loadscript", script_load, NULL, 1, 0, "s", "filename", SCRIPT_INTEGER, 0},
+	{0}
+};
+
 typedef struct {
 	int type;
 	int arg1, arg2, arg3;
@@ -76,6 +84,7 @@
 {
 	script_events = mstack_new(0);
 	registry_add_simple_chains(my_functions);
+	registry_lookup("script", "load script", &load_script, &load_script_h);
 	registry_lookup("script", "link int", &link_int, &link_int_h);
 	registry_lookup("script", "unlink int", &unlink_int, &unlink_int_h);
 	registry_lookup("script", "link str", &link_str, &link_str_h);
@@ -83,6 +92,14 @@
 	registry_lookup("script", "create cmd", &create_cmd, &create_cmd_h);
 	registry_lookup("script", "delete cmd", &delete_cmd, &delete_cmd_h);
 
+	script_create_cmd_table(&my_script_cmds);
+
+	return(0);
+}
+
+int script_load(char *fname)
+{
+	load_script(load_script_h, fname);
 	return(0);
 }
 
----------------------- End of diff -----------------------



More information about the Changes mailing list