From 427f95f87939e62b9903453a6b38b7f11c11d4c8 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 29 Jun 2009 14:58:07 -0400 Subject: [PATCH] logsave: Don't send the ^A and ^B delimiters to the console Some terminal programs may print wierd characters when they see the \001 or \002 characters. So filter them out if the -s option (skip_mode) is enabled. Signed-off-by: "Theodore Ts'o" --- misc/logsave.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/misc/logsave.c b/misc/logsave.c index 81ac9f6..43eb6f7 100644 --- a/misc/logsave.c +++ b/misc/logsave.c @@ -74,13 +74,32 @@ static int write_all(int fd, const char *buf, size_t count) static void send_output(const char *buffer, int c, int flag) { - char *n; + const char *cp; + char *n; + int cnt, d, del; if (c == 0) c = strlen(buffer); - if (flag & SEND_CONSOLE) - write_all(1, buffer, c); + if (flag & SEND_CONSOLE) { + cnt = c; + cp = buffer; + while (cnt) { + del = 0; + for (d=0; d < cnt; d++) { + if (skip_mode && + (cp[d] == '\001' || cp[d] == '\002')) { + del = 1; + break; + } + } + write_all(1, cp, d); + if (del) + d++; + cnt -= d; + cp += d; + } + } if (!(flag & SEND_LOG)) return; if (outfd > 0) -- 1.8.3.1