X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/blobdiff_plain/ec6c86c867cc10c723668a50381cbc0b2c4c34b4..8855bb48b449ed06cfd3ce528b3c0a77c37cb24b:/newsearch/ns-size.c diff --git a/newsearch/ns-size.c b/newsearch/ns-size.c index 231d6156..12e5acbd 100644 --- a/newsearch/ns-size.c +++ b/newsearch/ns-size.c @@ -7,62 +7,35 @@ #include #include -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); } -