From c279d43b7546f37e93dd6e449b08fdb7335e4dfa Mon Sep 17 00:00:00 2001 From: "B.Greenham" Date: Thu, 25 Feb 2010 19:15:13 -0500 Subject: [PATCH] Add has_common_channel(), which is needed by umode +G. --- include/channel.h | 2 ++ src/channel.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/channel.h b/include/channel.h index b3df6d2..93001a3 100644 --- a/include/channel.h +++ b/include/channel.h @@ -243,6 +243,8 @@ extern void del_invite(struct Channel *chptr, struct Client *who); const char *channel_modes(struct Channel *chptr, struct Client *who); +extern int has_common_channel(struct Client *client1, struct Client *client2); + extern struct Channel *find_bannickchange_channel(struct Client *client_p); extern struct Channel *find_nonickchange_channel(struct Client *client_p); diff --git a/src/channel.c b/src/channel.c index b5994d7..73cd655 100644 --- a/src/channel.c +++ b/src/channel.c @@ -1110,6 +1110,26 @@ set_channel_topic(struct Channel *chptr, const char *topic, const char *topic_in } } +/* has_common_channel() + * + * input - pointer to client + * - pointer to another client + * output - 1 if the two have a channel in common, 0 elsewise + * side effects - none + */ +int +has_common_channel(struct Client *client1, struct Client *client2) +{ + rb_dlink_node *ptr; + + RB_DLINK_FOREACH(ptr, client1->user->channel.head) + { + if(IsMember(client2, ((struct membership *)ptr->data)->chptr)) + return 1; + } + return; +} + /* channel_modes() * * inputs - pointer to channel