]> jfr.im git - irc/quakenet/newserv.git/blame - glines2/gline.h
Merge.
[irc/quakenet/newserv.git] / glines2 / gline.h
CommitLineData
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
32extern int gl_nodeext;
33
34typedef 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
98extern gline* glinelist;
99extern gline* glinelistnonnode;
100extern gline* badchanlist;
101extern int glinecount;
102extern int badchancount;
103extern int rnglinecount;
104extern int hostglinecount;
105extern int ipglinecount;
106
107int gline_glist(void* source, int cargc, char** cargv);
108int gline_glgrep(void* source, int cargc, char** cargv);
109int gline_glstats(void* source, int cargc, char** cargv);
110int gline_ungline(void* source, int cargc, char** cargv);
111int gline_rawglinefile(void* source, int cargc, char** cargv);
112int gline_glinefile(void* source, int cargc, char** cargv);
113int gline_unglinefile(void* source, int cargc, char** cargv);
114int gline_saveglines(void* source, int cargc, char** cargv);
115int handleglinemsg(void* source, int cargc, char** cargv);
116int gline_gline(void* source, int cargc, char** cargv);
117int gline_rngline(void* source, int cargc, char** cargv);
118int gline_block(void* source, int cargc, char** cargv);
119
120gline *newgline();
121void freegline (gline *gl);
122
123gline* gline_processmask(char *mask);
124int gline_match ( gline *gla, gline *glb);
125
126gline* gline_add(long creatornum, sstring *creator, char *mask, char *reason, time_t expires, time_t lastmod, time_t lifetime);
127
128/*
129int gline_add(char* mask, char* reason, char* creator, time_t expires, time_t lastmod, unsigned int flags, int propagate);
130gline* make_gline(char* nick, char* user, char* host, char* reason, char* creator, time_t expires, time_t lastmod, unsigned int flags);
131gline* gline_find(char* mask);
132void gline_free(gline* g);
133int check_if_ipmask(const char* mask);
134void canon_userhost(char* mask, char** nick, char** user, char** host, char* def_user);
135*/
136
137#endif