]>
Commit | Line | Data |
---|---|---|
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 | /** @file | |
21 | * @brief Declarations and interfaces for handling connection classes. | |
22 | * @version $Id: class.h,v 1.20.2.1 2005/10/05 01:51:34 entrope Exp $ | |
23 | */ | |
24 | #ifndef INCLUDED_class_h | |
25 | #define INCLUDED_class_h | |
26 | #ifndef INCLUDED_sys_types_h | |
27 | #include <sys/types.h> | |
28 | #define INCLUDED_sys_types_h | |
29 | #endif | |
30 | ||
31 | #include "client.h" | |
32 | ||
33 | struct ConfItem; | |
34 | struct StatDesc; | |
35 | ||
36 | /* | |
37 | * Structures | |
38 | */ | |
39 | /** Represents a connection class. */ | |
40 | struct ConnectionClass { | |
41 | struct ConnectionClass* next; /**< Link to next connection class. */ | |
42 | char *cc_name; /**< Name of connection class. */ | |
43 | char *default_umode; /**< Default usermode for users | |
44 | in this class. */ | |
45 | struct Privs privs; /**< Privilege bits that are set on | |
46 | or off. */ | |
47 | struct Privs privs_dirty; /**< Indication of which bits in | |
48 | ConnectionClass::privs are valid. */ | |
49 | unsigned int max_sendq; /**< Maximum client SendQ in bytes. */ | |
50 | unsigned int max_links; /**< Maximum connections allowed. */ | |
51 | unsigned int ref_count; /**< Number of references to class. */ | |
52 | unsigned short ping_freq; /**< Ping frequency for clients. */ | |
53 | unsigned short conn_freq; /**< Auto-connect frequency. */ | |
54 | unsigned char valid; /**< Valid flag (cleared after this | |
55 | class is removed from the config).*/ | |
56 | }; | |
57 | ||
58 | /* | |
59 | * Macro's | |
60 | */ | |
61 | ||
62 | /** Get class name for \a x. */ | |
63 | #define ConClass(x) ((x)->cc_name) | |
64 | /** Get ping frequency for \a x. */ | |
65 | #define PingFreq(x) ((x)->ping_freq) | |
66 | /** Get connection frequency for \a x. */ | |
67 | #define ConFreq(x) ((x)->conn_freq) | |
68 | /** Get maximum links allowed for \a x. */ | |
69 | #define MaxLinks(x) ((x)->max_links) | |
70 | /** Get maximum SendQ size for \a x. */ | |
71 | #define MaxSendq(x) ((x)->max_sendq) | |
72 | /** Get number of references to \a x. */ | |
73 | #define Links(x) ((x)->ref_count) | |
74 | ||
75 | /** Get class name for ConfItem \a x. */ | |
76 | #define ConfClass(x) ((x)->conn_class->cc_name) | |
77 | /** Get ping frequency for ConfItem \a x. */ | |
78 | #define ConfPingFreq(x) ((x)->conn_class->ping_freq) | |
79 | /** Get connection frequency for ConfItem \a x. */ | |
80 | #define ConfConFreq(x) ((x)->conn_class->conn_freq) | |
81 | /** Get maximum links allowed for ConfItem \a x. */ | |
82 | #define ConfMaxLinks(x) ((x)->conn_class->max_links) | |
83 | /** Get maximum SendQ size for ConfItem \a x. */ | |
84 | #define ConfSendq(x) ((x)->conn_class->max_sendq) | |
85 | /** Get number of references to class in ConfItem \a x. */ | |
86 | #define ConfLinks(x) ((x)->conn_class->ref_count) | |
87 | /** Get default usermode for ConfItem \a x. */ | |
88 | #define ConfUmode(x) ((x)->conn_class->default_umode) | |
89 | /** Find a valid configuration class by name. */ | |
90 | #define find_class(name) do_find_class((name), 0) | |
91 | ||
92 | /* | |
93 | * Proto types | |
94 | */ | |
95 | ||
96 | extern void init_class(void); | |
97 | ||
98 | extern const struct ConnectionClass* get_class_list(void); | |
99 | extern void class_mark_delete(void); | |
100 | extern void class_delete_marked(void); | |
101 | ||
102 | extern struct ConnectionClass *do_find_class(const char *name, int extras); | |
103 | extern struct ConnectionClass *make_class(void); | |
104 | extern void free_class(struct ConnectionClass * tmp); | |
105 | extern char *get_conf_class(const struct ConfItem *aconf); | |
106 | extern int get_conf_ping(const struct ConfItem *aconf); | |
107 | extern char *get_client_class(struct Client *acptr); | |
108 | extern void add_class(char *name, unsigned int ping, | |
109 | unsigned int confreq, unsigned int maxli, | |
110 | unsigned int sendq); | |
111 | extern void report_classes(struct Client *sptr, const struct StatDesc *sd, | |
112 | char *param); | |
113 | extern unsigned int get_sendq(struct Client* cptr); | |
114 | ||
115 | extern void class_send_meminfo(struct Client* cptr); | |
116 | #endif /* INCLUDED_class_h */ |