]> jfr.im git - irc/quakenet/newserv.git/blobdiff - newsearch/ns-age.c
LUA: add function for channel chanop notice
[irc/quakenet/newserv.git] / newsearch / ns-age.c
index 5218d7bf84c6970361164ba2ded7a065df6eb553..9b318371a769fdaf5d11c5110889f7c28e78fd5a 100644 (file)
@@ -1,7 +1,8 @@
 /*
- * quit functionality
+ * age functionality
  */
 
+#include "../irc/irc.h"
 #include "newsearch.h"
 
 #include <stdio.h>
@@ -28,9 +29,17 @@ struct searchNode *age_parse(searchCtx *ctx, int argc, char **argv) {
 
 void *age_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   nick *np = (nick *)theinput;
-  whowas *ww = (whowas *)np->next;
+  whowas *ww;
+  time_t ts;
+
+  if (ctx->searchcmd == reg_nicksearch)
+    ts = np->timestamp;
+  else {
+    ww = (whowas *)np->next;
+    ts = ww->timestamp;
+  }
 
-  return (void *)(getnettime() - ww->timestamp);
+  return (void *)(getnettime() - ts);
 }
 
 void age_free(searchCtx *ctx, struct searchNode *thenode) {