]>
Commit | Line | Data |
---|---|---|
c86edd1d Q |
1 | /* |
2 | * CHANNEL functionality | |
3 | */ | |
4 | ||
5 | #include "newsearch.h" | |
6 | ||
7 | #include <stdio.h> | |
8 | #include <stdlib.h> | |
9 | ||
c86edd1d Q |
10 | #include "../channel/channel.h" |
11 | ||
c8be5183 CP |
12 | void *channel_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); |
13 | void channel_free(searchCtx *ctx, struct searchNode *thenode); | |
c86edd1d | 14 | |
f33f3f52 | 15 | struct searchNode *channel_parse(searchCtx *ctx, int argc, char **argv) { |
c86edd1d Q |
16 | struct searchNode *thenode; |
17 | channel *cp; | |
18 | ||
c86edd1d Q |
19 | if (argc<1) { |
20 | parseError = "channel: usage: channel <channel name>"; | |
21 | return NULL; | |
22 | } | |
23 | ||
24 | if (!(cp=findchannel(argv[0]))) { | |
25 | parseError = "channel: unknown channel"; | |
26 | return NULL; | |
27 | } | |
28 | ||
9ce4f0be IB |
29 | if (!(thenode=(struct searchNode *)malloc(sizeof (struct searchNode)))) { |
30 | parseError = "malloc: could not allocate memory for this search."; | |
31 | return NULL; | |
32 | } | |
c86edd1d | 33 | |
c7f7a584 | 34 | thenode->returntype = RETURNTYPE_BOOL; |
c86edd1d Q |
35 | thenode->localdata = cp; |
36 | thenode->exe = channel_exe; | |
37 | thenode->free = channel_free; | |
38 | ||
39 | return thenode; | |
40 | } | |
41 | ||
c8be5183 | 42 | void *channel_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) { |
c86edd1d Q |
43 | nick *np = (nick *)theinput; |
44 | channel *cp = thenode->localdata; | |
45 | ||
46 | if (getnumerichandlefromchanhash(cp->users, np->numeric)) { | |
c7f7a584 | 47 | return (void *)1; |
c86edd1d | 48 | } else { |
c7f7a584 | 49 | return (void *)0; |
c86edd1d Q |
50 | } |
51 | } | |
52 | ||
c8be5183 | 53 | void channel_free(searchCtx *ctx, struct searchNode *thenode) { |
c86edd1d Q |
54 | free(thenode); |
55 | } | |
56 |