From d36ee8f0b67776cfbbbbe62f07d837c34dd20199 Mon Sep 17 00:00:00 2001 From: Love Hornquist Astrand Date: Sat, 27 Nov 2010 19:51:26 -0800 Subject: [PATCH] add readline alternative --- kuser/kswitch.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/kuser/kswitch.c b/kuser/kswitch.c index 45305f07f..c6915f7bd 100644 --- a/kuser/kswitch.c +++ b/kuser/kswitch.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008 Kungliga Tekniska Högskolan + * Copyright (c) 2008 - 2010 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -36,6 +36,20 @@ #ifdef HAVE_READLINE char *readline(char *prompt); +#else + +static char * +readline(char *prompt) +{ + char buf[BUFSIZ]; + printf ("%s", prompt); + fflush (stdout); + if(fgets(buf, sizeof(buf), stdin) == NULL) + return NULL; + buf[strcspn(buf, "\r\n")] = '\0'; + return strdup(buf); +} + #endif /*