]> jfr.im git - irc/quakenet/snircd.git/blame - include/gline.h
forward port of asuka-nickgline.patch to .12
[irc/quakenet/snircd.git] / include / gline.h
CommitLineData
189935b1 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/** @file
24 * @brief Structures and APIs for G-line manipulation.
25 * @version $Id: gline.h,v 1.17 2004/10/05 04:14:44 entrope Exp $
26 */
27#ifndef INCLUDED_sys_types_h
28#include <sys/types.h>
29#define INCLUDED_sys_types_h
30#endif
31
32#ifndef INCLUDED_res_h
33#include "res.h"
34#endif
35
36struct Client;
37struct StatDesc;
38
98de26a3 39#define GLINE_MAX_EXPIRE 31536000 /**< max expire: 1 year */
189935b1 40
41/** Description of a G-line. */
42struct Gline {
43 struct Gline *gl_next; /**< Next G-line in linked list. */
44 struct Gline**gl_prev_p; /**< Previous pointer to this G-line. */
98de26a3 45 char *gl_nick; /**< Nickname mask. */
189935b1 46 char *gl_user; /**< Username mask (or channel/realname mask). */
47 char *gl_host; /**< Host prtion of mask. */
48 char *gl_reason; /**< Reason for G-line. */
49 time_t gl_expire; /**< Expiration timestamp. */
50 time_t gl_lastmod; /**< Last modification timestamp. */
51 struct irc_in_addr gl_addr; /**< IP address (for IP-based G-lines). */
52 unsigned char gl_bits; /**< Usable bits in gl_addr. */
53 unsigned int gl_flags; /**< G-line status flags. */
54};
55
56#define GLINE_ACTIVE 0x0001 /**< G-line is active. */
57#define GLINE_IPMASK 0x0002 /**< gl_addr and gl_bits fields are valid. */
58#define GLINE_BADCHAN 0x0004 /**< G-line prohibits users from joining a channel. */
59#define GLINE_LOCAL 0x0008 /**< G-line only applies to this server. */
60#define GLINE_ANY 0x0010 /**< Search flag: Find any G-line. */
61#define GLINE_FORCE 0x0020 /**< Override normal limits on G-lines. */
62#define GLINE_EXACT 0x0040 /**< Exact match only (no wildcards). */
63#define GLINE_LDEACT 0x0080 /**< Locally deactivated. */
64#define GLINE_GLOBAL 0x0100 /**< Find only global G-lines. */
65#define GLINE_LASTMOD 0x0200 /**< Find only G-lines with non-zero lastmod. */
66#define GLINE_OPERFORCE 0x0400 /**< Oper forcing G-line to be set. */
67#define GLINE_REALNAME 0x0800 /**< G-line matches only the realname field. */
68
69/** Controllable flags that can be set on an actual G-line. */
70#define GLINE_MASK (GLINE_ACTIVE | GLINE_BADCHAN | GLINE_LOCAL | GLINE_REALNAME)
71/** Mask for G-line activity flags. */
72#define GLINE_ACTMASK (GLINE_ACTIVE | GLINE_LDEACT)
73
74/** Test whether \a g is active. */
75#define GlineIsActive(g) (((g)->gl_flags & GLINE_ACTMASK) == \
76 GLINE_ACTIVE)
77/** Test whether \a g is remotely (globally) active. */
78#define GlineIsRemActive(g) ((g)->gl_flags & GLINE_ACTIVE)
79/** Test whether \a g is an IP-based G-line. */
80#define GlineIsIpMask(g) ((g)->gl_flags & GLINE_IPMASK)
81/** Test whether \a g is a realname-based G-line. */
82#define GlineIsRealName(g) ((g)->gl_flags & GLINE_REALNAME)
83/** Test whether \a g is a BADCHAN. */
84#define GlineIsBadChan(g) ((g)->gl_flags & GLINE_BADCHAN)
85/** Test whether \a g is local to this server. */
86#define GlineIsLocal(g) ((g)->gl_flags & GLINE_LOCAL)
87
98de26a3 88/** Return nick mask of a G-line. */
89#define GlineNick(g) ((g)->gl_nick)
189935b1 90/** Return user mask of a G-line. */
91#define GlineUser(g) ((g)->gl_user)
92/** Return host mask of a G-line. */
93#define GlineHost(g) ((g)->gl_host)
94/** Return reason/message of a G-line. */
95#define GlineReason(g) ((g)->gl_reason)
96/** Return last modification time of a G-line. */
97#define GlineLastMod(g) ((g)->gl_lastmod)
98
99extern int gline_propagate(struct Client *cptr, struct Client *sptr,
100 struct Gline *gline);
101extern int gline_add(struct Client *cptr, struct Client *sptr, char *userhost,
102 char *reason, time_t expire, time_t lastmod,
103 unsigned int flags);
104extern int gline_activate(struct Client *cptr, struct Client *sptr,
105 struct Gline *gline, time_t lastmod,
106 unsigned int flags);
107extern int gline_deactivate(struct Client *cptr, struct Client *sptr,
108 struct Gline *gline, time_t lastmod,
109 unsigned int flags);
110extern struct Gline *gline_find(char *userhost, unsigned int flags);
111extern struct Gline *gline_lookup(struct Client *cptr, unsigned int flags);
112extern void gline_free(struct Gline *gline);
113extern void gline_burst(struct Client *cptr);
114extern int gline_resend(struct Client *cptr, struct Gline *gline);
115extern int gline_list(struct Client *sptr, char *userhost);
116extern void gline_stats(struct Client *sptr, const struct StatDesc *sd,
117 char *param);
118extern int gline_memory_count(size_t *gl_size);
98de26a3 119extern struct Gline *IsNickGlined(struct Client *cptr, char *nick);
189935b1 120
121#endif /* INCLUDED_gline_h */