Implement a per-connection-class default usermode option.
[ircu2.10.12-pk.git] / ircd / client.c
index f960a1d99f470e29e5e817e71b494c1d035a218a..0b4e4f93daed6282a1bc688e7e69a4e9116f728d 100644 (file)
@@ -67,6 +67,25 @@ int client_get_ping(const struct Client* acptr)
   return ping;
 }
 
+/*
+ * client_get_default_umode
+ * returns default usermode in attached client connection class
+ */
+const char* client_get_default_umode(const struct Client* sptr)
+{
+  struct ConfItem* aconf;
+  struct SLink* link;
+
+  assert(cli_verify(sptr));
+
+  for (link = cli_confs(sptr); link; link = link->next) {
+    aconf = link->value.aconf;
+    if ((aconf->status & CONF_CLIENT) && ConfUmode(aconf))
+      return ConfUmode(aconf);
+  }
+  return NULL;
+}
+
 /*
  * client_drop_sendq
  * removes the client's connection from the list of connections with
@@ -101,18 +120,20 @@ void client_add_sendq(struct Connection* con, struct Connection** con_p)
   }
 }
 
+enum FeatureFlag {
+  FEATFLAG_NULL,
+  FEATFLAG_DISABLES_PRIV,
+  FEATFLAG_ENABLES_PRIV,
+  FEATFLAG_GLOBAL_OPERS,
+  FEATFLAG_LOCAL_OPERS,
+  FEATFLAG_ALL_OPERS
+};
+
 static struct
 {
   enum Priv priv;
-  enum
-    {
-      FEATFLAG_DISABLES_PRIV,
-      FEATFLAG_ENABLES_PRIV,
-      FEATFLAG_GLOBAL_OPERS,
-      FEATFLAG_LOCAL_OPERS,
-      FEATFLAG_ALL_OPERS
-    } flag;
   enum Feature feat;
+  enum FeatureFlag flag;
 } feattab[] =
   {
     { PRIV_WHOX, FEAT_LAST_F, FEATFLAG_ALL_OPERS },
@@ -166,7 +187,7 @@ static struct
     { PRIV_SEE_CHAN, FEAT_LOCOP_SEE_IN_SECRET_CHANNELS, FEATFLAG_LOCAL_OPERS },
     { PRIV_WIDE_GLINE, FEAT_LOCOP_WIDE_GLINE, FEATFLAG_LOCAL_OPERS },
     
-    { PRIV_LAST_PRIV, FEAT_LAST_F, 0 }
+    { PRIV_LAST_PRIV, FEAT_LAST_F, FEATFLAG_NULL }
   };
 
 /* client_set_privs(struct Client* client)
@@ -201,7 +222,7 @@ client_set_privs(struct Client *client, struct ConfItem *oper)
   {
     if (PrivHas(&oper->privs_dirty, feattab[i].priv))
       continue;
-    if (feattab[i].feat != FEAT_LAST_F && !feature_bool(feattab[i].priv))
+    if (feattab[i].feat != FEAT_LAST_F && !feature_bool(feattab[i].feat))
       continue;
     switch (feattab[i].flag)
     {
@@ -225,6 +246,8 @@ client_set_privs(struct Client *client, struct ConfItem *oper)
       if (IsLocOp(client))
         PrivSet(&cli_privs(client), feattab[i].priv);
       continue;
+    default:
+      continue;  /* ?? */
     }
   }