]>
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) { |
31686847 | 16 | struct searchNode *thenode, *convsn; |
c86edd1d | 17 | channel *cp; |
31686847 CP |
18 | char *p; |
19 | ||
c86edd1d Q |
20 | if (argc<1) { |
21 | parseError = "channel: usage: channel <channel name>"; | |
22 | return NULL; | |
23 | } | |
24 | ||
31686847 CP |
25 | if (!(convsn=argtoconststr("channel", ctx, argv[0], &p))) |
26 | return NULL; | |
27 | ||
28 | cp=findchannel(p); | |
29 | convsn->free(ctx, convsn); | |
30 | if (!cp) { | |
c86edd1d Q |
31 | parseError = "channel: unknown channel"; |
32 | return NULL; | |
33 | } | |
34 | ||
9ce4f0be IB |
35 | if (!(thenode=(struct searchNode *)malloc(sizeof (struct searchNode)))) { |
36 | parseError = "malloc: could not allocate memory for this search."; | |
37 | return NULL; | |
38 | } | |
c86edd1d | 39 | |
c7f7a584 | 40 | thenode->returntype = RETURNTYPE_BOOL; |
c86edd1d Q |
41 | thenode->localdata = cp; |
42 | thenode->exe = channel_exe; | |
43 | thenode->free = channel_free; | |
44 | ||
45 | return thenode; | |
46 | } | |
47 | ||
c8be5183 | 48 | void *channel_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) { |
c86edd1d Q |
49 | nick *np = (nick *)theinput; |
50 | channel *cp = thenode->localdata; | |
51 | ||
52 | if (getnumerichandlefromchanhash(cp->users, np->numeric)) { | |
c7f7a584 | 53 | return (void *)1; |
c86edd1d | 54 | } else { |
c7f7a584 | 55 | return (void *)0; |
c86edd1d Q |
56 | } |
57 | } | |
58 | ||
c8be5183 | 59 | void channel_free(searchCtx *ctx, struct searchNode *thenode) { |
c86edd1d Q |
60 | free(thenode); |
61 | } | |
62 |