2 * ngIRCd -- The Next Generation IRC Daemon
3 * Copyright (c)2001-2012 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];
36 char Reject_Reason[COMMAND_LEN];
41 memset(My_Classes, 0, sizeof(My_Classes));
49 for (i = 0; i < CLASS_COUNT; Lists_Free(&My_Classes[i++]));
53 Class_GetMemberReason(const int Class, CLIENT *Client)
57 assert(Class < CLASS_COUNT);
58 assert(Client != NULL);
60 reason = Lists_CheckReason(&My_Classes[Class], Client);
69 snprintf(Reject_Reason, sizeof(Reject_Reason),
70 "\"%s\" (G-Line)", reason);
73 snprintf(Reject_Reason, sizeof(Reject_Reason),
74 "\"%s\" (K-Line)", reason);
81 * Check if a client is banned from this server: GLINE, KLINE.
83 * If a client isn't allowed to connect, it will be disconnected again.
85 * @param Client The client to check.
86 * @return CONNECTED if client is allowed to join, DISCONNECTED if not.
89 Class_HandleServerBans(CLIENT *Client)
93 assert(Client != NULL);
95 rejectptr = Class_GetMemberReason(CLASS_GLINE, Client);
97 rejectptr = Class_GetMemberReason(CLASS_KLINE, Client);
99 Client_Reject(Client, rejectptr, true);
108 Class_AddMask(const int Class, const char *Mask, time_t ValidUntil,
111 assert(Class < CLASS_COUNT);
112 assert(Mask != NULL);
113 assert(Reason != NULL);
115 return Lists_Add(&My_Classes[Class], Lists_MakeMask(Mask),
120 Class_DeleteMask(const int Class, const char *Mask)
122 assert(Class < CLASS_COUNT);
123 assert(Mask != NULL);
125 Lists_Del(&My_Classes[Class], Lists_MakeMask(Mask));
128 GLOBAL struct list_head *
129 Class_GetList(const int Class)
131 assert(Class < CLASS_COUNT);
133 return &My_Classes[Class];
139 Lists_Expire(&My_Classes[CLASS_GLINE], "G-Line");
140 Lists_Expire(&My_Classes[CLASS_KLINE], "K-Line");