added basic ssl support to ircu
[ircu2.10.12-pk.git] / include / class.h
index 97e483234ea556a9c1c8e5646bc445d77001e8fa..5a9647d2750c6de26616a1ba9425432e2cc0cb89 100644 (file)
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
+/** @file
+ * @brief Declarations and interfaces for handling connection classes.
+ * @version $Id$
+ */
+#ifndef INCLUDED_class_h
+#define INCLUDED_class_h
+#ifndef INCLUDED_sys_types_h
+#include <sys/types.h>
+#define INCLUDED_sys_types_h
+#endif
+
+#include "client.h"
 
-#ifndef CLASS_H
-#define CLASS_H
+struct ConfItem;
+struct StatDesc;
 
-/*=========================================================================
+/*
  * Structures
  */
-
-struct ConfClass {
-  unsigned int conClass;
-  unsigned int conFreq;
-  unsigned int pingFreq;
-  unsigned int maxLinks;
-  unsigned int maxSendq;
-  unsigned int links;
-  struct ConfClass *next;
+/** Represents a connection class. */
+struct ConnectionClass {
+  struct ConnectionClass* next;           /**< Link to next connection class. */
+  char                    *cc_name;       /**< Name of connection class. */
+  char                    *default_umode; /**< Default usermode for users
+                                             in this class. */
+  struct Privs            privs;          /**< Privilege bits that are set on
+                                             or off. */
+  struct Privs            privs_dirty;    /**< Indication of which bits in
+                                             ConnectionClass::privs are valid. */
+  unsigned int            max_sendq;      /**< Maximum client SendQ in bytes. */
+  unsigned int            max_links;      /**< Maximum connections allowed. */
+  unsigned int            ref_count;      /**< Number of references to class. */
+  unsigned short          ping_freq;      /**< Ping frequency for clients. */
+  unsigned short          conn_freq;      /**< Auto-connect frequency. */
+  unsigned char           valid;          /**< Valid flag (cleared after this
+                                             class is removed from the config).*/
 };
 
-/*=============================================================================
+/*
  * Macro's
  */
 
-#define ConClass(x)    ((x)->conClass)
-#define ConFreq(x)     ((x)->conFreq)
-#define PingFreq(x)    ((x)->pingFreq)
-#define MaxLinks(x)    ((x)->maxLinks)
-#define MaxSendq(x)    ((x)->maxSendq)
-#define Links(x)       ((x)->links)
+/** Get class name for \a x. */
+#define ConClass(x)     ((x)->cc_name)
+/** Get ping frequency for \a x. */
+#define PingFreq(x)     ((x)->ping_freq)
+/** Get connection frequency for \a x. */
+#define ConFreq(x)      ((x)->conn_freq)
+/** Get maximum links allowed for \a x. */
+#define MaxLinks(x)     ((x)->max_links)
+/** Get maximum SendQ size for \a x. */
+#define MaxSendq(x)     ((x)->max_sendq)
+/** Get number of references to \a x. */
+#define Links(x)        ((x)->ref_count)
 
-#define ConfLinks(x)   ((x)->confClass->links)
-#define ConfMaxLinks(x) ((x)->confClass->maxLinks)
-#define ConfClass(x)   ((x)->confClass->conClass)
-#define ConfConFreq(x) ((x)->confClass->conFreq)
-#define ConfPingFreq(x) ((x)->confClass->pingFreq)
-#define ConfSendq(x)   ((x)->confClass->maxSendq)
+/** Get class name for ConfItem \a x. */
+#define ConfClass(x)    ((x)->conn_class->cc_name)
+/** Get ping frequency for ConfItem \a x. */
+#define ConfPingFreq(x) ((x)->conn_class->ping_freq)
+/** Get connection frequency for ConfItem \a x. */
+#define ConfConFreq(x)  ((x)->conn_class->conn_freq)
+/** Get maximum links allowed for ConfItem \a x. */
+#define ConfMaxLinks(x) ((x)->conn_class->max_links)
+/** Get maximum SendQ size for ConfItem \a x. */
+#define ConfSendq(x)    ((x)->conn_class->max_sendq)
+/** Get number of references to class in ConfItem \a x. */
+#define ConfLinks(x)    ((x)->conn_class->ref_count)
+/** Get default usermode for ConfItem \a x. */
+#define ConfUmode(x)    ((x)->conn_class->default_umode)
+/** Find a valid configuration class by name. */
+#define find_class(name) do_find_class((name), 0)
 
-#define FirstClass()   classes
-#define NextClass(x)   ((x)->next)
-
-#define MarkDelete(x)  do { MaxLinks(x) = (unsigned int)-1; } while(0)
-#define IsMarkedDelete(x) (MaxLinks(x) == (unsigned int)-1)
-
-/*=============================================================================
+/*
  * Proto types
  */
 
-extern aConfClass *find_class(unsigned int cclass);
-extern aConfClass *make_class(void);
-extern void free_class(aConfClass * tmp);
-extern unsigned int get_con_freq(aConfClass * clptr);
-extern unsigned int get_client_ping(aClient *acptr);
-extern unsigned int get_conf_class(aConfItem *aconf);
-extern unsigned int get_client_class(aClient *acptr);
-extern void add_class(unsigned int conclass, unsigned int ping,
-    unsigned int confreq, unsigned int maxli, size_t sendq);
-extern void check_class(void);
-extern void initclass(void);
-extern void report_classes(aClient *sptr);
-extern size_t get_sendq(aClient *cptr);
+extern void init_class(void);
+
+extern const struct ConnectionClass* get_class_list(void);
+extern void class_mark_delete(void);
+extern void class_delete_marked(void);
 
-extern aConfClass *classes;
+extern struct ConnectionClass *do_find_class(const char *name, int extras);
+extern struct ConnectionClass *make_class(void);
+extern void free_class(struct ConnectionClass * tmp);
+extern char *get_conf_class(const struct ConfItem *aconf);
+extern int get_conf_ping(const struct ConfItem *aconf);
+extern char *get_client_class(struct Client *acptr);
+extern void add_class(char *name, unsigned int ping,
+                      unsigned int confreq, unsigned int maxli,
+                      unsigned int sendq);
+extern void report_classes(struct Client *sptr, const struct StatDesc *sd,
+                           char *param);
+extern unsigned int get_sendq(struct Client* cptr);
 
-#endif /* CLASS_H */
+extern void class_send_meminfo(struct Client* cptr);
+#endif /* INCLUDED_class_h */