Author: Bleep <tomh@inxpress.net>
[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  * $Id$
21  */
22 #ifndef INCLUDED_class_h
23 #define INCLUDED_class_h
24 #ifndef INCLUDED_sys_types_h
25 #include <sys/types.h>
26 #define INCLUDED_sys_types_h
27 #endif
28
29 struct Client;
30 struct ConfItem;
31
32 /*
33  * Structures
34  */
35 struct ConfClass {
36   unsigned int conClass;
37   unsigned int conFreq;
38   unsigned int pingFreq;
39   unsigned int maxLinks;
40   unsigned int maxSendq;
41   unsigned int links;
42   struct ConfClass *next;
43 };
44
45 /*
46  * Macro's
47  */
48
49 #define ConClass(x)     ((x)->conClass)
50 #define ConFreq(x)      ((x)->conFreq)
51 #define PingFreq(x)     ((x)->pingFreq)
52 #define MaxLinks(x)     ((x)->maxLinks)
53 #define MaxSendq(x)     ((x)->maxSendq)
54 #define Links(x)        ((x)->links)
55
56 #define ConfLinks(x)    ((x)->confClass->links)
57 #define ConfMaxLinks(x) ((x)->confClass->maxLinks)
58 #define ConfClass(x)    ((x)->confClass->conClass)
59 #define ConfConFreq(x)  ((x)->confClass->conFreq)
60 #define ConfPingFreq(x) ((x)->confClass->pingFreq)
61 #define ConfSendq(x)    ((x)->confClass->maxSendq)
62
63 #define FirstClass()    classes
64 #define NextClass(x)    ((x)->next)
65
66 #define MarkDelete(x)   do { MaxLinks(x) = (unsigned int)-1; } while(0)
67 #define IsMarkedDelete(x) (MaxLinks(x) == (unsigned int)-1)
68
69 /*
70  * Proto types
71  */
72
73 extern struct ConfClass *find_class(unsigned int cclass);
74 extern struct ConfClass *make_class(void);
75 extern void free_class(struct ConfClass * tmp);
76 extern unsigned int get_con_freq(struct ConfClass * clptr);
77 extern unsigned int get_client_ping(struct Client *acptr);
78 extern unsigned int get_conf_class(struct ConfItem *aconf);
79 extern unsigned int get_client_class(struct Client *acptr);
80 extern void add_class(unsigned int conclass, unsigned int ping,
81     unsigned int confreq, unsigned int maxli, size_t sendq);
82 extern void check_class(void);
83 extern void initclass(void);
84 extern void report_classes(struct Client *sptr);
85 extern size_t get_sendq(struct Client* cptr);
86
87 extern struct ConfClass *classes;
88
89 #endif /* INCLUDED_class_h */