]> jfr.im git - irc/quakenet/newserv.git/blobdiff - newsearch/ns-size.c
Remove test #ifs around the GL commands.
[irc/quakenet/newserv.git] / newsearch / ns-size.c
index 231d615664515561336aa4472d2d924a51c79a7c..12e5acbd1cef69c391a2de3cc3a8753761806a46 100644 (file)
@@ -7,62 +7,35 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-struct size_localdata {
-  long count;
-};
+void *size_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void size_free(searchCtx *ctx, struct searchNode *thenode);
 
-void *size_exe(struct searchNode *thenode, int type, void *theinput);
-void size_free(struct searchNode *thenode);
-
-struct searchNode *size_parse(int type, int argc, char **argv) {
-  struct size_localdata *localdata;
+struct searchNode *size_parse(searchCtx *ctx, int argc, char **argv) {
   struct searchNode *thenode;
 
-  if (type != SEARCHTYPE_CHANNEL) {
-    parseError = "size: this function is only valid for channel searches.";
-    return NULL;
-  }
-
-  if (argc!=1) {
-    parseError="size: usage: (size number)";
-    return NULL;
-  }
-
-  if (!(localdata=(struct size_localdata *)malloc(sizeof(struct size_localdata)))) {
-    parseError = "malloc: could not allocate memory for this search.";
-    return NULL;
-  }
-
-  localdata->count = strtoul(argv[0],NULL,10);
-
   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.";
-    free(localdata);
     return NULL;
   }
 
-  thenode->returntype = RETURNTYPE_BOOL;
-  thenode->localdata = localdata;
+  thenode->returntype = RETURNTYPE_INT;
+  thenode->localdata = NULL;
   thenode->exe = size_exe;
   thenode->free = size_free;
 
   return thenode;
 }
 
-void *size_exe(struct searchNode *thenode, int type, void *theinput) {
+void *size_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   chanindex *cip = (chanindex *)theinput;
-  struct size_localdata *localdata;
-
-  localdata = thenode->localdata;
   
-  if ((cip->channel==NULL) || (cip->channel->users->totalusers < localdata->count))
-    return falseval(type);
-  return trueval(type);
+  if (cip->channel==NULL)
+    return (void *)0;
+  
+  return (void *)((unsigned long)cip->channel->users->totalusers);
 }
 
-void size_free(struct searchNode *thenode) {
-  free(thenode->localdata);
+void size_free(searchCtx *ctx, struct searchNode *thenode) {
   free(thenode);
 }
-