97e483234ea556a9c1c8e5646bc445d77001e8fa
[ircu2.10.12-pk.git] / include / class.h
1 /*
2  * IRC - Internet Relay Chat, include/class.h
3  * Copyright (C) 1990 Darren Reed
4  * Copyright (C) 1996 - 1997 Carlo Wood
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20
21 #ifndef CLASS_H
22 #define CLASS_H
23
24 /*=========================================================================
25  * Structures
26  */
27
28 struct ConfClass {
29   unsigned int conClass;
30   unsigned int conFreq;
31   unsigned int pingFreq;
32   unsigned int maxLinks;
33   unsigned int maxSendq;
34   unsigned int links;
35   struct ConfClass *next;
36 };
37
38 /*=============================================================================
39  * Macro's
40  */
41
42 #define ConClass(x)     ((x)->conClass)
43 #define ConFreq(x)      ((x)->conFreq)
44 #define PingFreq(x)     ((x)->pingFreq)
45 #define MaxLinks(x)     ((x)->maxLinks)
46 #define MaxSendq(x)     ((x)->maxSendq)
47 #define Links(x)        ((x)->links)
48
49 #define ConfLinks(x)    ((x)->confClass->links)
50 #define ConfMaxLinks(x) ((x)->confClass->maxLinks)
51 #define ConfClass(x)    ((x)->confClass->conClass)
52 #define ConfConFreq(x)  ((x)->confClass->conFreq)
53 #define ConfPingFreq(x) ((x)->confClass->pingFreq)
54 #define ConfSendq(x)    ((x)->confClass->maxSendq)
55
56 #define FirstClass()    classes
57 #define NextClass(x)    ((x)->next)
58
59 #define MarkDelete(x)   do { MaxLinks(x) = (unsigned int)-1; } while(0)
60 #define IsMarkedDelete(x) (MaxLinks(x) == (unsigned int)-1)
61
62 /*=============================================================================
63  * Proto types
64  */
65
66 extern aConfClass *find_class(unsigned int cclass);
67 extern aConfClass *make_class(void);
68 extern void free_class(aConfClass * tmp);
69 extern unsigned int get_con_freq(aConfClass * clptr);
70 extern unsigned int get_client_ping(aClient *acptr);
71 extern unsigned int get_conf_class(aConfItem *aconf);
72 extern unsigned int get_client_class(aClient *acptr);
73 extern void add_class(unsigned int conclass, unsigned int ping,
74     unsigned int confreq, unsigned int maxli, size_t sendq);
75 extern void check_class(void);
76 extern void initclass(void);
77 extern void report_classes(aClient *sptr);
78 extern size_t get_sendq(aClient *cptr);
79
80 extern aConfClass *classes;
81
82 #endif /* CLASS_H */