]>
jfr.im git - irc/quakenet/newserv.git/blob - newsearch/ns-host.c
10 #include "../irc/irc_config.h"
11 #include "../lib/irc_string.h"
13 void *host_exe(struct searchNode
*thenode
, void *theinput
);
14 void *host_exe_real(struct searchNode
*thenode
, void *theinput
);
15 void host_free(struct searchNode
*thenode
);
17 struct searchNode
*host_parse(int type
, int argc
, char **argv
) {
18 struct searchNode
*thenode
;
20 if (type
!= SEARCHTYPE_NICK
) {
21 parseError
= "host: this function is only valid for nick searches.";
25 if (!(thenode
=(struct searchNode
*)malloc(sizeof (struct searchNode
)))) {
26 parseError
= "malloc: could not allocate memory for this search.";
30 thenode
->returntype
= RETURNTYPE_STRING
;
31 if (!(thenode
->localdata
= (void *)malloc(HOSTLEN
+1))) {
32 /* couldn't malloc() memory for thenode->localdata, so free thenode to avoid leakage */
33 parseError
= "malloc: could not allocate memory for this search.";
37 thenode
->exe
= host_exe
;
38 thenode
->free
= host_free
;
40 /* Allow "host real" to match realhost */
42 if (argc
>0 && !ircd_strcmp(argv
[0],"real")) {
43 thenode
->exe
= host_exe_real
;
49 void *host_exe(struct searchNode
*thenode
, void *theinput
) {
50 nick
*np
= (nick
*)theinput
;
51 char *buf
= thenode
->localdata
;
54 return np
->sethost
->content
;
55 } else if (IsHideHost(np
)) {
56 sprintf(buf
,"%s.%s",np
->authname
,HIS_HIDDENHOST
);
59 return np
->host
->name
->content
;
63 void *host_exe_real(struct searchNode
*thenode
, void *theinput
) {
64 nick
*np
= (nick
*)theinput
;
66 return np
->host
->name
->content
;
69 void host_free(struct searchNode
*thenode
) {
70 free(thenode
->localdata
);