about summary refs log tree commit diff
path: root/src/ngircd/class.c
blob: 1a4d4c0b6d1179ae22776d8f57df80c2754d71d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
 * ngIRCd -- The Next Generation IRC Daemon
 * Copyright (c)2001-2011 Alexander Barton (alex@barton.de) and Contributors.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * Please read the file COPYING, README and AUTHORS for more information.
 */

#include "portab.h"

/**
 * @file
 * User class management.
 */

#include "imp.h"
#include <assert.h>
#include <string.h>

#include "defines.h"
#include "array.h"
#include "conn.h"
#include "client.h"
#include "lists.h"
#include "match.h"

#include "exp.h"
#include "class.h"

struct list_head My_Classes[CLASS_COUNT];

GLOBAL void
Class_Init(void)
{
	memset(My_Classes, 0, sizeof(My_Classes));
}

GLOBAL void
Class_Exit(void)
{
	int i;

	for (i = 0; i < CLASS_COUNT; Lists_Free(&My_Classes[i++]));
}

GLOBAL bool
Class_IsMember(const int Class, CLIENT *Client)
{
	assert(Class < CLASS_COUNT);
	assert(Client != NULL);

	return Lists_Check(&My_Classes[Class], Client);
}

GLOBAL bool
Class_AddMask(const int Class, const char *Mask, time_t ValidUntil,
	      const char *Reason)
{
	assert(Class < CLASS_COUNT);
	assert(Mask != NULL);
	assert(Reason != NULL);

	return Lists_Add(&My_Classes[Class], Mask, ValidUntil, Reason);
}

GLOBAL void
Class_DeleteMask(const int Class, const char *Mask)
{
	assert(Class < CLASS_COUNT);
	assert(Mask != NULL);

	Lists_Del(&My_Classes[Class], Mask);
}

GLOBAL struct list_head
Class_GetList(const int Class)
{
	assert(Class < CLASS_COUNT);

	return My_Classes[Class];
}

GLOBAL void
Class_Expire(void)
{
	Lists_Expire(&My_Classes[CLASS_GLINE], "G-Line");
	Lists_Expire(&My_Classes[CLASS_KLINE], "K-Line");
}

/* -eof- */