]> arthur.barton.de Git - ngircd-alex.git/blob - src/ngircd/class.c
aeecaaecc7440313ca89f59b55e6fbf46a57e0c3
[ngircd-alex.git] / src / ngircd / class.c
1 /*
2  * ngIRCd -- The Next Generation IRC Daemon
3  * Copyright (c)2001-2011 Alexander Barton (alex@barton.de) and Contributors.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * Please read the file COPYING, README and AUTHORS for more information.
10  */
11
12 #include "portab.h"
13
14 /**
15  * @file
16  * User class management.
17  */
18
19 #include "imp.h"
20 #include <assert.h>
21 #include <string.h>
22
23 #include "defines.h"
24 #include "array.h"
25 #include "conn.h"
26 #include "client.h"
27 #include "lists.h"
28 #include "match.h"
29
30 #include "exp.h"
31 #include "class.h"
32
33 struct list_head My_Classes[CLASS_COUNT];
34
35 GLOBAL void
36 Class_Init(void)
37 {
38         memset(My_Classes, 0, sizeof(My_Classes));
39 }
40
41 GLOBAL void
42 Class_Exit(void)
43 {
44         int i;
45
46         for (i = 0; i < CLASS_COUNT; Lists_Free(&My_Classes[i++]));
47 }
48
49 GLOBAL bool
50 Class_IsMember(const int Class, CLIENT *Client)
51 {
52         assert(Class < CLASS_COUNT);
53         assert(Client != NULL);
54
55         return Lists_Check(&My_Classes[Class], Client);
56 }
57
58 GLOBAL bool
59 Class_AddMask(const int Class, const char *Mask, time_t ValidUntil,
60               const char *Reason)
61 {
62         assert(Class < CLASS_COUNT);
63         assert(Mask != NULL);
64         assert(Reason != NULL);
65
66         return Lists_Add(&My_Classes[Class], Mask, ValidUntil, Reason);
67 }
68
69 GLOBAL void
70 Class_DeleteMask(const int Class, const char *Mask)
71 {
72         assert(Class < CLASS_COUNT);
73         assert(Mask != NULL);
74
75         Lists_Del(&My_Classes[Class], Mask);
76 }
77
78 /* -eof- */