summaryrefslogtreecommitdiffstats
path: root/mux.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2010-04-14 15:08:12 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2010-04-14 15:29:09 +0200
commitf7e35c5989fc5090e343d041003fa7770da8997e (patch)
tree86508bb636905e8e226abce026abceb841ffeb19 /mux.c
parent54c5725681d406360f5b580c7893c0d9f147ed7c (diff)
downloadmicrocom-f7e35c5989fc5090e343d041003fa7770da8997e.tar.gz
microcom-f7e35c5989fc5090e343d041003fa7770da8997e.tar.xz
implement a cli for microcom
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'mux.c')
-rw-r--r--mux.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/mux.c b/mux.c
index be34078..b469479 100644
--- a/mux.c
+++ b/mux.c
@@ -182,6 +182,32 @@ static int handle_command(unsigned char *buf, int len)
return len;
}
+/* handle escape characters, writing to output */
+static void cook_buf(struct ios_ops *ios, unsigned char *buf, int num)
+{
+ int current = 0;
+
+ while (current < num) { /* big while loop, to process all the charactes in buffer */
+
+ /* look for the next escape character '~' */
+ while ((current < num) && (buf[current] != 28))
+ current++;
+ /* and write the sequence befor esc char to the comm port */
+ if (current)
+ write(ios->fd, buf, current);
+
+ if (current < num) { /* process an escape sequence */
+ /* found an escape character */
+ do_commandline();
+ return;
+ } /* if - end of processing escape sequence */
+ num -= current;
+ buf += current;
+ current = 0;
+ } /* while - end of processing all the charactes in the buffer */
+ return;
+}
+
/* main program loop */
void mux_loop(struct ios_ops *ios)
{