]>
jfr.im git - irc/quakenet/newserv.git/blob - newsearch/ns-or.c
10 void or_free(struct searchNode
*thenode
);
11 void *or_exe(struct searchNode
*thenode
, int type
, void *theinput
);
18 struct searchNode
*or_parse(int type
, int argc
, char **argv
) {
19 searchNode
*thenode
, *subnode
;
20 struct or_localdata
*localdata
;
23 /* Set up our local data - a list of nodes to OR together */
24 localdata
=(struct or_localdata
*)malloc(sizeof(struct or_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
= or_exe
;
34 thenode
->free
= or_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 or_free(struct searchNode
*thenode
) {
50 struct or_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 *or_exe(struct searchNode
*thenode
, int type
, void *theinput
) {
66 struct or_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
);
74 case RETURNTYPE_STRING
:
86 case RETURNTYPE_STRING
: