#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"
#include "s_misc.h"
#include "s_user.h"
#include "send.h"
-#include "sprintf_irc.h"
#include "struct.h"
#include "support.h"
#include "sys.h"
strcat(p1, sptr == acptr ? "0" : "3");
p1++;
#else
- p1 = sprintf_irc(p1, "%d", cli_hopcount(acptr));
+ /* three digit hopcount maximum */
+ p1 += ircd_snprintf(0, p1, 3, "%d", cli_hopcount(acptr));
#endif
}
{
*p1++ = ' ';
if (MyUser(acptr)) {
- p1 = sprintf_irc(p1, "%d", CurrentTime - cli_user(acptr)->last);
+ p1 += ircd_snprintf(0, p1, 11, "%d",
+ CurrentTime - cli_user(acptr)->last);
}
else {
*p1++ = '0';
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;
+}