]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * authedpct functionality | |
3 | */ | |
4 | ||
5 | #include "newsearch.h" | |
6 | ||
7 | #include <stdio.h> | |
8 | #include <stdlib.h> | |
9 | ||
10 | void *authedpct_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput); | |
11 | void authedpct_free(searchCtx *ctx, struct searchNode *thenode); | |
12 | ||
13 | struct searchNode *authedpct_parse(searchCtx *ctx, int argc, char **argv) { | |
14 | struct searchNode *thenode; | |
15 | ||
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."; | |
19 | return NULL; | |
20 | } | |
21 | ||
22 | thenode->returntype = RETURNTYPE_INT; | |
23 | thenode->localdata = NULL; | |
24 | thenode->exe = authedpct_exe; | |
25 | thenode->free = authedpct_free; | |
26 | ||
27 | return thenode; | |
28 | } | |
29 | ||
30 | void *authedpct_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) { | |
31 | int i; | |
32 | int j=0; | |
33 | nick *np; | |
34 | chanindex *cip = (chanindex *)theinput; | |
35 | ||
36 | if (!cip->channel) | |
37 | return (void *)0; | |
38 | ||
39 | for (i=0;i<cip->channel->users->hashsize;i++) { | |
40 | if (cip->channel->users->content[i]==nouser) | |
41 | continue; | |
42 | ||
43 | if ((np=getnickbynumeric(cip->channel->users->content[i])) && IsAccount(np)) | |
44 | j++; | |
45 | } | |
46 | ||
47 | return (void *)(long)((j * 100) / cip->channel->users->totalusers); | |
48 | } | |
49 | ||
50 | void authedpct_free(searchCtx *ctx, struct searchNode *thenode) { | |
51 | free(thenode); | |
52 | } | |
53 |