clean_string() is related to m_links.c ONLY - moved it there
This commit is contained in:
parent
4a2651e520
commit
e3b33fe3e6
3 changed files with 34 additions and 47 deletions
|
@ -77,12 +77,6 @@ extern int ircncmp(const char *s1, const char *s2, int n);
|
||||||
extern char *canonize(char *);
|
extern char *canonize(char *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
* clean_string - cleanup control and high ascii characters
|
|
||||||
* -Dianora
|
|
||||||
*/
|
|
||||||
char *clean_string(char *dest, const unsigned char *src, size_t len);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* strip_colour - remove colour codes from a string
|
* strip_colour - remove colour codes from a string
|
||||||
* -asuffield (?)
|
* -asuffield (?)
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
|
|
||||||
static int m_links(struct Client *, struct Client *, int, const char **);
|
static int m_links(struct Client *, struct Client *, int, const char **);
|
||||||
static int mo_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 = {
|
struct Message links_msgtab = {
|
||||||
"LINKS", 0, 0, 0, MFLG_SLOW,
|
"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;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -33,47 +33,6 @@
|
||||||
#define INT16SZ 2
|
#define INT16SZ 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
* clean_string - clean up a string possibly containing garbage
|
|
||||||
*
|
|
||||||
* *sigh* Before the kiddies find this new and exciting way of
|
|
||||||
* annoying opers, lets clean up what is sent to local opers
|
|
||||||
* -Dianora
|
|
||||||
*/
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* strip_tabs(dst, src, length)
|
* strip_tabs(dst, src, length)
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue