forked from XthemeOrg/xtheme-contrib-modules
/
os_alert.h
105 lines (84 loc) · 2.22 KB
/
os_alert.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#ifndef INCLUDE_OS_ALERT_H
#define INCLUDE_OS_ALERT_H
/* A pattern, represented by a glob or a regex */
typedef struct {
enum {
PAT_GLOB = 0, PAT_REGEX = 1
} type;
union {
char *glob;
struct {
char *pattern;
int flags;
atheme_regex_t *regex;
} regex;
} pattern;
} alert_pattern_t;
/* The type of event that a criteria can be triggered on. */
typedef enum {
EVT_CONNECT = 0x01,
EVT_IDENTIFY = 0x02,
EVT_REGISTER = 0x04,
EVT_DROP = 0x08,
EVT_HOST = 0x10,
EVT_JOIN = 0x20,
EVT_PART = 0x40,
EVT_NICK = 0x80
} alert_event_t;
typedef struct alert_criteria_ alert_criteria_t;
typedef struct alert_action_ alert_action_t;
typedef struct alert_ alert_t;
/* A constructor for an alert criteria. */
typedef struct {
alert_criteria_t *(*prepare)(char **args);
bool (*exec)(user_t *u, alert_criteria_t *c);
void (*cleanup)(alert_criteria_t *c);
void (*display)(char *s, size_t size, alert_criteria_t *c);
alert_event_t event_mask;
} alert_criteria_constructor_t;
/* An alert criteria. */
struct alert_criteria_ {
alert_criteria_constructor_t *cons;
};
typedef struct {
alert_criteria_t base;
alert_pattern_t *pattern;
} alert_pattern_criteria_t;
typedef struct {
alert_criteria_t base;
bool identified;
} alert_identified_criteria_t;
typedef enum {
OP_LT = 0,
OP_LEQ = 1,
OP_EQ = 2,
OP_GEQ = 3,
OP_GT = 4
} alert_op_t;
typedef struct {
alert_criteria_t base;
alert_op_t op;
size_t numchans;
} alert_numchan_criteria_t;
/* A constructor for an alert action. */
typedef struct {
alert_action_t *(*prepare)(char **args);
void (*exec)(user_t *u, alert_action_t *a);
void (*cleanup)(alert_action_t *a);
void (*display)(char *s, size_t size, alert_action_t *a);
} alert_action_constructor_t;
/* An alert action. */
struct alert_action_ {
alert_action_constructor_t *cons;
alert_t *alert;
};
/* An alert */
struct alert_ {
char *owner; /* Who owns the alert. This is an entity name. */
alert_event_t event_mask; /* What events this triggers on. */
alert_action_t *action; /* The alert action. */
mowgli_list_t criteria; /* The list of criteria. */
mowgli_node_t *node; /* The pointer in nodes */
mowgli_node_t *owned_node; /* The pointer in owned_nodes */
};
#endif