2 * ngIRCd -- The Next Generation IRC Daemon
3 * Copyright (c)2001-2014 Alexander Barton (alex@barton.de) and Contributors.
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.
16 * User class management.
34 struct list_head My_Classes[CLASS_COUNT];
39 memset(My_Classes, 0, sizeof(My_Classes));
47 for (i = 0; i < CLASS_COUNT; Lists_Free(&My_Classes[i++]));
51 Class_GetMemberReason(const int Class, CLIENT *Client, char *reason, size_t len)
53 char str[COMMAND_LEN];
55 assert(Class < CLASS_COUNT);
56 assert(Client != NULL);
58 strlcpy(str, "listed", sizeof(str));
60 if (!Lists_CheckReason(&My_Classes[Class], Client, str, sizeof(str)))
65 snprintf(reason, len, "\"%s\" (G-Line)", str);
68 snprintf(reason, len, "\"%s\" (K-Line)", str);
71 snprintf(reason, len, "%s", str);
78 * Check if a client is banned from this server: GLINE, KLINE.
80 * If a client isn't allowed to connect, it will be disconnected again.
82 * @param Client The client to check.
83 * @return CONNECTED if client is allowed to join, DISCONNECTED if not.
86 Class_HandleServerBans(CLIENT *Client)
88 char reject[COMMAND_LEN];
90 assert(Client != NULL);
92 if (Class_GetMemberReason(CLASS_GLINE, Client, reject, sizeof(reject)) ||
93 Class_GetMemberReason(CLASS_KLINE, Client, reject, sizeof(reject))) {
94 Client_Reject(Client, reject, true);
103 Class_AddMask(const int Class, const char *Pattern, time_t ValidUntil,
108 assert(Class < CLASS_COUNT);
109 assert(Pattern != NULL);
110 assert(Reason != NULL);
112 Lists_MakeMask(Pattern, mask, sizeof(mask));
113 return Lists_Add(&My_Classes[Class], mask,
118 Class_DeleteMask(const int Class, const char *Pattern)
122 assert(Class < CLASS_COUNT);
123 assert(Pattern != NULL);
125 Lists_MakeMask(Pattern, mask, sizeof(mask));
126 Lists_Del(&My_Classes[Class], mask);
129 GLOBAL struct list_head *
130 Class_GetList(const int Class)
132 assert(Class < CLASS_COUNT);
134 return &My_Classes[Class];
140 Lists_Expire(&My_Classes[CLASS_GLINE], "G-Line");
141 Lists_Expire(&My_Classes[CLASS_KLINE], "K-Line");