]>
jfr.im git - irc/quakenet/newserv.git/blob - countusers/countusers.c
1 #include "../control/control.h"
2 #include "../nick/nick.h"
3 #include "../channel/channel.h"
4 #include "../lib/irc_string.h"
7 int do_countusers(void *source
, int cargc
, char **cargv
) {
8 nick
*sender
=(nick
*)source
, *np
;
10 unsigned int i
=0,count
=0;
11 char *chp
,*host
,*ident
;
14 controlreply(sender
, "Usage: countusers <user@host or host>");
18 for (chp
=cargv
[0]; ;chp
++) {
20 /* found @, so it's user@host */
25 } else if (*chp
=='\0') {
26 /* found NULL, so just host */
33 if ((hp
=findhost(host
))==NULL
) {
34 controlreply(sender
,"0 users match %s%s%s",ident
?ident
:"",ident
?"@":"",host
);
39 /* We want *@host, so it's just the clonecount we have for free */
40 controlreply(sender
,"%d users match %s",hp
->clonecount
,host
);
42 /* Do it the slow way */
43 for (np
=hp
->nicks
;np
;np
=np
->nextbyhost
) {
44 if (!ircd_strcmp(np
->ident
,ident
))
47 controlreply(sender
,"%d users match %s@%s",count
,ident
,host
);
54 registercontrolcmd("countusers", 10, 1, do_countusers
);
58 deregistercontrolcmd("countusers", do_countusers
);