comparison 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
comparison
equal deleted inserted replaced
6244:519028f52516 6245:9083f92e0d58
796 return ret; 796 return ret;
797 } 797 }
798 798
799 struct buddy *gaim_find_buddy(GaimAccount *account, const char *name) 799 struct buddy *gaim_find_buddy(GaimAccount *account, const char *name)
800 { 800 {
801 static struct buddy *buddy = NULL; 801 struct buddy *buddy;
802 struct _gaim_hbuddy hb; 802 struct _gaim_hbuddy hb;
803 GaimBlistNode *group; 803 GaimBlistNode *group;
804 const char *n = NULL;
805 804
806 if (!gaimbuddylist) 805 if (!gaimbuddylist)
807 return NULL; 806 return NULL;
808 807
809 if (!name && !buddy) 808 if (!name)
810 return NULL; 809 return NULL;
811 810
812 if (name) { 811 hb.name = normalize(name);
813 group = gaimbuddylist->root; 812 hb.account = account;
814 n = name; 813
815 } else { 814 for(group = gaimbuddylist->root; group; group = group->next) {
816 group = ((GaimBlistNode*)buddy)->parent->next;
817 n = buddy->name;
818 }
819
820 while (group) {
821 hb.name = normalize(n);
822 hb.account = account;
823 hb.group = group; 815 hb.group = group;
824 if ((buddy = g_hash_table_lookup(gaimbuddylist->buddies, &hb)) != NULL) 816 if ((buddy = g_hash_table_lookup(gaimbuddylist->buddies, &hb)) != NULL)
825 return buddy; 817 return buddy;
826 group = ((GaimBlistNode*)group)->next; 818 }
827 } 819
828 return NULL; 820 return NULL;
821 }
822
823 GSList *gaim_find_buddies(GaimAccount *account, const char *name)
824 {
825 struct buddy *buddy;
826 struct _gaim_hbuddy hb;
827 GaimBlistNode *group;
828 GSList *ret = NULL;
829
830 if (!gaimbuddylist)
831 return NULL;
832
833 if (!name)
834 return NULL;
835
836 hb.name = normalize(name);
837 hb.account = account;
838
839 for(group = gaimbuddylist->root; group; group = group->next) {
840 hb.group = group;
841 if ((buddy = g_hash_table_lookup(gaimbuddylist->buddies, &hb)) != NULL)
842 ret = g_slist_append(ret, buddy);
843 }
844
845 return ret;
829 } 846 }
830 847
831 struct group *gaim_find_group(const char *name) 848 struct group *gaim_find_group(const char *name)
832 { 849 {
833 GaimBlistNode *node; 850 GaimBlistNode *node;