]> jfr.im git - irc/quakenet/newserv.git/blame - newsearch/ns-timestamp.c
Merge pull request #132 from retropc/lua_country
[irc/quakenet/newserv.git] / newsearch / ns-timestamp.c
CommitLineData
f1903ace
CP
1/*
2 * TIMESTAMP functionality
3 */
4
5#include "newsearch.h"
6
7#include <stdio.h>
8#include <stdlib.h>
9
10#include "../irc/irc_config.h"
f1903ace
CP
11#include "../lib/irc_string.h"
12
c8be5183
CP
13void *timestamp_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
14void timestamp_free(searchCtx *ctx, struct searchNode *thenode);
f1903ace 15
f33f3f52 16struct searchNode *timestamp_parse(searchCtx *ctx, int argc, char **argv) {
f1903ace
CP
17 struct searchNode *thenode;
18
9ce4f0be
IB
19 if (!(thenode=(struct searchNode *)malloc(sizeof (struct searchNode)))) {
20 parseError = "malloc: could not allocate memory for this search.";
21 return NULL;
22 }
f1903ace
CP
23
24 thenode->returntype = RETURNTYPE_INT;
25 thenode->localdata = NULL;
26 thenode->exe = timestamp_exe;
27 thenode->free = timestamp_free;
28
29 return thenode;
30}
31
c8be5183 32void *timestamp_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
f1903ace 33 nick *np = (nick *)theinput;
4354c087 34 chanindex *cip = (chanindex *)theinput;
0a0cd49a 35
0eb4cbd3 36 if (ctx->searchcmd == reg_nicksearch || ctx->searchcmd == reg_whowassearch) {
4354c087 37 return (void *)np->timestamp;
38 } else {
39 if (cip->channel)
40 return (void *)cip->channel->timestamp;
41 else
42 return 0;
43 }
f1903ace
CP
44}
45
c8be5183 46void timestamp_free(searchCtx *ctx, struct searchNode *thenode) {
f1903ace
CP
47 free(thenode);
48}