aboutsummaryrefslogtreecommitdiffstats
path: root/com32/libutil
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2012-10-31 15:55:02 +0000
committerMatt Fleming <matt.fleming@intel.com>2012-11-02 14:06:18 +0000
commit7cb503fd746b80c8613a3e76dde93aedb6e75830 (patch)
treeebd1d5e082729d25c2b3d603b7bb8336cecfbc28 /com32/libutil
parent06f042df3c483c442f1150b862ef043711288f5e (diff)
downloadsyslinux-7cb503fd746b80c8613a3e76dde93aedb6e75830.tar.gz
syslinux-7cb503fd746b80c8613a3e76dde93aedb6e75830.tar.xz
syslinux-7cb503fd746b80c8613a3e76dde93aedb6e75830.zip
ldlinux: get_key() requires raw access to user input
commit 4503e6260c0 ("ldlinux: Use stdcon instead of rawcon for the console") broke get_key() because it was no longer possible to read raw data from stdin. Provide a new function raw_read() that will return user input a character at a time. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Diffstat (limited to 'com32/libutil')
-rw-r--r--com32/libutil/ansiraw.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/com32/libutil/ansiraw.c b/com32/libutil/ansiraw.c
index 2afd48a7..b67768c5 100644
--- a/com32/libutil/ansiraw.c
+++ b/com32/libutil/ansiraw.c
@@ -47,6 +47,7 @@ void console_ansi_raw(void)
#include <stdio.h>
#include <termios.h>
+#include <unistd.h>
static struct termios original_termios_settings;
@@ -82,4 +83,22 @@ void console_ansi_raw(void)
tcsetattr(0, TCSAFLUSH, &tio);
}
+int raw_read(int fd, void *buf, size_t count)
+{
+ struct termios tio, rtio;
+ int rv;
+
+ tcgetattr(fd, &tio);
+
+ cfmakeraw(&rtio);
+ tcsetattr(fd, 0, &rtio);
+
+ rv = read(fd, buf, count);
+
+ /* Restore settings */
+ tcsetattr(fd, 0, &tio);
+
+ return rv;
+}
+
#endif