X-Git-Url: https://git.librecmc.org/?p=oweals%2Fopkg-lede.git;a=blobdiff_plain;f=libopkg%2Fuser.c;h=8c960dc8bcdd5207694f5404b713bac2f5c9f7be;hp=04dfd9e157a5251f3c1e4e462a6dafdf1e5ad649;hb=a03d7bafd2ada5d8d8d67388a450362d7e427258;hpb=fe5e98ee4104f8d192a0107e0e7bb3fddd582dbe diff --git a/libopkg/user.c b/libopkg/user.c index 04dfd9e..8c960dc 100644 --- a/libopkg/user.c +++ b/libopkg/user.c @@ -23,30 +23,21 @@ #include "str_util.h" #include "user.h" -static char *question = NULL; -static int question_len = 255; - -opkg_response_callback opkg_cb_response = NULL; - char *get_user_response(const char *format, ...) { - int len = question_len; - va_list ap; - char *response; - - do { - if (question == NULL || len > question_len) { - question = realloc(question, len + 1); - question_len = len; - } - - va_start(ap, format); - len = vsnprintf(question,question_len,format,ap); - va_end(ap); - } while (len > question_len); - response = strdup(opkg_cb_response(question)); - str_chomp(response); - str_tolower(response); - - return response; + va_list ap; + char *response; + + va_start(ap, format); + vprintf(format, ap); + va_end(ap); + + response = (char *)file_read_line_alloc(stdin); + if (response == NULL) + return NULL; + + str_chomp(response); + str_tolower(response); + + return response; }