From 5b36aeeb92d550051dbe5740917cfc9788c3ee81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Wed, 23 Feb 2005 17:57:15 +0000 Subject: [PATCH] remove dependency on asprintf git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14589 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/des/ui.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/des/ui.c b/lib/des/ui.c index 1bf8f2686..b79994bdb 100644 --- a/lib/des/ui.c +++ b/lib/des/ui.c @@ -53,7 +53,8 @@ intr(int sig) } static int -read_string(const char *prompt, char *buf, size_t len, int echo) +read_string(const char *preprompt, const char *prompt, + char *buf, size_t len, int echo) { struct sigaction sigs[47]; struct sigaction sa; @@ -76,7 +77,7 @@ read_string(const char *prompt, char *buf, size_t len, int echo) if((tty = fopen("/dev/tty", "r")) == NULL) tty = stdin; - fprintf(stderr, "%s", prompt); + fprintf(stderr, "%s%s", preprompt, prompt); fflush(stderr); if(echo == 0){ @@ -127,24 +128,20 @@ read_string(const char *prompt, char *buf, size_t len, int echo) int UI_UTIL_read_pw_string(char *buf, int length, char *prompt, int verify) { + size_t plen; int ret; - ret = read_string(prompt, buf, length, 0); + ret = read_string("", prompt, buf, length, 0); if (ret) return ret; if (verify) { - char *prompt2, *buf2; + char *buf2; buf2 = malloc(length); if (buf2 == NULL) return 1; - asprintf(&prompt2, "Verify password - %s", prompt2); - if (prompt2 == NULL) { - free(buf2); - return 1; - } - ret = read_string(prompt2, buf2, length, 0); - free(prompt2); + + ret = read_string("Verify password - ", prompt, buf2, length, 0); if (ret) { free(buf2); return ret;