]>
jfr.im git - irc/quakenet/newserv.git/blob - newsearch/ns-gline.c
7675f64c36dc181a1757383587a9ca0542afb823
10 #include "../control/control.h" /* controlreply() */
11 #include "../irc/irc.h" /* irc_send() */
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 *gline_exe(struct searchNode
*thenode
, int type
, void *theinput
);
19 void gline_free(struct searchNode
*thenode
);
21 struct gline_localdata
{
27 struct searchNode
*gline_parse(int type
, int argc
, char **argv
) {
28 struct gline_localdata
*localdata
;
29 struct searchNode
*thenode
;
31 localdata
= (struct gline_localdata
*) malloc(sizeof(struct gline_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
= gline_exe
;
41 thenode
->free
= gline_free
;
46 void *gline_exe(struct searchNode
*thenode
, int type
, void *theinput
) {
47 struct gline_localdata
*localdata
;
48 nick
*np
= (nick
*)theinput
;
50 localdata
= thenode
->localdata
;
52 np
->marker
= localdata
->marker
;
59 case RETURNTYPE_STRING
:
65 void gline_free(struct searchNode
*thenode
) {
66 struct gline_localdata
*localdata
;
70 localdata
= thenode
->localdata
;
72 if (localdata
->count
> NSMAX_GLINE_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 if (np
->ident
[0] == '~')
87 irc_send("%s GL * +*@%s %u 1 :You (%s!%s@%s) have been glined for violating our terms of service.",
88 mynumeric
->content
, IPtostr(np
->ipaddress
), NSGLINE_DURATION
, np
->nick
, np
->ident
, IPtostr(np
->ipaddress
));
90 irc_send("%s GL * +%s@%s %u 1 :You (%s!%s@%s) have been glined for violating our terms of service.",
91 mynumeric
->content
, np
->ident
, IPtostr(np
->ipaddress
), NSGLINE_DURATION
, np
->nick
, np
->ident
, IPtostr(np
->ipaddress
));
99 controlreply(senderNSExtern
, "Warning: your pattern matched privileged users (%d in total) - these have not been touched.", safe
);
100 free(localdata
->nodes
);