Author: Kev <klmitch@mit.edu>
[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_config_h
26 #include "config.h"
27 #endif
28 #ifndef INCLUDED_sys_types_h
29 #include <sys/types.h>
30 #define INCLUDED_sys_types_h
31 #endif
32
33
34 struct Client;
35
36 #define GLINE_MAX_EXPIRE 604800 /* max expire: 7 days */
37
38 struct Gline {
39   struct Gline *gl_next;
40   struct Gline**gl_prev_p;
41   char         *gl_user;
42   char         *gl_host;
43   char         *gl_reason;
44   time_t        gl_expire;
45   time_t        gl_lastmod;
46   unsigned int  gl_flags;
47 };
48
49 #define GLINE_ACTIVE    0x0001
50 #define GLINE_IPMASK    0x0002
51 #define GLINE_BADCHAN   0x0004
52 #define GLINE_LOCAL     0x0008
53 #define GLINE_ANY       0x0010
54 #define GLINE_FORCE     0x0020
55 #define GLINE_EXACT     0x0040
56
57 #define GLINE_MASK      (GLINE_ACTIVE | GLINE_BADCHAN | GLINE_LOCAL)
58
59 #define GlineIsActive(g)        ((g)->gl_flags & GLINE_ACTIVE)
60 #define GlineIsIpMask(g)        ((g)->gl_flags & GLINE_IPMASK)
61 #define GlineIsBadChan(g)       ((g)->gl_flags & GLINE_BADCHAN)
62 #define GlineIsLocal(g)         ((g)->gl_flags & GLINE_LOCAL)
63
64 #define GlineUser(g)            ((g)->gl_user)
65 #define GlineHost(g)            ((g)->gl_host)
66 #define GlineReason(g)          ((g)->gl_reason)
67 #define GlineLastMod(g)         ((g)->gl_lastmod)
68
69 extern int gline_add(struct Client *cptr, struct Client *sptr, char *userhost,
70                      char *reason, time_t expire, time_t lastmod,
71                      unsigned int flags);
72 extern int gline_activate(struct Client *cptr, struct Client *sptr,
73                           struct Gline *gline, time_t lastmod);
74 extern int gline_deactivate(struct Client *cptr, struct Client *sptr,
75                             struct Gline *gline, time_t lastmod);
76 extern struct Gline *gline_find(char *userhost, unsigned int flags);
77 extern struct Gline *gline_lookup(struct Client *cptr);
78 extern void gline_free(struct Gline *gline);
79 extern void gline_burst(struct Client *cptr);
80 extern int gline_resend(struct Client *cptr, struct Gline *gline);
81 extern int gline_list(struct Client *sptr, char *userhost);
82 extern void gline_stats(struct Client *sptr);
83
84 #if 0 /* forget it! */
85 #define SetActive(g)        ((g)->gl_flags |= GLINE_ACTIVE)
86 #define ClearActive(g)      ((g)->gl_flags &= ~GLINE_ACTIVE)
87 #define SetGlineIsIpMask(g) ((g)->gl_flags |= GLINE_IPMASK)
88 #define SetGlineIsLocal(g)  ((g)->gl_flags |= GLINE_LOCAL)
89
90 extern struct Gline* GlobalGlineList;
91 extern struct Gline* BadChanGlineList;
92
93 extern void gline_remove_expired(time_t now);
94
95 extern void add_gline(struct Client *sptr, int ip_mask,
96                       char *host, char *comment, char *user,
97                       time_t expire, int local);
98 extern struct Gline* make_gline(int is_ipmask, char *host, char *reason,
99                                 char *name, time_t expire);
100 extern struct Gline* find_gline(struct Client *cptr, struct Gline **pgline);
101 extern void free_gline(struct Gline *gline, struct Gline *prev);
102
103 #ifdef BADCHAN
104 extern int bad_channel(const char* name);
105 extern void bad_channel_remove_expired(time_t now);
106 #endif
107 #endif /* 0 */
108
109 #endif /* INCLUDED_gline_h */