]> jfr.im git - irc/quakenet/newserv.git/blame - trusts2_newsearch/tsns-tglastused.c
Merge.
[irc/quakenet/newserv.git] / trusts2_newsearch / tsns-tglastused.c
CommitLineData
e2527cba
P
1#include "trusts_newsearch.h"
2
3#include <stdio.h>
4#include <stdlib.h>
5
6void *tsns_tglastused_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
7void tsns_tglastused_free(searchCtx *ctx, struct searchNode *thenode);
8
9struct searchNode *tsns_tglastused_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_tglastused_exe;
20 thenode->free = tsns_tglastused_free;
21
22 return thenode;
23}
24
25void *tsns_tglastused_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
26 trustgroup_t *tg;
27 patricia_node_t *node = (patricia_node_t *)theinput;
28
29 if (ctx->searchcmd == reg_nodesearch) {
30 if (node->exts[tgh_ext] != NULL)
31 return (void *)(((trusthost_t *)node->exts[tgh_ext])->trustgroup->lastused);
32 else
33 return (void *)0; /* will cast to a FALSE */
34 } else if (ctx->searchcmd == reg_tgsearch) {
35 tg = (trustgroup_t *)theinput;
36 return (void *)(tg->lastused);
37 } else {
38 return NULL;
39 }
40}
41
42void tsns_tglastused_free(searchCtx *ctx, struct searchNode *thenode) {
43 free(thenode);
44}