]> jfr.im git - irc/quakenet/newserv.git/blobdiff - newsearch/ns-oppct.c
LUA: add function for channel chanop notice
[irc/quakenet/newserv.git] / newsearch / ns-oppct.c
index 438403a3a8816d430907ec5614032c4401eeb5be..7533b8b7f1da6eccf69b5a49d418e456e3f68276 100644 (file)
@@ -7,17 +7,12 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-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;i<cip->channel->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);
 }