#include "../lib/sstring.h"
#include "../nick/nick.h"
#include "../channel/channel.h"
+#include "../whowas/whowas.h"
-#define SNIRCD_13
-#undef SNIRCD_14
+#define SNIRCD_VERSION 134
-#define MAXGLINEUSERS 100
+#define MAXUSERGLINEUSERHITS 100
+#define MAXUSERGLINECHANNELHITS 10
-#define MAXUSERGLINEDURATION (90 * 86400)
-#define MINUSERGLINEREASON 10
+#define MAXGLINEDURATION 90 * 86400
+#define MINGLINEREASONLEN 10
+
+#define MAXGLINEUSERHITS 500
+#define MAXGLINECHANNELHITS 50
+
+#define MAXGLINELOG 500
#define GLINE_IGNORE_TRUST 1
#define GLINE_ALWAYS_NICK 2
#define GLINE_ALWAYS_USER 4
-#define GLINE_NO_LIMIT 8
-#define GLINE_SIMULATE 16
-
-#define GLINE_NICKEXACT 0x000001 /* Gline includes an exact nick (no wildcards) */
-#define GLINE_NICKMASK 0x000002 /* Gline includes a nick mask with wildcards */
-#define GLINE_NICKANY 0x000004 /* Gline is *!.. */
-#define GLINE_NICKNULL 0x000008 /* Gline has no nick */
-#define GLINE_USEREXACT 0x000010 /* Gline includes an exact user (no wildcards) */
-#define GLINE_USERMASK 0x000020 /* Gline includes a user mask with wildcards */
-#define GLINE_USERANY 0x000040 /* Gline is ..!*@.. */
-#define GLINE_USERNULL 0x000080 /* Gline has no user */
-#define GLINE_HOSTEXACT 0x000100 /* Gline includes an exact host */
-#define GLINE_HOSTMASK 0x000200 /* Gline includes a host mask */
-#define GLINE_HOSTANY 0x000400 /* Gline is ..@* */
-#define GLINE_HOSTNULL 0x000800 /* Gline has no host */
-#define GLINE_BADCHAN 0x001000 /* Gline includes a badchan */
-#define GLINE_REALNAME 0x002000 /* Gline includes a realname */
-#define GLINE_ACTIVATE 0x004000 /* Gline should be activated */
-#define GLINE_DEACTIVATE 0x008000 /* Gline should be deactivated */
-#define GLINE_ACTIVE 0x010000 /* Gline is active */
-#define GLINE_IPMASK 0x020000 /* Gline includes an CIDR mask */
-#define GLINE_HOST 0x040000
-#define GLINE_BADMASK 0x100000
+#define GLINE_SIMULATE 8
+
+#define GLINE_HOSTMASK 1 /* Gline includes a host mask */
+#define GLINE_IPMASK 2 /* Gline includes an CIDR mask */
+#define GLINE_BADCHAN 4 /* Gline includes a badchan */
+#define GLINE_REALNAME 8 /* Gline includes a realname */
+#define GLINE_ACTIVATE 16 /* Gline should be activated */
+#define GLINE_DEACTIVATE 32 /* Gline should be deactivated */
+#define GLINE_DESTROY 64 /* Gline should be destroyed */
+#define GLINE_ACTIVE 128 /* Gline is active */
+#define GLINE_DESTROYED 256 /* Gline is destroyed */
/**
* glist flags
#define GLIST_REALNAME 0x40 /* -R */
#define GLIST_INACTIVE 0x80 /* -i */
+#define GLSTORE_PATH_PREFIX "data/glines"
+#define GLSTORE_SAVE_FILES 5
+#define GLSTORE_SAVE_INTERVAL 3600
+
/**
* Interpret absolute/relative timestamps with same method as snircd
* If the expiration value, interpreted as an absolute timestamp, is
time_t lifetime;
unsigned int flags;
+ int glinebufid;
struct gline *next;
} gline;
-extern gline *glinelist;
+typedef struct glinebuf {
+ int id;
+ sstring *comment;
+ time_t commit;
+ time_t amend;
-typedef struct gline_params {
- int duration;
- const char *reason;
- const char *creator;
-} gline_params;
+ gline *glines;
-typedef void (*gline_callback)(const char *, int, void *);
+ int hitsvalid;
+ int userhits;
+ int channelhits;
-/* glines.c */
-void glinesetmask(const char *mask, int duration, const char *reason, const char *creator);
-void glineunsetmask(const char *mask);
+ array hits;
+} glinebuf;
-int glinesuggestbyip(const char *, struct irc_in_addr *, unsigned char, int, gline_callback callback, void *uarg);
-int glinesuggestbynick(nick *, int, gline_callback callback, void *uarg);
-int glinebyip(const char *, struct irc_in_addr *, unsigned char, int, const char *, int, const char *);
-int glinebynick(nick *, int, const char *, int, const char *);
+typedef struct glineinfo {
+ int hits;
+ char *mask;
+} glineinfo;
-gline *gline_add(const char *creator, const char *mask, const char *reason, time_t expire, time_t lastmod, time_t lifetime);
-char *glinetostring(gline *g);
-gline *gline_find(const char *);
-gline *makegline(const char *);
+extern gline *glinelist;
+extern glinebuf *glinebuflog[MAXGLINELOG];
+extern int glinebuflogoffset;
+
+/* glines.c */
+gline *findgline(const char *);
void gline_propagate(gline *);
-gline *gline_deactivate(gline *, time_t, int);
-gline *gline_activate(gline *agline, time_t lastmod, int propagate);
+void gline_deactivate(gline *, time_t, int);
+void gline_destroy(gline *, time_t, int);
+void gline_activate(gline *agline, time_t lastmod, int propagate);
int glineequal(gline *, gline *);
-int gline_count_hits(gline *gl);
int gline_match_mask(gline *gla, gline *glb);
int gline_match_nick(gline *gl, nick *np);
int gline_match_channel(gline *gl, channel *cp);
+int isglinesane(gline *gl, const char **hint);
+gline *glinedup(gline *gl);
+
+/* glines_formats.c */
+gline *makegline(const char *);
+char *glinetostring(gline *g);
+
+/* glines_util.c */
+int glinebyip(const char *user, struct irc_in_addr *ip, unsigned char bits, int duration, const char *reason, int flags, const char *creator);
+glineinfo *glinebynickex(nick *np, int duration, const char *reason, int flags, const char *creator);
+int glinebynick(nick *np, int duration, const char *reason, int flags, const char *creator);
+void glineunsetmask(const char *mask);
+
+/* glines_buf.c */
+void glinebufinit(glinebuf *gbuf, int id);
+gline *glinebufadd(glinebuf *gbuf, const char *mask, const char *creator, const char *reason, time_t expire, time_t lastmod, time_t lifetime);
+char *glinebufaddbyip(glinebuf *gbuf, const char *user, struct irc_in_addr *ip, unsigned char bits, int flags, const char *creator, const char *reason, time_t expire, time_t lastmod, time_t lifetime);
+char *glinebufaddbynick(glinebuf *gbuf, nick *, int flags, const char *creator, const char *reason, time_t expire, time_t lastmod, time_t lifetime);
+void glinebufaddbywhowas(glinebuf *gbuf, whowas *, int flags, const char *creator, const char *reason, time_t expire, time_t lastmod, time_t lifetime);
+void glinebufcounthits(glinebuf *gbuf, int *users, int *channels);
+int glinebufchecksane(glinebuf *gbuf, nick *spewto, int overridesanity, int overridelimit);
+void glinebufspew(glinebuf *gbuf, nick *spewto);
+void glinebufmerge(glinebuf *gbuf);
+int glinebufcommit(glinebuf *gbuf, int propagate);
+void glinebufabort(glinebuf *gbuf);
+int glinebufundo(int id);
+void glinebufcommentf(glinebuf *gbuf, const char *format, ...);
+void glinebufcommentv(glinebuf *gbuf, const char *prefix, int cargc, char **cargv);
+int glinebufwritelog(glinebuf *gbuf, int propagating);
/* glines_alloc.c */
void freegline(gline *);
int handleglinemsg(void *, int, char **);
void handleglinestats(int hooknum, void *arg);
+/* glines_store.c */
+int glstore_save(void);
+int glstore_load(void);
+
#endif