]> jfr.im git - irc/quakenet/newserv.git/blame - glines/glines_util.c
BUILD: add require-all build mode
[irc/quakenet/newserv.git] / glines / glines_util.c
CommitLineData
c60d02ed 1#include "../irc/irc.h"
26097de7 2#include "../trusts/trusts.h"
c60d02ed
GB
3#include "glines.h"
4
dd1aa3fb 5int glinebyip(const char *user, struct irc_in_addr *ip, unsigned char bits, int duration, const char *reason, int flags, const char *creator) {
c60d02ed
GB
6 glinebuf gbuf;
7 int hits;
8
324b4e11 9 glinebufinit(&gbuf, 0);
3898f973 10 glinebufcommentf(&gbuf, "on IP mask %s@%s, set by %s", user, CIDRtostr(*ip, bits), creator);
c60d02ed
GB
11 glinebufaddbyip(&gbuf, user, ip, bits, flags, creator, reason, getnettime() + duration, getnettime(), getnettime() + duration);
12
ac80e3ab 13 glinebufcounthits(&gbuf, &hits, NULL);
c60d02ed
GB
14
15 if (flags & GLINE_SIMULATE)
0b2e8a55 16 glinebufabort(&gbuf);
c60d02ed 17 else
0b2e8a55 18 glinebufcommit(&gbuf, 1);
c60d02ed
GB
19
20 return hits;
21}
22
0e1e87e6
TS
23glineinfo *glinebynickex(nick *np, int duration, const char *reason, int flags, const char *creator) {
24 static glineinfo info;
c60d02ed 25 glinebuf gbuf;
c60d02ed 26
324b4e11 27 glinebufinit(&gbuf, 0);
26097de7 28 glinebufcommentf(&gbuf, "on nick %s!%s@%s, set by %s", np->nick, np->ident, np->host->name->content, creator);
0e1e87e6 29 info.mask = glinebufaddbynick(&gbuf, np, flags, creator, reason, getnettime() + duration, getnettime(), getnettime() + duration);
c60d02ed 30
0e1e87e6 31 glinebufcounthits(&gbuf, &info.hits, NULL);
c60d02ed
GB
32
33 if (flags & GLINE_SIMULATE)
0b2e8a55 34 glinebufabort(&gbuf);
c60d02ed 35 else
0b2e8a55 36 glinebufcommit(&gbuf, 1);
c60d02ed 37
0e1e87e6
TS
38 return &info;
39}
40
41int glinebynick(nick *np, int duration, const char *reason, int flags, const char *creator) {
42 glineinfo *result = glinebynickex(np, duration, reason, flags, creator);
43 return result->hits;
c60d02ed
GB
44}
45
18845894
GB
46void glineunsetmask(const char *mask) {
47 gline *gl;
48
49 gl = findgline(mask);
50
51 if (!gl)
52 return;
53
54 gline_deactivate(gl, 0, 1);
55}