added support for user privileges through connection class
[ircu2.10.12-pk.git] / include / client.h
index aea930ab404da257135bb8b298e07cb618e0120c..4fb584c3cb827defe72c2c6d464baf1943e5514a 100644 (file)
@@ -90,7 +90,7 @@ typedef unsigned long flagpage_t;
 #define FlagClr(set,flag) ((set)->bits[FLAGSET_INDEX(flag)] &= ~FLAGSET_MASK(flag))
 
 /** String containing valid user modes, in no particular order. */
-#define infousermodes "dioswkgx"
+#define infousermodes "diOoswkgx"
 
 /** Operator privileges. */
 enum Priv
@@ -317,6 +317,8 @@ struct Client {
 #define cli_username(cli)      ((cli)->cli_username)
 /** Get client realname (information field). */
 #define cli_info(cli)          ((cli)->cli_info)
+/** Get client account string. */
+#define cli_account(cli)       (cli_user(cli) ? cli_user(cli)->account : "0")
 
 /** Get number of incoming bytes queued for client. */
 #define cli_count(cli)         con_count(cli_connect(cli))
@@ -531,7 +533,7 @@ struct Client {
 #define HasFlag(cli, flag)  FlagHas(&cli_flags(cli), flag)
 
 /** Return non-zero if the client is an IRC operator (global or local). */
-#define IsAnOper(x)             (HasFlag(x, FLAG_OPER) || HasFlag(x, FLAG_LOCOP))
+#define IsAnOper(x)             (IsOper(x) || IsLocOp(x))
 /** Return non-zero if the client's connection is blocked. */
 #define IsBlocked(x)            HasFlag(x, FLAG_BLOCKED)
 /** Return non-zero if the client's connection is still being burst. */
@@ -555,8 +557,8 @@ struct Client {
 #define IsInvisible(x)          HasFlag(x, FLAG_INVISIBLE)
 /** Return non-zero if the client caused a net.burst. */
 #define IsJunction(x)           HasFlag(x, FLAG_JUNCTION)
-/** Return non-zero if the client has set mode +O (local operator). */
-#define IsLocOp(x)              HasFlag(x, FLAG_LOCOP)
+/** Return non-zero if the client has set mode +O (local operator) locally. */
+#define IsLocOp(x)              (MyConnect(x) && HasFlag(x, FLAG_LOCOP))
 /** Return non-zero if the client has set mode +o (global operator). */
 #define IsOper(x)               HasFlag(x, FLAG_OPER)
 /** Return non-zero if the client has an active UDP ping request. */
@@ -660,6 +662,8 @@ struct Client {
 #define ClearHiddenHost(x)      ClrFlag(x, FLAG_HIDDENHOST)
 /** Clear the client's pending PING flag. */
 #define ClearPingSent(x)        ClrFlag(x, FLAG_PINGSENT)
+/** Clear the client's HUB flag. */
+#define ClearHub(x)             ClrFlag(x, FLAG_HUB)
 
 /* free flags */
 #define FREEFLAG_SOCKET        0x0001  /**< socket needs to be freed */
@@ -711,7 +715,7 @@ 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(client_get_privs(cli), priv)
 /** Grant a privilege to a client. */
 #define SetPriv(cli, priv)  FlagSet(cli_privs(cli), priv)
 /** Revoke a privilege from a client. */
@@ -734,5 +738,7 @@ extern void client_add_sendq(struct Connection* con,
 extern void client_set_privs(struct Client *client, struct ConfItem *oper);
 extern int client_report_privs(struct Client* to, struct Client* client);
 
+extern int client_get_privs(struct Client* client);
+
 #endif /* INCLUDED_client_h */