]> jfr.im git - irc/quakenet/newserv.git/blame - newsearch/ns-size.c
newsearch changes to support addition of trust_search/patriciasearch
[irc/quakenet/newserv.git] / newsearch / ns-size.c
CommitLineData
24f0affb
IB
1/*
2 * size functionality
3 */
4
5#include "newsearch.h"
6
7#include <stdio.h>
8#include <stdlib.h>
9
c8be5183
CP
10void *size_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
11void size_free(searchCtx *ctx, struct searchNode *thenode);
24f0affb 12
f33f3f52 13struct searchNode *size_parse(searchCtx *ctx, int argc, char **argv) {
24f0affb
IB
14 struct searchNode *thenode;
15
24f0affb
IB
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.";
24f0affb
IB
19 return NULL;
20 }
21
c7f7a584 22 thenode->returntype = RETURNTYPE_INT;
23 thenode->localdata = NULL;
24f0affb
IB
24 thenode->exe = size_exe;
25 thenode->free = size_free;
26
27 return thenode;
28}
29
c8be5183 30void *size_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
24f0affb 31 chanindex *cip = (chanindex *)theinput;
24f0affb 32
c7f7a584 33 if (cip->channel==NULL)
34 return (void *)0;
35
36 return (void *)((unsigned long)cip->channel->users->totalusers);
24f0affb
IB
37}
38
c8be5183 39void size_free(searchCtx *ctx, struct searchNode *thenode) {
24f0affb
IB
40 free(thenode);
41}