X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/blobdiff_plain/c7f7a584fd6c8ee4a0ede6e79e8ce2177ab863f0..78546f2b0f59b5c8fede1ce5535972716eb17041:/newsearch/ns-oppct.c?ds=inline diff --git a/newsearch/ns-oppct.c b/newsearch/ns-oppct.c index 438403a3..7533b8b7 100644 --- a/newsearch/ns-oppct.c +++ b/newsearch/ns-oppct.c @@ -7,17 +7,12 @@ #include #include -void *oppct_exe(struct searchNode *thenode, void *theinput); -void oppct_free(struct searchNode *thenode); +void *oppct_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); +void oppct_free(searchCtx *ctx, struct searchNode *thenode); -struct searchNode *oppct_parse(int type, int argc, char **argv) { +struct searchNode *oppct_parse(searchCtx *ctx, int argc, char **argv) { struct searchNode *thenode; - if (type != SEARCHTYPE_CHANNEL) { - parseError = "oppct: this function is only valid for channel searches."; - return NULL; - } - if (!(thenode=(struct searchNode *)malloc(sizeof(struct searchNode)))) { /* couldn't malloc() memory for thenode, so free localdata to avoid leakage */ parseError = "malloc: could not allocate memory for this search."; @@ -32,7 +27,7 @@ struct searchNode *oppct_parse(int type, int argc, char **argv) { return thenode; } -void *oppct_exe(struct searchNode *thenode, void *theinput) { +void *oppct_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) { int i; int ops; chanindex *cip = (chanindex *)theinput; @@ -44,16 +39,17 @@ void *oppct_exe(struct searchNode *thenode, void *theinput) { for (i=0;ichannel->users->hashsize;i++) { if (cip->channel->users->content[i]!=nouser) { - if (!(cip->channel->users->content[i] & CUMODE_OP)) { + if (cip->channel->users->content[i] & CUMODE_OP) { ops++; } } } - return (void *)((ops * 100) / cip->channel->users->totalusers); + return (void *)(long)((ops * 100) / cip->channel->users->totalusers); } -void oppct_free(struct searchNode *thenode) { +void oppct_free(searchCtx *ctx, struct searchNode *thenode) { + ctx->reply(senderNSExtern, "Notice: oppct is deprecated by cumodepct"); free(thenode); }