]> jfr.im git - irc/quakenet/newserv.git/blame - glines/glines.h
Implement support for O's 4 parameter (local) glines.
[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"
7
c684f472
GB
8#define SNIRCD_13
9#undef SNIRCD_14
10
11#define MAXGLINEUSERS 100
96662a86 12#define MAXGLINECHANNELS 10
a473a1be 13
a44fc5f7
GB
14#define MAXUSERGLINEDURATION (90 * 86400)
15#define MINUSERGLINEREASON 10
16
a473a1be 17#define GLINE_IGNORE_TRUST 1
8f128e0d
GB
18#define GLINE_ALWAYS_NICK 2
19#define GLINE_ALWAYS_USER 4
20#define GLINE_NO_LIMIT 8
21#define GLINE_SIMULATE 16
a473a1be 22
96662a86
GB
23#define GLINE_HOSTMASK 1 /* Gline includes a host mask */
24#define GLINE_IPMASK 2 /* Gline includes an CIDR mask */
25#define GLINE_BADCHAN 4 /* Gline includes a badchan */
26#define GLINE_REALNAME 8 /* Gline includes a realname */
27#define GLINE_ACTIVATE 16 /* Gline should be activated */
28#define GLINE_DEACTIVATE 32 /* Gline should be deactivated */
29#define GLINE_ACTIVE 64 /* Gline is active */
a44fc5f7
GB
30
31/**
32 * glist flags
33 */
34#define GLIST_COUNT 0x01 /* -c */
35#define GLIST_EXACT 0x02 /* -x */
36#define GLIST_FIND 0x04 /* -f */
37#define GLIST_REASON 0x10 /* -r */
38#define GLIST_OWNER 0x20 /* -o */
39#define GLIST_REALNAME 0x40 /* -R */
40#define GLIST_INACTIVE 0x80 /* -i */
41
42/**
43 * Interpret absolute/relative timestamps with same method as snircd
44 * If the expiration value, interpreted as an absolute timestamp, is
45 * more recent than 5 years in the past, we interpret it as an
46 * absolute timestamp; otherwise, we assume it's relative and convert
47 * it to an absolute timestamp.
48 */
49#define abs_expire(exp) ((exp) >= getnettime() - 157680000 ? (exp) : (exp) + getnettime())
50
c684f472 51#define gline_max(a, b) (((a)<(b)) ? (b) : (a))
a44fc5f7
GB
52
53typedef struct gline {
54 sstring *nick;
55 sstring *user;
56 sstring *host;
57 sstring *reason;
58 sstring *creator;
59
60 struct irc_in_addr ip;
61 unsigned char bits;
62
63 time_t expire;
64 time_t lastmod;
65 time_t lifetime;
66
67 unsigned int flags;
68
69 struct gline *next;
70} gline;
71
c684f472
GB
72extern gline *glinelist;
73
8f128e0d
GB
74typedef struct gline_params {
75 int duration;
76 const char *reason;
3c5c26a8 77 const char *creator;
8f128e0d
GB
78} gline_params;
79
80typedef void (*gline_callback)(const char *, int, void *);
81
a44fc5f7 82/* glines.c */
96662a86
GB
83int glinesetmask(const char *mask, int duration, const char *reason, const char *creator);
84int glineunsetmask(const char *mask);
8f128e0d
GB
85
86int glinesuggestbyip(const char *, struct irc_in_addr *, unsigned char, int, gline_callback callback, void *uarg);
87int glinesuggestbynick(nick *, int, gline_callback callback, void *uarg);
3c5c26a8
GB
88int glinebyip(const char *, struct irc_in_addr *, unsigned char, int, const char *, int, const char *);
89int glinebynick(nick *, int, const char *, int, const char *);
813c5b73 90
a44fc5f7
GB
91gline *gline_add(const char *creator, const char *mask, const char *reason, time_t expire, time_t lastmod, time_t lifetime);
92char *glinetostring(gline *g);
96662a86 93gline *findgline(const char *);
a44fc5f7
GB
94gline *makegline(const char *);
95void gline_propagate(gline *);
96gline *gline_deactivate(gline *, time_t, int);
97gline *gline_activate(gline *agline, time_t lastmod, int propagate);
98int glineequal(gline *, gline *);
c684f472 99int gline_count_hits(gline *gl);
a44fc5f7
GB
100int gline_match_mask(gline *gla, gline *glb);
101int gline_match_nick(gline *gl, nick *np);
102int gline_match_channel(gline *gl, channel *cp);
103
104/* glines_alloc.c */
105void freegline(gline *);
106gline *newgline();
107void removegline(gline *);
108
109/* glines_handler.c */
110int handleglinemsg(void *, int, char **);
111void handleglinestats(int hooknum, void *arg);
112
813c5b73 113#endif