]>
jfr.im git - irc/quakenet/newserv.git/blob - newsearch/ns-hostpct.c
2 * hostpct functionality
10 void *hostpct_exe(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
);
11 void hostpct_free(searchCtx
*ctx
, struct searchNode
*thenode
);
13 struct searchNode
*hostpct_parse(searchCtx
*ctx
, int argc
, char **argv
) {
14 struct searchNode
*thenode
;
16 if (!(thenode
=(struct searchNode
*)malloc(sizeof(struct searchNode
)))) {
17 /* couldn't malloc() memory for thenode, so free localdata to avoid leakage */
18 parseError
= "malloc: could not allocate memory for this search.";
22 thenode
->returntype
= RETURNTYPE_INT
;
23 thenode
->localdata
= NULL
;
24 thenode
->exe
= hostpct_exe
;
25 thenode
->free
= hostpct_free
;
30 void *hostpct_exe(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
) {
35 chanindex
*cip
= (chanindex
*)theinput
;
37 if (cip
->channel
==NULL
)
40 marker
=nexthostmarker();
42 for (i
=0;i
<cip
->channel
->users
->hashsize
;i
++) {
43 if (cip
->channel
->users
->content
[i
]==nouser
)
46 if (!(np
=getnickbynumeric(cip
->channel
->users
->content
[i
])))
49 if (np
->host
->marker
!=marker
) {
51 np
->host
->marker
=marker
;
55 return (void *)(long)((hosts
* 100)/cip
->channel
->users
->totalusers
);
58 void hostpct_free(searchCtx
*ctx
, struct searchNode
*thenode
) {