]> jfr.im git - irc/quakenet/newserv.git/blame - glines/glines.h
Merge chanserv-live into default.
[irc/quakenet/newserv.git] / glines / glines.h
CommitLineData
813c5b73
CP
1#ifndef __GLINES_H
2#define __GLINES_H
3
a44fc5f7
GB
4#include "../lib/sstring.h"
5#include "../nick/nick.h"
6#include "../channel/channel.h"
accce086 7#include "../whowas/whowas.h"
a44fc5f7 8
22833ec3 9#define SNIRCD_VERSION 134
c684f472 10
cb581522
GB
11#define MAXUSERGLINEUSERHITS 100
12#define MAXUSERGLINECHANNELHITS 10
18845894
GB
13
14#define MAXGLINEDURATION 90 * 86400
15#define MINGLINEREASONLEN 10
a473a1be 16
cb581522
GB
17#define MAXGLINEUSERHITS 500
18#define MAXGLINECHANNELHITS 50
a44fc5f7 19
ce11a200
GB
20#define MAXGLINELOG 500
21
a473a1be 22#define GLINE_IGNORE_TRUST 1
8f128e0d
GB
23#define GLINE_ALWAYS_NICK 2
24#define GLINE_ALWAYS_USER 4
18845894 25#define GLINE_SIMULATE 8
a473a1be 26
96662a86
GB
27#define GLINE_HOSTMASK 1 /* Gline includes a host mask */
28#define GLINE_IPMASK 2 /* Gline includes an CIDR mask */
29#define GLINE_BADCHAN 4 /* Gline includes a badchan */
30#define GLINE_REALNAME 8 /* Gline includes a realname */
31#define GLINE_ACTIVATE 16 /* Gline should be activated */
32#define GLINE_DEACTIVATE 32 /* Gline should be deactivated */
20447d72
GB
33#define GLINE_DESTROY 64 /* Gline should be destroyed */
34#define GLINE_ACTIVE 128 /* Gline is active */
35#define GLINE_DESTROYED 256 /* Gline is destroyed */
a44fc5f7
GB
36
37/**
38 * glist flags
39 */
40#define GLIST_COUNT 0x01 /* -c */
41#define GLIST_EXACT 0x02 /* -x */
42#define GLIST_FIND 0x04 /* -f */
43#define GLIST_REASON 0x10 /* -r */
44#define GLIST_OWNER 0x20 /* -o */
45#define GLIST_REALNAME 0x40 /* -R */
46#define GLIST_INACTIVE 0x80 /* -i */
47
580103bc
GB
48#define GLSTORE_PATH_PREFIX "data/glines"
49#define GLSTORE_SAVE_FILES 5
50#define GLSTORE_SAVE_INTERVAL 3600
51
a44fc5f7
GB
52/**
53 * Interpret absolute/relative timestamps with same method as snircd
54 * If the expiration value, interpreted as an absolute timestamp, is
55 * more recent than 5 years in the past, we interpret it as an
56 * absolute timestamp; otherwise, we assume it's relative and convert
57 * it to an absolute timestamp.
58 */
59#define abs_expire(exp) ((exp) >= getnettime() - 157680000 ? (exp) : (exp) + getnettime())
60
c684f472 61#define gline_max(a, b) (((a)<(b)) ? (b) : (a))
a44fc5f7
GB
62
63typedef struct gline {
64 sstring *nick;
65 sstring *user;
66 sstring *host;
67 sstring *reason;
68 sstring *creator;
69
70 struct irc_in_addr ip;
71 unsigned char bits;
72
73 time_t expire;
74 time_t lastmod;
75 time_t lifetime;
76
77 unsigned int flags;
31c690b7 78 int glinebufid;
a44fc5f7
GB
79
80 struct gline *next;
81} gline;
82
cb581522 83typedef struct glinebuf {
ce11a200
GB
84 int id;
85 sstring *comment;
324b4e11 86 time_t commit;
9f47116c 87 time_t amend;
ce11a200 88
bbb80250
GB
89 gline *glines;
90
33e09c2c 91 int hitsvalid;
bbb80250
GB
92 int userhits;
93 int channelhits;
a887af59
GB
94
95 array hits;
cb581522 96} glinebuf;
8f128e0d 97
0e1e87e6
TS
98typedef struct glineinfo {
99 int hits;
100 char *mask;
101} glineinfo;
102
cb581522 103extern gline *glinelist;
ce11a200
GB
104extern glinebuf *glinebuflog[MAXGLINELOG];
105extern int glinebuflogoffset;
8f128e0d 106
a44fc5f7 107/* glines.c */
96662a86 108gline *findgline(const char *);
a44fc5f7 109void gline_propagate(gline *);
331ecd41 110void gline_deactivate(gline *, time_t, int);
20447d72 111void gline_destroy(gline *, time_t, int);
331ecd41 112void gline_activate(gline *agline, time_t lastmod, int propagate);
a44fc5f7
GB
113int glineequal(gline *, gline *);
114int gline_match_mask(gline *gla, gline *glb);
115int gline_match_nick(gline *gl, nick *np);
116int gline_match_channel(gline *gl, channel *cp);
a86fc0c4 117int isglinesane(gline *gl, const char **hint);
ce11a200 118gline *glinedup(gline *gl);
a86fc0c4
GB
119
120/* glines_formats.c */
121gline *makegline(const char *);
122char *glinetostring(gline *g);
a44fc5f7 123
a86fc0c4 124/* glines_util.c */
dd1aa3fb 125int glinebyip(const char *user, struct irc_in_addr *ip, unsigned char bits, int duration, const char *reason, int flags, const char *creator);
0e1e87e6 126glineinfo *glinebynickex(nick *np, int duration, const char *reason, int flags, const char *creator);
dd1aa3fb 127int glinebynick(nick *np, int duration, const char *reason, int flags, const char *creator);
18845894 128void glineunsetmask(const char *mask);
cb581522
GB
129
130/* glines_buf.c */
324b4e11 131void glinebufinit(glinebuf *gbuf, int id);
cb581522 132gline *glinebufadd(glinebuf *gbuf, const char *mask, const char *creator, const char *reason, time_t expire, time_t lastmod, time_t lifetime);
0e1e87e6
TS
133char *glinebufaddbyip(glinebuf *gbuf, const char *user, struct irc_in_addr *ip, unsigned char bits, int flags, const char *creator, const char *reason, time_t expire, time_t lastmod, time_t lifetime);
134char *glinebufaddbynick(glinebuf *gbuf, nick *, int flags, const char *creator, const char *reason, time_t expire, time_t lastmod, time_t lifetime);
accce086 135void glinebufaddbywhowas(glinebuf *gbuf, whowas *, int flags, const char *creator, const char *reason, time_t expire, time_t lastmod, time_t lifetime);
33e09c2c
GB
136void glinebufcounthits(glinebuf *gbuf, int *users, int *channels);
137int glinebufchecksane(glinebuf *gbuf, nick *spewto, int overridesanity, int overridelimit);
56af56be 138void glinebufspew(glinebuf *gbuf, nick *spewto);
324b4e11 139void glinebufmerge(glinebuf *gbuf);
0c925dc0 140int glinebufcommit(glinebuf *gbuf, int propagate);
0b2e8a55
GB
141void glinebufabort(glinebuf *gbuf);
142int glinebufundo(int id);
ce11a200
GB
143void glinebufcommentf(glinebuf *gbuf, const char *format, ...);
144void glinebufcommentv(glinebuf *gbuf, const char *prefix, int cargc, char **cargv);
fe262e64 145int glinebufwritelog(glinebuf *gbuf, int propagating);
cb581522 146
a44fc5f7
GB
147/* glines_alloc.c */
148void freegline(gline *);
149gline *newgline();
150void removegline(gline *);
151
152/* glines_handler.c */
153int handleglinemsg(void *, int, char **);
154void handleglinestats(int hooknum, void *arg);
155
580103bc
GB
156/* glines_store.c */
157int glstore_save(void);
158int glstore_load(void);
159
813c5b73 160#endif