# HG changeset patch # User Space Falcon # Date 1441615862 0 # Node ID 841982f31be344e00e7a44e4364dae3e4c693896 # Parent e54abee27e8f4fcf0dbd9be69958408002ad49a6 lcdemu: got to input lines diff -r e54abee27e8f -r 841982f31be3 lcdemu/process.c --- 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); +}