IPv6 support (hopefully with fewer future transition pains)
[ircu2.10.12-pk.git] / include / gline.h
1 #ifndef INCLUDED_gline_h
2 #define INCLUDED_gline_h
3 /*
4  * IRC - Internet Relay Chat, include/gline.h
5  * Copyright (C) 1990 Jarkko Oikarinen and
6  *                    University of Oulu, Computing Center
7  * Copyright (C) 1996 -1997 Carlo Wood
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2, or (at your option)
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  *
23  * $Id$
24  */
25 #ifndef INCLUDED_sys_types_h
26 #include <sys/types.h>
27 #define INCLUDED_sys_types_h
28 #endif
29
30 #ifndef INCLUDED_res_h
31 #include "res.h"
32 #endif
33
34 struct Client;
35 struct StatDesc;
36
37 #define GLINE_MAX_EXPIRE 604800 /* max expire: 7 days */
38
39 struct Gline {
40   struct Gline *gl_next;
41   struct Gline**gl_prev_p;
42   char         *gl_user;
43   char         *gl_host;
44   char         *gl_reason;
45   time_t        gl_expire;
46   time_t        gl_lastmod;
47   struct irc_in_addr gl_addr;  /* We store the IP in binary for ip glines */
48   unsigned char gl_bits;
49   unsigned int  gl_flags;
50 };
51
52 #define GLINE_ACTIVE    0x0001
53 #define GLINE_IPMASK    0x0002
54 #define GLINE_BADCHAN   0x0004
55 #define GLINE_LOCAL     0x0008
56 #define GLINE_ANY       0x0010
57 #define GLINE_FORCE     0x0020
58 #define GLINE_EXACT     0x0040
59 #define GLINE_LDEACT    0x0080  /* locally deactivated */
60 #define GLINE_GLOBAL    0x0100  /* find only global glines */
61 #define GLINE_LASTMOD   0x0200  /* find only glines with non-zero lastmod */
62 #define GLINE_OPERFORCE 0x0400  /* oper forcing gline to be set */
63 #define GLINE_REALNAME  0x0800  /* gline matches only the realname field */
64
65 #define GLINE_MASK      (GLINE_ACTIVE | GLINE_BADCHAN | GLINE_LOCAL | GLINE_REALNAME)
66 #define GLINE_ACTMASK   (GLINE_ACTIVE | GLINE_LDEACT)
67
68 #define GlineIsActive(g)        (((g)->gl_flags & GLINE_ACTMASK) == \
69                                  GLINE_ACTIVE)
70 #define GlineIsRemActive(g)     ((g)->gl_flags & GLINE_ACTIVE)
71 #define GlineIsIpMask(g)        ((g)->gl_flags & GLINE_IPMASK)
72 #define GlineIsRealName(g)      ((g)->gl_flags & GLINE_REALNAME)
73 #define GlineIsBadChan(g)       ((g)->gl_flags & GLINE_BADCHAN)
74 #define GlineIsLocal(g)         ((g)->gl_flags & GLINE_LOCAL)
75
76 #define GlineUser(g)            ((g)->gl_user)
77 #define GlineHost(g)            ((g)->gl_host)
78 #define GlineReason(g)          ((g)->gl_reason)
79 #define GlineLastMod(g)         ((g)->gl_lastmod)
80
81 extern int gline_propagate(struct Client *cptr, struct Client *sptr,
82                            struct Gline *gline);
83 extern int gline_add(struct Client *cptr, struct Client *sptr, char *userhost,
84                      char *reason, time_t expire, time_t lastmod,
85                      unsigned int flags);
86 extern int gline_activate(struct Client *cptr, struct Client *sptr,
87                           struct Gline *gline, time_t lastmod,
88                           unsigned int flags);
89 extern int gline_deactivate(struct Client *cptr, struct Client *sptr,
90                             struct Gline *gline, time_t lastmod,
91                             unsigned int flags);
92 extern struct Gline *gline_find(char *userhost, unsigned int flags);
93 extern struct Gline *gline_lookup(struct Client *cptr, unsigned int flags);
94 extern void gline_free(struct Gline *gline);
95 extern void gline_burst(struct Client *cptr);
96 extern int gline_resend(struct Client *cptr, struct Gline *gline);
97 extern int gline_list(struct Client *sptr, char *userhost);
98 extern void gline_stats(struct Client *sptr, struct StatDesc *sd, int stat,
99                         char *param);
100 extern int gline_memory_count(size_t *gl_size);
101
102 #endif /* INCLUDED_gline_h */