forked from quakenet/newserv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathns-authname.c
47 lines (34 loc) · 1.01 KB
/
ns-authname.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* AUTHNAME functionality
*/
#include "newsearch.h"
#include <stdio.h>
#include <stdlib.h>
void *authname_exe(struct searchNode *thenode, void *theinput);
void authname_free(struct searchNode *thenode);
struct searchNode *authname_parse(int type, int argc, char **argv) {
struct searchNode *thenode;
if (type != SEARCHTYPE_NICK) {
parseError = "authname: this function is only valid for nick searches.";
return NULL;
}
if (!(thenode=(struct searchNode *)malloc(sizeof (struct searchNode)))) {
parseError = "malloc: could not allocate memory for this search.";
return NULL;
}
thenode->returntype = RETURNTYPE_STRING;
thenode->localdata = NULL;
thenode->exe = authname_exe;
thenode->free = authname_free;
return thenode;
}
void *authname_exe(struct searchNode *thenode, void *theinput) {
nick *np = (nick *)theinput;
if (IsAccount(np))
return np->authname;
else
return ""; /* will cast to a FALSE */
}
void authname_free(struct searchNode *thenode) {
free(thenode);
}