]>
jfr.im git - irc/quakenet/newserv.git/blob - newsearch/ns-kill.c
10 #include "../control/control.h" /* controlreply() */
11 #include "../localuser/localuser.h" /* killuser() */
12 #include "../lib/irc_string.h" /* IPtostr() */
14 /* used for *_free functions that need to warn users of certain things
15 i.e. hitting too many users in a (kill) or (gline) - declared in newsearch.c */
16 extern const struct nick
*senderNSExtern
;
18 void *kill_exe(struct searchNode
*thenode
, int type
, void *theinput
);
19 void kill_free(struct searchNode
*thenode
);
21 struct kill_localdata
{
27 struct searchNode
*kill_parse(int type
, int argc
, char **argv
) {
28 struct kill_localdata
*localdata
;
29 struct searchNode
*thenode
;
31 localdata
= (struct kill_localdata
*) malloc(sizeof(struct kill_localdata
));
32 localdata
->nodes
= (struct searchNode
**) malloc(sizeof(struct searchNode
*) * argc
);
34 localdata
->marker
= nextnickmarker();
36 thenode
=(struct searchNode
*)malloc(sizeof (struct searchNode
));
38 thenode
->returntype
= RETURNTYPE_BOOL
;
39 thenode
->localdata
= localdata
;
40 thenode
->exe
= kill_exe
;
41 thenode
->free
= kill_free
;
46 void *kill_exe(struct searchNode
*thenode
, int type
, void *theinput
) {
47 struct kill_localdata
*localdata
;
48 nick
*np
= (nick
*)theinput
;
50 localdata
= thenode
->localdata
;
52 np
->marker
= localdata
->marker
;
59 case RETURNTYPE_STRING
:
65 void kill_free(struct searchNode
*thenode
) {
66 struct kill_localdata
*localdata
;
70 localdata
= thenode
->localdata
;
72 if (localdata
->count
> NSMAX_KILL_LIMIT
) {
73 /* need to warn the user that they have just tried to twat half the network ... */
74 controlreply(senderNSExtern
, "Warning: your pattern matches too many users (%d) - nothing done.", localdata
->count
);
75 free(localdata
->nodes
);
81 for (i
=0;i
<NICKHASHSIZE
;i
++) {
82 for (np
=nicktable
[i
];np
;np
=nnp
) {
84 if (np
->marker
== localdata
->marker
) {
85 if (!IsOper(np
) && !IsService(np
) && !IsXOper(np
)) {
86 killuser(NULL
, np
, "You (%s!%s@%s) have been disconnected for violating our terms of service.", np
->nick
,
87 np
->ident
, IPtostr(np
->ipaddress
));
95 controlreply(senderNSExtern
, "Warning: your pattern matched privileged users (%d in total) - these have not been touched.", safe
);
96 /* notify opers of the action */
97 controlwall(NO_OPER
, NL_KICKKILLS
, "%s/%s killed %d %s via nicksearch [%d untouched].", senderNSExtern
->nick
, senderNSExtern
->authname
, localdata
->count
,
98 localdata
->count
!= 1 ? "users" : "user", safe
);
99 free(localdata
->nodes
);