]>
Commit | Line | Data |
---|---|---|
1 | #include "../lib/sstring.h" | |
2 | #include "../lib/strlfunc.h" | |
3 | #include "../lib/stringbuf.h" | |
4 | #include <stdarg.h> | |
5 | #include <string.h> | |
6 | #include "patriciasearch.h" | |
7 | ||
8 | int ast_nodesearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, NodeDisplayFunc display, HeaderFunc header, void *headerarg, int limit, patricia_node_t *target) { | |
9 | searchCtx ctx; | |
10 | searchASTCache cache; | |
11 | searchNode *search; | |
12 | char buf[1024]; | |
13 | ||
14 | newsearch_ctxinit(&ctx, search_astparse, reply, wall, &cache, reg_nodesearch, sender, display, limit, target); | |
15 | ||
16 | memset(&cache, 0, sizeof(cache)); | |
17 | cache.tree = tree; | |
18 | ||
19 | buf[0] = '\0'; | |
20 | reply(sender, "Parsing: %s", ast_printtree(buf, sizeof(buf), tree, reg_nodesearch)); | |
21 | search = ctx.parser(&ctx, (char *)tree); | |
22 | if(!search) { | |
23 | reply(sender, "Parse error: %s", parseError); | |
24 | return CMD_ERROR; | |
25 | } | |
26 | ||
27 | reply(sender, "Executing..."); | |
28 | if(header) | |
29 | header(sender, headerarg); | |
30 | pnodesearch_exe(search, &ctx, iptree->head); | |
31 | ||
32 | (search->free)(&ctx, search); | |
33 | ||
34 | return CMD_OK; | |
35 | } | |
36 |