#include "../channel/channel.h"
-void *channel_exe(struct searchNode *thenode, int type, void *theinput);
-void channel_free(struct searchNode *thenode);
+void *channel_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void channel_free(searchCtx *ctx, struct searchNode *thenode);
-struct searchNode *channel_parse(int type, int argc, char **argv) {
- struct searchNode *thenode;
+struct searchNode *channel_parse(searchCtx *ctx, int argc, char **argv) {
+ struct searchNode *thenode, *convsn;
channel *cp;
-
- if (type != SEARCHTYPE_NICK) {
- parseError = "channel: this function is only valid for nick searches.";
- return NULL;
- }
-
+ char *p;
+
if (argc<1) {
parseError = "channel: usage: channel <channel name>";
return NULL;
}
- if (!(cp=findchannel(argv[0]))) {
+ if (!(convsn=argtoconststr("channel", ctx, argv[0], &p)))
+ return NULL;
+
+ cp=findchannel(p);
+ convsn->free(ctx, convsn);
+ if (!cp) {
parseError = "channel: unknown channel";
return NULL;
}
- thenode=(struct searchNode *)malloc(sizeof (struct searchNode));
+ if (!(thenode=(struct searchNode *)malloc(sizeof (struct searchNode)))) {
+ parseError = "malloc: could not allocate memory for this search.";
+ return NULL;
+ }
- thenode->returntype = RETURNTYPE_STRING;
+ thenode->returntype = RETURNTYPE_BOOL;
thenode->localdata = cp;
thenode->exe = channel_exe;
thenode->free = channel_free;
return thenode;
}
-void *channel_exe(struct searchNode *thenode, int type, void *theinput) {
+void *channel_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
nick *np = (nick *)theinput;
channel *cp = thenode->localdata;
if (getnumerichandlefromchanhash(cp->users, np->numeric)) {
- return trueval(type);
+ return (void *)1;
} else {
- return falseval(type);
+ return (void *)0;
}
}
-void channel_free(struct searchNode *thenode) {
+void channel_free(searchCtx *ctx, struct searchNode *thenode) {
free(thenode);
}