Move unreg, privs, capab and active fields from struct Client to struct Connection.
[ircu2.10.12-pk.git] / include / client.h
index 7b97409d5fa12dd4fe7d4a0ffc519b3bf579f33a..42881b140efc14d36bc42446e5ad42cbcbac22b7 100644 (file)
@@ -212,6 +212,7 @@ struct Connection
   struct DNSReply*    con_dns_reply; /**< DNS reply received during client
                                        registration. */
   struct ListingArgs* con_listing;   /**< Current LIST status. */
+  unsigned long       con_unreg;     /**< Indicate what still needs to be done */
   unsigned int        con_max_sendq; /**< cached max send queue for client */
   unsigned int        con_ping_freq; /**< cached ping freq */
   unsigned short      con_lastsq;    /**< # 2k blocks when sendqueued
@@ -230,6 +231,9 @@ struct Connection
                                       client */
   struct Timer        con_proc;      /**< process latent messages from
                                       client */
+  struct Privs        con_privs;     /**< Oper privileges */
+  struct CapSet       con_capab;     /**< Client capabilities */
+  struct CapSet       con_active;    /**< Active client capabilities */
   struct AuthRequest* con_auth;      /**< auth request for client */
   struct IAuthRequest* con_iauth;    /**< iauth request for client */
 };
@@ -256,10 +260,6 @@ struct Client {
   unsigned int   cli_hopcount;    /**< number of servers to this 0 = local */
   struct irc_in_addr cli_ip;      /**< Real IP of client */
   short          cli_status;      /**< Client type */
-  struct Privs   cli_privs;       /**< Oper privileges */
-  struct CapSet  cli_capab;       /**< Client capabilities */
-  struct CapSet  cli_active;      /**< Active client capabilities */
-  unsigned long  cli_unreg;       /**< Indicate what still needs to be done */
   char cli_name[HOSTLEN + 1];     /**< Unique name of the client, nick or host */
   char cli_username[USERLEN + 1]; /**< username here now for auth stuff */
   char cli_info[REALLEN + 1];     /**< Free form additional client information */
@@ -318,13 +318,13 @@ struct Client {
 /** Return non-zero if the client is local. */
 #define cli_local(cli)          (cli_from(cli) == cli)
 /** Get oper privileges for client. */
-#define cli_privs(cli)         ((cli)->cli_privs)
+#define cli_privs(cli)         con_privs(cli_connect(cli))
 /** Get client capabilities for client */
-#define cli_capab(cli)         (&((cli)->cli_capab))
+#define cli_capab(cli)         con_capab(cli_connect(cli))
 /** Get active client capabilities for client */
-#define cli_active(cli)                (&((cli)->cli_active))
+#define cli_active(cli)                con_active(cli_connect(cli))
 /** Get flags for remaining registration tasks */
-#define cli_unreg(cli)         ((cli)->cli_unreg)
+#define cli_unreg(cli)         con_unreg(cli_connect(cli))
 /** Get client name. */
 #define cli_name(cli)          ((cli)->cli_name)
 /** Get client username (ident). */
@@ -451,6 +451,8 @@ struct Client {
 #define con_dns_reply(con)     ((con)->con_dns_reply)
 /** Get the LIST status for the connection. */
 #define con_listing(con)       ((con)->con_listing)
+/** Get remining steps before registration completes. */
+#define con_unreg(con)          ((con)->con_unreg)
 /** Get the maximum permitted SendQ size for the connection. */
 #define con_max_sendq(con)     ((con)->con_max_sendq)
 /** Get the ping frequency for the connection. */
@@ -471,6 +473,12 @@ struct Client {
 #define con_socket(con)                ((con)->con_socket)
 /** Get the Timer for processing more data from the connection. */
 #define con_proc(con)          ((con)->con_proc)
+/** Get the oper privilege set for the connection. */
+#define con_privs(con)          (&(con)->con_privs)
+/** Get the peer's capabilities for the connection. */
+#define con_capab(con)          (&(con)->con_capab)
+/** Get the active capabilities for the connection. */
+#define con_active(con)         (&(con)->con_active)
 /** Get the auth request for the connection. */
 #define con_auth(con)          ((con)->con_auth)
 /** Get the iauth request for the connection. */
@@ -734,7 +742,11 @@ struct Client {
 #define SNO_NOISY (SNO_SERVKILL|SNO_UNAUTH)
 
 /** Test whether a privilege has been granted to a client. */
-#define HasPriv(cli, priv)  FlagHas(&cli_privs(cli), priv)
+#define HasPriv(cli, priv)  FlagHas(cli_privs(cli), priv)
+/** Grant a privilege to a client. */
+#define SetPriv(cli, priv)  FlagSet(cli_privs(cli), priv)
+/** Revoke a privilege from a client. */
+#define ClrPriv(cli, priv)  FlagClr(cli_privs(cli), priv)
 
 /** Test whether a client has a capability */
 #define HasCap(cli, cap)    CapHas(cli_capab(cli), (cap))