]>
jfr.im git - irc/quakenet/newserv.git/blob - newsearch/ns-hostmask.c
2 * HOSTMASK functionality
10 #include "../irc/irc_config.h"
11 #include "../lib/irc_string.h"
13 void *hostmask_exe(struct searchNode
*thenode
, int type
, void *theinput
);
14 void *hostmask_exe_real(struct searchNode
*thenode
, int type
, void *theinput
);
15 void hostmask_free(struct searchNode
*thenode
);
17 struct searchNode
*hostmask_parse(int type
, int argc
, char **argv
) {
18 struct searchNode
*thenode
;
20 if (type
!= SEARCHTYPE_NICK
) {
21 parseError
= "hostmask: this function is only valid for nick searches.";
25 thenode
=(struct searchNode
*)malloc(sizeof (struct searchNode
));
27 thenode
->returntype
= RETURNTYPE_STRING
;
28 thenode
->localdata
= (void *)malloc(HOSTLEN
+USERLEN
+NICKLEN
+3);
29 thenode
->exe
= hostmask_exe
;
30 thenode
->free
= hostmask_free
;
32 /* Allow "hostmask real" to match realhost */
34 if (argc
>0 && !ircd_strcmp(argv
[0],"real")) {
35 thenode
->exe
= hostmask_exe_real
;
41 void *hostmask_exe(struct searchNode
*thenode
, int type
, void *theinput
) {
42 nick
*np
= (nick
*)theinput
;
43 char *buf
= thenode
->localdata
;
45 if (type
!= RETURNTYPE_STRING
) {
49 return visiblehostmask(np
, buf
);
52 void *hostmask_exe_real(struct searchNode
*thenode
, int type
, void *theinput
) {
53 nick
*np
= (nick
*)theinput
;
54 char *buf
= thenode
->localdata
;
56 if (type
!= RETURNTYPE_STRING
) {
60 sprintf(buf
,"%s!%s@%s",np
->nick
,np
->ident
,np
->host
->name
->content
);
65 void hostmask_free(struct searchNode
*thenode
) {
66 free(thenode
->localdata
);