|
|
27390d |
From 2886582f6e48258d7b8c941725a4456ed62578e9 Mon Sep 17 00:00:00 2001
|
|
|
27390d |
From: Jakub Filak <jfilak@redhat.com>
|
|
|
27390d |
Date: Tue, 28 Jan 2014 16:58:04 +0100
|
|
|
27390d |
Subject: [LIBREPORT PATCH 16/17] report-cli: use the Client API for
|
|
|
27390d |
communication to user
|
|
|
27390d |
|
|
|
27390d |
Closes rhbz#1058845
|
|
|
27390d |
|
|
|
27390d |
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
|
|
27390d |
---
|
|
|
27390d |
src/cli/cli-report.c | 30 ++++--------------------------
|
|
|
27390d |
1 file changed, 4 insertions(+), 26 deletions(-)
|
|
|
27390d |
|
|
|
27390d |
diff --git a/src/cli/cli-report.c b/src/cli/cli-report.c
|
|
|
27390d |
index 5b32fbc..68baa8b 100644
|
|
|
27390d |
--- a/src/cli/cli-report.c
|
|
|
27390d |
+++ b/src/cli/cli-report.c
|
|
|
27390d |
@@ -408,26 +408,6 @@ static int run_report_editor(problem_data_t *problem_data)
|
|
|
27390d |
}
|
|
|
27390d |
|
|
|
27390d |
/**
|
|
|
27390d |
- * Asks user for a text response.
|
|
|
27390d |
- * @param question
|
|
|
27390d |
- * Question displayed to user.
|
|
|
27390d |
- * @param result
|
|
|
27390d |
- * Output array.
|
|
|
27390d |
- * @param result_size
|
|
|
27390d |
- * Maximum byte count to be written.
|
|
|
27390d |
- */
|
|
|
27390d |
-static void read_from_stdin(const char *question, char *result, int result_size)
|
|
|
27390d |
-{
|
|
|
27390d |
- assert(result_size > 1);
|
|
|
27390d |
- printf("%s", question);
|
|
|
27390d |
- fflush(NULL);
|
|
|
27390d |
- if (NULL == fgets(result, result_size, stdin))
|
|
|
27390d |
- result[0] = '\0';
|
|
|
27390d |
- // Remove the trailing newline
|
|
|
27390d |
- strchrnul(result, '\n')[0] = '\0';
|
|
|
27390d |
-}
|
|
|
27390d |
-
|
|
|
27390d |
-/**
|
|
|
27390d |
* Asks user for missing information
|
|
|
27390d |
*/
|
|
|
27390d |
static void ask_for_missing_settings(const char *event_name)
|
|
|
27390d |
@@ -731,17 +711,15 @@ static int choose_number_from_range(unsigned min, unsigned max, const char *mess
|
|
|
27390d |
unsigned ii;
|
|
|
27390d |
for (ii = 0; ii < 3; ++ii)
|
|
|
27390d |
{
|
|
|
27390d |
- char answer[16];
|
|
|
27390d |
-
|
|
|
27390d |
- read_from_stdin(message, answer, sizeof(answer));
|
|
|
27390d |
- if (!*answer)
|
|
|
27390d |
- continue;
|
|
|
27390d |
+ char *answer = ask(message);
|
|
|
27390d |
|
|
|
27390d |
picked = xatou(answer);
|
|
|
27390d |
if (min <= picked && picked <= max)
|
|
|
27390d |
return picked;
|
|
|
27390d |
|
|
|
27390d |
- printf("%s (%u - %u)\n", _("You have chosen number out of range"), min, max);
|
|
|
27390d |
+ char *msg = xasprintf("%s (%u - %u)\n", _("You have chosen number out of range"), min, max);
|
|
|
27390d |
+ alert(msg);
|
|
|
27390d |
+ free(msg);
|
|
|
27390d |
}
|
|
|
27390d |
|
|
|
27390d |
error_msg_and_die(_("Invalid input, exiting."));
|
|
|
27390d |
--
|
|
|
27390d |
1.8.3.1
|
|
|
27390d |
|