[cvslog] (2004-10-01 16:13:41 UTC) Module eggdrop1.9: Change committed!

cvslog cvs at tsss.org
Fri Oct 1 10:13:41 CST 2004


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.9
Commit time: 2004-10-01 16:13:41 UTC
Commited by: stdarg <stdarg at techmonkeys.org>

Modified files:
     modules/server/channels.c modules/server/egg_server_api.h
     modules/server/egg_server_internal.h modules/server/input.c
     modules/server/schan.c modules/server/schan.h
     modules/server/servsock.c

Log message:

* Join channels when connecting, free channels when disconnecting

---------------------- diff included ----------------------
Index: eggdrop1.9/modules/server/channels.c
diff -u eggdrop1.9/modules/server/channels.c:1.32 eggdrop1.9/modules/server/channels.c:1.33
--- eggdrop1.9/modules/server/channels.c:1.32	Sun Sep 26 04:42:09 2004
+++ eggdrop1.9/modules/server/channels.c	Fri Oct  1 11:13:31 2004
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: channels.c,v 1.32 2004/09/26 09:42:09 stdarg Exp $";
+static const char rcsid[] = "$Id: channels.c,v 1.33 2004/10/01 16:13:31 stdarg Exp $";
  #endif
 
 #include "server.h"
@@ -71,8 +71,9 @@
 }
 
 /* Free online data like nicklist, banmasks, etc.. */
-static void free_channel_online(channel_t *chan)
+static void free_channel(channel_t *chan)
 {
+	channel_t *chanptr;
 	channel_member_t *m, *next_mem;
 
 	for (m = chan->member_head; m; m = next_mem) {
@@ -81,31 +82,28 @@
 		free_member(m);
 	}
 
+	if (chan->name) free(chan->name);
 	if (chan->topic) free(chan->topic);
 	if (chan->topic_nick) free(chan->topic_nick);
 	if (chan->key) free(chan->key);
-
 	clear_masklists(chan);
+	if (chan->args) free(chan->args);
 
-	free(chan->args);
-	chan->args = NULL;
-	chan->nargs = 0;
-}
-
-/* Free offline data like settings, etc. */
-static void free_channel_offline(channel_t *chan)
-{
+	/* Unlink. */
+	if (channel_head == chan) channel_head = chan->next;
+	else for (chanptr = channel_head; chanptr && chanptr->next; chanptr = chanptr->next) {
+		if (chanptr->next == chan) {
+			chanptr->next = chan->next;
+			break;
+		}
+	}
 }
 
-/* Free online related settings for all cahnnels */
-static void free_all_online_stuff()
+/* Reset everything when we disconnect from the server. */
+void channel_reset()
 {
-	channel_t *chan;
-
 	/* Clear out channel list. */
-	for (chan = channel_head; chan; chan = chan->next) {
-		free_channel_online(chan);
-	}
+	while (channel_head) free_channel(channel_head);
 
 	/* And the uhost cache. */
 	hash_table_walk(uhost_cache_ht, uhost_cache_delete, NULL);
@@ -319,18 +317,15 @@
 
 	bind_check(BT_leave, u ? &u->settings[0].flags : NULL, chan_name, nick, uhost, u, chan_name);
 
-	if (match_my_nick(nick)) free_channel_online(chan);
+	if (match_my_nick(nick)) free_channel(chan);
 }
 
 void channel_on_quit(const char *nick, const char *uhost, user_t *u)
 {
 	channel_t *chan;
 
-	if (match_my_nick(nick)) free_all_online_stuff();
-	else {
-		for (chan = channel_head; chan; chan = chan->next) {
-			channel_on_leave(chan->name, nick, uhost, u);
-		}
+	for (chan = channel_head; chan; chan = chan->next) {
+		channel_on_leave(chan->name, nick, uhost, u);
 	}
 }
 
Index: eggdrop1.9/modules/server/egg_server_api.h
diff -u eggdrop1.9/modules/server/egg_server_api.h:1.3 eggdrop1.9/modules/server/egg_server_api.h:1.4
--- eggdrop1.9/modules/server/egg_server_api.h:1.3	Mon Jun  7 18:14:48 2004
+++ eggdrop1.9/modules/server/egg_server_api.h	Fri Oct  1 11:13:31 2004
@@ -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: egg_server_api.h,v 1.3 2004/06/07 23:14:48 stdarg Exp $
+ * $Id: egg_server_api.h,v 1.4 2004/10/01 16:13:31 stdarg Exp $
  */
 
 #ifndef _EGG_MOD_SERVER_API_H_
@@ -47,7 +47,6 @@
 	int next_id;
 } queue_t;
 
-
 /* API structure. */
 typedef struct {
 	int major, minor; /* Version of this instance. */
Index: eggdrop1.9/modules/server/egg_server_internal.h
diff -u eggdrop1.9/modules/server/egg_server_internal.h:1.5 eggdrop1.9/modules/server/egg_server_internal.h:1.6
--- eggdrop1.9/modules/server/egg_server_internal.h:1.5	Sun Sep 26 04:42:09 2004
+++ eggdrop1.9/modules/server/egg_server_internal.h	Fri Oct  1 11:13:31 2004
@@ -29,7 +29,7 @@
 #define nchannels server_LTX_nchannels
 #define server_channel_init server_LTX_server_channel_init
 #define server_channel_destroy server_LTX_server_channel_destroy
-#define free_all_online_stuff server_LTX_free_all_online_stuff
+#define channel_reset server_LTX_channel_reset
 #define channel_lookup server_LTX_channel_lookup
 #define uhost_cache_lookup server_LTX_uhost_cache_lookup
 #define uhost_cache_addref server_LTX_uhost_cache_addref
Index: eggdrop1.9/modules/server/input.c
diff -u eggdrop1.9/modules/server/input.c:1.35 eggdrop1.9/modules/server/input.c:1.36
--- eggdrop1.9/modules/server/input.c:1.35	Sun Sep 26 04:42:09 2004
+++ eggdrop1.9/modules/server/input.c	Fri Oct  1 11:13:31 2004
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: input.c,v 1.35 2004/09/26 09:42:09 stdarg Exp $";
+static const char rcsid[] = "$Id: input.c,v 1.36 2004/10/01 16:13:31 stdarg Exp $";
 #endif
 
 #include "server.h"
@@ -199,6 +199,8 @@
 		str_redup(&current_server.whoprefix, "@+");
 	}
 
+	/* Join all channels. */
+	schan_on_connect();
 	return(0);
 }
 
Index: eggdrop1.9/modules/server/schan.c
diff -u eggdrop1.9/modules/server/schan.c:1.1 eggdrop1.9/modules/server/schan.c:1.2
--- eggdrop1.9/modules/server/schan.c:1.1	Fri Oct  1 10:32:11 2004
+++ eggdrop1.9/modules/server/schan.c	Fri Oct  1 11:13:31 2004
@@ -17,6 +17,17 @@
 	schan_save(server_config.chanfile);
 }
 
+/* We just finished connecting (got motd), join our channels. */
+void schan_on_connect()
+{
+	schan_t *chan;
+
+	for (chan = schan_head; chan; chan = chan->next) {
+		if (chan->key && strlen(chan->key)) printserv(SERVER_NORMAL, "JOIN %s %s", chan->name, chan->key);
+		else printserv(SERVER_NORMAL, "JOIN %s", chan->name);
+	}
+}
+
 /* Append a new channel. */
 static schan_t *schan_append(const char *chan_name, xml_node_t *settings)
 {
@@ -109,7 +120,8 @@
 {
 	xml_node_t *root = xml_parse_file(fname);
 	xml_node_t *chan_node, *settings;
-	char *name;
+	schan_t *chan;
+	char *name, *key;
 
 	if (!root) {
 		putlog(LOG_MISC, "*", "Could not load channel file '%s': %s", fname, xml_last_error());
@@ -118,10 +130,11 @@
 
 	chan_node = xml_node_lookup(root, 0, "channel", 0, 0);
 	for (; chan_node; chan_node = chan_node->next_sibling) {
-		xml_node_get_vars(chan_node, "sn", "name", &name, "settings", &settings);
+		xml_node_get_vars(chan_node, "ssn", "name", &name, "key", &key, "settings", &settings);
 		if (!name) continue;
 		if (settings) xml_node_unlink(settings);
-		schan_append(name, settings);
+		chan = schan_append(name, settings);
+		if (chan) str_redup(&chan->key, key);
 	}
 	return(0);
 }
@@ -138,6 +151,7 @@
 		chan_node = xml_node_new();
 		chan_node->name = strdup("channel");
 		xml_node_set_str(chan->name, chan_node, "name", 0, 0);
+		xml_node_set_str(chan->key, chan_node, "key", 0, 0);
 		xml_node_append(chan_node, chan->settings);
 		xml_node_append(root, chan_node);
 	}
Index: eggdrop1.9/modules/server/schan.h
diff -u eggdrop1.9/modules/server/schan.h:1.1 eggdrop1.9/modules/server/schan.h:1.2
--- eggdrop1.9/modules/server/schan.h:1.1	Fri Oct  1 10:32:11 2004
+++ eggdrop1.9/modules/server/schan.h	Fri Oct  1 11:13:31 2004
@@ -4,11 +4,13 @@
 typedef struct schan {
 	struct schan *next;
 	char *name;
+	char *key;
 	xml_node_t *settings;
 } schan_t;
 
 void server_schan_init();
 void server_schan_destroy();
+void schan_on_connect();
 schan_t *schan_lookup(const char *chan_name, int create);
 int schan_delete(const char *chan_name);
 int schan_set(schan_t *chan, const char *value, ...);
Index: eggdrop1.9/modules/server/servsock.c
diff -u eggdrop1.9/modules/server/servsock.c:1.23 eggdrop1.9/modules/server/servsock.c:1.24
--- eggdrop1.9/modules/server/servsock.c:1.23	Sun Sep 26 04:42:09 2004
+++ eggdrop1.9/modules/server/servsock.c	Fri Oct  1 11:13:31 2004
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: servsock.c,v 1.23 2004/09/26 09:42:09 stdarg Exp $";
+static const char rcsid[] = "$Id: servsock.c,v 1.24 2004/10/01 16:13:31 stdarg Exp $";
 #endif
 
 #include "server.h"
@@ -84,7 +84,7 @@
 
 	cycle_delay = server_config.cycle_delay;
 
-	//channel_reset();
+	channel_reset();
 	if (current_server.server_host) free(current_server.server_host);
 	if (current_server.server_self) free(current_server.server_self);
 	if (current_server.nick) free(current_server.nick);
----------------------- End of diff -----------------------



More information about the Changes mailing list