X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=ircd%2Fwhocmds.c;h=39a9bc7507a0b1a1e0e1a5b81612db39ab55d83b;hb=037ea5b9ceaec42f9000cd6d3c47e548fd472d31;hp=26c12d4e2507a2a3646e322507bae183f6ed0b54;hpb=ebd77a83f3ddfc6e7951b747acc2851bcfc19f16;p=ircu2.10.12-pk.git diff --git a/ircd/whocmds.c b/ircd/whocmds.c index 26c12d4..39a9bc7 100644 --- a/ircd/whocmds.c +++ b/ircd/whocmds.c @@ -32,6 +32,7 @@ #include "ircd_chattr.h" #include "ircd_policy.h" #include "ircd_reply.h" +#include "ircd_snprintf.h" #include "ircd_string.h" #include "list.h" #include "match.h" @@ -231,3 +232,26 @@ void do_who(struct Client* sptr, struct Client* acptr, struct Channel* repchan, send_reply(sptr, fields ? RPL_WHOSPCRPL : RPL_WHOREPLY, ++p1); } +int +count_users(char *mask) +{ + struct Client *acptr; + int count = 0; + char namebuf[USERLEN + HOSTLEN + 2]; + char ipbuf[USERLEN + 16 + 2]; + + for (acptr = GlobalClientList; acptr; acptr = cli_next(acptr)) { + if (!IsUser(acptr)) + continue; + + ircd_snprintf(0, namebuf, sizeof(namebuf), "%s@%s", + cli_user(acptr)->username, cli_user(acptr)->host); + ircd_snprintf(0, ipbuf, sizeof(ipbuf), "%s@%s", cli_user(acptr)->username, + ircd_ntoa((const char *) &(cli_ip(acptr)))); + + if (!match(mask, namebuf) || !match(mask, ipbuf)) + count++; + } + + return count; +}