X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/blobdiff_plain/0f402ca493cf3e63e2b8f195e7b8c4c9887a8643..8855bb48b449ed06cfd3ce528b3c0a77c37cb24b:/newsearch/ns-and.c?ds=sidebyside diff --git a/newsearch/ns-and.c b/newsearch/ns-and.c index cedb3e8b..2a341c22 100644 --- a/newsearch/ns-and.c +++ b/newsearch/ns-and.c @@ -7,15 +7,15 @@ #include #include -void and_free(struct searchNode *thenode); -void *and_exe(struct searchNode *thenode, int type, void *theinput); +void and_free(searchCtx *ctx, struct searchNode *thenode); +void *and_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); struct and_localdata { int count; searchNode **nodes; }; -struct searchNode *and_parse(int type, int argc, char **argv) { +struct searchNode *and_parse(searchCtx *ctx, int argc, char **argv) { searchNode *thenode, *subnode; struct and_localdata *localdata; int i; @@ -48,11 +48,12 @@ struct searchNode *and_parse(int type, int argc, char **argv) { thenode->free = and_free; for (i=0;iparser(ctx, argv[i]); /* Propogate the search type */ + subnode=coerceNode(ctx, subnode, RETURNTYPE_BOOL); /* Needs to return BOOL */ if (subnode) { localdata->nodes[localdata->count++] = subnode; } else { - and_free(thenode); + and_free(ctx, thenode); /* ?? */ return NULL; } } @@ -60,13 +61,13 @@ struct searchNode *and_parse(int type, int argc, char **argv) { return thenode; } -void and_free(struct searchNode *thenode) { +void and_free(searchCtx *ctx, struct searchNode *thenode) { struct and_localdata *localdata; int i; localdata=thenode->localdata; for (i=0;icount;i++) { - (localdata->nodes[i]->free)(localdata->nodes[i]); + (localdata->nodes[i]->free)(ctx, localdata->nodes[i]); } free(localdata->nodes); @@ -74,36 +75,15 @@ void and_free(struct searchNode *thenode) { free(thenode); } -void *and_exe(struct searchNode *thenode, int type, void *theinput) { +void *and_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) { int i; - void *ret; struct and_localdata *localdata; localdata=thenode->localdata; for (i=0;icount;i++) { - ret = (localdata->nodes[i]->exe)(localdata->nodes[i], RETURNTYPE_BOOL, theinput); - if (ret == NULL) { - switch (type) { - - case RETURNTYPE_INT: - case RETURNTYPE_BOOL: - return NULL; - - case RETURNTYPE_STRING: - return ""; - } - } - } - - switch (type) { - case RETURNTYPE_INT: - case RETURNTYPE_BOOL: - return (void *)1; - - case RETURNTYPE_STRING: - return "1"; + if (!(localdata->nodes[i]->exe)(ctx, localdata->nodes[i], theinput)) + return NULL; } - - return NULL; + return (void *)1; }