]>
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(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
);
14 void *host_exe_real(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
);
15 void host_free(searchCtx
*ctx
, struct searchNode
*thenode
);
17 struct searchNode
*host_parse(searchCtx
*ctx
, int argc
, char **argv
) {
18 struct searchNode
*thenode
;
20 if (!(thenode
=(struct searchNode
*)malloc(sizeof (struct searchNode
)))) {
21 parseError
= "malloc: could not allocate memory for this search.";
25 thenode
->returntype
= RETURNTYPE_STRING
;
26 if (!(thenode
->localdata
= (void *)malloc(HOSTLEN
+1))) {
27 /* couldn't malloc() memory for thenode->localdata, so free thenode to avoid leakage */
28 parseError
= "malloc: could not allocate memory for this search.";
32 thenode
->exe
= host_exe
;
33 thenode
->free
= host_free
;
35 /* Allow "host real" to match realhost */
37 if (argc
>0 && !ircd_strcmp(argv
[0],"real")) {
38 thenode
->exe
= host_exe_real
;
44 void *host_exe(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
) {
45 nick
*np
= (nick
*)theinput
;
46 char *buf
= thenode
->localdata
;
49 return np
->sethost
->content
;
50 } else if (IsHideHost(np
)) {
51 sprintf(buf
,"%s.%s",np
->authname
,HIS_HIDDENHOST
);
54 return np
->host
->name
->content
;
58 void *host_exe_real(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
) {
59 nick
*np
= (nick
*)theinput
;
61 return np
->host
->name
->content
;
64 void host_free(searchCtx
*ctx
, struct searchNode
*thenode
) {
65 free(thenode
->localdata
);