diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-05-05 23:00:31 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-05-05 23:00:31 +0000 |
commit | 42bb6b27fd6d8645876e460a765eadef0a212ee7 (patch) | |
tree | 14b8ae6f2e25150215ed5f884fc6035d58834698 /main/asterisk.c | |
parent | 9933d27a31eae38164de54b250e6527444365e64 (diff) |
Merged revisions 115333 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r115333 | tilghman | 2008-05-05 17:50:31 -0500 (Mon, 05 May 2008) | 7 lines
Separate verbose output from CLI output, by using a preamble.
(closes issue #12402)
Reported by: Corydon76
Patches:
20080410__no_verbose_in_rx_output.diff.txt uploaded by Corydon76 (license 14)
20080501__no_verbose_in_rx_output__1.4.diff.txt uploaded by Corydon76 (license 14)
........
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@115334 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/asterisk.c')
-rw-r--r-- | main/asterisk.c | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/main/asterisk.c b/main/asterisk.c index 05a3230c6..8b1cc7460 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -1420,6 +1420,12 @@ static void __quit_handler(int num) static const char *fix_header(char *outbuf, int maxout, const char *s, char *cmp) { const char *c; + + /* Check for verboser preamble */ + if (*s == 127) { + s++; + } + if (!strncmp(s, cmp, strlen(cmp))) { c = s + strlen(cmp); term_color(outbuf, cmp, COLOR_GRAY, 0, maxout); @@ -1928,6 +1934,7 @@ static int ast_el_read_char(EditLine *el, char *cp) buf[res] = '\0'; + /* Write over the CLI prompt */ if (!ast_opt_exec && !lastpos) write(STDOUT_FILENO, "\r", 1); write(STDOUT_FILENO, buf, res); @@ -2425,13 +2432,38 @@ static void ast_remotecontrol(char * data) ast_el_read_history(filename); if (ast_opt_exec && data) { /* hack to print output then exit if asterisk -rx is used */ - char tempchar; struct pollfd fds; fds.fd = ast_consock; fds.events = POLLIN; fds.revents = 0; - while (poll(&fds, 1, 100) > 0) - ast_el_read_char(el, &tempchar); + while (poll(&fds, 1, 500) > 0) { + char buf[512] = "", *curline = buf, *nextline; + int not_written = 1; + + if (read(ast_consock, buf, sizeof(buf) - 1) < 0) { + break; + } + + do { + if ((nextline = strchr(curline, '\n'))) { + nextline++; + } else { + nextline = strchr(curline, '\0'); + } + + /* Skip verbose lines */ + if (*curline != 127) { + not_written = 0; + write(STDOUT_FILENO, curline, nextline - curline + (*nextline == '\0' ? 1 : 0)); + } + curline = nextline; + } while (!ast_strlen_zero(curline)); + + /* No non-verbose output in 500ms */ + if (not_written) { + break; + } + } return; } for (;;) { |