]> jfr.im git - irc/rizon/plexus4.git/commitdiff
- m_who.c: merged big mask matching conditional statement found in who_global() and...
authormichael <redacted>
Fri, 15 Jul 2016 19:46:58 +0000 (19:46 +0000)
committerAdam <redacted>
Sun, 17 Jul 2016 15:49:48 +0000 (11:49 -0400)
git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/trunk@7641 82007160-df01-0410-b94d-b575c5fd34c7

modules/m_who.c

index 7a45f56b482229a491ca27a4633a1df6d05a6452..a4701c86a651a0a13256f5167fcd4b6789a847ba 100644 (file)
@@ -78,6 +78,38 @@ do_who(struct Client *source_p, struct Client *target_p,
                status, target_p->hopcount, target_p->info);
 }
 
+/*!
+ * \param source_p Pointer to client requesting who
+ * \param target_p Pointer to client to do who on
+ * \param mask Mask to match
+ * \return 1 if mask matches, 0 otherwise
+ */
+static int
+who_matches(struct Client *source_p, struct Client *target_p, const char *mask)
+{
+  if (!mask)
+    return 1;
+
+  if (!match(mask, target_p->name))
+    return 1;
+
+  if (!match(mask, target_p->username))
+    return 1;
+
+  if (!match(mask, target_p->host))
+    return 1;
+
+  if (!match(mask, target_p->info))
+    return 1;
+
+  if (HasUMode(source_p, UMODE_OPER) ||
+      (!ConfigServerHide.hide_servers && !IsHidden(target_p->servptr)))
+    if (!match(mask, target_p->servptr->name))
+      return 1;
+
+  return 0;
+}
+
 /* who_common_channel
  * inputs      - pointer to client requesting who
  *             - pointer to channel member chain.
@@ -110,12 +142,7 @@ who_common_channel(struct Client *source_p, struct Channel *chptr,
 
     assert(target_p->servptr != NULL);
 
-    if ((mask == NULL) ||
-      !match(mask, target_p->name) || !match(mask, target_p->username) ||
-      !match(mask, target_p->host) ||
-      ((!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER)) &&
-       !match(mask, target_p->servptr->name)) ||
-      !match(mask, target_p->info))
+    if (who_matches(source_p, target_p, mask))
     {
       do_who(source_p, target_p, NULL, "");
 
@@ -185,10 +212,7 @@ who_global(struct Client *source_p, char *mask, int server_oper)
 
     assert(target_p->servptr != NULL);
 
-    if (!mask ||
-        !match(mask, target_p->name) || !match(mask, target_p->username) ||
-        !match(mask, target_p->host) || !match(mask, target_p->servptr->name) ||
-        !match(mask, target_p->info))
+    if (who_matches(source_p, target_p, mask))
     {
       do_who(source_p, target_p, NULL, "");