65 |
|
*/ |
66 |
|
void |
67 |
|
add_user_to_channel(struct Channel *chptr, struct Client *client_p, |
68 |
< |
unsigned int flags, int flood_ctrl) |
68 |
> |
unsigned int flags, bool flood_ctrl) |
69 |
|
{ |
70 |
|
assert(IsClient(client_p)); |
71 |
|
|
72 |
|
if (GlobalSetOptions.joinfloodtime) |
73 |
|
{ |
74 |
< |
if (flood_ctrl) |
74 |
> |
if (flood_ctrl == true) |
75 |
|
++chptr->number_joined; |
76 |
|
|
77 |
|
chptr->number_joined -= (CurrentTime - chptr->last_join_time) * |
611 |
|
* \param list Pointer to ban list to search |
612 |
|
* \return 1 if ban found for given n!u\@h mask, 0 otherwise |
613 |
|
*/ |
614 |
< |
static int |
614 |
> |
static bool |
615 |
|
find_bmask(const struct Client *client_p, const dlink_list *list) |
616 |
|
{ |
617 |
|
dlink_node *node; |
626 |
|
{ |
627 |
|
case HM_HOST: |
628 |
|
if (!match(ban->host, client_p->host) || !match(ban->host, client_p->sockhost)) |
629 |
< |
return 1; |
629 |
> |
return true; |
630 |
|
break; |
631 |
|
case HM_IPV4: |
632 |
|
if (client_p->ip.ss.ss_family == AF_INET) |
633 |
|
if (match_ipv4(&client_p->ip, &ban->addr, ban->bits)) |
634 |
< |
return 1; |
634 |
> |
return true; |
635 |
|
break; |
636 |
|
case HM_IPV6: |
637 |
|
if (client_p->ip.ss.ss_family == AF_INET6) |
638 |
|
if (match_ipv6(&client_p->ip, &ban->addr, ban->bits)) |
639 |
< |
return 1; |
639 |
> |
return true; |
640 |
|
break; |
641 |
|
default: |
642 |
|
assert(0); |
644 |
|
} |
645 |
|
} |
646 |
|
|
647 |
< |
return 0; |
647 |
> |
return false; |
648 |
|
} |
649 |
|
|
650 |
|
/*! |
652 |
|
* \param client_p Pointer to client to check access fo |
653 |
|
* \return 0 if not banned, 1 otherwise |
654 |
|
*/ |
655 |
< |
int |
655 |
> |
bool |
656 |
|
is_banned(const struct Channel *chptr, const struct Client *client_p) |
657 |
|
{ |
658 |
< |
if (find_bmask(client_p, &chptr->banlist)) |
659 |
< |
if (!find_bmask(client_p, &chptr->exceptlist)) |
660 |
< |
return 1; |
658 |
> |
if (find_bmask(client_p, &chptr->banlist) == true) |
659 |
> |
if (find_bmask(client_p, &chptr->exceptlist) == false) |
660 |
> |
return true; |
661 |
|
|
662 |
< |
return 0; |
662 |
> |
return false; |
663 |
|
} |
664 |
|
|
665 |
|
/*! Tests if a client can join a certain channel |
683 |
|
|
684 |
|
if (HasCMode(chptr, MODE_INVITEONLY)) |
685 |
|
if (!find_invite(chptr, client_p)) |
686 |
< |
if (!find_bmask(client_p, &chptr->invexlist)) |
686 |
> |
if (find_bmask(client_p, &chptr->invexlist) == false) |
687 |
|
return ERR_INVITEONLYCHAN; |
688 |
|
|
689 |
|
if (chptr->mode.key[0] && (!key || strcmp(chptr->mode.key, key))) |
693 |
|
chptr->mode.limit) |
694 |
|
return ERR_CHANNELISFULL; |
695 |
|
|
696 |
< |
if (is_banned(chptr, client_p)) |
696 |
> |
if (is_banned(chptr, client_p) == true) |
697 |
|
return ERR_BANNEDFROMCHAN; |
698 |
|
|
699 |
|
return 0; |
817 |
|
|
818 |
|
if (!(member->flags & CHFL_BAN_CHECKED)) |
819 |
|
{ |
820 |
< |
if (is_banned(chptr, client_p)) |
820 |
> |
if (is_banned(chptr, client_p) == true) |
821 |
|
{ |
822 |
|
member->flags |= (CHFL_BAN_CHECKED | CHFL_BAN_SILENCED); |
823 |
|
return ERR_CANNOTSENDTOCHAN; |
826 |
|
member->flags |= CHFL_BAN_CHECKED; |
827 |
|
} |
828 |
|
} |
829 |
< |
else if (is_banned(chptr, client_p)) |
829 |
> |
else if (is_banned(chptr, client_p) == true) |
830 |
|
return ERR_CANNOTSENDTOCHAN; |
831 |
|
} |
832 |
|
|
990 |
|
if (!HasUMode(client_p, UMODE_OPER)) |
991 |
|
check_spambot_warning(client_p, chptr->name); |
992 |
|
|
993 |
< |
add_user_to_channel(chptr, client_p, flags, 1); |
993 |
> |
add_user_to_channel(chptr, client_p, flags, true); |
994 |
|
|
995 |
|
/* |
996 |
|
* Set timestamp if appropriate, and propagate |