]>
Commit | Line | Data |
---|---|---|
e2527cba P |
1 | #include "trusts_newsearch.h" |
2 | ||
3 | #include <stdio.h> | |
4 | #include <stdlib.h> | |
5 | ||
6 | void *tsns_tgid_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); | |
7 | void tsns_tgid_free(searchCtx *ctx, struct searchNode *thenode); | |
8 | ||
9 | struct searchNode *tsns_tgid_parse(searchCtx *ctx, int argc, char **argv) { | |
10 | struct searchNode *thenode; | |
11 | ||
12 | if (!(thenode=(struct searchNode *)malloc(sizeof (struct searchNode)))) { | |
13 | parseError = "malloc: could not allocate memory for this search."; | |
14 | return NULL; | |
15 | } | |
16 | ||
17 | thenode->returntype = RETURNTYPE_INT; | |
18 | thenode->localdata = NULL; | |
19 | thenode->exe = tsns_tgid_exe; | |
20 | thenode->free = tsns_tgid_free; | |
21 | ||
22 | return thenode; | |
23 | } | |
24 | ||
25 | void *tsns_tgid_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) { | |
26 | patricia_node_t *node; | |
27 | trustgroup_t *tg; | |
28 | ||
29 | if (ctx->searchcmd == reg_nodesearch) { | |
30 | node = (patricia_node_t *)theinput; | |
31 | if (node->exts[tgh_ext] != NULL) | |
32 | return (void *)(((trusthost_t *)node->exts[tgh_ext])->trustgroup->id); | |
33 | else | |
34 | return (void *)0; /* will cast to a FALSE */ | |
35 | } else if (ctx->searchcmd == reg_tgsearch) { | |
36 | tg = (trustgroup_t *)theinput; | |
37 | return (void *)(tg->id); | |
38 | } else { | |
39 | return NULL; | |
40 | } | |
41 | ||
42 | } | |
43 | ||
44 | void tsns_tgid_free(searchCtx *ctx, struct searchNode *thenode) { | |
45 | free(thenode); | |
46 | } |