changeset 905:841982f31be3

lcdemu: got to input lines
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 07 Sep 2015 08:51:02 +0000
parents e54abee27e8f
children 69623c4cbf6c
files lcdemu/process.c
diffstat 1 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lcdemu/process.c	Mon Sep 07 08:43:30 2015 +0000
+++ b/lcdemu/process.c	Mon Sep 07 08:51:02 2015 +0000
@@ -15,5 +15,25 @@
 input_on_stdin(inbuf, incount)
 	char *inbuf;
 {
-	/* to be implemented */
+	char *input_end = inbuf + incount;
+	static char linebuf[1024];
+	static int linesz;
+	char *cp;
+
+	for (cp = inbuf; cp < input_end; cp++) {
+		if (*cp == '\n') {
+			linebuf[linesz] = '\0';
+			process_input_line(linebuf);
+			linesz = 0;
+			continue;
+		}
+		if (linesz < sizeof(linebuf) - 1)
+			linebuf[linesz++] = *cp;
+	}
 }
+
+process_input_line(line)
+	char *line;
+{
+	printf("Got input line: %s\n", line);
+}