]> jfr.im git - irc/quakenet/newserv.git/blame - trusts2_newsearch/tsns-thlastused.c
Merge.
[irc/quakenet/newserv.git] / trusts2_newsearch / tsns-thlastused.c
CommitLineData
e2527cba
P
1#include "trusts_newsearch.h"
2
3#include <stdio.h>
4#include <stdlib.h>
5
6void *tsns_thlastused_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
7void tsns_thlastused_free(searchCtx *ctx, struct searchNode *thenode);
8
9struct searchNode *tsns_thlastused_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_thlastused_exe;
20 thenode->free = tsns_thlastused_free;
21
22 return thenode;
23}
24
25void *tsns_thlastused_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
26 trusthost_t *th;
27 patricia_node_t *node;
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])->lastused);
33 else
34 return (void *)0; /* will cast to a FALSE */
35 } else if (ctx->searchcmd == reg_thsearch) {
36 th = (trusthost_t *)theinput;
37 return (void *)(th->lastused);
38 } else {
39 return NULL;
40 }
41}
42
43void tsns_thlastused_free(searchCtx *ctx, struct searchNode *thenode) {
44 free(thenode);
45}