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