From 0cc9b20c15460213e488bf5e70963b941482f628 Mon Sep 17 00:00:00 2001 From: William Harrington Date: Tue, 14 Jan 2025 16:06:02 -0600 Subject: Add source. --- sdk/dev/input.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 sdk/dev/input.c (limited to 'sdk/dev/input.c') diff --git a/sdk/dev/input.c b/sdk/dev/input.c new file mode 100644 index 0000000..95494d3 --- /dev/null +++ b/sdk/dev/input.c @@ -0,0 +1,34 @@ +/* + * Read a line of input from device. + * $Id$ + * Copyright (c) 1997 by Tycho Softworks. + * For conditions of distribution and reuse see product license. + */ + +#include +#include + +int input(int fd, uchar *buf, size_t len, int timeout, const uchar *term) +{ + int key; + int idx = 0; + + while(idx < len) + { + key = inkey(fd, timeout); + if(key < 0) + return idx; + + if(!key) + continue; + + buf[idx++] = (uchar)(key & 0xff); + if(strchr((char *)term, key)) + break; + } + buf[idx] = 0; + return idx; +} + + + -- cgit v1.2.3-54-g00ecf