]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - modules/m_links.c
burst_TS6(): assume users have a UID
[irc/rqf/shadowircd.git] / modules / m_links.c
index f68d19a7aa49ce1029890b74f28f4586fd9542c0..e4a0f881142b8bedd2f8b59992bcce4ec476cbfe 100644 (file)
@@ -26,7 +26,7 @@
 
 #include "stdinc.h"
 #include "client.h"
-#include "irc_string.h"
+#include "match.h"
 #include "ircd.h"
 #include "numeric.h"
 #include "s_serv.h"
@@ -40,6 +40,7 @@
 
 static int m_links(struct Client *, struct Client *, int, const char **);
 static int mo_links(struct Client *, struct Client *, int, const char **);
+static char * clean_string(char *dest, const unsigned char *src, size_t len);
 
 struct Message links_msgtab = {
        "LINKS", 0, 0, 0, MFLG_SLOW,
@@ -129,3 +130,36 @@ mo_links(struct Client *client_p, struct Client *source_p, int parc, const char
        return 0;
 }
 
+static char *
+clean_string(char *dest, const unsigned char *src, size_t len)
+{
+       char *d = dest;
+       s_assert(0 != dest);
+       s_assert(0 != src);
+
+       if(dest == NULL || src == NULL)
+               return NULL;
+
+       len -= 3;               /* allow for worst case, '^A\0' */
+
+       while (*src && (len > 0))
+       {
+               if(*src & 0x80) /* if high bit is set */
+               {
+                       *d++ = '.';
+                       --len;
+               }
+               else if(!IsPrint(*src)) /* if NOT printable */
+               {
+                       *d++ = '^';
+                       --len;
+                       *d++ = 0x40 + *src;     /* turn it into a printable */
+               }
+               else
+                       *d++ = *src;
+               ++src;
+               --len;
+       }
+       *d = '\0';
+       return dest;
+}