fix possible crash on user deletion
[srvx.git] / src / gline.h
1 /* gline.h - Gline database
2  * Copyright 2001-2004 srvx Development Team
3  *
4  * This file is part of srvx.
5  *
6  * srvx is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with srvx; if not, write to the Free Software Foundation,
18  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
19  */
20
21 #ifndef GLINE_H
22 #define GLINE_H
23
24 #include "hash.h"
25
26 struct gline {
27     /** When the G-line was first created. */
28     unsigned long issued;
29     /** When the G-line was last modified. */
30     unsigned long lastmod;
31     /** When the G-line becomes ineffective. */
32     unsigned long expires;
33     /** When the G-line may be forgotten (the maximum "expires" value
34      * from any modification period).
35      */
36     unsigned long lifetime;
37     /** Account or nick name of the person creating the G-line. */
38     char *issuer;
39     /** user@host mask covered by the G-line. */
40     char *target;
41     /** What to tell affected users. */
42     char *reason;
43 };
44
45 struct gline_discrim {
46     unsigned int limit;
47     enum { SUBSET, EXACT, SUPERSET } target_mask_type;
48     char *issuer_mask;
49     char *target_mask;
50     char *alt_target_mask;
51     char *reason_mask;
52     unsigned long max_issued;
53     unsigned long min_expire;
54     unsigned long min_lastmod;
55     unsigned long max_lastmod;
56     unsigned long min_lifetime;
57     unsigned long max_lifetime;
58 };
59
60 void gline_init(void);
61 struct gline *gline_add(const char *issuer, const char *target, unsigned long duration, const char *reason, unsigned long issued, unsigned long lastmod, unsigned long lifetime, int announce);
62 struct gline *gline_find(const char *target);
63 int gline_remove(const char *target, int announce);
64 void gline_refresh_server(struct server *srv);
65 void gline_refresh_all(void);
66 unsigned int gline_count(void);
67
68 typedef void (*gline_search_func)(struct gline *gline, void *extra);
69 struct gline_discrim *gline_discrim_create(struct userNode *user, struct userNode *src, unsigned int argc, char *argv[]);
70 unsigned int gline_discrim_search(struct gline_discrim *discrim, gline_search_func gsf, void *data);
71
72 #endif /* !defined(GLINE_H) */