]> jfr.im git - irc/quakenet/newserv.git/blame - newsearch/ns-hostmask.c
removed usless nodes datatype from kill_localdata/gline_localdata (+ corresponding...
[irc/quakenet/newserv.git] / newsearch / ns-hostmask.c
CommitLineData
c86edd1d
Q
1/*
2 * HOSTMASK functionality
3 */
4
5#include "newsearch.h"
6
7#include <stdio.h>
8#include <stdlib.h>
9
10#include "../irc/irc_config.h"
c86edd1d
Q
11#include "../lib/irc_string.h"
12
13void *hostmask_exe(struct searchNode *thenode, int type, void *theinput);
14void *hostmask_exe_real(struct searchNode *thenode, int type, void *theinput);
15void hostmask_free(struct searchNode *thenode);
16
17struct searchNode *hostmask_parse(int type, int argc, char **argv) {
18 struct searchNode *thenode;
19
20 if (type != SEARCHTYPE_NICK) {
21 parseError = "hostmask: this function is only valid for nick searches.";
22 return NULL;
23 }
24
25 thenode=(struct searchNode *)malloc(sizeof (struct searchNode));
26
27 thenode->returntype = RETURNTYPE_STRING;
28 thenode->localdata = (void *)malloc(HOSTLEN+USERLEN+NICKLEN+3);
29 thenode->exe = hostmask_exe;
30 thenode->free = hostmask_free;
31
32 /* Allow "hostmask real" to match realhost */
33
34 if (argc>0 && !ircd_strcmp(argv[0],"real")) {
35 thenode->exe = hostmask_exe_real;
36 }
37
38 return thenode;
39}
40
41void *hostmask_exe(struct searchNode *thenode, int type, void *theinput) {
42 nick *np = (nick *)theinput;
43 char *buf = thenode->localdata;
44
45 if (type != RETURNTYPE_STRING) {
46 return (void *)1;
47 }
48
49 return visiblehostmask(np, buf);
50}
51
52void *hostmask_exe_real(struct searchNode *thenode, int type, void *theinput) {
53 nick *np = (nick *)theinput;
54 char *buf = thenode->localdata;
55
56 if (type != RETURNTYPE_STRING) {
57 return (void *)1;
58 }
59
60 sprintf(buf,"%s!%s@%s",np->nick,np->ident,np->host->name->content);
61
62 return buf;
63}
64
65void hostmask_free(struct searchNode *thenode) {
66 free(thenode->localdata);
67 free(thenode);
68}
69