Doxyfy class.h and class.c.
authorMichael Poole <mdpoole@troilus.org>
Mon, 4 Oct 2004 01:01:46 +0000 (01:01 +0000)
committerMichael Poole <mdpoole@troilus.org>
Mon, 4 Oct 2004 01:01:46 +0000 (01:01 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1214 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

include/class.h
ircd/class.c

index f1e027d0fc1f9bc6229d3e102bad7ee44366c2d3..dfffb7b9b557afdb981579785a50af394cf0f83d 100644 (file)
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
+ */
+/** @file
+ * @brief Declarations and interfaces for handling connection classes.
+ * @version $Id$
  */
 #ifndef INCLUDED_class_h
 #define INCLUDED_class_h
@@ -34,37 +36,55 @@ struct StatDesc;
 /*
  * Structures
  */
+/** Represents a connection class. */
 struct ConnectionClass {
-  struct ConnectionClass* next;
-  char                    *cc_name;
-  char                    *default_umode;
-  struct Privs            privs;
-  struct Privs            privs_dirty;
-  unsigned int            max_sendq;
-  unsigned int            max_links;
-  unsigned int            ref_count;
-  unsigned short          ping_freq;
-  unsigned short          conn_freq;
-  unsigned char           valid;
+  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
  */
 
+/** 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)
 
+/** 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)
 
 /*
@@ -87,7 +107,6 @@ 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 check_class(void);
 extern void report_classes(struct Client *sptr, const struct StatDesc *sd,
                            char *param);
 extern unsigned int get_sendq(struct Client* cptr);
index 41ed4e62aa501f51324424fa2fe593fe9fcadf3d..9c00e848bc145f9c615eac23744c1c0308f1c0d1 100644 (file)
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
+ */
+/** @file
+ * @brief Implementation of connection class handling functions.
+ * @version $Id$
  */
 #include "config.h"
 
 
 #include <assert.h>
 
-#define BAD_CONF_CLASS          ((unsigned int)-1)
-#define BAD_PING                ((unsigned int)-2)
-#define BAD_CLIENT_CLASS        ((unsigned int)-3)
-
+/** List of all connection classes. */
 static struct ConnectionClass* connClassList = 0;
+/** Number of allocated connection classes. */
 static unsigned int connClassAllocCount;
 
+/** Get start of connection class linked list. */
 const struct ConnectionClass* get_class_list(void)
 {
   return connClassList;
 }
 
+/** Allocate a new connection class.
+ * @return Newly allocated connection class structure.
+ */
 struct ConnectionClass* make_class(void)
 {
   struct ConnectionClass *tmp;
@@ -58,6 +62,9 @@ struct ConnectionClass* make_class(void)
   return tmp;
 }
 
+/** Dereference a connection class.
+ * @param[in] p Connection class to dereference.
+ */
 void free_class(struct ConnectionClass* p)
 {
   if (p)
@@ -70,8 +77,10 @@ void free_class(struct ConnectionClass* p)
   }
 }
 
-/*
- * init_class - initialize the class list
+/** Initialize the connection class list.
+ * A connection class named "default" is created, with ping frequency,
+ * connection frequency, maximum links and max SendQ values from the
+ * corresponding configuration features.
  */
 void init_class(void)
 {
@@ -89,11 +98,7 @@ void init_class(void)
   connClassList->next     = 0;
 }
 
-/*
- * class_mark_delete - mark classes for delete
- * We don't delete the class table, rather mark all entries
- * for deletion. The table is cleaned up by class_delete_marked(). - avalon
- * XXX - This destroys data
+/** Mark current connection classes as invalid.
  */
 void class_mark_delete(void)
 {
@@ -104,11 +109,10 @@ void class_mark_delete(void)
     p->valid = 0;
 }
 
-/*
- * class_delete_marked
- * delete classes marked for deletion
- * XXX - memory leak, no one deletes classes that become unused
- * later
+/** Unlink (and dereference) invalid connection classes.
+ * This is used in combination with class_mark_delete() during rehash
+ * to get rid of connection classes that are no longer in the
+ * configuration.
  */
 void class_delete_marked(void)
 {
@@ -135,6 +139,10 @@ void class_delete_marked(void)
   }
 }
 
+/** Get connection class name for a configuration item.
+ * @param[in] aconf Configuration item to check.
+ * @return Name of connection class associated with \a aconf.
+ */
 char*
 get_conf_class(const struct ConfItem* aconf)
 {
@@ -146,6 +154,10 @@ get_conf_class(const struct ConfItem* aconf)
   return NULL;
 }
 
+/** Get ping time for a configuration item.
+ * @param[in] aconf Configuration item to check.
+ * @return Ping time for connection class associated with \a aconf.
+ */
 int get_conf_ping(const struct ConfItem* aconf)
 {
   assert(0 != aconf);
@@ -157,6 +169,10 @@ int get_conf_ping(const struct ConfItem* aconf)
   return -1;
 }
 
+/** Get connection class name for a particular client.
+ * @param[in] acptr Client to check.
+ * @return Name of connection class to which \a acptr belongs.
+ */
 char*
 get_client_class(struct Client *acptr)
 {
@@ -173,6 +189,11 @@ get_client_class(struct Client *acptr)
   return "(null-class)";
 }
 
+/** Get connection interval for a connection class.
+ * @param[in] clptr Connection class to check (or NULL).
+ * @return If \a clptr != NULL, its connection frequency; else default
+ * connection frequency.
+ */
 unsigned int get_con_freq(struct ConnectionClass * clptr)
 {
   if (clptr)
@@ -181,12 +202,15 @@ unsigned int get_con_freq(struct ConnectionClass * clptr)
     return feature_int(FEAT_CONNECTFREQUENCY);
 }
 
-/*
- * When adding a class, check to see if it is already present first.
- * if so, then update the information for that class, rather than create
- * a new entry for it and later delete the old entry.
- * if no present entry is found, then create a new one and add it in
- * immeadiately after the first one (class 0).
+/** Make sure we have a connection class named \a name.
+ * If one does not exist, create it.  Then set its ping frequency,
+ * connection frequency, maximum link count, and max SendQ according
+ * to the parameters.
+ * @param[in] name Connection class name.
+ * @param[in] ping Ping frequency for clients in this class.
+ * @param[in] confreq Connection frequency for clients.
+ * @param[in] maxli Maximum link count for class.
+ * @param[in] sendq Max SendQ for clients.
  */
 void add_class(char *name, unsigned int ping, unsigned int confreq,
                unsigned int maxli, unsigned int sendq)
@@ -220,6 +244,10 @@ void add_class(char *name, unsigned int ping, unsigned int confreq,
     Links(p) = 0;
 }
 
+/** Find a connection class by name.
+ * @param[in] name Name of connection class to search for.
+ * @return Pointer to connection class structure (or NULL if none match).
+ */
 struct ConnectionClass* find_class(const char *name)
 {
   struct ConnectionClass *cltmp;
@@ -231,6 +259,11 @@ struct ConnectionClass* find_class(const char *name)
   return connClassList;
 }
 
+/** Report connection classes to a client.
+ * @param[in] sptr Client requesting statistics.
+ * @param[in] sd Stats descriptor for request (ignored).
+ * @param[in] param Extra parameter from user (ignored).
+ */
 void
 report_classes(struct Client *sptr, const struct StatDesc *sd,
                char *param)
@@ -243,6 +276,10 @@ report_classes(struct Client *sptr, const struct StatDesc *sd,
               Links(cltmp));
 }
 
+/** Return maximum SendQ length for a client.
+ * @param[in] cptr Local client to check.
+ * @return Number of bytes allowed in SendQ for \a cptr.
+ */
 unsigned int
 get_sendq(struct Client *cptr)
 {
@@ -268,6 +305,10 @@ get_sendq(struct Client *cptr)
   return feature_int(FEAT_DEFAULTMAXSENDQLENGTH);
 }
 
+/** Report connection class memory statistics to a client.
+ * Send number of classes and number of bytes allocated for them.
+ * @param[in] cptr Client requesting statistics.
+ */
 void class_send_meminfo(struct Client* cptr)
 {
   send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":Classes: inuse: %d(%d)",