Author: Alex Badea <vampire@p16.pub.ro> (by way of Kev <klmitch@mit.edu>)
[ircu2.10.12-pk.git] / ircd / whocmds.c
index 39a9bc7507a0b1a1e0e1a5b81612db39ab55d83b..fa8def4b5be396fc45af8c3d7f2529d9c7bc837d 100644 (file)
@@ -45,7 +45,6 @@
 #include "s_misc.h"
 #include "s_user.h"
 #include "send.h"
-#include "sprintf_irc.h"
 #include "struct.h"
 #include "support.h"
 #include "sys.h"
@@ -123,7 +122,9 @@ void do_who(struct Client* sptr, struct Client* acptr, struct Channel* repchan,
 
   if (fields & WHO_FIELD_NIP)
   {
-    const char* p2 = ircd_ntoa((const char*) &(cli_ip(acptr)));
+    const char* p2 = HasHiddenHost(acptr) && !IsAnOper(sptr) ?
+      feature_str(FEAT_HIDDEN_IP) :
+      ircd_ntoa((const char*) &(cli_ip(acptr)));
     *(p1++) = ' ';
     while ((*p2) && (*(p1++) = *(p2++)));
   }
@@ -137,7 +138,15 @@ void do_who(struct Client* sptr, struct Client* acptr, struct Channel* repchan,
 
   if (!fields || (fields & WHO_FIELD_SER))
   {
-    char *p2 = cli_name(cli_user(acptr)->server);
+    char *p2;
+#ifdef HEAD_IN_SAND_WHO_SERVERNAME
+    if (IsAnOper(sptr))
+#endif
+      p2 = cli_name(cli_user(acptr)->server);
+#ifdef HEAD_IN_SAND_WHO_SERVERNAME
+    else
+      p2 = HEAD_IN_SAND_SERVERNAME;
+#endif
     *(p1++) = ' ';
     while ((*p2) && (*(p1++) = *(p2++)));
   }
@@ -190,6 +199,8 @@ void do_who(struct Client* sptr, struct Client* acptr, struct Channel* repchan,
       if (SendDebug(acptr))
         *(p1++) = 'g';
     }
+    if (HasHiddenHost(acptr))
+      *(p1++) = 'x';
   }
 
   if (!fields || (fields & WHO_FIELD_DIS))
@@ -198,10 +209,10 @@ void do_who(struct Client* sptr, struct Client* acptr, struct Channel* repchan,
     if (!fields)
       *p1++ = ':';              /* Place colon here for default reply */
 #ifdef HEAD_IN_SAND_WHO_HOPCOUNT
-    strcat(p1, sptr == acptr ? "0" : "3");
-    p1++;
+    *p1++ = (sptr == acptr) ? '0' : '3';
 #else
-    p1 = sprintf_irc(p1, "%d", cli_hopcount(acptr));
+    /* three digit hopcount maximum */
+    p1 += ircd_snprintf(0, p1, 3, "%d", cli_hopcount(acptr));
 #endif
   }
 
@@ -209,7 +220,8 @@ void do_who(struct Client* sptr, struct Client* acptr, struct Channel* repchan,
   {
     *p1++ = ' ';
     if (MyUser(acptr)) {
-           p1 = sprintf_irc(p1, "%d", CurrentTime - cli_user(acptr)->last);
+           p1 += ircd_snprintf(0, p1, 11, "%d",
+                               CurrentTime - cli_user(acptr)->last);
     }    
     else {
            *p1++ = '0';