]> jfr.im git - irc/quakenet/newserv.git/blame - chanserv/newsearch/csns-qsuspendreason.c
chanserv nicksearch additions:
[irc/quakenet/newserv.git] / chanserv / newsearch / csns-qsuspendreason.c
CommitLineData
6d349eb0
CP
1/*
2 * qsuspendreason functionality
3 */
4
5#include "../../newsearch/newsearch.h"
6#include "../chanserv.h"
7
8#include <stdlib.h>
9
10void *qsuspendreason_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
11void qsuspendreason_free(searchCtx *ctx, struct searchNode *thenode);
12
13struct searchNode *qsuspendreason_parse(searchCtx *ctx, int type, int argc, char **argv) {
14 struct searchNode *thenode;
15
16 if (type != SEARCHTYPE_USER) {
17 parseError = "qsuspendreason: this function is only valid for user searches.";
18 return NULL;
19 }
20
21 if (!(thenode=(struct searchNode *)malloc(sizeof (struct searchNode)))) {
22 parseError = "malloc: could not allocate memory for this search.";
23 return NULL;
24 }
25
26 thenode->returntype = RETURNTYPE_STRING;
27 thenode->exe = qsuspendreason_exe;
28 thenode->free = qsuspendreason_free;
29
30 return thenode;
31}
32
33void *qsuspendreason_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
34 authname *ap = (authname *)theinput;
35 reguser *rup = ap->exts[chanservext];
36 if(!rup || !UHasSuspension(rup) || !rup->suspendreason)
37 return "";
38
39 return rup->suspendreason->content;
40}
41
42void qsuspendreason_free(searchCtx *ctx, struct searchNode *thenode) {
43 free(thenode);
44}
45