]>
jfr.im git - irc/quakenet/newserv.git/blob - newsearch/ns-hostmask.c
2 * HOSTMASK functionality
10 #include "../irc/irc_config.h"
11 #include "../nick/nick.h"
12 #include "../lib/irc_string.h"
14 void *hostmask_exe(struct searchNode
*thenode
, int type
, void *theinput
);
15 void *hostmask_exe_real(struct searchNode
*thenode
, int type
, void *theinput
);
16 void hostmask_free(struct searchNode
*thenode
);
18 struct searchNode
*hostmask_parse(int type
, int argc
, char **argv
) {
19 struct searchNode
*thenode
;
21 if (type
!= SEARCHTYPE_NICK
) {
22 parseError
= "hostmask: 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
+USERLEN
+NICKLEN
+3);
30 thenode
->exe
= hostmask_exe
;
31 thenode
->free
= hostmask_free
;
33 /* Allow "hostmask real" to match realhost */
35 if (argc
>0 && !ircd_strcmp(argv
[0],"real")) {
36 thenode
->exe
= hostmask_exe_real
;
42 void *hostmask_exe(struct searchNode
*thenode
, int type
, void *theinput
) {
43 nick
*np
= (nick
*)theinput
;
44 char *buf
= thenode
->localdata
;
46 if (type
!= RETURNTYPE_STRING
) {
50 return visiblehostmask(np
, buf
);
53 void *hostmask_exe_real(struct searchNode
*thenode
, int type
, void *theinput
) {
54 nick
*np
= (nick
*)theinput
;
55 char *buf
= thenode
->localdata
;
57 if (type
!= RETURNTYPE_STRING
) {
61 sprintf(buf
,"%s!%s@%s",np
->nick
,np
->ident
,np
->host
->name
->content
);
66 void hostmask_free(struct searchNode
*thenode
) {
67 free(thenode
->localdata
);