aboutsummaryrefslogtreecommitdiffstats
path: root/com32/elflink/ldlinux/cli.c
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2011-11-25 16:22:44 +0000
committerMatt Fleming <matt.fleming@intel.com>2011-12-02 12:13:31 +0000
commit1e4789d4bd9db075929b03015826e4996cb0a37a (patch)
treea283a88884af791d8e294b4d658b503d4732ec07 /com32/elflink/ldlinux/cli.c
parent086d698c642f0b8901757a40cef56b04d05bf19c (diff)
downloadsyslinux-1e4789d4bd9db075929b03015826e4996cb0a37a.tar.gz
syslinux-1e4789d4bd9db075929b03015826e4996cb0a37a.tar.xz
syslinux-1e4789d4bd9db075929b03015826e4996cb0a37a.zip
ldlinux: Accept commands from the serial console
To mimic the old (pre-elflink) command-line interface behaviour let's use getchar() instead of reading from stdin. This way, if the user types a command on the serial console it will actually be executed. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Diffstat (limited to 'com32/elflink/ldlinux/cli.c')
-rw-r--r--com32/elflink/ldlinux/cli.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/com32/elflink/ldlinux/cli.c b/com32/elflink/ldlinux/cli.c
index 1ed3ea63..7b2da880 100644
--- a/com32/elflink/ldlinux/cli.c
+++ b/com32/elflink/ldlinux/cli.c
@@ -29,6 +29,31 @@ void clear_screen(void)
fputs("\033e\033%@\033)0\033(B\1#0\033[?25l\033[2J", stdout);
}
+static int __get_key(void)
+{
+ unsigned char buffer[KEY_MAXLEN];
+ int another;
+ int nc, rv;
+ int code;
+
+ nc = 0;
+ do {
+ buffer[nc++] = getchar();
+
+ another = 0;
+ rv = get_key_decode(buffer, nc, &code);
+ if (!rv)
+ return code;
+ else if (rv == 1)
+ another = 1;
+
+ } while (another);
+
+ /* We got an unrecognized sequence; return the first character */
+ /* We really should remember this and return subsequent characters later */
+ return buffer[0];
+}
+
int mygetkey(clock_t timeout)
{
clock_t t0, t;
@@ -37,14 +62,14 @@ int mygetkey(clock_t timeout)
//dprintf("enter");
if (!totaltimeout)
- return get_key(stdin, timeout);
+ return __get_key();
for (;;) {
tto = min(totaltimeout, INT_MAX);
to = timeout ? min(tto, timeout) : tto;
t0 = 0;
- key = get_key(stdin, to);
+ key = __get_key();
t = 0 - t0;
if (totaltimeout <= t)