]> jfr.im git - irc/quakenet/newserv.git/blame - regexgline/regexgline.h
Add multiple uplink/hub/server support.
[irc/quakenet/newserv.git] / regexgline / regexgline.h
CommitLineData
1e0c4014
CP
1#ifndef __regexgline_H
2#define __regexgline_H
3
4#include <stdio.h>
5#include <stdlib.h>
6#include <stdarg.h>
1e0c4014
CP
7#include <errno.h>
8#include <pcre.h>
9#include <string.h>
4ad1cf7a 10#include <strings.h>
1e0c4014
CP
11
12#include "../core/config.h"
13#include "../control/control.h"
14#include "../lib/irc_string.h"
15#include "../localuser/localuserchannel.h"
16#include "../lib/sstring.h"
17#include "../core/schedule.h"
18
19#define RG_QUERY_BUF_SIZE 5120
20#define RG_MAX_CASUALTIES_DEFAULT 5000
21#define RG_MAX_SPEW_DEFAULT 300
22#define RG_REGEXGLINE_MAX 512
23#define RG_REASON_MAX 255
24#define RG_EXPIRY_BUFFER 200
25#define RG_MASKLEN HOSTLEN + USERLEN + NICKLEN + REALLEN + 5 /* includes NULL terminator */
26#define RG_PCREFLAGS PCRE_CASELESS
27#define RG_MIN_MASK_LEN 5
28#define RG_MAX_PER_GLINE_DEFAULT 5
5f3eb6fa
CP
29#define RG_MINIMUM_DELAY_TIME 5
30#define RG_MAXIMUM_RAND_TIME 15
1e0c4014 31#define RG_EXPIRY_TIME_DEFAULT 1800
481738a4 32#define RG_NETWORK_WIDE_MAX_GLINES_PER_8_SEC 625*8 /* 5000 / 8 */
1e0c4014
CP
33
34#define RGStringise(x) #x
d28e0741 35#define RGBuildHostname(buf, np) snprintf(buf, sizeof(buf), "%s!%s@%s\r%s", np->nick, np->ident, np->host->name->content, np->realname->name->content);
1e0c4014
CP
36#define RGMasksEqual(a, b) !strcasecmp(a, b)
37
1e0c4014
CP
38typedef struct rg_struct {
39 int id; /* database id */
40 sstring *mask; /* gline mask */
41 sstring *setby; /* who it's set by */
42 sstring *reason; /* reason for gline */
43 time_t expires; /* when it expires */
44 int type; /* gline type (user@ip or *@ip) */
45 pcre *regex; /* pcre expression */
46 pcre_extra *hint; /* pcre hint */
47 long glineid; /* gline ID */
86178656 48 const char *class; /* class of gline */
1e0c4014
CP
49 struct rg_struct *next; /* ... pointer to next item */
50} rg_struct;
51
1e0c4014
CP
52struct rg_struct *rg_list = NULL;
53
54int rg_max_casualties, rg_max_spew, rg_expiry_time, rg_max_per_gline;
1e0c4014
CP
55void *rg_schedule = NULL;
56
57void rg_nick(int hooknum, void *arg);
5f3eb6fa 58void rg_lostnick(int hooknum, void *arg);
1e0c4014
CP
59void rg_startup(void);
60
61int rg_gline(void *source, int cargc, char **cargv);
62int rg_delgline(void *source, int cargc, char **cargv);
63int rg_glist(void *source, int cargc, char **cargv);
64int rg_idlist(void *source, int cargc, char **cargv);
65int rg_spew(void *source, int cargc, char **cargv);
66int rg_sanitycheck(char *mask, int *count);
67
68int rg_dbconnect(void);
eba15ac4 69void rg_dbload(void);
1e0c4014
CP
70
71void rg_freestruct(struct rg_struct *rp);
72struct rg_struct *rg_newstruct(time_t expires);
86178656 73struct rg_struct *rg_newsstruct(unsigned long id, char *mask, char *setby, char *reason, char *expires, char *type, time_t iexpires, char *class);
1e0c4014
CP
74
75void rg_displaygline(nick *np, struct rg_struct *rp);
76
1e0c4014
CP
77void rg_checkexpiry(void *arg);
78
79void rg_logevent(nick *np, char *event, char *details, ...);
d28e0741 80void rg_loggline(struct rg_struct *rg, nick *np);
1e0c4014
CP
81
82unsigned char rc_hexlookup[256] = {
83 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
84 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
85 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
86 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
87 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x01,
88 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xff, 0xff,
89 0xff, 0xff, 0xff, 0xff, 0xff, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
90 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
91 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
92 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0a, 0x0b, 0x0c,
93 0x0d, 0x0e, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
94 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
95 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
96 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
97 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
98 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
99 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
100 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
101 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
102 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
103 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
104 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
105 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
106 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
107 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
108 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
109 };
110
111#endif