]>
jfr.im git - irc/quakenet/newserv.git/blob - newsearch/ns-and.c
10 void and_free(struct searchNode
*thenode
);
11 void *and_exe(struct searchNode
*thenode
, int type
, void *theinput
);
13 struct and_localdata
{
18 struct searchNode
*and_parse(int type
, int argc
, char **argv
) {
19 searchNode
*thenode
, *subnode
;
20 struct and_localdata
*localdata
;
23 /* Set up our local data - a list of nodes to AND together */
24 localdata
=(struct and_localdata
*)malloc(sizeof(struct and_localdata
));
25 localdata
->nodes
=(searchNode
**)malloc(argc
* sizeof(searchNode
*));
28 /* Allocate our actual node */
29 thenode
=(searchNode
*)malloc(sizeof(searchNode
));
31 thenode
->returntype
= RETURNTYPE_BOOL
;
32 thenode
->localdata
= localdata
;
33 thenode
->exe
= and_exe
;
34 thenode
->free
= and_free
;
36 for (i
=0;i
<argc
;i
++) {
37 subnode
=search_parse(type
, argv
[i
]); /* Propogate the search type */
39 localdata
->nodes
[localdata
->count
++] = subnode
;
49 void and_free(struct searchNode
*thenode
) {
50 struct and_localdata
*localdata
;
53 localdata
=thenode
->localdata
;
54 for (i
=0;i
<localdata
->count
;i
++) {
55 (localdata
->nodes
[i
]->free
)(localdata
->nodes
[i
]);
58 free(localdata
->nodes
);
63 void *and_exe(struct searchNode
*thenode
, int type
, void *theinput
) {
66 struct and_localdata
*localdata
;
68 localdata
=thenode
->localdata
;
70 for (i
=0;i
<localdata
->count
;i
++) {
71 ret
= (localdata
->nodes
[i
]->exe
)(localdata
->nodes
[i
], RETURNTYPE_BOOL
, theinput
);
79 case RETURNTYPE_STRING
:
90 case RETURNTYPE_STRING
: