Initial import (again)
[srvx.git] / src / gline.h
1 /* gline.h - Gline database
2  * Copyright 2001-2004 srvx Development Team
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.  Important limitations are
8  * listed in the COPYING file that accompanies this software.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, email srvx-maintainers@srvx.net.
17  */
18
19 #ifndef GLINE_H
20 #define GLINE_H
21
22 #include "hash.h"
23
24 struct gline {
25     time_t issued;
26     time_t expires;
27     char *issuer;
28     char *target;
29     char *reason;
30 };
31
32 struct gline_discrim {
33     unsigned int limit;
34     enum { SUBSET, EXACT, SUPERSET } target_mask_type;
35     char *issuer_mask;
36     char *target_mask;
37     char *alt_target_mask;
38     char *reason_mask;
39     time_t max_issued;
40     time_t min_expire;
41 };
42
43 void gline_init(void);
44 struct gline *gline_add(const char *issuer, const char *target, unsigned long duration, const char *reason, time_t issued, int announce);
45 struct gline *gline_find(const char *target);
46 int gline_remove(const char *target, int announce);
47 void gline_refresh_server(struct server *srv);
48 void gline_refresh_all(void);
49 unsigned int gline_count(void);
50
51 typedef void (*gline_search_func)(struct gline *gline, void *extra);
52 struct gline_discrim *gline_discrim_create(struct userNode *user, struct userNode *src, unsigned int argc, char *argv[]);
53 unsigned int gline_discrim_search(struct gline_discrim *discrim, gline_search_func gsf, void *data);
54
55 #endif /* !defined(GLINE_H) */