]>
jfr.im git - irc/quakenet/newserv.git/blob - newsearch/ns-eq.c
12 struct searchNode
**nodes
;
15 void eq_free(struct searchNode
*thenode
);
16 void *eq_exe(struct searchNode
*thenode
, int type
, void *theinput
);
18 struct searchNode
*eq_parse(int type
, int argc
, char **argv
) {
19 struct eq_localdata
*localdata
;
20 struct searchNode
*thenode
;
23 localdata
= (struct eq_localdata
*)malloc(sizeof(struct eq_localdata
));
24 localdata
->nodes
= (struct searchNode
**)malloc(sizeof(struct searchNode
*) * argc
);
27 thenode
= (struct searchNode
*)malloc(sizeof(struct searchNode
));
29 thenode
->localdata
= localdata
;
30 thenode
->returntype
= RETURNTYPE_BOOL
;
31 thenode
->exe
= eq_exe
;
32 thenode
->free
= eq_free
;
34 for (i
=0;i
<argc
;i
++) {
35 if (!(localdata
->nodes
[i
] = search_parse(type
, argv
[i
]))) {
45 void eq_free(struct searchNode
*thenode
) {
46 struct eq_localdata
*localdata
;
49 localdata
=thenode
->localdata
;
51 for (i
=0;i
<localdata
->count
;i
++) {
52 (localdata
->nodes
[i
]->free
)(localdata
->nodes
[i
]);
55 free(localdata
->nodes
);
60 void *eq_exe(struct searchNode
*thenode
, int type
, void *theinput
) {
65 struct eq_localdata
*localdata
;
67 localdata
=thenode
->localdata
;
69 if (localdata
->count
==0)
72 switch (localdata
->nodes
[0]->returntype
& RETURNTYPE_TYPE
) {
74 intval
= (int)(localdata
->nodes
[0]->exe
)(localdata
->nodes
[0], RETURNTYPE_INT
, theinput
);
75 for (i
=1;i
<localdata
->count
;i
++) {
76 if ((int)(localdata
->nodes
[i
]->exe
)(localdata
->nodes
[i
], RETURNTYPE_INT
, theinput
) != intval
)
77 return falseval(type
);
83 intval
= (int)(localdata
->nodes
[0]->exe
)(localdata
->nodes
[0], RETURNTYPE_BOOL
, theinput
);
84 for (i
=1;i
<localdata
->count
;i
++) {
85 rval
=(int)(localdata
->nodes
[i
]->exe
)(localdata
->nodes
[i
], RETURNTYPE_BOOL
, theinput
);
86 if ((rval
&& !intval
) || (!rval
&& intval
)) { /* LOGICAL XOR GOES HERE FS */
87 return falseval(type
);
93 case RETURNTYPE_STRING
:
94 strval
= (char *)(localdata
->nodes
[0]->exe
)(localdata
->nodes
[0], RETURNTYPE_STRING
, theinput
);
95 for (i
=1;i
<localdata
->count
;i
++) {
96 if (ircd_strcmp(strval
, (char *)(localdata
->nodes
[i
]->exe
)(localdata
->nodes
[i
], RETURNTYPE_STRING
, theinput
)))
97 return falseval(type
);
100 return trueval(type
);
103 return falseval(type
);