]>
jfr.im git - irc/quakenet/newserv.git/blob - newsearch/ns-authedpct.c
2 * authedpct functionality
10 void *authedpct_exe(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
);
11 void authedpct_free(searchCtx
*ctx
, struct searchNode
*thenode
);
13 struct searchNode
*authedpct_parse(searchCtx
*ctx
, int type
, int argc
, char **argv
) {
14 struct searchNode
*thenode
;
16 if (type
!= SEARCHTYPE_CHANNEL
) {
17 parseError
= "authedpct: this function is only valid for channel searches.";
21 if (!(thenode
=(struct searchNode
*)malloc(sizeof(struct searchNode
)))) {
22 /* couldn't malloc() memory for thenode, so free localdata to avoid leakage */
23 parseError
= "malloc: could not allocate memory for this search.";
27 thenode
->returntype
= RETURNTYPE_INT
;
28 thenode
->localdata
= NULL
;
29 thenode
->exe
= authedpct_exe
;
30 thenode
->free
= authedpct_free
;
35 void *authedpct_exe(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
) {
39 chanindex
*cip
= (chanindex
*)theinput
;
40 struct authedpct_localdata
*localdata
;
42 localdata
= thenode
->localdata
;
47 for (i
=0;i
<cip
->channel
->users
->hashsize
;i
++) {
48 if (cip
->channel
->users
->content
[i
]==nouser
)
51 if ((np
=getnickbynumeric(cip
->channel
->users
->content
[i
])) && IsAccount(np
))
55 return (void *)(long)((j
* 100) / cip
->channel
->users
->totalusers
);
58 void authedpct_free(searchCtx
*ctx
, struct searchNode
*thenode
) {