chansearch's seperate newsearch module will be updated to support this in a seperate changeset
return CMD_OK;
}
-void newsearch_ctxinit(searchCtx *ctx, searchParseFunc searchfn, replyFunc replyfn, wallFunc wallfn, void *arg) {
+void newsearch_ctxinit(searchCtx *ctx, searchParseFunc searchfn, replyFunc replyfn, wallFunc wallfn, void *arg, int type) {
memset(ctx, 0, sizeof(searchCtx));
ctx->reply = replyfn;
ctx->wall = wallfn;
ctx->parser = searchfn;
ctx->arg = arg;
+ ctx->type = type;
}
int do_nicksearch_real(replyFunc reply, wallFunc wall, void *source, int cargc, char **cargv) {
rejoinline(cargv[arg],cargc-arg);
}
- newsearch_ctxinit(&ctx, search_parse, reply, wall, NULL);
+ newsearch_ctxinit(&ctx, search_parse, reply, wall, NULL, SEARCHTYPE_NICK);
- if (!(search = ctx.parser(&ctx, SEARCHTYPE_NICK, cargv[arg]))) {
+ if (!(search = ctx.parser(&ctx, cargv[arg]))) {
reply(sender,"Parse error: %s",parseError);
return CMD_ERROR;
}
rejoinline(cargv[arg],cargc-arg);
}
- newsearch_ctxinit(&ctx, search_parse, reply, wall, NULL);
- if (!(search = ctx.parser(&ctx, SEARCHTYPE_CHANNEL, cargv[arg]))) {
+ newsearch_ctxinit(&ctx, search_parse, reply, wall, NULL, SEARCHTYPE_CHANNEL);
+ if (!(search = ctx.parser(&ctx, cargv[arg]))) {
reply(sender,"Parse error: %s",parseError);
return CMD_ERROR;
}
rejoinline(cargv[arg],cargc-arg);
}
- newsearch_ctxinit(&ctx, search_parse, reply, wall, NULL);
- if (!(search = ctx.parser(&ctx, SEARCHTYPE_USER, cargv[arg]))) {
+ newsearch_ctxinit(&ctx, search_parse, reply, wall, NULL, SEARCHTYPE_USER);
+ if (!(search = ctx.parser(&ctx, cargv[arg]))) {
reply(sender,"Parse error: %s",parseError);
return CMD_ERROR;
}
* Given an input string, return a searchNode.
*/
-struct searchNode *search_parse(searchCtx *ctx, int type, char *input) {
+struct searchNode *search_parse(searchCtx *ctx, char *input) {
/* OK, we need to split the input into chunks on spaces and brackets.. */
char *argvector[100];
char thestring[500];
parseError = "Unknown command";
return NULL;
} else {
- return ((parseFunc)cmd->handler)(ctx, type, j, argvector+1);
+ return ((parseFunc)cmd->handler)(ctx, j, argvector+1);
}
} else {
/* Literal */
*/
}
-static char *var_tochar(searchCtx *ctx, int nstype, char *arg, searchNode **variable) {
- *variable = ctx->parser(ctx, nstype, arg);
+static char *var_tochar(searchCtx *ctx, char *arg, searchNode **variable) {
+ *variable = ctx->parser(ctx, arg);
if (!(*variable = coerceNode(ctx, *variable, RETURNTYPE_STRING)))
return NULL;
void free_val_null(searchCtx *ctx, struct searchNode *thenode) {
}
-struct searchVariable *var_register(searchCtx *ctx, int nstype, char *arg, int type) {
+struct searchVariable *var_register(searchCtx *ctx, char *arg, int type) {
searchNode *variable;
struct searchVariable *us;
char *var;
us = &ctx->vars[ctx->lastvar];
- var = var_tochar(ctx, nstype, arg, &variable);
+ var = var_tochar(ctx, arg, &variable);
if(!var)
return NULL;
return us;
}
-searchNode *var_get(searchCtx *ctx, int nstype, char *arg) {
+searchNode *var_get(searchCtx *ctx, char *arg) {
searchNode *variable, *found = NULL;
int i;
- char *var = var_tochar(ctx, nstype, arg, &variable);
+ char *var = var_tochar(ctx, arg, &variable);
if(!var)
return NULL;
struct searchCtx;
struct coercedata;
-typedef struct searchNode *(*searchParseFunc)(struct searchCtx *ctx, int type, char *input);
+typedef struct searchNode *(*searchParseFunc)(struct searchCtx *ctx, char *input);
typedef void (*replyFunc)(nick *np, char *format, ...);
typedef void (*wallFunc)(int level, char *format, ...);
-typedef struct searchNode *(*parseFunc)(struct searchCtx *, int, int, char **);
+typedef struct searchNode *(*parseFunc)(struct searchCtx *, int, char **);
typedef void (*freeFunc)(struct searchCtx *, struct searchNode *);
typedef void *(*exeFunc)(struct searchCtx *, struct searchNode *, void *);
typedef void (*ChanDisplayFunc)(struct searchCtx *, nick *, chanindex *);
void *arg;
struct searchVariable vars[MAX_VARIABLES];
int lastvar;
+ int type;
} searchCtx;
/* Core functions */
/* Logical (BOOL -> BOOL)*/
-struct searchNode *and_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *not_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *or_parse(searchCtx *ctx, int type, int argc, char **argv);
+struct searchNode *and_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *not_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *or_parse(searchCtx *ctx, int argc, char **argv);
/* Comparison (INT -> BOOL) */
-struct searchNode *eq_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *lt_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *gt_parse(searchCtx *ctx, int type, int argc, char **argv);
+struct searchNode *eq_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *lt_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *gt_parse(searchCtx *ctx, int argc, char **argv);
/* String match (STRING -> BOOL) */
-struct searchNode *match_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *regex_parse(searchCtx *ctx, int type, int argc, char **argv);
+struct searchNode *match_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *regex_parse(searchCtx *ctx, int argc, char **argv);
/* Length (STRING -> INT) */
-struct searchNode *length_parse(searchCtx *ctx, int type, int argc, char **argv);
+struct searchNode *length_parse(searchCtx *ctx, int argc, char **argv);
/* kill/gline actions (BOOL) */
-struct searchNode *kill_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *gline_parse(searchCtx *ctx, int type, int argc, char **argv);
+struct searchNode *kill_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *gline_parse(searchCtx *ctx, int argc, char **argv);
/* notice action (BOOL) */
-struct searchNode *notice_parse(searchCtx *ctx, int type, int argc, char **argv);
+struct searchNode *notice_parse(searchCtx *ctx, int argc, char **argv);
/* Nick/Channel functions (various types) */
-struct searchNode *nick_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *modes_parse(searchCtx *ctx, int type, int argc, char **argv);
+struct searchNode *nick_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *modes_parse(searchCtx *ctx, int argc, char **argv);
/* Nick functions (various types) */
-struct searchNode *hostmask_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *realname_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *authname_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *authts_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *ident_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *host_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *channel_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *timestamp_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *country_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *ip_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *channels_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *server_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *authid_parse(searchCtx *ctx, int type, int argc, char **argv);
+struct searchNode *hostmask_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *realname_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 *host_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *channel_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *timestamp_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *country_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *ip_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *channels_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);
/* Channel functions (various types) */
-struct searchNode *exists_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *services_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *size_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *name_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *topic_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *oppct_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *hostpct_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *authedpct_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *kick_parse(searchCtx *ctx, int type, int argc, char **argv);
+struct searchNode *exists_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *services_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *size_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *name_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *topic_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *oppct_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *hostpct_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, int type, char *input);
+struct searchNode *search_parse(searchCtx *ctx, char *input);
/* Iteration functions */
-struct searchNode *any_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *all_parse(searchCtx *ctx, int type, int argc, char **argv);
-struct searchNode *var_parse(searchCtx *ctx, int type, int argc, char **argv);
+struct searchNode *any_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *all_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *var_parse(searchCtx *ctx, int argc, char **argv);
/* Iteraterable functions */
-struct searchNode *channeliter_parse(searchCtx *ctx, int type, int argc, char **argv);
+struct searchNode *channeliter_parse(searchCtx *ctx, int argc, char **argv);
/* Force a node to return the thing you want */
struct searchNode *coerceNode(searchCtx *ctx, struct searchNode *thenode, int type);
void *literal_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void literal_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchVariable *var_register(searchCtx *ctx, int nstype, char *arg, int type);
-searchNode *var_get(searchCtx *ctx, int nstype, char *arg);
+struct searchVariable *var_register(searchCtx *ctx, char *arg, int type);
+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);
+void newsearch_ctxinit(searchCtx *ctx, searchParseFunc searchfn, replyFunc replyfn, wallFunc wallfn, void *arg, int type);
/* AST functions */
#define NSASTLiteral(data) __NSASTExpr(AST_NODE_LITERAL, literal, data)
#define NSASTNode(fn, ...) __NSASTChild(__NSASTNode(fn, __VA_ARGS__))
-searchNode *search_astparse(searchCtx *, int, char *);
+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);
}
/* ast parser, the way we pass context around is very very hacky... */
-searchNode *search_astparse(searchCtx *ctx, int type, char *loc) {
+searchNode *search_astparse(searchCtx *ctx, char *loc) {
searchASTCache *cache = ctx->arg;
searchASTExpr *expr = cachesearch(cache, (exprunion *)&loc);
searchNode *node;
}
}
- node = expr->u.child->fn(ctx, type, expr->u.child->argc, v);
+ node = expr->u.child->fn(ctx, expr->u.child->argc, v);
free(v);
return node;
default:
memset(&cache, 0, sizeof(cache));
cache.tree = tree;
- newsearch_ctxinit(&ctx, search_astparse, reply, wall, &cache);
+ newsearch_ctxinit(&ctx, search_astparse, reply, wall, &cache, SEARCHTYPE_NICK);
buf[0] = '\0';
reply(sender, "Parsing: %s", ast_printtree(buf, sizeof(buf), tree));
- search = ctx.parser(&ctx, SEARCHTYPE_NICK, (char *)tree);
+ search = ctx.parser(&ctx, (char *)tree);
if(!search) {
reply(sender, "Parse error: %s", parseError);
return CMD_ERROR;
searchNode *search;
char buf[1024];
- newsearch_ctxinit(&ctx, search_astparse, reply, wall, &cache);
+ newsearch_ctxinit(&ctx, search_astparse, reply, wall, &cache, SEARCHTYPE_CHANNEL);
buf[0] = '\0';
reply(sender, "Parsing: %s", ast_printtree(buf, sizeof(buf), tree));
- search = ctx.parser(&ctx, SEARCHTYPE_CHANNEL, (char *)tree);
+ search = ctx.parser(&ctx, (char *)tree);
if(!search) {
reply(sender, "Parse error: %s", parseError);
return CMD_ERROR;
memset(&cache, 0, sizeof(cache));
cache.tree = tree;
- newsearch_ctxinit(&ctx, search_astparse, reply, wall, &cache);
+ newsearch_ctxinit(&ctx, search_astparse, reply, wall, &cache, SEARCHTYPE_USER);
buf[0] = '\0';
reply(sender, "Parsing: %s", ast_printtree(buf, sizeof(buf), tree));
- search = ctx.parser(&ctx, SEARCHTYPE_USER, (char *)tree);
+ search = ctx.parser(&ctx, (char *)tree);
if(!search) {
reply(sender, "Parse error: %s", parseError);
return CMD_ERROR;
int hitlimit;
};
-struct searchNode *all_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *all_parse(searchCtx *ctx, int argc, char **argv) {
searchNode *thenode;
struct all_localdata *localdata;
localdata->hitlimit = 0;
- if(!(localdata->genfn=ctx->parser(ctx, type, argv[0]))) {
+ if(!(localdata->genfn=ctx->parser(ctx, argv[0]))) {
free(localdata);
return NULL;
}
- localdata->lambdafn = ctx->parser(ctx, type, argv[1]);
+ localdata->lambdafn = ctx->parser(ctx, argv[1]);
if(!(localdata->lambdafn = coerceNode(ctx, localdata->lambdafn, RETURNTYPE_BOOL))) {
(localdata->genfn->free)(ctx, localdata->genfn);
free(localdata);
searchNode **nodes;
};
-struct searchNode *and_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *and_parse(searchCtx *ctx, int argc, char **argv) {
searchNode *thenode, *subnode;
struct and_localdata *localdata;
int i;
thenode->free = and_free;
for (i=0;i<argc;i++) {
- subnode=ctx->parser(ctx, type, argv[i]); /* Propogate the search type */
+ subnode=ctx->parser(ctx, argv[i]); /* Propogate the search type */
subnode=coerceNode(ctx, subnode, RETURNTYPE_BOOL); /* Needs to return BOOL */
if (subnode) {
localdata->nodes[localdata->count++] = subnode;
int hitlimit;
};
-struct searchNode *any_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *any_parse(searchCtx *ctx, int argc, char **argv) {
searchNode *thenode;
struct any_localdata *localdata;
localdata->hitlimit = 0;
- if(!(localdata->genfn=ctx->parser(ctx, type, argv[0]))) {
+ if(!(localdata->genfn=ctx->parser(ctx, argv[0]))) {
free(localdata);
return NULL;
}
- localdata->lambdafn = ctx->parser(ctx, type, argv[1]);
+ localdata->lambdafn = ctx->parser(ctx, argv[1]);
if(!(localdata->lambdafn = coerceNode(ctx, localdata->lambdafn, RETURNTYPE_BOOL))) {
(localdata->genfn->free)(ctx, localdata->genfn);
free(localdata);
void *authedpct_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void authedpct_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchNode *authedpct_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *authedpct_parse(searchCtx *ctx, int argc, char **argv) {
struct searchNode *thenode;
- if (type != SEARCHTYPE_CHANNEL) {
+ if (ctx->type != SEARCHTYPE_CHANNEL) {
parseError = "authedpct: this function is only valid for channel searches.";
return NULL;
}
void *authid_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void authid_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchNode *authid_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *authid_parse(searchCtx *ctx, int argc, char **argv) {
struct searchNode *thenode;
- if (type != SEARCHTYPE_NICK) {
+ if (ctx->type != SEARCHTYPE_NICK) {
parseError = "authid: this function is only valid for nick searches.";
return NULL;
}
void *authname_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void authname_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchNode *authname_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *authname_parse(searchCtx *ctx, int argc, char **argv) {
struct searchNode *thenode;
- if (type != SEARCHTYPE_NICK) {
+ if (ctx->type != SEARCHTYPE_NICK) {
parseError = "authname: this function is only valid for nick searches.";
return NULL;
}
void *authts_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void authts_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchNode *authts_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *authts_parse(searchCtx *ctx, int argc, char **argv) {
struct searchNode *thenode;
- if (type != SEARCHTYPE_NICK) {
+ if (ctx->type != SEARCHTYPE_NICK) {
parseError = "authts: this function is only valid for nick searches.";
return NULL;
}
void *channel_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void channel_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchNode *channel_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *channel_parse(searchCtx *ctx, int argc, char **argv) {
struct searchNode *thenode;
channel *cp;
- if (type != SEARCHTYPE_NICK) {
+ if (ctx->type != SEARCHTYPE_NICK) {
parseError = "channel: this function is only valid for nick searches.";
return NULL;
}
nick *lastnick;
};
-struct searchNode *channeliter_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *channeliter_parse(searchCtx *ctx, int argc, char **argv) {
searchNode *thenode;
struct channeliter_localdata *localdata;
return NULL;
}
- if(type != SEARCHTYPE_NICK) {
+ if(ctx->type != SEARCHTYPE_NICK) {
parseError = "channeliter: this function is only valid for nick searches.";
return NULL;
}
return NULL;
}
- if(!(localdata->variable=var_register(ctx, type, argv[0], RETURNTYPE_STRING))) {
+ if(!(localdata->variable=var_register(ctx, argv[0], RETURNTYPE_STRING))) {
free(localdata);
return NULL;
}
void *channels_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void channels_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchNode *channels_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *channels_parse(searchCtx *ctx, int argc, char **argv) {
struct searchNode *thenode;
- if (type != SEARCHTYPE_NICK) {
+ if (ctx->type != SEARCHTYPE_NICK) {
parseError = "channels: this function is only valid for nick searches.";
return NULL;
}
int ext;
-struct searchNode *country_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *country_parse(searchCtx *ctx, int argc, char **argv) {
struct searchNode *thenode;
GeoIP_LookupCode l;
long target;
- if (type != SEARCHTYPE_NICK) {
+ if (ctx->type != SEARCHTYPE_NICK) {
parseError = "country: this function is only valid for nick searches.";
return NULL;
}
void eq_free(searchCtx *ctx, struct searchNode *thenode);
void *eq_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
-struct searchNode *eq_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *eq_parse(searchCtx *ctx, int argc, char **argv) {
struct eq_localdata *localdata;
struct searchNode *thenode;
int i;
for (i=0;i<argc;i++) {
/* Parse the node.. */
- localdata->nodes[i] = ctx->parser(ctx, type, argv[i]);
+ localdata->nodes[i] = ctx->parser(ctx, argv[i]);
/* Subsequent nodes get coerced to match the type of the first node */
if (i)
void *exists_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void exists_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchNode *exists_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *exists_parse(searchCtx *ctx, int argc, char **argv) {
struct searchNode *thenode;
- if (type != SEARCHTYPE_CHANNEL) {
+ if (ctx->type != SEARCHTYPE_CHANNEL) {
parseError = "exists: this function is only valid for channel searches.";
return NULL;
}
unsigned int marker;
unsigned int duration;
int count;
- int type;
char reason[NSMAX_REASON_LEN];
};
-struct searchNode *gline_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *gline_parse(searchCtx *ctx, int argc, char **argv) {
struct gline_localdata *localdata;
struct searchNode *thenode;
int len;
return NULL;
}
localdata->count = 0;
- localdata->type = type;
- if (type == SEARCHTYPE_CHANNEL)
+ if (ctx->type == SEARCHTYPE_CHANNEL)
localdata->marker = nextchanmarker();
else
localdata->marker = nextnickmarker();
localdata = thenode->localdata;
- if (localdata->type == SEARCHTYPE_CHANNEL) {
+ if (ctx->type == SEARCHTYPE_CHANNEL) {
cip = (chanindex *)theinput;
cip->marker = localdata->marker;
localdata->count += cip->channel->users->totalusers;
return;
}
- if (localdata->type == SEARCHTYPE_CHANNEL) {
+ if (ctx->type == SEARCHTYPE_CHANNEL) {
for (i=0;i<CHANNELHASHSIZE;i++) {
for (cip=chantable[i];cip;cip=ncip) {
ncip = cip->next;
ctx->reply(senderNSExtern, "Warning: your pattern matched privileged users (%d in total) - these have not been touched.", safe);
/* notify opers of the action */
ctx->wall(NL_GLINES, "%s/%s glined %d %s via %s for %s [%d untouched].", senderNSExtern->nick, senderNSExtern->authname, (localdata->count - safe),
- (localdata->count - safe) != 1 ? "users" : "user", (localdata->type == SEARCHTYPE_CHANNEL) ? "chansearch" : "nicksearch", longtoduration(localdata->duration, 1), safe);
+ (localdata->count - safe) != 1 ? "users" : "user", (ctx->type == SEARCHTYPE_CHANNEL) ? "chansearch" : "nicksearch", longtoduration(localdata->duration, 1), safe);
free(localdata);
free(thenode);
}
void gt_free(searchCtx *ctx, struct searchNode *thenode);
void *gt_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
-struct searchNode *gt_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *gt_parse(searchCtx *ctx, int argc, char **argv) {
struct gt_localdata *localdata;
struct searchNode *thenode;
int i;
for (i=0;i<argc;i++) {
/* Parse the node.. */
- localdata->nodes[i] = ctx->parser(ctx, type, argv[i]);
+ localdata->nodes[i] = ctx->parser(ctx, argv[i]);
/* Subsequent nodes get coerced to match the type of the first node */
if (i)
void *host_exe_real(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void host_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchNode *host_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *host_parse(searchCtx *ctx, int argc, char **argv) {
struct searchNode *thenode;
- if (type != SEARCHTYPE_NICK) {
+ if (ctx->type != SEARCHTYPE_NICK) {
parseError = "host: this function is only valid for nick searches.";
return NULL;
}
void *hostmask_exe_real(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void hostmask_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchNode *hostmask_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *hostmask_parse(searchCtx *ctx, int argc, char **argv) {
struct searchNode *thenode;
- if (type != SEARCHTYPE_NICK) {
+ if (ctx->type != SEARCHTYPE_NICK) {
parseError = "hostmask: this function is only valid for nick searches.";
return NULL;
}
void *hostpct_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void hostpct_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchNode *hostpct_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *hostpct_parse(searchCtx *ctx, int argc, char **argv) {
struct searchNode *thenode;
- if (type != SEARCHTYPE_CHANNEL) {
+ if (ctx->type != SEARCHTYPE_CHANNEL) {
parseError = "uniquehostpct: this function is only valid for channel searches.";
return NULL;
}
void *ident_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void ident_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchNode *ident_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *ident_parse(searchCtx *ctx, int argc, char **argv) {
struct searchNode *thenode;
- if (type != SEARCHTYPE_NICK) {
+ if (ctx->type != SEARCHTYPE_NICK) {
parseError = "ident: this function is only valid for nick searches.";
return NULL;
}
void *ip_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void ip_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchNode *ip_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *ip_parse(searchCtx *ctx, int argc, char **argv) {
struct searchNode *thenode;
- if (type != SEARCHTYPE_NICK) {
+ if (ctx->type != SEARCHTYPE_NICK) {
parseError = "ip: this function is only valid for nick searches.";
return NULL;
}
void *kick_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void kick_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchNode *kick_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *kick_parse(searchCtx *ctx, int argc, char **argv) {
struct searchNode *thenode;
nick *np;
- if (type!=SEARCHTYPE_CHANNEL) {
+ if (ctx->type!=SEARCHTYPE_CHANNEL) {
parseError="kick: only channel searches are supported";
return NULL;
}
struct kill_localdata {
unsigned int marker;
int count;
- int type;
char reason[NSMAX_REASON_LEN];
};
-struct searchNode *kill_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *kill_parse(searchCtx *ctx, int argc, char **argv) {
struct kill_localdata *localdata;
struct searchNode *thenode;
int len;
return NULL;
}
localdata->count = 0;
- localdata->type = type;
- if (type == SEARCHTYPE_CHANNEL)
+ if (ctx->type == SEARCHTYPE_CHANNEL)
localdata->marker = nextchanmarker();
else
localdata->marker = nextnickmarker();
localdata = thenode->localdata;
- if (localdata->type == SEARCHTYPE_CHANNEL) {
+ if (ctx->type == SEARCHTYPE_CHANNEL) {
cip = (chanindex *)theinput;
cip->marker = localdata->marker;
localdata->count += cip->channel->users->totalusers;
}
/* For channel searches, mark up all the nicks in the relevant channels first */
- if (localdata->type == SEARCHTYPE_CHANNEL) {
+ if (ctx->type == SEARCHTYPE_CHANNEL) {
nickmarker=nextnickmarker();
for (i=0;i<CHANNELHASHSIZE;i++) {
for (cip=chantable[i];cip;cip=cip->next) {
ctx->reply(senderNSExtern, "Warning: your pattern matched privileged users (%d in total) - these have not been touched.", safe);
/* notify opers of the action */
ctx->wall(NL_KICKKILLS, "%s/%s killed %d %s via %s [%d untouched].", senderNSExtern->nick, senderNSExtern->authname, (localdata->count - safe),
- (localdata->count - safe) != 1 ? "users" : "user", (localdata->type == SEARCHTYPE_CHANNEL) ? "chansearch" : "nicksearch", safe);
+ (localdata->count - safe) != 1 ? "users" : "user", (ctx->type == SEARCHTYPE_CHANNEL) ? "chansearch" : "nicksearch", safe);
free(localdata);
free(thenode);
}
void length_free(searchCtx *ctx, struct searchNode *thenode);
void *length_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
-struct searchNode *length_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *length_parse(searchCtx *ctx, int argc, char **argv) {
struct searchNode *thenode, *childnode;
if (!(thenode = (struct searchNode *)malloc(sizeof(struct searchNode)))) {
return NULL;
}
- childnode = ctx->parser(ctx, type, argv[0]);
+ childnode = ctx->parser(ctx, argv[0]);
if (!(thenode->localdata = coerceNode(ctx, childnode, RETURNTYPE_STRING))) {
length_free(ctx, thenode);
return NULL;
void lt_free(searchCtx *ctx, struct searchNode *thenode);
void *lt_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
-struct searchNode *lt_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *lt_parse(searchCtx *ctx, int argc, char **argv) {
struct lt_localdata *localdata;
struct searchNode *thenode;
int i;
for (i=0;i<argc;i++) {
/* Parse the node.. */
- localdata->nodes[i] = ctx->parser(ctx, type, argv[i]);
+ localdata->nodes[i] = ctx->parser(ctx, argv[i]);
/* Subsequent nodes get coerced to match the type of the first node */
if (i)
void *match_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void match_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchNode *match_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *match_parse(searchCtx *ctx, int argc, char **argv) {
struct match_localdata *localdata;
struct searchNode *thenode;
struct searchNode *targnode, *patnode;
}
/* @fixme check this works with new parsing semantics */
- targnode = ctx->parser(ctx, type, argv[0]);
+ targnode = ctx->parser(ctx, argv[0]);
if (!(targnode = coerceNode(ctx,targnode, RETURNTYPE_STRING)))
return NULL;
- patnode = ctx->parser(ctx, type, argv[1]);
+ patnode = ctx->parser(ctx, argv[1]);
if (!(patnode = coerceNode(ctx,patnode, RETURNTYPE_STRING))) {
(targnode->free)(ctx, targnode);
return NULL;
#include <stdlib.h>
struct modes_localdata {
- int type;
flag_t setmodes;
flag_t clearmodes;
};
void *modes_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void modes_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchNode *modes_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *modes_parse(searchCtx *ctx, int argc, char **argv) {
struct modes_localdata *localdata;
struct searchNode *thenode;
const flag *flaglist;
return NULL;
}
- switch (type) {
+ switch (ctx->type) {
case SEARCHTYPE_CHANNEL:
flaglist=cmodeflags;
break;
return NULL;
}
- localdata->type=type;
localdata->setmodes=0;
localdata->clearmodes = ~0;
localdata = (struct modes_localdata *)thenode->localdata;
- switch (localdata->type) {
+ switch (ctx->type) {
case SEARCHTYPE_CHANNEL:
cip=(chanindex *)value;
if (!cip->channel)
void *name_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void name_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchNode *name_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *name_parse(searchCtx *ctx, int argc, char **argv) {
struct searchNode *thenode;
- if (type != SEARCHTYPE_CHANNEL) {
+ if (ctx->type != SEARCHTYPE_CHANNEL) {
parseError = "name: this function is only valid for channel searches.";
return NULL;
}
struct nick_localdata {
nick *np;
- int type;
};
void *nick_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void nick_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchNode *nick_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *nick_parse(searchCtx *ctx, int argc, char **argv) {
struct nick_localdata *localdata;
struct searchNode *thenode;
return NULL;
}
- switch (type) {
+ switch (ctx->type) {
case SEARCHTYPE_CHANNEL:
if (argc!=1) {
parseError="nick: usage: (nick target)";
free(localdata);
return NULL;
}
- localdata->type = type;
break;
case SEARCHTYPE_NICK:
free(localdata);
return NULL;
}
- localdata->type = type;
localdata->np = NULL;
break;
return NULL;
}
- if (type == SEARCHTYPE_CHANNEL)
+ if (ctx->type == SEARCHTYPE_CHANNEL)
thenode->returntype = RETURNTYPE_BOOL;
else
thenode->returntype = RETURNTYPE_STRING;
localdata = thenode->localdata;
- switch (localdata->type) {
+ switch (ctx->type) {
case SEARCHTYPE_CHANNEL:
cip = (chanindex *)theinput;
void not_free(searchCtx *ctx, struct searchNode *thenode);
void *not_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
-struct searchNode *not_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *not_parse(searchCtx *ctx, int argc, char **argv) {
searchNode *thenode, *subnode;
if (argc!=1) {
thenode->exe = not_exe;
thenode->free = not_free;
- subnode=ctx->parser(ctx, type, argv[0]); /* Propogate the search type */
+ subnode=ctx->parser(ctx, argv[0]); /* Propogate the search type */
if (!subnode) {
free(thenode);
struct notice_localdata {
unsigned int marker;
int count;
- int type;
char message[NSMAX_NOTICE_LEN];
};
-struct searchNode *notice_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *notice_parse(searchCtx *ctx, int argc, char **argv) {
struct notice_localdata *localdata;
struct searchNode *thenode;
int len;
return NULL;
}
localdata->count = 0;
- localdata->type = type;
- if (type == SEARCHTYPE_CHANNEL)
+ if (ctx->type == SEARCHTYPE_CHANNEL)
localdata->marker = nextchanmarker();
else
localdata->marker = nextnickmarker();
localdata = thenode->localdata;
- if (localdata->type == SEARCHTYPE_CHANNEL) {
+ if (ctx->type == SEARCHTYPE_CHANNEL) {
cip = (chanindex *)theinput;
cip->marker = localdata->marker;
localdata->count += cip->channel->users->totalusers;
localdata = thenode->localdata;
- if (localdata->type == SEARCHTYPE_CHANNEL) {
+ if (ctx->type == SEARCHTYPE_CHANNEL) {
nickmarker=nextnickmarker();
for (i=0;i<CHANNELHASHSIZE;i++) {
for (cip=chantable[i];cip;cip=ncip) {
void *oppct_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void oppct_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchNode *oppct_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *oppct_parse(searchCtx *ctx, int argc, char **argv) {
struct searchNode *thenode;
- if (type != SEARCHTYPE_CHANNEL) {
+ if (ctx->type != SEARCHTYPE_CHANNEL) {
parseError = "oppct: this function is only valid for channel searches.";
return NULL;
}
searchNode **nodes;
};
-struct searchNode *or_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *or_parse(searchCtx *ctx, int argc, char **argv) {
searchNode *thenode, *subnode;
struct or_localdata *localdata;
int i;
thenode->free = or_free;
for (i=0;i<argc;i++) {
- subnode=ctx->parser(ctx, type, argv[i]); /* Propogate the search type */
+ subnode=ctx->parser(ctx, argv[i]); /* Propogate the search type */
subnode=coerceNode(ctx, subnode, RETURNTYPE_BOOL); /* BOOL please */
if (subnode) {
localdata->nodes[localdata->count++] = subnode;
void *realname_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void realname_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchNode *realname_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *realname_parse(searchCtx *ctx, int argc, char **argv) {
struct searchNode *thenode;
- if (type != SEARCHTYPE_NICK) {
+ if (ctx->type != SEARCHTYPE_NICK) {
parseError = "realname: this function is only valid for nick searches.";
return NULL;
}
void *regex_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void regex_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchNode *regex_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *regex_parse(searchCtx *ctx, int argc, char **argv) {
struct regex_localdata *localdata;
struct searchNode *thenode;
struct searchNode *targnode, *patnode;
return NULL;
}
- targnode=ctx->parser(ctx, type, argv[0]);
+ targnode=ctx->parser(ctx, argv[0]);
if (!(targnode = coerceNode(ctx,targnode, RETURNTYPE_STRING)))
return NULL;
- patnode=ctx->parser(ctx, type, argv[1]);
+ patnode=ctx->parser(ctx, argv[1]);
if (!(patnode = coerceNode(ctx,patnode, RETURNTYPE_STRING))) {
(targnode->free)(ctx, targnode);
return NULL;
int ext;
-struct searchNode *server_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *server_parse(searchCtx *ctx, int argc, char **argv) {
struct searchNode *thenode;
int i;
long numeric;
- if (type != SEARCHTYPE_NICK) {
+ if (ctx->type != SEARCHTYPE_NICK) {
parseError = "server: this function is only valid for nick searches.";
return NULL;
}
void *services_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void services_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchNode *services_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *services_parse(searchCtx *ctx, int argc, char **argv) {
struct searchNode *thenode;
- if (type != SEARCHTYPE_CHANNEL) {
+ if (ctx->type != SEARCHTYPE_CHANNEL) {
parseError = "services: this function is only valid for channel searches.";
return NULL;
}
void *size_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void size_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchNode *size_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *size_parse(searchCtx *ctx, int argc, char **argv) {
struct searchNode *thenode;
- if (type != SEARCHTYPE_CHANNEL) {
+ if (ctx->type != SEARCHTYPE_CHANNEL) {
parseError = "size: this function is only valid for channel searches.";
return NULL;
}
void *timestamp_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void timestamp_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchNode *timestamp_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *timestamp_parse(searchCtx *ctx, int argc, char **argv) {
struct searchNode *thenode;
- if (type != SEARCHTYPE_NICK) {
+ if (ctx->type != SEARCHTYPE_NICK) {
parseError = "timestamp: this function is only valid for nick searches.";
return NULL;
}
void *topic_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
void topic_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchNode *topic_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *topic_parse(searchCtx *ctx, int argc, char **argv) {
struct searchNode *thenode;
- if (type != SEARCHTYPE_CHANNEL) {
+ if (ctx->type != SEARCHTYPE_CHANNEL) {
parseError = "topic: this function is only valid for channel searches.";
return NULL;
}
#include <stdio.h>
#include <stdlib.h>
-struct searchNode *var_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *var_parse(searchCtx *ctx, int argc, char **argv) {
if(argc < 1) {
parseError = "var: usage: var variable";
return NULL;
}
- return var_get(ctx, type, argv[0]);
+ return var_get(ctx, argv[0]);
}