fixed ssl.c bug when ssl backend returns IO_BLOCKED but IO engine doesn't get informe...
[ircu2.10.12-pk.git] / ircd / m_names.c
index 16cee5cac1b624879891b32d2d57277bbeb33c44..1951922084696784a743848495bad15e328af11f 100644 (file)
  *  NAMES_DEL - Show join-delayed names list.
  *  NAMES_EON - When OR'd with the other two, adds an 'End of Names' numeric
  *              used by m_join
+ *  NAMES_OPS - Only list oped (+o) or voiced (+v) users
  *
  */
 
@@ -140,8 +141,11 @@ void do_names(struct Client* sptr, struct Channel* chptr, int filter)
   flag = 1;
   needs_space = 0;
 
-  if (!ShowChannel(sptr, chptr)) /* Don't list private channels unless we are on them. */
+  if (!ShowChannel(sptr, chptr)) { /* Don't list private channels unless we are on them. */
+    if (filter&NAMES_EON)
+      send_reply(sptr, RPL_ENDOFNAMES, chptr->chname);
     return;
+  }
 
   /* Iterate over all channel members, and build up the list. */
 
@@ -165,6 +169,9 @@ void do_names(struct Client* sptr, struct Channel* chptr, int filter)
                
        if (IsInvisibleJoin(member) && member->user != sptr)
                continue;
+       
+       if (!IsChanOpOrHalfOp(member) && !HasVoice(member) && member->user != sptr && (filter & NAMES_OPS))
+               continue;
 
     if (needs_space)
       buf[idx++] = ' ';
@@ -173,6 +180,8 @@ void do_names(struct Client* sptr, struct Channel* chptr, int filter)
       buf[idx++] = '!';
     else if (IsChanOp(member))
       buf[idx++] = '@';
+    else if (IsHalfOp(member))
+      buf[idx++] = '%';
     else if (HasVoice(member))
       buf[idx++] = '+';
     strcpy(buf + idx, cli_name(c2ptr));
@@ -242,15 +251,15 @@ int m_names(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
       mlen = strlen(cli_name(&me)) + 10 + strlen(cli_name(sptr));
 
       /* List all visible channels/visible members */ 
-
+      struct Membership *member;
       for (ch2ptr = GlobalChannelList; ch2ptr; ch2ptr = ch2ptr->next)
       { 
         if (!ShowChannel(sptr, ch2ptr))
           continue;                 /* Don't show secret chans. */ 
-        else if (find_channel_member(sptr, ch2ptr))
-          do_names(sptr, ch2ptr, showingdelayed|NAMES_ALL); /* Full list if we're in this chan. */
-        else
-          do_names(sptr, ch2ptr, showingdelayed|NAMES_VIS);
+        else if ((member = find_channel_member(sptr, ch2ptr))) {
+          do_names(sptr, ch2ptr, showingdelayed|NAMES_ALL|((ch2ptr->mode.mode & MODE_AUDITORIUM) && !(member->status & MODE_CHANOP) ? NAMES_OPS : 0)); /* Full list if we're in this chan. */
+        else
+          do_names(sptr, ch2ptr, showingdelayed|NAMES_VIS|((ch2ptr->mode.mode & MODE_AUDITORIUM) ? NAMES_OPS : 0));
       } 
 
       /* List all remaining users on channel '*' */
@@ -307,7 +316,7 @@ int m_names(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
          *  Special Case 2: User is on this channel, requesting full names list.
          *  (As performed with each /join) - ** High frequency usage **
          */
-        do_names(sptr, chptr, showingdelayed|NAMES_ALL|NAMES_EON);
+        do_names(sptr, chptr, showingdelayed|NAMES_ALL|NAMES_EON|((chptr->mode.mode & MODE_AUDITORIUM) && !(member->status & MODE_CHANOP) ? NAMES_OPS : 0));
       }
       else
       {
@@ -315,7 +324,7 @@ int m_names(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
          *  Special Case 3: User isn't on this channel, show all visible users, in 
          *  non secret channels.
          */ 
-        do_names(sptr, chptr, showingdelayed|NAMES_VIS|NAMES_EON);
+        do_names(sptr, chptr, showingdelayed|NAMES_VIS|NAMES_EON|((chptr->mode.mode & MODE_AUDITORIUM) ? NAMES_OPS : 0));
       } 
     }
     else