.PHONY: all
all: newsearch.so
-newsearch.so: newsearch.o ns-not.o ns-and.o ns-or.o ns-eq.o ns-match.o ns-hostmask.o ns-realname.o ns-modes.o ns-nick.o ns-ident.o ns-regex.o ns-host.o ns-channel.o
+newsearch.so: newsearch.o ns-not.o ns-and.o ns-or.o ns-eq.o ns-match.o ns-hostmask.o ns-realname.o ns-modes.o ns-nick.o ns-ident.o ns-regex.o ns-host.o ns-channel.o ns-lt.o ns-gt.o ns-timestamp.o
ld -shared -Bdynamic $(LIBPCRE) -o $@ $^
registersearchterm("and",and_parse);
registersearchterm("not",not_parse);
registersearchterm("or",or_parse);
-
+
registersearchterm("eq",eq_parse);
+
+ registersearchterm("lt",lt_parse);
+ registersearchterm("gt",gt_parse);
/* String operations */
registersearchterm("match",match_parse);
registersearchterm("ident",ident_parse);
registersearchterm("host",host_parse);
registersearchterm("channel",channel_parse);
+ registersearchterm("timestamp",timestamp_parse);
/* Nickname / channel operations */
registersearchterm("modes",modes_parse);
struct searchNode *not_parse(int type, int argc, char **argv);
struct searchNode *or_parse(int type, int argc, char **argv);
struct searchNode *eq_parse(int type, int argc, char **argv);
+struct searchNode *lt_parse(int type, int argc, char **argv);
+struct searchNode *gt_parse(int type, int argc, char **argv);
struct searchNode *match_parse(int type, int argc, char **argv);
struct searchNode *regex_parse(int type, int argc, char **argv);
struct searchNode *hostmask_parse(int type, int argc, char **argv);
struct searchNode *ident_parse(int type, int argc, char **argv);
struct searchNode *host_parse(int type, int argc, char **argv);
struct searchNode *channel_parse(int type, int argc, char **argv);
+struct searchNode *timestamp_parse(int type, int argc, char **argv);
struct searchNode *search_parse(int type, char *input);
--- /dev/null
+/*
+ * GT functionality
+ */
+
+#include "newsearch.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+struct gt_localdata {
+ int count;
+ struct searchNode **nodes;
+};
+
+void gt_free(struct searchNode *thenode);
+void *gt_exe(struct searchNode *thenode, int type, void *theinput);
+
+struct searchNode *gt_parse(int type, int argc, char **argv) {
+ struct gt_localdata *localdata;
+ struct searchNode *thenode;
+ int i;
+
+ localdata = (struct gt_localdata *)malloc(sizeof(struct gt_localdata));
+ localdata->nodes = (struct searchNode **)malloc(sizeof(struct searchNode *) * argc);
+ localdata->count = 0;
+
+ thenode = (struct searchNode *)malloc(sizeof(struct searchNode));
+
+ thenode->localdata = localdata;
+ thenode->returntype = RETURNTYPE_BOOL;
+ thenode->exe = gt_exe;
+ thenode->free = gt_free;
+
+ for (i=0;i<argc;i++) {
+ if (!(localdata->nodes[i] = search_parse(type, argv[i]))) {
+ gt_free(thenode);
+ return NULL;
+ }
+ localdata->count++;
+ }
+
+ return thenode;
+}
+
+void gt_free(struct searchNode *thenode) {
+ struct gt_localdata *localdata;
+ int i;
+
+ localdata=thenode->localdata;
+
+ for (i=0;i<localdata->count;i++) {
+ (localdata->nodes[i]->free)(localdata->nodes[i]);
+ }
+
+ free(localdata->nodes);
+ free(localdata);
+ free(thenode);
+}
+
+void *gt_exe(struct searchNode *thenode, int type, void *theinput) {
+ int i;
+ char *strval;
+ int intval;
+ int rval;
+ struct gt_localdata *localdata;
+
+ localdata=thenode->localdata;
+
+ if (localdata->count==0)
+ return trueval(type);
+
+ switch (localdata->nodes[0]->returntype & RETURNTYPE_TYPE) {
+ case RETURNTYPE_INT:
+ intval = (int)(localdata->nodes[0]->exe)(localdata->nodes[0], RETURNTYPE_INT, theinput);
+ for (i=1;i<localdata->count;i++) {
+ if ((int)(localdata->nodes[i]->exe)(localdata->nodes[i], RETURNTYPE_INT, theinput) > intval)
+ return falseval(type);
+ }
+
+ return trueval(type);
+
+ case RETURNTYPE_STRING:
+ strval = (char *)(localdata->nodes[0]->exe)(localdata->nodes[0], RETURNTYPE_STRING, theinput);
+ for (i=1;i<localdata->count;i++) {
+ if (ircd_strcmp(strval, (char *)(localdata->nodes[i]->exe)(localdata->nodes[i], RETURNTYPE_STRING, theinput)) > 0)
+ return falseval(type);
+ }
+
+ return trueval(type);
+
+ default:
+ return falseval(type);
+ }
+}
+
--- /dev/null
+/*
+ * GT functionality
+ */
+
+#include "newsearch.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+struct lt_localdata {
+ int count;
+ struct searchNode **nodes;
+};
+
+void lt_free(struct searchNode *thenode);
+void *lt_exe(struct searchNode *thenode, int type, void *theinput);
+
+struct searchNode *lt_parse(int type, int argc, char **argv) {
+ struct lt_localdata *localdata;
+ struct searchNode *thenode;
+ int i;
+
+ localdata = (struct lt_localdata *)malloc(sizeof(struct lt_localdata));
+ localdata->nodes = (struct searchNode **)malloc(sizeof(struct searchNode *) * argc);
+ localdata->count = 0;
+
+ thenode = (struct searchNode *)malloc(sizeof(struct searchNode));
+
+ thenode->localdata = localdata;
+ thenode->returntype = RETURNTYPE_BOOL;
+ thenode->exe = lt_exe;
+ thenode->free = lt_free;
+
+ for (i=0;i<argc;i++) {
+ if (!(localdata->nodes[i] = search_parse(type, argv[i]))) {
+ lt_free(thenode);
+ return NULL;
+ }
+ localdata->count++;
+ }
+
+ return thenode;
+}
+
+void lt_free(struct searchNode *thenode) {
+ struct lt_localdata *localdata;
+ int i;
+
+ localdata=thenode->localdata;
+
+ for (i=0;i<localdata->count;i++) {
+ (localdata->nodes[i]->free)(localdata->nodes[i]);
+ }
+
+ free(localdata->nodes);
+ free(localdata);
+ free(thenode);
+}
+
+void *lt_exe(struct searchNode *thenode, int type, void *theinput) {
+ int i;
+ char *strval;
+ int intval;
+ int rval;
+ struct lt_localdata *localdata;
+
+ localdata=thenode->localdata;
+
+ if (localdata->count==0)
+ return trueval(type);
+
+ switch (localdata->nodes[0]->returntype & RETURNTYPE_TYPE) {
+ case RETURNTYPE_INT:
+ intval = (int)(localdata->nodes[0]->exe)(localdata->nodes[0], RETURNTYPE_INT, theinput);
+ for (i=1;i<localdata->count;i++) {
+ if ((int)(localdata->nodes[i]->exe)(localdata->nodes[i], RETURNTYPE_INT, theinput) < intval)
+ return falseval(type);
+ }
+
+ return trueval(type);
+
+ case RETURNTYPE_STRING:
+ strval = (char *)(localdata->nodes[0]->exe)(localdata->nodes[0], RETURNTYPE_STRING, theinput);
+ for (i=1;i<localdata->count;i++) {
+ if (ircd_strcmp(strval, (char *)(localdata->nodes[i]->exe)(localdata->nodes[i], RETURNTYPE_STRING, theinput)) < 0)
+ return falseval(type);
+ }
+
+ return trueval(type);
+
+ default:
+ return falseval(type);
+ }
+}
+
--- /dev/null
+/*
+ * TIMESTAMP functionality
+ */
+
+#include "newsearch.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#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);
+
+struct searchNode *timestamp_parse(int type, int argc, char **argv) {
+ struct searchNode *thenode;
+
+ if (type != SEARCHTYPE_NICK) {
+ parseError = "timestamp: this function is only valid for nick searches.";
+ return NULL;
+ }
+
+ thenode=(struct searchNode *)malloc(sizeof (struct searchNode));
+
+ thenode->returntype = RETURNTYPE_INT;
+ thenode->localdata = NULL;
+ thenode->exe = timestamp_exe;
+ thenode->free = timestamp_free;
+
+ return thenode;
+}
+
+void *timestamp_exe(struct searchNode *thenode, int type, void *theinput) {
+ nick *np = (nick *)theinput;
+
+ if (type != RETURNTYPE_INT)
+ return (void *)1;
+
+ return (void *)np->timestamp;
+}
+
+void timestamp_free(struct searchNode *thenode) {
+ free(thenode);
+}