diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2009-04-29 22:25:20 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2009-04-29 22:25:20 +0000 |
commit | cc9cc1aea8694dec3067246d4483bb3c2860592e (patch) | |
tree | 852e36aecb8ebaae8b3b114b9abeecf61d5adfc3 /util.c | |
parent | 323b7cbfbea012ab9358b639c089012a84552bc6 (diff) | |
download | rtmux-cc9cc1aea8694dec3067246d4483bb3c2860592e.tar.gz rtmux-cc9cc1aea8694dec3067246d4483bb3c2860592e.tar.bz2 rtmux-cc9cc1aea8694dec3067246d4483bb3c2860592e.zip |
Some tweaks for Solaris.
Get rid of vis.* in favour of a small replacement function.
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -1,4 +1,4 @@ -/* $Id: util.c,v 1.1 2009-01-18 17:20:52 nicm Exp $ */ +/* $Id: util.c,v 1.2 2009-04-29 22:25:20 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -50,3 +50,23 @@ section_string(char *buf, size_t len, size_t sectoff, size_t sectlen) (int) (last - first), buf + first, last == len ? "" : "..."); return (s); } + +/* Clean string of invisible characters. */ +void +clean_string(const char *in, char *buf, size_t len) +{ + const u_char *cp; + size_t off; + + off = 0; + for (cp = in; *cp != '\0'; cp++) { + if (off >= len) + break; + if (*cp >= 0x20 && *cp <= 0x7f) + buf[off++] = *cp; + else + off += xsnprintf(buf + off, len - off, "\\%03hho", *cp); + } + if (off < len) + buf[off] = '\0'; +} |