]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - include/inline/stringops.h
Fix multiple RPL_LISTEND replies when aborting a /LIST.
[irc/rqf/shadowircd.git] / include / inline / stringops.h
index 594109d2ecc7d0e1869f54d58f69a023d56bea2f..a2792c9dbf1003a9230357de4ffa86fbbd6b7207 100644 (file)
@@ -58,6 +58,7 @@ strip_colour(char *string)
                case 22:
                case 23:
                case 27:
+               case 29:
                case 31:
                        break;
                case 32:
@@ -77,4 +78,48 @@ strip_colour(char *string)
        return string;
 }
 
+static inline char *
+strip_unprintable(char *string)
+{
+       char *c = string;
+       char *c2 = string;
+       char *last_non_space = NULL;
+
+       /* c is source, c2 is target */
+       for(; c && *c; c++)
+               switch (*c)
+               {
+               case 3:
+                       if(isdigit(c[1]))
+                       {
+                               c++;
+                               if(isdigit(c[1]))
+                                       c++;
+                               if(c[1] == ',' && isdigit(c[2]))
+                               {
+                                       c += 2;
+                                       if(isdigit(c[1]))
+                                               c++;
+                               }
+                       }
+                       break;
+               case 32:
+                       *c2++ = *c;
+                       break;
+               default:
+                       if (*c < 32)
+                               break;
+                       *c2++ = *c;
+                       last_non_space = c2;
+                       break;
+               }
+
+       *c2 = '\0';
+
+       if(last_non_space)
+               *last_non_space = '\0';
+
+       return string;
+}
+
 #endif