X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/blobdiff_plain/26cbd0999d84e80dc93d01bc7cc432b00c1b3f06..78546f2b0f59b5c8fede1ce5535972716eb17041:/newsearch/ns-timestamp.c diff --git a/newsearch/ns-timestamp.c b/newsearch/ns-timestamp.c index 97cdd79b..31894266 100644 --- a/newsearch/ns-timestamp.c +++ b/newsearch/ns-timestamp.c @@ -8,23 +8,19 @@ #include #include "../irc/irc_config.h" -#include "../nick/nick.h" #include "../lib/irc_string.h" -void *timestamp_exe(struct searchNode *thenode, int type, void *theinput); -void *timestamp_exe_real(struct searchNode *thenode, int type, void *theinput); -void timestamp_free(struct searchNode *thenode); +void *timestamp_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); +void timestamp_free(searchCtx *ctx, struct searchNode *thenode); -struct searchNode *timestamp_parse(int type, int argc, char **argv) { +struct searchNode *timestamp_parse(searchCtx *ctx, int argc, char **argv) { struct searchNode *thenode; - if (type != SEARCHTYPE_NICK) { - parseError = "timestamp: this function is only valid for nick searches."; + if (!(thenode=(struct searchNode *)malloc(sizeof (struct searchNode)))) { + parseError = "malloc: could not allocate memory for this search."; return NULL; } - thenode=(struct searchNode *)malloc(sizeof (struct searchNode)); - thenode->returntype = RETURNTYPE_INT; thenode->localdata = NULL; thenode->exe = timestamp_exe; @@ -33,15 +29,20 @@ struct searchNode *timestamp_parse(int type, int argc, char **argv) { return thenode; } -void *timestamp_exe(struct searchNode *thenode, int type, void *theinput) { +void *timestamp_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) { nick *np = (nick *)theinput; - - if (type != RETURNTYPE_INT) - return (void *)1; - - return (void *)np->timestamp; + chanindex *cip = (chanindex *)theinput; + + if (ctx->searchcmd == reg_nicksearch) { + return (void *)np->timestamp; + } else { + if (cip->channel) + return (void *)cip->channel->timestamp; + else + return 0; + } } -void timestamp_free(struct searchNode *thenode) { +void timestamp_free(searchCtx *ctx, struct searchNode *thenode) { free(thenode); }