[cvslog] (2007-08-19 19:49:29 UTC) Module eggdrop1.9: Change committed!

cvslog cvs at tsss.org
Sun Aug 19 13:49:29 CST 2007


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.9
Commit time: 2007-08-19 19:49:28 UTC
Commited by: sven

Modified files:
     lib/eggdrop/botnet.c lib/eggdrop/botnet.h lib/eggdrop/module.c
     lib/eggdrop/partymember.c lib/eggdrop/partymember.h
     lib/eggdrop/xml.c modules/botnet/botnet.c
     modules/oldbotnet/oldbotnet.c

Log message:

Just bugfixes, boring stuff.

---------------------- diff included ----------------------
Index: eggdrop1.9/lib/eggdrop/botnet.c
diff -u eggdrop1.9/lib/eggdrop/botnet.c:1.11 eggdrop1.9/lib/eggdrop/botnet.c:1.12
--- eggdrop1.9/lib/eggdrop/botnet.c:1.11	Sat Aug 18 17:32:23 2007
+++ eggdrop1.9/lib/eggdrop/botnet.c	Sun Aug 19 14:49:16 2007
@@ -28,7 +28,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: botnet.c,v 1.11 2007-08-18 22:32:23 sven Exp $";
+static const char rcsid[] = "$Id: botnet.c,v 1.12 2007-08-19 19:49:16 sven Exp $";
 #endif
 
 #include <eggdrop/eggdrop.h>
@@ -272,7 +272,7 @@
  * \todo Find a better way to log this. But for now ::LOG_MISC is good enough.
  */
 
-botnet_bot_t *botnet_new(const char *name, user_t *user, botnet_bot_t *uplink, botnet_bot_t *direction, botnet_handler_t *handler, void *client_data, event_owner_t *owner, int netburst)
+botnet_bot_t *botnet_new(const char *name, user_t *user, botnet_bot_t *uplink, botnet_bot_t *direction, xml_node_t *info, botnet_handler_t *handler, void *client_data, event_owner_t *owner, int netburst)
 {
 	const char *temp;
 	botnet_bot_t *bot, *tmp;
@@ -295,7 +295,7 @@
 	bot->handler = handler;
 	bot->client_data = client_data;
 	bot->owner = owner;
-	bot->info = xml_node_new();
+	bot->info = info ? info : xml_node_new();
 
 	hash_table_insert(bot_ht, bot->name, bot);
 	
@@ -580,7 +580,7 @@
 
 	if (start && dst->handler->on_new_bot) dst->handler->on_new_bot(dst->client_data, start, 1);
 	
-	for (p = start->partys; p; p = p->next_on_bot) {
+	for (p = start ? start->partys : partymember_get_local_head(); p; p = p->next_on_bot) {
 		if (p->flags & PARTY_DELETED) continue;
 		if (dst->handler->on_login) dst->handler->on_login(dst->client_data, p, 1);
 		for (i = 0; i < p->nchannels; ++i) {
@@ -818,18 +818,18 @@
 {
 	char *ret;
 
-	xml_node_get_str(&ret, bot->info, name, (void *) 0);
+	xml_node_get_str(&ret, bot->info, name, 0, (void *) 0);
 	return ret;
 }
 
 void botnet_set_info(botnet_bot_t *bot, const char *name, const char *value)
 {
-	xml_node_set_str(value, bot->info, name, (void *) 0);
+	xml_node_set_str(value, bot->info, name, 0, (void *) 0);
 }
 
 void botnet_set_info_int(botnet_bot_t *bot, const char *name, int value)
 {
-	xml_node_set_int(value, bot->info, name, (void *) 0);
+	xml_node_set_int(value, bot->info, name, 0, (void *) 0);
 }
 
 /*!
Index: eggdrop1.9/lib/eggdrop/botnet.h
diff -u eggdrop1.9/lib/eggdrop/botnet.h:1.7 eggdrop1.9/lib/eggdrop/botnet.h:1.8
--- eggdrop1.9/lib/eggdrop/botnet.h:1.7	Sat Aug 18 17:32:23 2007
+++ eggdrop1.9/lib/eggdrop/botnet.h	Sun Aug 19 14:49:17 2007
@@ -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: botnet.h,v 1.7 2007-08-18 22:32:23 sven Exp $
+ * $Id: botnet.h,v 1.8 2007-08-19 19:49:17 sven Exp $
  */
 
 #ifndef _EGG_BOTNET_H_
@@ -144,7 +144,7 @@
 const botnet_bot_t *botnet_get_head(void);
 
 botnet_bot_t *botnet_lookup(const char *name);
-botnet_bot_t *botnet_new(const char *name, user_t *user, botnet_bot_t *uplink, botnet_bot_t *direction, botnet_handler_t *handler, void *client_data, event_owner_t *owner, int netburst);
+botnet_bot_t *botnet_new(const char *name, user_t *user, botnet_bot_t *uplink, botnet_bot_t *direction, xml_node_t *info, botnet_handler_t *handler, void *client_data, event_owner_t *owner, int netburst);
 void botnet_count_subtree(botnet_bot_t *bot, int *bots, int *members);
 void botnet_link_failed(user_t *user, const char *reason);
 void botnet_link_success(botnet_bot_t *bot);
Index: eggdrop1.9/lib/eggdrop/module.c
diff -u eggdrop1.9/lib/eggdrop/module.c:1.13 eggdrop1.9/lib/eggdrop/module.c:1.14
--- eggdrop1.9/lib/eggdrop/module.c:1.13	Sat Jan 13 06:23:39 2007
+++ eggdrop1.9/lib/eggdrop/module.c	Sun Aug 19 14:49:17 2007
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: module.c,v 1.13 2007-01-13 12:23:39 sven Exp $";
+static const char rcsid[] = "$Id: module.c,v 1.14 2007-08-19 19:49:17 sven Exp $";
 #endif
 
 #include <eggdrop/eggdrop.h>
@@ -88,6 +88,7 @@
 	bind_table_del(BT_load);
 	bind_table_del(BT_unload);
 
+	garbage_run();
 	return (0);
 }
 
Index: eggdrop1.9/lib/eggdrop/partymember.c
diff -u eggdrop1.9/lib/eggdrop/partymember.c:1.29 eggdrop1.9/lib/eggdrop/partymember.c:1.30
--- eggdrop1.9/lib/eggdrop/partymember.c:1.29	Sat Aug 18 17:32:23 2007
+++ eggdrop1.9/lib/eggdrop/partymember.c	Sun Aug 19 14:49:17 2007
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: partymember.c,v 1.29 2007-08-18 22:32:23 sven Exp $";
+static const char rcsid[] = "$Id: partymember.c,v 1.30 2007-08-19 19:49:17 sven Exp $";
 #endif
 
 #include <eggdrop/eggdrop.h>
@@ -71,7 +71,7 @@
 
 	if (p->prev_on_bot) p->prev_on_bot->next_on_bot = p->next_on_bot;
 	else if (p->bot) p->bot->partys = p->next_on_bot;
-	else local_party_head = p->next_on_bot;
+	else if (local_party_head == p) local_party_head = p->next_on_bot;
 	if (p->next_on_bot) p->next_on_bot->prev_on_bot = p->prev_on_bot;
 
 	/* Free! */
@@ -104,6 +104,11 @@
 	return party_head;
 }
 
+partymember_t *partymember_get_local_head()
+{
+	return local_party_head;
+}
+
 static int partymember_get_id(botnet_bot_t *bot)
 {
 	int id;
@@ -221,6 +226,7 @@
 		(p->handler->on_quit)(p->client_data, p, lost_bot, text, strlen(text));
 	}
 	if (p->owner && p->owner->on_delete) p->owner->on_delete(p->owner, p->client_data);
+	p->bot = NULL;
 	return(0);
 }
 
@@ -318,8 +324,8 @@
 		}
 	}
 
+	if (p && id != -1 && nick && strcmp(p->nick, nick)) p = NULL;
 	if (name) free(name);
-	if (p && id != -1 && nick && strcmp(p->nick, nick)) return NULL;
 	return p;
 }
 
Index: eggdrop1.9/lib/eggdrop/partymember.h
diff -u eggdrop1.9/lib/eggdrop/partymember.h:1.8 eggdrop1.9/lib/eggdrop/partymember.h:1.9
--- eggdrop1.9/lib/eggdrop/partymember.h:1.8	Sat Aug 18 17:32:23 2007
+++ eggdrop1.9/lib/eggdrop/partymember.h	Sun Aug 19 14:49:17 2007
@@ -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: partymember.h,v 1.8 2007-08-18 22:32:23 sven Exp $
+ * $Id: partymember.h,v 1.9 2007-08-19 19:49:17 sven Exp $
  */
 
 #ifndef _EGG_PARTYMEMBER_H
@@ -50,6 +50,7 @@
 partymember_t *partymember_lookup(const char *name, struct botnet_bot *bot, int id);
 partymember_t *partymember_new(int id, user_t *user, struct botnet_bot *bot, const char *nick, const char *ident, const char *host, partyline_event_t *handler, void *client_data, event_owner_t *owner);
 partymember_t *partymember_get_head(void);
+partymember_t *partymember_get_local_head(void);
 int partymember_delete(partymember_t *p, const struct botnet_bot *lost_bot, const char *text);
 int partymember_delete_by_owner(struct egg_module *module, void *script);
 int partymember_update_info(partymember_t *p, const char *ident, const char *host);
Index: eggdrop1.9/lib/eggdrop/xml.c
diff -u eggdrop1.9/lib/eggdrop/xml.c:1.26 eggdrop1.9/lib/eggdrop/xml.c:1.27
--- eggdrop1.9/lib/eggdrop/xml.c:1.26	Sat Aug 18 17:32:23 2007
+++ eggdrop1.9/lib/eggdrop/xml.c	Sun Aug 19 14:49:17 2007
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: xml.c,v 1.26 2007-08-18 22:32:23 sven Exp $";
+static const char rcsid[] = "$Id: xml.c,v 1.27 2007-08-19 19:49:17 sven Exp $";
 #endif
 
 #include <eggdrop/eggdrop.h>
@@ -145,14 +145,15 @@
 
 void xml_node_delete_callbacked(xml_node_t *node, void (*callback)(void *))
 {
-	xml_node_t *child;
+	xml_node_t *child, *child_next;
 
 	if (node->client_data && callback) callback(node->client_data);
 
 	xml_node_unlink(node);
 
 	/* Delete children. */
-	for (child = node->children; child; child = child->next) {
+	for (child = node->children; child; child = child_next) {
+		child_next = child->next;
 		child->parent = NULL;
 		xml_node_delete_callbacked(child, callback);
 	}
Index: eggdrop1.9/modules/botnet/botnet.c
diff -u eggdrop1.9/modules/botnet/botnet.c:1.2 eggdrop1.9/modules/botnet/botnet.c:1.3
--- eggdrop1.9/modules/botnet/botnet.c:1.2	Sat Aug 18 17:32:24 2007
+++ eggdrop1.9/modules/botnet/botnet.c	Sun Aug 19 14:49:18 2007
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: botnet.c,v 1.2 2007-08-18 22:32:24 sven Exp $";
+static const char rcsid[] = "$Id: botnet.c,v 1.3 2007-08-19 19:49:18 sven Exp $";
 #endif
 
 #include <eggdrop/eggdrop.h>
@@ -232,19 +232,24 @@
 static int got_newbot(bot_t *bot, botnet_entity_t *src, char *cmd, int argc, char *argv[21], int len)
 {
 	int flags;
+	xml_node_t *info;
 	botnet_bot_t *new;
 
 	if (argc < 5) return 0;
 	
 	flags = b64dec_int(argv[4]);
-	new = botnet_new(argv[0], NULL, src->bot, bot->bot, NULL, NULL, &generic_owner, flags & 1);
+
+	info = xml_node_new();
+	xml_node_set_str(argv[1], info, "type", 0, (void *) 0);
+	xml_node_set_int(b64dec_int(argv[2]), info, "numversion", 0, (void *) 0);
+	xml_node_set_str(argv[3], info, "version", (void *) 0);
+
+	new = botnet_new(argv[0], NULL, src->bot, bot->bot, info, NULL, NULL, &generic_owner, flags & 1);
 	if (!new) {
 		botnet_delete(bot->bot, _("Couldn't create introduced bot"));
+		xml_node_delete(info);
 		return 0;
 	}
-	botnet_set_info(new, "type", argv[1]);
-	botnet_set_info_int(new, "numversion", b64dec_int(argv[2]));
-	botnet_set_info(new, "version", argv[3]);
 
 	return 0;
 }
@@ -356,6 +361,8 @@
 		*bot->pass = 0;
 		egg_iprintf(bot->idx, "thisbot %s eggdrop %s %s :%s", botnet_get_name(), "1090000", "eggdrop1.9.0+cvs", "some informative stuff");
 	} else if (!strcasecmp(cmd, "THISBOT")) {
+		xml_node_t *info;
+
 		if (!bot->pass || *bot->pass || argc != 5 || strcmp(bot->user->handle, argv[0])) {
 			sockbuf_delete(bot->idx);
 			return 0;
@@ -363,10 +370,13 @@
 		free(bot->pass);
 		bot->pass = NULL;
 		bot->linking = 0;
-		bot->bot = botnet_new(bot->user->handle, bot->user, NULL, NULL, &bothandler, bot, &bot_owner, 0);
-		botnet_set_info(bot->bot, "type", argv[0]);
-		botnet_set_info_int(bot->bot, "numversion", b64dec_int(argv[2]));
-		botnet_set_info(bot->bot, "version", argv[3]);
+		
+		info = xml_node_new();
+		xml_node_set_str(argv[0], info, "type", 0, (void *) 0);
+		xml_node_set_int(b64dec_int(argv[2]), info, "numversion", 0, (void *) 0);
+		xml_node_set_str(argv[3], info, "version", 0, (void *) 0);
+		
+		bot->bot = botnet_new(bot->user->handle, bot->user, NULL, NULL, info, &bothandler, bot, &bot_owner, 0);
 		botnet_replay_net(bot->bot);
 		egg_iprintf(bot->idx, "el");
 	} else {
@@ -409,6 +419,8 @@
 		egg_iprintf(bot->idx, "pass %s", buf);
 		*bot->pass = 0;
 	} else if (!strcasecmp(cmd, "THISBOT")) {
+		xml_node_t *info;
+
 		if (argc != 5 || strcmp(bot->user->handle, argv[0])) {
 			sockbuf_delete(bot->idx);
 			return 0;
@@ -417,10 +429,13 @@
 		free(bot->pass);
 		bot->pass = NULL;
 		bot->linking = 0;
-		bot->bot = botnet_new(bot->user->handle, bot->user, NULL, NULL, &bothandler, bot, &bot_owner, 0);
-		botnet_set_info(bot->bot, "type", argv[0]);
-		botnet_set_info_int(bot->bot, "numversion", b64dec_int(argv[2]));
-		botnet_set_info(bot->bot, "version", argv[3]);
+
+		info = xml_node_new();
+		xml_node_set_str(argv[0], info, "type", 0, (void *) 0);
+		xml_node_set_int(b64dec_int(argv[2]), info, "numversion", 0, (void *) 0);
+		xml_node_set_str(argv[3], info, "version", 0, (void *) 0);
+
+		bot->bot = botnet_new(bot->user->handle, bot->user, NULL, NULL, info, &bothandler, bot, &bot_owner, 0);
 		botnet_replay_net(bot->bot);
 		egg_iprintf(bot->idx, "el");
 	} else {
Index: eggdrop1.9/modules/oldbotnet/oldbotnet.c
diff -u eggdrop1.9/modules/oldbotnet/oldbotnet.c:1.22 eggdrop1.9/modules/oldbotnet/oldbotnet.c:1.23
--- eggdrop1.9/modules/oldbotnet/oldbotnet.c:1.22	Sat Aug 18 17:32:24 2007
+++ eggdrop1.9/modules/oldbotnet/oldbotnet.c	Sun Aug 19 14:49:18 2007
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: oldbotnet.c,v 1.22 2007-08-18 22:32:24 sven Exp $";
+static const char rcsid[] = "$Id: oldbotnet.c,v 1.23 2007-08-19 19:49:18 sven Exp $";
 #endif
 
 #include <eggdrop/eggdrop.h>
@@ -455,6 +455,7 @@
 static void got_version(oldbotnet_t *bot, const char *next)
 {
 	char buf[32];
+	xml_node_t *info;
 	/* Get their version and handlen. */
 	sscanf(next, "%d %d", &bot->version, &bot->handlen);
 
@@ -462,20 +463,24 @@
 	egg_iprintf(bot->idx, "version 1090000 %d eggdrop v1.9 <alrighty.then>\n", bot->handlen);
 	egg_iprintf(bot->idx, "tb %s\n", bot->name);
 
+	if (bot->version % 100) sprintf(buf, "eggdrop%d.%d.%d.%d", bot->version / 1000000, bot->version / 10000 % 100, bot->version / 100 % 100, bot->version % 100);
+	else sprintf(buf, "eggdrop%d.%d.%d", bot->version / 1000000, bot->version / 10000 % 100, bot->version / 100 % 100);
+
+	info = xml_node_new();
+	xml_node_set_str("eggdrop", info, "type", 0, (void *) 0);
+	xml_node_set_int(bot->version, info, "numversion", 0, (void *) 0);
+	xml_node_set_str(buf, info, "version", 0, (void *) 0);
+
 	/* And now we're connected. */
 	bot->linking = 1;
-	bot->bot = botnet_new(bot->user->handle, bot->user, NULL, NULL, &bothandler, bot, &bot_owner, 0);
+	bot->bot = botnet_new(bot->user->handle, bot->user, NULL, NULL, info, &bothandler, bot, &bot_owner, 0);
 	if (!bot->bot) {
 		botnet_link_failed(bot->user, "Could not create bot.");
 		bot->user = NULL;
 		sockbuf_delete(bot->idx);
+		xml_node_delete(info);
 		return;
 	}
-	if (bot->version % 100) sprintf(buf, "eggdrop%d.%d.%d.%d", bot->version / 1000000, bot->version / 10000 % 100, bot->version / 100 % 100, bot->version % 100);
-	else sprintf(buf, "eggdrop%d.%d.%d", bot->version / 1000000, bot->version / 10000 % 100, bot->version / 100 % 100);
-	botnet_set_info(bot->bot, "type", "eggdrop");
-	botnet_set_info_int(bot->bot, "numversion", bot->version);
-	botnet_set_info(bot->bot, "version", buf);
 	botnet_replay_net(bot->bot);
 	egg_iprintf(bot->idx, "el\n");
 }
@@ -684,6 +689,7 @@
 	char *word[3], buf[32];
 	int n, linking = 1, version;
 	botnet_bot_t *src, *new;
+	xml_node_t *info;
 	oldbotnet_t *obot = bot->client_data;
 
 	n = egg_get_word_array(next, NULL, word, 3);
@@ -712,19 +718,23 @@
 	} else {
 		version = b64dec_int(word[2]);
 	}
-	new = botnet_new(word[0], NULL, src, bot, NULL, NULL, &generic_owner, linking);
+
+	if (version % 100) sprintf(buf, "eggdrop%d.%d.%d.%d", version / 1000000, version / 10000 % 100, version / 100 % 100, version % 100);
+	else sprintf(buf, "eggdrop%d.%d.%d", version / 1000000, version / 10000 % 100, version / 100 % 100);
+	info = xml_node_new();
+	xml_node_set_str("eggdrop", info, "type", 0, (void *) 0);
+	xml_node_set_int(version, info, "numversion", 0, (void *) 0);
+	xml_node_set_str(buf, info, "version", 0, (void *) 0);
+
+	new = botnet_new(word[0], NULL, src, bot, info, NULL, NULL, &generic_owner, linking);
 	if (!new) {
 		/* Invalid botname ... should probably do some really clever name mangleing here ... */
 		char obuf[512];
 		snprintf(obuf, sizeof(obuf), "Botname incompatiblity: %s linked from %s", word[0], src->name);
 		botnet_delete(bot, obuf);
 		/* or just be lazy and kill the bot -_- */
+		xml_node_delete(info);
 	}
-	if (version % 100) sprintf(buf, "eggdrop%d.%d.%d.%d", version / 1000000, version / 10000 % 100, version / 100 % 100, version % 100);
-	else sprintf(buf, "eggdrop%d.%d.%d", version / 1000000, version / 10000 % 100, version / 100 % 100);
-	botnet_set_info(new, "type", "eggdrop");
-	botnet_set_info_int(new, "numversion", version);
-	botnet_set_info(new, "version", buf);
 	return BIND_RET_BREAK;
 }
 
----------------------- End of diff -----------------------



More information about the Changes mailing list