]>
Commit | Line | Data |
---|---|---|
88cd4141 IB |
1 | /* |
2 | * topic functionality | |
3 | */ | |
4 | ||
5 | #include "newsearch.h" | |
6 | ||
7 | #include <stdio.h> | |
8 | #include <stdlib.h> | |
9 | ||
c8be5183 CP |
10 | void *topic_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); |
11 | void topic_free(searchCtx *ctx, struct searchNode *thenode); | |
88cd4141 | 12 | |
f33f3f52 | 13 | struct searchNode *topic_parse(searchCtx *ctx, int argc, char **argv) { |
88cd4141 IB |
14 | struct searchNode *thenode; |
15 | ||
88cd4141 IB |
16 | if (!(thenode=(struct searchNode *)malloc(sizeof(struct searchNode)))) { |
17 | /* couldn't malloc() memory for thenode, so free localdata to avoid leakage */ | |
18 | parseError = "malloc: could not allocate memory for this search."; | |
88cd4141 IB |
19 | return NULL; |
20 | } | |
21 | ||
c7f7a584 | 22 | thenode->returntype = RETURNTYPE_STRING; |
23 | thenode->localdata = NULL; | |
88cd4141 IB |
24 | thenode->exe = topic_exe; |
25 | thenode->free = topic_free; | |
26 | ||
27 | return thenode; | |
28 | } | |
29 | ||
c8be5183 | 30 | void *topic_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) { |
88cd4141 | 31 | chanindex *cip = (chanindex *)theinput; |
88cd4141 | 32 | |
c7f7a584 | 33 | if ((cip->channel==NULL) || (cip->channel->topic==NULL)) |
34 | return ""; | |
35 | else | |
36 | return cip->channel->topic->content; | |
88cd4141 IB |
37 | } |
38 | ||
c8be5183 | 39 | void topic_free(searchCtx *ctx, struct searchNode *thenode) { |
88cd4141 IB |
40 | free(thenode); |
41 | } | |
42 |