]> jfr.im git - irc/quakenet/newserv.git/blob - newsearch/newsearch.h
28714aa52424f1ad68259691320c0eba54828fd3
[irc/quakenet/newserv.git] / newsearch / newsearch.h
1 #include "../nick/nick.h"
2 #include "../parser/parser.h"
3 #include "../channel/channel.h"
4 #include "../lib/flags.h"
5
6 #define SEARCHTYPE_CHANNEL 1
7 #define SEARCHTYPE_NICK 2
8
9
10 #define NSMAX_KILL_LIMIT 500
11 #define NSMAX_GLINE_LIMIT 500
12
13
14 #define NSMAX_GLINE_CLONES 5
15
16
17 /* gline duration, in seconds */
18 #define NSGLINE_DURATION 3600
19
20
21 #define RETURNTYPE_BOOL 0x01
22 #define RETURNTYPE_INT 0x02
23 #define RETURNTYPE_STRING 0x03
24 #define RETURNTYPE_TYPE 0xFF
25 #define RETURNTYPE_CONST 0x100
26
27 struct searchNode;
28
29 typedef struct searchNode *(*parseFunc)(int, int, char **);
30 typedef void (*freeFunc)(struct searchNode *);
31 typedef void *(*exeFunc)(struct searchNode *, void *);
32
33 /* Core functions */
34 /* Logical (BOOL -> BOOL)*/
35 struct searchNode *and_parse(int type, int argc, char **argv);
36 struct searchNode *not_parse(int type, int argc, char **argv);
37 struct searchNode *or_parse(int type, int argc, char **argv);
38
39 /* Comparison (INT -> BOOL) */
40 struct searchNode *eq_parse(int type, int argc, char **argv);
41 struct searchNode *lt_parse(int type, int argc, char **argv);
42 struct searchNode *gt_parse(int type, int argc, char **argv);
43
44 /* String match (STRING -> BOOL) */
45 struct searchNode *match_parse(int type, int argc, char **argv);
46 struct searchNode *regex_parse(int type, int argc, char **argv);
47
48 /* Length (STRING -> INT) */
49 struct searchNode *length_parse(int type, int argc, char **argv);
50
51 /* kill/gline actions (BOOL) */
52 struct searchNode *kill_parse(int type, int argc, char **argv);
53 struct searchNode *gline_parse(int type, int argc, char **argv);
54
55 /* Nick/Channel functions (various types) */
56 struct searchNode *nick_parse(int type, int argc, char **argv);
57 struct searchNode *modes_parse(int type, int argc, char **argv);
58
59 /* Nick functions (various types) */
60 struct searchNode *hostmask_parse(int type, int argc, char **argv);
61 struct searchNode *realname_parse(int type, int argc, char **argv);
62 struct searchNode *authname_parse(int type, int argc, char **argv);
63 struct searchNode *ident_parse(int type, int argc, char **argv);
64 struct searchNode *host_parse(int type, int argc, char **argv);
65 struct searchNode *channel_parse(int type, int argc, char **argv);
66 struct searchNode *timestamp_parse(int type, int argc, char **argv);
67 struct searchNode *country_parse(int type, int argc, char **argv);
68 struct searchNode *ip_parse(int type, int argc, char **argv);
69
70 /* Channel functions (various types) */
71 struct searchNode *exists_parse(int type, int argc, char **argv);
72 struct searchNode *services_parse(int type, int argc, char **argv);
73 struct searchNode *size_parse(int type, int argc, char **argv);
74 struct searchNode *name_parse(int type, int argc, char **argv);
75 struct searchNode *topic_parse(int type, int argc, char **argv);
76 struct searchNode *oppct_parse(int type, int argc, char **argv);
77 struct searchNode *hostpct_parse(int type, int argc, char **argv);
78 struct searchNode *authedpct_parse(int type, int argc, char **argv);
79
80 /* Interpret a string to give a node */
81 struct searchNode *search_parse(int type, char *input);
82
83 /* Force a node to return the thing you want */
84 struct searchNode *coerceNode(struct searchNode *thenode, int type);
85
86 /* Registration functions */
87 void registersearchterm(char *term, parseFunc parsefunc);
88 void deregistersearchterm(char *term, parseFunc parsefunc);
89
90 void *trueval(int type);
91 void *falseval(int type);
92
93 typedef struct searchNode {
94 int returntype;
95 exeFunc exe;
96 freeFunc free;
97 void *localdata;
98 } searchNode;
99
100 extern const char *parseError;