ircu2.10.12 pk910 fork
[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 /** @file
21  * @brief Declarations and interfaces for handling connection classes.
22  * @version $Id: class.h 1511 2005-10-05 01:53:30Z entrope $
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 int            max_channels;   /**< Maximum number of channels */
53   unsigned short          ping_freq;      /**< Ping frequency for clients. */
54   unsigned short          conn_freq;      /**< Auto-connect frequency. */
55   unsigned char           valid;          /**< Valid flag (cleared after this
56                                              class is removed from the config).*/
57 };
58
59 /*
60  * Macro's
61  */
62
63 /** Get class name for \a x. */
64 #define ConClass(x)     ((x)->cc_name)
65 /** Get ping frequency for \a x. */
66 #define PingFreq(x)     ((x)->ping_freq)
67 /** Get connection frequency for \a x. */
68 #define ConFreq(x)      ((x)->conn_freq)
69 /** Get maximum links allowed for \a x. */
70 #define MaxLinks(x)     ((x)->max_links)
71 /** Get maximum SendQ size for \a x. */
72 #define MaxSendq(x)     ((x)->max_sendq)
73 /** Get number of references to \a x. */
74 #define Links(x)        ((x)->ref_count)
75 /** Get maximum number of channels for \a x. */
76 #define MaxChannels(x)  (((x)->max_channels)?((x)->max_channels):feature_int(FEAT_MAXCHANNELSPERUSER))
77
78 /** Get class name for ConfItem \a x. */
79 #define ConfClass(x)    ((x)->conn_class->cc_name)
80 /** Get ping frequency for ConfItem \a x. */
81 #define ConfPingFreq(x) ((x)->conn_class->ping_freq)
82 /** Get connection frequency for ConfItem \a x. */
83 #define ConfConFreq(x)  ((x)->conn_class->conn_freq)
84 /** Get maximum links allowed for ConfItem \a x. */
85 #define ConfMaxLinks(x) ((x)->conn_class->max_links)
86 /** Get maximum SendQ size for ConfItem \a x. */
87 #define ConfSendq(x)    ((x)->conn_class->max_sendq)
88 /** Get number of references to class in ConfItem \a x. */
89 #define ConfLinks(x)    ((x)->conn_class->ref_count)
90 /** Get default usermode for ConfItem \a x. */
91 #define ConfUmode(x)    ((x)->conn_class->default_umode)
92 /** Get maximum number of channels for ConfItem \a x. */
93 #define ConfMaxChannels(x) (((x)->conn_class->max_channels)?((x)->conn_class->max_channels):feature_int(FEAT_MAXCHANNELSPERUSER))
94 /** Find a valid configuration class by name. */
95 #define find_class(name) do_find_class((name), 0)
96
97 /*
98  * Proto types
99  */
100
101 extern void init_class(void);
102
103 extern const struct ConnectionClass* get_class_list(void);
104 extern void class_mark_delete(void);
105 extern void class_delete_marked(void);
106
107 extern struct ConnectionClass *do_find_class(const char *name, int extras);
108 extern struct ConnectionClass *make_class(void);
109 extern void free_class(struct ConnectionClass * tmp);
110 extern char *get_conf_class(const struct ConfItem *aconf);
111 extern int get_conf_ping(const struct ConfItem *aconf);
112 extern char *get_client_class(struct Client *acptr);
113 extern void add_class(char *name, unsigned int ping,
114                       unsigned int confreq, unsigned int maxli,
115                       unsigned int sendq, unsigned int max_channels);
116 extern void report_classes(struct Client *sptr, const struct StatDesc *sd,
117                            char *param);
118 extern unsigned int get_sendq(struct Client* cptr);
119
120 extern void class_send_meminfo(struct Client* cptr);
121 #endif /* INCLUDED_class_h */