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