Mercurial > hg
comparison mcabber/src/roster.c @ 265:49e9e02dd6d0
Add "/roster search" command
author | mikael@frmp8452 |
---|---|
date | Sat, 02 Jul 2005 19:23:45 +0100 |
parents | 57f9005b8844 |
children | efcbd3c1ad15 |
comparison
equal
deleted
inserted
replaced
264:b7dd4c337888 | 265:49e9e02dd6d0 |
---|---|
17 * along with this program; if not, write to the Free Software | 17 * along with this program; if not, write to the Free Software |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
19 * USA | 19 * USA |
20 */ | 20 */ |
21 | 21 |
22 #define _GNU_SOURCE /* for strcasestr() */ | |
22 #include <string.h> | 23 #include <string.h> |
23 | 24 |
24 #include "roster.h" | 25 #include "roster.h" |
25 | 26 |
26 | 27 |
625 { | 626 { |
626 roster *roster_usr = rosterdata; | 627 roster *roster_usr = rosterdata; |
627 return roster_usr->flags; | 628 return roster_usr->flags; |
628 } | 629 } |
629 | 630 |
631 // buddy_search(string) | |
632 // Look for a buddy whose name or jid contains string. | |
633 // Search begins at current_buddy; if no match is found in the the buddylist, | |
634 // return NULL; | |
635 GList *buddy_search(char *string) | |
636 { | |
637 GList *buddy = current_buddy; | |
638 roster *roster_usr; | |
639 if (!buddylist || !current_buddy) return NULL; | |
640 for (;;) { | |
641 buddy = g_list_next(buddy); | |
642 if (!buddy) | |
643 buddy = buddylist; | |
644 | |
645 roster_usr = (roster*)buddy->data; | |
646 if (roster_usr->jid && strcasestr(roster_usr->jid, string)) | |
647 return buddy; | |
648 if (roster_usr->name && strcasestr(roster_usr->name, string)) | |
649 return buddy; | |
650 | |
651 if (buddy == current_buddy) | |
652 return NULL; // Back to the beginning, and no match found | |
653 } | |
654 } | |
655 | |
630 // compl_list(type) | 656 // compl_list(type) |
631 // Returns a list of jid's or groups. (For commands completion) | 657 // Returns a list of jid's or groups. (For commands completion) |
632 // type: ROSTER_TYPE_USER (jid's) or ROSTER_TYPE_GROUP (group names) | 658 // type: ROSTER_TYPE_USER (jid's) or ROSTER_TYPE_GROUP (group names) |
633 // The list should be freed by the caller after use. | 659 // The list should be freed by the caller after use. |
634 GSList *compl_list(guint type) | 660 GSList *compl_list(guint type) |