]>
jfr.im git - irc/quakenet/newserv.git/blob - gline/gline.h
5 #include <netinet/in.h>
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"
15 #define MAX_USERS_RN 1
17 #define PASTWATCH 157680000 /* number of seconds in 5 years */
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 ;)
27 #define abs_expire(exp) \
28 ((exp) >= getnettime() - PASTWATCH ? (exp) : (exp) + getnettime())
30 #define gline_max(a,b) (((a)<(b)) ? (b) : (a))
32 extern int gl_nodeext
;
34 typedef struct gline
{
36 struct gline
* nextbynode
;
37 struct gline
* nextbynonnode
;
48 patricia_node_t
* node
;
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
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)
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)
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 */
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
;
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
);
121 void freegline (gline
*gl
);
123 gline
* gline_processmask(char *mask
);
124 int gline_match ( gline
*gla
, gline
*glb
);
126 gline
* gline_add(long creatornum
, sstring
*creator
, char *mask
, char *reason
, time_t expires
, time_t lastmod
, time_t lifetime
);
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);