]> jfr.im git - irc/quakenet/newserv.git/blame - regexgline/regexgline.h
only send suspend reason if its set
[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>
7#include <mysql/mysql.h>
8#include <errno.h>
9#include <pcre.h>
10#include <string.h>
4ad1cf7a 11#include <strings.h>
1e0c4014
CP
12
13#include "../core/config.h"
14#include "../control/control.h"
15#include "../lib/irc_string.h"
16#include "../localuser/localuserchannel.h"
17#include "../lib/sstring.h"
18#include "../core/schedule.h"
19
20#define RG_QUERY_BUF_SIZE 5120
21#define RG_MAX_CASUALTIES_DEFAULT 5000
22#define RG_MAX_SPEW_DEFAULT 300
23#define RG_REGEXGLINE_MAX 512
24#define RG_REASON_MAX 255
25#define RG_EXPIRY_BUFFER 200
26#define RG_MASKLEN HOSTLEN + USERLEN + NICKLEN + REALLEN + 5 /* includes NULL terminator */
27#define RG_PCREFLAGS PCRE_CASELESS
28#define RG_MIN_MASK_LEN 5
29#define RG_MAX_PER_GLINE_DEFAULT 5
5f3eb6fa
CP
30#define RG_MINIMUM_DELAY_TIME 5
31#define RG_MAXIMUM_RAND_TIME 15
1e0c4014
CP
32#define RG_EXPIRY_TIME_DEFAULT 1800
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
38typedef MYSQL_RES *rg_sqlresult;
39typedef MYSQL_ROW rg_sqlrow;
40typedef MYSQL rg_sqlconnection;
41
42typedef struct rg_struct {
43 int id; /* database id */
44 sstring *mask; /* gline mask */
45 sstring *setby; /* who it's set by */
46 sstring *reason; /* reason for gline */
47 time_t expires; /* when it expires */
48 int type; /* gline type (user@ip or *@ip) */
49 pcre *regex; /* pcre expression */
50 pcre_extra *hint; /* pcre hint */
51 long glineid; /* gline ID */
52 struct rg_struct *next; /* ... pointer to next item */
53} rg_struct;
54
55rg_sqlconnection rg_sql;
56struct rg_struct *rg_list = NULL;
57
58int rg_max_casualties, rg_max_spew, rg_expiry_time, rg_max_per_gline;
59int rg_sqlconnected = 0;
60void *rg_schedule = NULL;
61
62void rg_nick(int hooknum, void *arg);
5f3eb6fa 63void rg_lostnick(int hooknum, void *arg);
1e0c4014
CP
64void rg_startup(void);
65
66int rg_gline(void *source, int cargc, char **cargv);
67int rg_delgline(void *source, int cargc, char **cargv);
68int rg_glist(void *source, int cargc, char **cargv);
69int rg_idlist(void *source, int cargc, char **cargv);
70int rg_spew(void *source, int cargc, char **cargv);
71int rg_sanitycheck(char *mask, int *count);
72
73int rg_dbconnect(void);
74int rg_dbload(void);
75
76int rg_sqlconnect(char *dbhost, char *dbuser, char *dbpass, char *db, unsigned int port);
77void rg_sqldisconnect(void);
78void rg_sqlescape_string(char *dest, char *source, size_t length);
79int rg_sqlquery(char *format, ...);
80rg_sqlresult rg_sqlstoreresult(void);
81rg_sqlrow rg_sqlgetrow(rg_sqlresult res);
82void rg_sqlfree(rg_sqlresult res);
83
84void rg_freestruct(struct rg_struct *rp);
85struct rg_struct *rg_newstruct(time_t expires);
86struct rg_struct *rg_newsstruct(char *id, char *mask, char *setby, char *reason, char *expires, char *type, time_t iexpires, int iid);
87
88void rg_displaygline(nick *np, struct rg_struct *rp);
89
1e0c4014
CP
90void rg_checkexpiry(void *arg);
91
92void rg_logevent(nick *np, char *event, char *details, ...);
d28e0741 93void rg_loggline(struct rg_struct *rg, nick *np);
1e0c4014
CP
94
95unsigned char rc_hexlookup[256] = {
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, 0x00, 0x01,
101 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xff, 0xff,
102 0xff, 0xff, 0xff, 0xff, 0xff, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
103 0x0f, 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, 0x0a, 0x0b, 0x0c,
106 0x0d, 0x0e, 0x0f, 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, 0xff, 0xff, 0xff, 0xff,
109 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
110 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
111 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
112 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
113 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
114 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
115 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
116 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
117 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
118 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
119 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
120 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
121 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
122 };
123
124#endif