diff src/blist.c @ 6245:9083f92e0d58

[gaim-migrate @ 6739] this should really fix the infinite looping in server.c that KingAnt tried to fix. gaim_find_buddy() behaves like it used to now, and gaim_find_buddies() must be used to get all matching buddies committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Sun, 20 Jul 2003 16:19:31 +0000
parents de49cfd8fd59
children 55588b222901
line wrap: on
line diff
--- a/src/blist.c	Sun Jul 20 14:11:43 2003 +0000
+++ b/src/blist.c	Sun Jul 20 16:19:31 2003 +0000
@@ -798,36 +798,53 @@
 
 struct buddy *gaim_find_buddy(GaimAccount *account, const char *name)
 {
-	static struct buddy *buddy = NULL;
+	struct buddy *buddy;
 	struct _gaim_hbuddy hb;
 	GaimBlistNode *group;
-	const char *n = NULL;
 
 	if (!gaimbuddylist)
 		return NULL;
-	
-	if (!name && !buddy)
+
+	if (!name)
 		return NULL;
 
-	if (name) {
-		group = gaimbuddylist->root;
-		n = name;
-	} else {
-		group = ((GaimBlistNode*)buddy)->parent->next;
-		n = buddy->name;
-	}
+	hb.name = normalize(name);
+	hb.account = account;
 
-	while (group) {
-		hb.name = normalize(n);
-		hb.account = account;
+	for(group = gaimbuddylist->root; group; group = group->next) {
 		hb.group = group;
 		if ((buddy = g_hash_table_lookup(gaimbuddylist->buddies, &hb)) != NULL)
 			return buddy;
-		group = ((GaimBlistNode*)group)->next;
 	}
+
 	return NULL;
 }
 
+GSList *gaim_find_buddies(GaimAccount *account, const char *name)
+{
+	struct buddy *buddy;
+	struct _gaim_hbuddy hb;
+	GaimBlistNode *group;
+	GSList *ret = NULL;
+
+	if (!gaimbuddylist)
+		return NULL;
+
+	if (!name)
+		return NULL;
+
+	hb.name = normalize(name);
+	hb.account = account;
+
+	for(group = gaimbuddylist->root; group; group = group->next) {
+		hb.group = group;
+		if ((buddy = g_hash_table_lookup(gaimbuddylist->buddies, &hb)) != NULL)
+			ret = g_slist_append(ret, buddy);
+	}
+
+	return ret;
+}
+
 struct group *gaim_find_group(const char *name)
 {
 	GaimBlistNode *node;