]>
Commit | Line | Data |
---|---|---|
1151d736 P |
1 | #ifndef _GLINE_H |
2 | #define _GLINE_H | |
3 | ||
4 | #include <time.h> | |
5 | #include <netinet/in.h> | |
6 | #include <arpa/inet.h> | |
7 | ||
8 | #include "../lib/sstring.h" | |
9 | #include "../lib/flags.h" | |
10 | #include "../nick/nick.h" | |
11 | #include "../channel/channel.h" | |
12 | #include "../parser/parser.h" | |
13 | #include "../localuser/localuserchannel.h" | |
14 | ||
15 | #define MAX_USERS_RN 1 | |
16 | ||
17 | #define PASTWATCH 157680000 /* number of seconds in 5 years */ | |
18 | ||
19 | /* | |
20 | * If the expiration value, interpreted as an absolute timestamp, is | |
21 | * more recent than 5 years in the past, we interpret it as an | |
22 | * absolute timestamp; otherwise, we assume it's relative and convert | |
23 | * it to an absolute timestamp. Either way, the output of this macro | |
24 | * is an absolute timestamp--not guaranteed to be a *valid* timestamp, | |
25 | * but you can't have everything in a macro ;) | |
26 | */ | |
27 | #define abs_expire(exp) \ | |
28 | ((exp) >= getnettime() - PASTWATCH ? (exp) : (exp) + getnettime()) | |
29 | ||
30 | #define gline_max(a,b) (((a)<(b)) ? (b) : (a)) | |
31 | ||
32 | extern int gl_nodeext; | |
33 | ||
34 | typedef struct gline { | |
35 | struct gline* next; | |
36 | struct gline* nextbynode; | |
37 | struct gline* nextbynonnode; | |
38 | ||
39 | long glineid; | |
40 | long numeric; | |
41 | ||
42 | sstring* nick; | |
43 | sstring* user; | |
44 | sstring* host; | |
45 | sstring* reason; | |
46 | sstring* creator; | |
47 | ||
48 | patricia_node_t* node; | |
49 | ||
50 | time_t expires; | |
51 | time_t lastmod; | |
52 | time_t lifetime; | |
53 | ||
54 | unsigned int flags; | |
55 | } gline; | |
56 | ||
57 | #define GLINE_NICKEXACT 0x00001 /* Gline includes an exact nick (no wildcards) */ | |
58 | #define GLINE_NICKMASK 0x00002 /* Gline includes a nick mask with wildcards */ | |
59 | #define GLINE_NICKANY 0x00004 /* Gline is *!.. */ | |
60 | #define GLINE_NICKNULL 0x00008 /* Gline has no nick */ | |
61 | #define GLINE_USEREXACT 0x00010 /* Gline includes an exact user (no wildcards) */ | |
62 | #define GLINE_USERMASK 0x00020 /* Gline includes a user mask with wildcards */ | |
63 | #define GLINE_USERANY 0x00040 /* Gline is ..!*@.. */ | |
64 | #define GLINE_USERNULL 0x00080 /* Gline has no user */ | |
65 | #define GLINE_HOSTEXACT 0x00100 /* Gline includes an exact host */ | |
66 | #define GLINE_HOSTMASK 0x00200 /* Gline includes a host mask */ | |
67 | #define GLINE_HOSTANY 0x00400 /* Gline is ..@* */ | |
68 | #define GLINE_HOSTNULL 0x00800 /* Gline has no host */ | |
69 | #define GLINE_BADCHAN 0x01000 | |
70 | #define GLINE_REALNAME 0x02000 | |
71 | #define GLINE_IPMASK 0x04000 | |
72 | #define GLINE_FORCED 0x08000 | |
73 | #define GLINE_ACTIVATE 0x10000 | |
74 | #define GLINE_DEACTIVATE 0x20000 | |
75 | #define GLINE_ACTIVE 0x40000 | |
76 | #define GLINE_HOST 0x80000 | |
77 | ||
78 | #define GlineIsBadChan(x) ((x)->flags & GLINE_BADCHAN) | |
79 | #define GlineIsRealName(x) ((x)->flags & GLINE_REALNAME) | |
80 | #define GlineIsIpMask(x) ((x)->flags & GLINE_IPMASK) | |
81 | #define GlineIsForced(x) ((x)->flags & GLINE_FORCED) | |
82 | ||
83 | #define GlineNick(x) ((x)->nick) | |
84 | #define GlineUser(x) ((x)->user) | |
85 | #define GlineHost(x) ((x)->host) | |
86 | #define GlineReason(x) ((x)->reason) | |
87 | #define GlineCreator(x) ((x)->creator) | |
88 | #define GlineExpires(x) ((x)->expires) | |
89 | #define GlineLastMod(x) ((x)->lastmod) | |
90 | ||
91 | #define GLIST_COUNT 0x01 /* -c */ | |
92 | #define GLIST_EXACT 0x02 /* -x */ | |
93 | #define GLIST_FIND 0x04 /* -f */ | |
94 | #define GLIST_REASON 0x10 /* -r */ | |
95 | #define GLIST_OWNER 0x20 /* -o */ | |
96 | #define GLIST_REALNAME 0x40 /* -R */ | |
97 | ||
98 | extern gline* glinelist; | |
99 | extern gline* glinelistnonnode; | |
100 | extern gline* badchanlist; | |
101 | extern int glinecount; | |
102 | extern int badchancount; | |
103 | extern int rnglinecount; | |
104 | extern int hostglinecount; | |
105 | extern int ipglinecount; | |
106 | ||
107 | int gline_glist(void* source, int cargc, char** cargv); | |
108 | int gline_glgrep(void* source, int cargc, char** cargv); | |
109 | int gline_glstats(void* source, int cargc, char** cargv); | |
110 | int gline_ungline(void* source, int cargc, char** cargv); | |
111 | int gline_rawglinefile(void* source, int cargc, char** cargv); | |
112 | int gline_glinefile(void* source, int cargc, char** cargv); | |
113 | int gline_unglinefile(void* source, int cargc, char** cargv); | |
114 | int gline_saveglines(void* source, int cargc, char** cargv); | |
115 | int handleglinemsg(void* source, int cargc, char** cargv); | |
116 | int gline_gline(void* source, int cargc, char** cargv); | |
117 | int gline_rngline(void* source, int cargc, char** cargv); | |
118 | int gline_block(void* source, int cargc, char** cargv); | |
119 | ||
120 | gline *newgline(); | |
121 | void freegline (gline *gl); | |
122 | ||
123 | gline* gline_processmask(char *mask); | |
124 | int gline_match ( gline *gla, gline *glb); | |
125 | ||
126 | gline* gline_add(long creatornum, sstring *creator, char *mask, char *reason, time_t expires, time_t lastmod, time_t lifetime); | |
127 | ||
128 | /* | |
129 | int gline_add(char* mask, char* reason, char* creator, time_t expires, time_t lastmod, unsigned int flags, int propagate); | |
130 | gline* make_gline(char* nick, char* user, char* host, char* reason, char* creator, time_t expires, time_t lastmod, unsigned int flags); | |
131 | gline* gline_find(char* mask); | |
132 | void gline_free(gline* g); | |
133 | int check_if_ipmask(const char* mask); | |
134 | void canon_userhost(char* mask, char** nick, char** user, char** host, char* def_user); | |
135 | */ | |
136 | ||
137 | #endif |