]>
jfr.im git - irc/quakenet/newserv.git/blob - newsearch/ns-host.c
10 #include "../irc/irc_config.h"
11 #include "../nick/nick.h"
12 #include "../lib/irc_string.h"
14 void *host_exe(struct searchNode
*thenode
, int type
, void *theinput
);
15 void *host_exe_real(struct searchNode
*thenode
, int type
, void *theinput
);
16 void host_free(struct searchNode
*thenode
);
18 struct searchNode
*host_parse(int type
, int argc
, char **argv
) {
19 struct searchNode
*thenode
;
21 if (type
!= SEARCHTYPE_NICK
) {
22 parseError
= "host: this function is only valid for nick searches.";
26 thenode
=(struct searchNode
*)malloc(sizeof (struct searchNode
));
28 thenode
->returntype
= RETURNTYPE_STRING
;
29 thenode
->localdata
= (void *)malloc(HOSTLEN
+1);
30 thenode
->exe
= host_exe
;
31 thenode
->free
= host_free
;
33 /* Allow "host real" to match realhost */
35 if (argc
>0 && !ircd_strcmp(argv
[0],"real")) {
36 thenode
->exe
= host_exe_real
;
42 void *host_exe(struct searchNode
*thenode
, int type
, void *theinput
) {
43 nick
*np
= (nick
*)theinput
;
44 char *buf
= thenode
->localdata
;
46 if (type
!= RETURNTYPE_STRING
) {
51 return np
->sethost
->content
;
52 } else if (IsHideHost(np
)) {
53 sprintf(buf
,"%s.%s",np
->authname
,HIS_HIDDENHOST
);
56 return np
->host
->name
->content
;
60 void *host_exe_real(struct searchNode
*thenode
, int type
, void *theinput
) {
61 nick
*np
= (nick
*)theinput
;
63 if (type
!= RETURNTYPE_STRING
) {
67 return np
->host
->name
->content
;
70 void host_free(struct searchNode
*thenode
) {
71 free(thenode
->localdata
);