#include "../lib/flags.h"
#include "../authext/authext.h"
#include "../patricia/patricia.h"
+#include "../whowas/whowas.h"
#ifndef __NEWSEARCH_H
#define __NEWSEARCH_H
#define NSMAX_KILL_LIMIT 500
#define NSMAX_GLINE_LIMIT 500
-#define NSMAX_GLINE_CLONES 5
/* gline duration, in seconds */
#define NSGLINE_DURATION 3600
typedef void (*ChanDisplayFunc)(struct searchCtx *, nick *, chanindex *);
typedef void (*NickDisplayFunc)(struct searchCtx *, nick *, nick *);
typedef void (*UserDisplayFunc)(struct searchCtx *, nick *, authname *);
+typedef void (*WhowasDisplayFunc)(struct searchCtx *, nick *, whowas *);
typedef void (*HeaderFunc)(void *sender, void *arg);
struct coercedata {
struct searchCmd *searchcmd;
nick *sender;
int limit;
+ array *targets;
void *displayfn;
} searchCtx;
/* kill/gline actions (BOOL) */
struct searchNode *kill_parse(searchCtx *ctx, int argc, char **argv);
struct searchNode *gline_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *delaygline_parse(searchCtx *ctx, int argc, char **argv);
/* notice action (BOOL) */
struct searchNode *notice_parse(searchCtx *ctx, int argc, char **argv);
/* Nick functions (various types) */
struct searchNode *hostmask_parse(searchCtx *ctx, int argc, char **argv);
struct searchNode *realname_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *away_parse(searchCtx *ctx, int argc, char **argv);
struct searchNode *authname_parse(searchCtx *ctx, int argc, char **argv);
struct searchNode *authts_parse(searchCtx *ctx, int argc, char **argv);
struct searchNode *ident_parse(searchCtx *ctx, int argc, char **argv);
struct searchNode *server_parse(searchCtx *ctx, int argc, char **argv);
struct searchNode *authid_parse(searchCtx *ctx, int argc, char **argv);
struct searchNode *cidr_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *ipv6_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *message_parse(searchCtx *ctx, int argc, char **argv);
+
+/* Whowas functions (various types) */
+struct searchNode *quit_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *killed_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *renamed_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *age_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *newnick_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *reason_parse(searchCtx *ctx, int argc, char **argv);
/* Channel functions (various types) */
struct searchNode *exists_parse(searchCtx *ctx, int argc, char **argv);
struct searchNode *authedpct_parse(searchCtx *ctx, int argc, char **argv);
struct searchNode *kick_parse(searchCtx *ctx, int argc, char **argv);
-/* Interpret a string to give a node */
-struct searchNode *search_parse(searchCtx *ctx, char *input);
-
/* Iteration functions */
struct searchNode *any_parse(searchCtx *ctx, int argc, char **argv);
struct searchNode *all_parse(searchCtx *ctx, int argc, char **argv);
/* Special nick* printf */
void nssnprintf(char *, size_t, const char *, nick *);
+void displaystrerror(replyFunc reply, nick *np, const char *input);
+
extern const char *parseError;
extern nick *senderNSExtern;
void printnick(searchCtx *, nick *, nick *);
void printuser(searchCtx *, nick *, authname *);
void printchannel(searchCtx *, nick *, chanindex *);
+void printwhowas(searchCtx *, nick *, whowas *);
void nicksearch_exe(struct searchNode *search, searchCtx *sctx);
void chansearch_exe(struct searchNode *search, searchCtx *sctx);
void usersearch_exe(struct searchNode *search, searchCtx *ctx);
+void whowassearch_exe(struct searchNode *search, searchCtx *ctx);
int do_nicksearch_real(replyFunc reply, wallFunc wall, void *source, int cargc, char **cargv);
int do_chansearch_real(replyFunc reply, wallFunc wall, void *source, int cargc, char **cargv);
int do_usersearch_real(replyFunc reply, wallFunc wall, void *source, int cargc, char **cargv);
+int do_whowassearch_real(replyFunc reply, wallFunc wall, void *source, int cargc, char **cargv);
void *literal_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void literal_free(searchCtx *ctx, struct searchNode *thenode);
searchNode *var_get(searchCtx *ctx, char *arg);
void var_setstr(struct searchVariable *v, char *data);
-void newsearch_ctxinit(searchCtx *ctx, searchParseFunc searchfn, replyFunc replyfn, wallFunc wallfn, void *arg, searchCmd *cmd, nick *sender, void *displayfn, int limit);
+void newsearch_ctxinit(searchCtx *ctx, searchParseFunc searchfn, replyFunc replyfn, wallFunc wallfn, void *arg, searchCmd *cmd, nick *sender, void *displayfn, int limit, array *targets);
/* AST functions */
} u;
} searchASTExpr;
+typedef struct searchASTCache {
+ searchASTExpr *tree;
+ searchASTExpr *cache[AST_RECENT];
+ int nextpos;
+} searchASTCache;
+
#define __NSASTSizeOfArray(x) (sizeof(x) / sizeof(x[0]))
#define __NSASTExpr(x, y, ...) (searchASTExpr){.type = x, .u.y = __VA_ARGS__}
searchNode *search_astparse(searchCtx *, char *);
-int ast_nicksearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, NickDisplayFunc display, HeaderFunc header, void *headerarg, int limit);
-int ast_chansearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, ChanDisplayFunc display, HeaderFunc header, void *headerarg, int limit);
-int ast_usersearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, UserDisplayFunc display, HeaderFunc header, void *headerarg, int limit);
+int ast_nicksearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, NickDisplayFunc display, HeaderFunc header, void *headerarg, int limit, array *);
+int ast_chansearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, ChanDisplayFunc display, HeaderFunc header, void *headerarg, int limit, array *);
+int ast_usersearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, UserDisplayFunc display, HeaderFunc header, void *headerarg, int limit, array *);
+int ast_whowassearch(searchASTExpr *tree, replyFunc reply, void *sender, wallFunc wall, WhowasDisplayFunc display, HeaderFunc header, void *headerarg, int limit, array *);
char *ast_printtree(char *buf, size_t bufsize, searchASTExpr *expr, searchCmd *cmd);
int parseopts(int cargc, char **cargv, int *arg, int *limit, void **subset, void *display, CommandTree *sl, replyFunc reply, void *sender);
-typedef int (*ASTFunc)(searchASTExpr *, replyFunc, void *, wallFunc, void *, HeaderFunc, void *, int limit);
+typedef int (*ASTFunc)(searchASTExpr *, replyFunc, void *, wallFunc, void *, HeaderFunc, void *, int limit, array *targets);
/* erk */
extern searchList *globalterms;
extern searchCmd *reg_nicksearch;
extern searchCmd *reg_chansearch;
extern searchCmd *reg_usersearch;
+extern searchCmd *reg_whowassearch;
extern UserDisplayFunc defaultuserfn;
extern NickDisplayFunc defaultnickfn;
extern ChanDisplayFunc defaultchanfn;
+extern WhowasDisplayFunc defaultwhowasfn;
struct searchNode *argtoconststr(char *command, searchCtx *ctx, char *arg, char **p);