]> jfr.im git - irc/quakenet/newserv.git/blob - newsearch/ns-channels.c
8627eddb958ca2eeea9507495b03c4fee5fe545e
[irc/quakenet/newserv.git] / newsearch / ns-channels.c
1 /*
2 * CHANNELS functionality
3 */
4
5 #include "newsearch.h"
6
7 #include <stdio.h>
8 #include <stdlib.h>
9
10 #include "../irc/irc_config.h"
11 #include "../lib/irc_string.h"
12
13 void *channels_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
14 void channels_free(searchCtx *ctx, struct searchNode *thenode);
15
16 struct searchNode *channels_parse(searchCtx *ctx, int argc, char **argv) {
17 struct searchNode *thenode;
18
19 if (ctx->type != SEARCHTYPE_NICK) {
20 parseError = "channels: this function is only valid for nick searches.";
21 return NULL;
22 }
23
24 if (!(thenode=(struct searchNode *)malloc(sizeof (struct searchNode)))) {
25 parseError = "malloc: could not allocate memory for this search.";
26 return NULL;
27 }
28
29 thenode->returntype = RETURNTYPE_INT;
30 thenode->localdata = NULL;
31 thenode->exe = channels_exe;
32 thenode->free = channels_free;
33
34 return thenode;
35 }
36
37 void *channels_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
38 nick *np = (nick *)theinput;
39
40 return (void *)(long)np->channels->cursi;
41 }
42
43 void channels_free(searchCtx *ctx, struct searchNode *thenode) {
44 free(thenode);
45 }