#include "../irc/irc_config.h"
#include "../lib/irc_string.h"
-void *timestamp_exe(struct searchNode *thenode, 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 type, int argc, char **argv) {
struct searchNode *thenode;
- if (type != SEARCHTYPE_NICK) {
- parseError = "timestamp: this function is only valid for nick searches.";
+ if ((type != SEARCHTYPE_NICK) && (type != SEARCHTYPE_CHANNEL)){
+ parseError = "timestamp: this function is only valid for nick or channel searches.";
return NULL;
}
}
thenode->returntype = RETURNTYPE_INT;
- thenode->localdata = NULL;
+ thenode->localdata = (void *)type;
thenode->exe = timestamp_exe;
thenode->free = timestamp_free;
return thenode;
}
-void *timestamp_exe(struct searchNode *thenode, void *theinput) {
+void *timestamp_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
nick *np = (nick *)theinput;
-
- return (void *)np->timestamp;
+ chanindex *cip = (chanindex *)theinput;
+
+ if ((int)thenode->localdata == SEARCHTYPE_NICK) {
+ 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);
}