]>
jfr.im git - irc/quakenet/newserv.git/blob - newsearch/ns-oppct.c
10 void *oppct_exe(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
);
11 void oppct_free(searchCtx
*ctx
, struct searchNode
*thenode
);
13 struct searchNode
*oppct_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
= oppct_exe
;
25 thenode
->free
= oppct_free
;
30 void *oppct_exe(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
) {
33 chanindex
*cip
= (chanindex
*)theinput
;
35 if (cip
->channel
==NULL
|| cip
->channel
->users
->totalusers
==0)
40 for (i
=0;i
<cip
->channel
->users
->hashsize
;i
++) {
41 if (cip
->channel
->users
->content
[i
]!=nouser
) {
42 if (!(cip
->channel
->users
->content
[i
] & CUMODE_OP
)) {
48 return (void *)(long)((ops
* 100) / cip
->channel
->users
->totalusers
);
51 void oppct_free(searchCtx
*ctx
, struct searchNode
*thenode
) {