aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-12-30 20:13:39 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-12-30 20:13:39 +0000
commit27963980dbe1262fd6c447fc7d06839aea0861bc (patch)
treecf04b9d237cb1c9dc47c76919342d25a11e815c0
parentd3c042fc605737643c265a7f86fc7a77c88f629e (diff)
downloadbusybox-w32-27963980dbe1262fd6c447fc7d06839aea0861bc.tar.gz
busybox-w32-27963980dbe1262fd6c447fc7d06839aea0861bc.tar.bz2
busybox-w32-27963980dbe1262fd6c447fc7d06839aea0861bc.zip
adding libbb/printable.c
-rw-r--r--libbb/printable.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/libbb/printable.c b/libbb/printable.c
new file mode 100644
index 000000000..2420a91f0
--- /dev/null
+++ b/libbb/printable.c
@@ -0,0 +1,34 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Utility routines.
4 *
5 * Copyright (C) 2007 Denis Vlasenko
6 *
7 * Licensed under GPL version 2, see file LICENSE in this tarball for details.
8 */
9
10#include "libbb.h"
11
12void fputc_printable(int ch, FILE *file)
13{
14 if ((ch & (0x80 + PRINTABLE_META)) == (0x80 + PRINTABLE_META)) {
15 fputs("M-", file);
16 ch &= 0x7f;
17 }
18 ch = (unsigned char) ch;
19 if (ch == 0x9b) {
20 /* VT100's CSI, aka Meta-ESC, is not printable on vt-100 */
21 ch = '{';
22 goto print_caret;
23 }
24 if (ch < ' ') {
25 ch += '@';
26 goto print_caret;
27 }
28 if (ch == 0x7f) {
29 ch = '?';
30 print_caret:
31 fputc('^', file);
32 }
33 fputc(ch, file);
34}