[cvslog] (2003-06-15 05:43:34 UTC) Module eggdrop1.7: Change committed

cvslog cvs at tsss.org
Sat Jun 14 23:43:34 CST 2003


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

Modified files:
     lib/eggdrop/binds.c lib/eggdrop/partyline.h
     lib/eggdrop/partymember.c lib/eggdrop/users.c lib/eggdrop/users.h
     lib/eggdrop/xml.c modules/telnetparty/events.c src/core_party.c
     src/main.h

Log message:



---------------------- diff included ----------------------
Index: eggdrop1.7/lib/eggdrop/binds.c
diff -u eggdrop1.7/lib/eggdrop/binds.c:1.6 eggdrop1.7/lib/eggdrop/binds.c:1.7
--- eggdrop1.7/lib/eggdrop/binds.c:1.6	Thu Jun 12 22:35:14 2003
+++ eggdrop1.7/lib/eggdrop/binds.c	Sun Jun 15 00:43:23 2003
@@ -375,7 +375,7 @@
 	table = bind_table_lookup_or_fake(table_name);
 
 	for (; cmds->callback; cmds++) {
-		snprintf(name, 50, "*%s:%s", table->name, cmds->mask);
+		snprintf(name, 50, "*%s:%s", table->name, cmds->mask ? cmds->mask : "");
 		bind_entry_add(table, cmds->user_flags, cmds->mask, name, 0, cmds->callback, NULL);
 	}
 }
Index: eggdrop1.7/lib/eggdrop/partyline.h
diff -u eggdrop1.7/lib/eggdrop/partyline.h:1.7 eggdrop1.7/lib/eggdrop/partyline.h:1.8
--- eggdrop1.7/lib/eggdrop/partyline.h:1.7	Thu Jun 12 22:35:14 2003
+++ eggdrop1.7/lib/eggdrop/partyline.h	Sun Jun 15 00:43:23 2003
@@ -85,6 +85,7 @@
 partymember_t *partymember_lookup_pid(int pid);
 partymember_t *partymember_new(int pid, user_t *user, const char *nick, const char *ident, const char *host, partyline_event_t *handler, void *client_data);
 int partymember_update_info(partymember_t *p, const char *ident, const char *host);
+int partymember_who(int **pids, int *len);
 int partymember_write_pid(int pid, const char *text, int len);
 int partymember_write(partymember_t *p, const char *text, int len);
 int partymember_printf_pid(int pid, const char *fmt, ...);
Index: eggdrop1.7/lib/eggdrop/partymember.c
diff -u eggdrop1.7/lib/eggdrop/partymember.c:1.4 eggdrop1.7/lib/eggdrop/partymember.c:1.5
--- eggdrop1.7/lib/eggdrop/partymember.c:1.4	Thu Jun 12 22:35:14 2003
+++ eggdrop1.7/lib/eggdrop/partymember.c	Sun Jun 15 00:43:23 2003
@@ -6,13 +6,21 @@
 
 static hash_table_t *pid_ht = NULL;
 static partymember_t *party_head = NULL;
+static int npartymembers = 0;
 static int g_pid = 0;	/* Keep track of next available pid. */
 
 static int partymember_cleanup(void *client_data);
+static int on_udelete(user_t *u);
+
+static bind_list_t partymember_udelete_binds[] = {
+	{NULL, NULL, on_udelete},
+	{0}
+};
 
 int partymember_init()
 {
 	pid_ht = hash_table_create(NULL, NULL, 13, HASH_TABLE_INTS);
+	bind_add_list("udelete", partymember_udelete_binds);
 	return(0);
 }
 
@@ -85,6 +93,8 @@
 	mem->next = party_head;
 	if (party_head) party_head->prev = mem;
 	party_head = mem;
+	hash_table_insert(pid_ht, (void *)pid, mem);
+	npartymembers++;
 	return(mem);
 }
 
@@ -99,6 +109,7 @@
 	/* Mark it as deleted so it doesn't get reused before it's free. */
 	p->flags |= PARTY_DELETED;
 	garbage_add(partymember_cleanup, NULL, GARBAGE_ONCE);
+	npartymembers--;
 
 	len = strlen(text);
 
@@ -157,6 +168,23 @@
 	return(0);
 }
 
+int partymember_who(int **pids, int *len)
+{
+	int i;
+	partymember_t *p;
+
+	*pids = malloc(sizeof(int) * (npartymembers+1));
+	*len = npartymembers;
+	i = 0;
+	for (p = party_head; p; p = p->next) {
+		if (p->flags & PARTY_DELETED) continue;
+		(*pids)[i] = p->pid;
+		i++;
+	}
+	(*pids)[i] = -1;
+	return(0);
+}
+
 int partymember_write_pid(int pid, const char *text, int len)
 {
 	partymember_t *p;
@@ -203,5 +231,15 @@
 	partymember_write(p, ptr, len);
 
 	if (ptr != buf) free(ptr);
+	return(0);
+}
+
+static int on_udelete(user_t *u)
+{
+	partymember_t *p;
+
+	for (p = party_head; p; p = p->next) {
+		if (p->user == u) partymember_delete(p, "User deleted!");
+	}
 	return(0);
 }
Index: eggdrop1.7/lib/eggdrop/users.c
diff -u eggdrop1.7/lib/eggdrop/users.c:1.15 eggdrop1.7/lib/eggdrop/users.c:1.16
--- eggdrop1.7/lib/eggdrop/users.c:1.15	Thu Jun 12 22:35:14 2003
+++ eggdrop1.7/lib/eggdrop/users.c	Sun Jun 15 00:43:23 2003
@@ -34,7 +34,8 @@
 
 /* Bind tables. */
 static bind_table_t *BT_uflags = NULL,	/* user flags */
-	*BT_uset = NULL;	/* settings */
+	*BT_uset = NULL,	/* settings */
+	*BT_udelete = NULL;	/* user got deleted */
 
 /* Prototypes for internal functions. */
 static user_t *real_user_new(const char *handle, int uid);
@@ -52,8 +53,9 @@
 	irchost_cache_ht = hash_table_create(NULL, NULL, HOST_HASH_SIZE, HASH_TABLE_STRINGS);
 
 	/* And bind tables. */
-	BT_uflags = bind_table_add("uflag", 4, "ssss", MATCH_MASK, 0);
-	BT_uset = bind_table_add("uset", 4, "ssss", MATCH_MASK, 0);
+	BT_uflags = bind_table_add("uflag", 4, "ssss", MATCH_MASK, BIND_STACKABLE);
+	BT_uset = bind_table_add("uset", 4, "ssss", MATCH_MASK, BIND_STACKABLE);
+	BT_udelete = bind_table_add("udelete", 1, "U", MATCH_NONE, BIND_STACKABLE);
 	return(0);
 }
 
@@ -237,24 +239,15 @@
 	return(u);
 }
 
-int user_delete(user_t *u)
+static int user_really_delete(void *client_data)
 {
 	int i, j;
+	user_t *u = client_data;
 	user_setting_t *setting;
 
-	nusers--;
-	hash_table_delete(handle_ht, u->handle, NULL);
-	hash_table_delete(uid_ht, (void *)u->uid, NULL);
-
-	/* Get rid of the ircmasks. */
-	cache_user_del(u, "*");
-	for (i = 0; i < u->nircmasks; i++) {
-		ircmask_list_del(&ircmask_list, u->ircmasks[i], u);
-		free(u->ircmasks[i]);
-	}
+	/* Free the ircmasks. */
+	for (i = 0; i < u->nircmasks; i++) free(u->ircmasks[i]);
 	if (u->ircmasks) free(u->ircmasks);
-	u->ircmasks = NULL;
-	u->nircmasks = 0;
 
 	/* And all of the settings. */
 	for (i = 0; i < u->nsettings; i++) {
@@ -267,9 +260,26 @@
 		if (setting->chan) free(setting->chan);
 	}
 	if (u->settings) free(u->settings);
-	u->settings = NULL;
-	u->nsettings = 0;
 
+	memset(u, 0, sizeof(*u));
+	free(u);
+	return(0);
+}
+
+int user_delete(user_t *u)
+{
+	int i;
+
+	if (!u || (u->flags & USER_DELETED)) return(-1);
+
+	nusers--;
+	hash_table_delete(handle_ht, u->handle, NULL);
+	hash_table_delete(uid_ht, (void *)u->uid, NULL);
+	cache_user_del(u, "*");
+	for (i = 0; i < u->nircmasks; i++) ircmask_list_del(&ircmask_list, u->ircmasks[i], u);
+	u->flags |= USER_DELETED;
+	bind_check(BT_udelete, NULL, NULL, u);
+	garbage_add(user_really_delete, u, 0);
 	return(0);
 }
 
@@ -376,7 +386,7 @@
 	hash_table_walk(irchost_cache_ht, cache_check_del, &info);
 	for (i = 0; i < info.nentries; i++) {
 		hash_table_delete(irchost_cache_ht, info.entries[i], NULL);
-		free(info.entries[i]);
+		free((void *)info.entries[i]);
 	}
 	if (info.entries) free(info.entries);
 
Index: eggdrop1.7/lib/eggdrop/users.h
diff -u eggdrop1.7/lib/eggdrop/users.h:1.5 eggdrop1.7/lib/eggdrop/users.h:1.6
--- eggdrop1.7/lib/eggdrop/users.h:1.5	Wed Jun 11 03:37:38 2003
+++ eggdrop1.7/lib/eggdrop/users.h	Sun Jun 15 00:43:23 2003
@@ -4,6 +4,8 @@
 #define USER_HASH_SIZE	50
 #define HOST_HASH_SIZE	50
 
+#define USER_DELETED	1
+
 typedef struct {
 	char *name;
 	char *value;
@@ -33,6 +35,9 @@
 	/* Settings for this user. */
 	user_setting_t *settings;
 	int nsettings;
+
+	/* Flags for the structure, e.g. USER_DELETED. */
+	int flags;
 } user_t;
 
 int user_init();
Index: eggdrop1.7/lib/eggdrop/xml.c
diff -u eggdrop1.7/lib/eggdrop/xml.c:1.3 eggdrop1.7/lib/eggdrop/xml.c:1.4
--- eggdrop1.7/lib/eggdrop/xml.c:1.3	Sun Feb 16 05:15:06 2003
+++ eggdrop1.7/lib/eggdrop/xml.c	Sun Jun 15 00:43:23 2003
@@ -78,7 +78,7 @@
 		index = va_arg(args, int);
 		child = NULL;
 		for (i = 0; i < root->nchildren; i++) {
-			if (!strcasecmp(root->children[i]->name, path)) {
+			if (root->children[i]->name && !strcasecmp(root->children[i]->name, path)) {
 				if (index-- > 0) continue;
 				child = root->children[i];
 				break;
Index: eggdrop1.7/modules/telnetparty/events.c
diff -u eggdrop1.7/modules/telnetparty/events.c:1.3 eggdrop1.7/modules/telnetparty/events.c:1.4
--- eggdrop1.7/modules/telnetparty/events.c:1.3	Wed Jun 11 03:37:38 2003
+++ eggdrop1.7/modules/telnetparty/events.c	Sun Jun 15 00:43:24 2003
@@ -38,12 +38,9 @@
 {
 	telnet_session_t *session = client_data;
 
-	if (src == session->party) {
-		sockbuf_delete(session->idx);
-	}
-	else {
-		egg_iprintf(session->idx, "%s (%s@%s) has quit: %s\n", src->nick, src->ident, src->host, text);
-	}
+	egg_iprintf(session->idx, "%s (%s@%s) has quit: %s\n", src->nick, src->ident, src->host, text);
+	if (src == session->party) sockbuf_delete(session->idx);
+
 	return(0);
 }
 
Index: eggdrop1.7/src/core_party.c
diff -u eggdrop1.7/src/core_party.c:1.6 eggdrop1.7/src/core_party.c:1.7
--- eggdrop1.7/src/core_party.c:1.6	Thu Jun 12 22:35:15 2003
+++ eggdrop1.7/src/core_party.c	Sun Jun 15 00:43:24 2003
@@ -57,14 +57,84 @@
 	return(0);
 }
 
+static int intsorter(const void *left, const void *right)
+{
+	return(*(int *)left - *(int *)right);
+}
+
+static int party_who(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
+{
+	partymember_t *who;
+	int *pids, len, i;
+
+	partymember_printf(p, "Partyline members");
+	partymember_who(&pids, &len);
+	qsort(pids, len, sizeof(int), intsorter);
+	for (i = 0; i < len; i++) {
+		who = partymember_lookup_pid(pids[i]);
+		partymember_printf(p, "  [%.5d] %s (%s@%s)", who->pid, who->nick, who->ident, who->host);
+	}
+	free(pids);
+	return(0);
+}
+
+static int party_die(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
+{
+	exit(0);
+}
+
+static int party_plus_user(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
+{
+	user_t *newuser;
+
+	if (!text || !*text) {
+		partymember_printf(p, "Syntax: +user <handle>");
+		return(0);
+	}
+	if (user_lookup_by_handle(text)) {
+		partymember_printf(p, "User '%s' already exists!");
+		return(0);
+	}
+	newuser = user_new(text);
+	if (newuser) partymember_printf(p, "User '%s' created", text);
+	else partymember_printf(p, "Could not create user '%s'", text);
+	return(0);
+}
+
+static int party_minus_user(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
+{
+	user_t *who;
+
+	if (!text || !*text) {
+		partymember_printf(p, "Syntax: -user <handle>");
+		return(0);
+	}
+	who = user_lookup_by_handle(text);
+	if (!who) partymember_printf(p, "User '%s' not found");
+	else {
+		partymember_printf(p, "Deleting user '%s'", who->handle);
+		user_delete(who);
+	}
+	return(0);
+}
+
+static int party_plus_host(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
+{
+	return(0);
+}
+
 static bind_list_t core_party_binds[] = {
 	{NULL, "join", party_join},
 	{NULL, "msg", party_msg},
 	{NULL, "newpass", party_newpass},
 	{NULL, "part", party_part},
 	{NULL, "quit", party_quit},
+	{NULL, "who", party_who},
 	{"n", "set", party_set},
 	{"n", "save", party_save},
+	{"n", "die", party_die},
+	{"n", "+user", party_plus_user},
+	{"n", "-user", party_minus_user},
 	{0}
 };
 
Index: eggdrop1.7/src/main.h
diff -u eggdrop1.7/src/main.h:1.34 eggdrop1.7/src/main.h:1.35
--- eggdrop1.7/src/main.h:1.34	Tue Apr 15 03:18:03 2003
+++ eggdrop1.7/src/main.h	Sun Jun 15 00:43:24 2003
@@ -22,7 +22,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 /*
- * $Id: main.h,v 1.34 2003/04/15 08:18:03 stdarg Exp $
+ * $Id: main.h,v 1.35 2003/06/15 05:43:24 stdarg Exp $
  */
 
 #ifndef _EGG_MAIN_H
@@ -39,6 +39,5 @@
 extern eggdrop_t *egg;
 
 void fatal(const char *, int);
-int owner_check(const char *handle);
 
 #endif				/* !_EGG_MAIN_H */
----------------------- End of diff -----------------------


More information about the Changes mailing list