]> jfr.im git - irc/quakenet/newserv.git/blame - glines/glines_util.c
whowas: Make sure temporary whowas records are properly cleaned up.
[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
dd1aa3fb 23int glinebynick(nick *np, int duration, const char *reason, int flags, const char *creator) {
c60d02ed
GB
24 glinebuf gbuf;
25 int hits;
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);
c60d02ed
GB
29 glinebufaddbynick(&gbuf, np, flags, creator, reason, getnettime() + duration, getnettime(), getnettime() + duration);
30
ac80e3ab 31 glinebufcounthits(&gbuf, &hits, NULL);
c60d02ed
GB
32
33 if (flags & GLINE_SIMULATE)
0b2e8a55 34 glinebufabort(&gbuf);
c60d02ed 35 else
0b2e8a55 36 glinebufcommit(&gbuf, 1);
c60d02ed
GB
37
38 return hits;
39}
40
18845894
GB
41void glineunsetmask(const char *mask) {
42 gline *gl;
43
44 gl = findgline(mask);
45
46 if (!gl)
47 return;
48
49 gline_deactivate(gl, 0, 1);
50}