let's try this again...*without* CVS substituting part of my sed lines!
[ircu2.10.12-pk.git] / ircd / m_names.c
index 02e80d2282789716c0268f46a7d0ff7d419b5687..54a299d33c5142f5f4fa14421f3de55248bfca82 100644 (file)
@@ -85,6 +85,7 @@
 #include "client.h"
 #include "hash.h"
 #include "ircd.h"
+#include "ircd_log.h"
 #include "ircd_reply.h"
 #include "ircd_string.h"
 #include "msg.h"
@@ -93,7 +94,7 @@
 #include "s_user.h"
 #include "send.h"
  
-#include <assert.h>
+/* #include <assert.h> -- Now using assert in ircd_log.h */
 #include <string.h>
 
 /*
@@ -155,6 +156,12 @@ void do_names(struct Client* sptr, struct Channel* chptr, int filter)
     if (IsZombie(member) && member->user != sptr)
       continue;
 
+    if (IsDelayedJoin(member) && (member->user != sptr) && !(filter & NAMES_DEL))
+        continue;
+
+    if ((!IsDelayedJoin(member) || (member->user == sptr)) && (filter & NAMES_DEL))
+        continue;
+
     if (needs_space) {
        strcat(buf, " ");
       idx++;
@@ -181,7 +188,7 @@ void do_names(struct Client* sptr, struct Channel* chptr, int filter)
     if (mlen + idx + NICKLEN + 5 > BUFSIZE)
       /* space, modifier, nick, \r \n \0 */
     { 
-      send_reply(sptr, RPL_NAMREPLY, buf);
+      send_reply(sptr, (filter & NAMES_DEL) ? RPL_DELNAMREPLY : RPL_NAMREPLY, buf);
       strcpy(buf, "* ");
       ircd_strncpy(buf + 2, chptr->chname, len + 1);
       buf[len + 2] = 0;
@@ -196,7 +203,7 @@ void do_names(struct Client* sptr, struct Channel* chptr, int filter)
     }
   }
   if (flag)
-    send_reply(sptr, RPL_NAMREPLY, buf); 
+    send_reply(sptr, (filter & NAMES_DEL) ? RPL_DELNAMREPLY : RPL_NAMREPLY, buf); 
   if (filter&NAMES_EON)
     send_reply(sptr, RPL_ENDOFNAMES, chptr->chname);
 }
@@ -216,9 +223,15 @@ int m_names(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   struct Membership* member; 
   char* s;
   char* para = parc > 1 ? parv[1] : 0; 
-
-  if (parc > 2 && hunt_server_cmd(sptr, CMD_NAMES, cptr, 1, "%s %C", 2, parc, parv))
-    return 0; 
+  int showingdelayed = 0;
+
+  if (parc > 1 && !ircd_strcmp(parv[1], "-D")) {
+    para = (parc > 2) ? parv[2] : 0;
+    showingdelayed = 1;
+    if (parc > 3 && hunt_server_cmd(sptr, CMD_NAMES, cptr, 1, "%s %s %C", 3, parc, parv))
+      return 0;
+  } else if (parc > 2 && hunt_server_cmd(sptr, CMD_NAMES, cptr, 1, "%s %C", 2, parc, parv))
+    return 0;
 
   if (EmptyString(para)) {
     send_reply(sptr, RPL_ENDOFNAMES, "*");
@@ -227,9 +240,10 @@ int m_names(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   else if (*para == '0')
     *para = '\0';
   
-  s = strchr(para, ','); /* Recursively call m_names for each comma-seperated channel. Eww. */
+  s = strchr(para, ','); /* Recursively call m_names for each comma-separated channel. Eww. */
   if (s) {
-    parv[1] = ++s;
+    *s++ = '\0';
+    parv[1+showingdelayed] = s;
     m_names(cptr, sptr, parc, parv);
   }
  
@@ -256,9 +270,9 @@ int m_names(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 
       if (find_channel_member(sptr, ch2ptr))
       {
-        do_names(sptr, ch2ptr, NAMES_ALL); /* Full list if we're in this chan. */
+        do_names(sptr, ch2ptr, (showingdelayed?NAMES_DEL:0)|NAMES_ALL); /* Full list if we're in this chan. */
       } else { 
-        do_names(sptr, ch2ptr, NAMES_VIS);
+        do_names(sptr, ch2ptr, (showingdelayed?NAMES_DEL:0)|NAMES_VIS);
       }
     } 
 
@@ -314,14 +328,13 @@ int m_names(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
    *  (As performed with each /join) - ** High frequency usage **
    */
 
-  clean_channelname(para);
   chptr = FindChannel(para); 
 
   if (chptr) {
     member = find_member_link(chptr, sptr);
     if (member)
     { 
-      do_names(sptr, chptr, NAMES_ALL);
+      do_names(sptr, chptr, (showingdelayed?NAMES_DEL:0)|NAMES_ALL);
       if (!EmptyString(para))
       {
         send_reply(sptr, RPL_ENDOFNAMES, chptr ? chptr->chname : para);
@@ -334,7 +347,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, NAMES_VIS);
+      do_names(sptr, chptr, (showingdelayed?NAMES_DEL:0)|NAMES_VIS);
       send_reply(sptr, RPL_ENDOFNAMES, para);
     } 
   } else { /* Channel doesn't exist. */ 
@@ -358,9 +371,15 @@ int ms_names(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   struct Membership* member; 
   char* s;
   char* para = parc > 1 ? parv[1] : 0; 
-
-  if (parc > 2 && hunt_server_cmd(sptr, CMD_NAMES, cptr, 1, "%s %C", 2, parc, parv))
-    return 0; 
+  int showingdelayed = 0;
+
+  if (parc > 1 && !ircd_strcmp(parv[1], "-D")) {
+    para = (parc > 2) ? parv[2] : 0;
+    showingdelayed = NAMES_DEL;
+    if (parc > 3 && hunt_server_cmd(sptr, CMD_NAMES, cptr, 1, "%s %s %C", 3, parc, parv))
+      return 0;
+  } else if (parc > 2 && hunt_server_cmd(sptr, CMD_NAMES, cptr, 1, "%s %C", 2, parc, parv))
+    return 0;
 
   if (EmptyString(para)) {
     send_reply(sptr, RPL_ENDOFNAMES, "*");
@@ -369,9 +388,10 @@ int ms_names(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   else if (*para == '0')
     *para = '\0';
   
-  s = strchr(para, ','); /* Recursively call m_names for each comma-seperated channel. */
+  s = strchr(para, ','); /* Recursively call m_names for each comma-separated channel. */
   if (s) {
-    parv[1] = ++s;
+    *s++ = '\0';
+    parv[1+!!showingdelayed] = s;
     m_names(cptr, sptr, parc, parv);
   }
  
@@ -398,9 +418,9 @@ int ms_names(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 
       if (find_channel_member(sptr, ch2ptr))
       {
-        do_names(sptr, ch2ptr, NAMES_ALL); /* Full list if we're in this chan. */
+        do_names(sptr, ch2ptr, showingdelayed|NAMES_ALL); /* Full list if we're in this chan. */
       } else { 
-        do_names(sptr, ch2ptr, NAMES_VIS);
+        do_names(sptr, ch2ptr, showingdelayed|NAMES_VIS);
       }
     } 
  
@@ -456,14 +476,13 @@ int ms_names(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
    *  (As performed with each /join) - ** High frequency usage **
    */
 
-  clean_channelname(para);
   chptr = FindChannel(para); 
 
   if (chptr) {
     member = find_member_link(chptr, sptr);
     if (member)
     { 
-      do_names(sptr, chptr, NAMES_ALL);
+      do_names(sptr, chptr, showingdelayed|NAMES_ALL);
       if (!EmptyString(para))
       {
         send_reply(sptr, RPL_ENDOFNAMES, chptr ? chptr->chname : para);
@@ -476,7 +495,7 @@ int ms_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, NAMES_VIS);
+      do_names(sptr, chptr, showingdelayed|NAMES_VIS);
     } 
   } else { /* Channel doesn't exist. */ 
       send_reply(sptr, RPL_ENDOFNAMES, para);