summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/stdio-frontend.c
diff options
context:
space:
mode:
Diffstat (limited to 'mdk-stage1/stdio-frontend.c')
-rw-r--r--mdk-stage1/stdio-frontend.c47
1 files changed, 16 insertions, 31 deletions
diff --git a/mdk-stage1/stdio-frontend.c b/mdk-stage1/stdio-frontend.c
index fa6bb7358..8c09330b5 100644
--- a/mdk-stage1/stdio-frontend.c
+++ b/mdk-stage1/stdio-frontend.c
@@ -1,7 +1,7 @@
/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
+ * Guillaume Cottenceau (gc)
*
- * Copyright 2000 Mandrakesoft
+ * Copyright 2000 Mandriva
*
* This software may be freely redistributed under the terms of the GNU
* public license.
@@ -30,7 +30,7 @@
#include <probing.h>
#include "frontend.h"
-
+#include "utils.h"
void init_frontend(char * welcome_msg)
{
@@ -53,7 +53,7 @@ static void get_any_response(void)
while (read(0, &t, 1) > 0);
fcntl(0, F_SETFL, 0);
}
-
+
static int get_int_response(void)
{
char s[50];
@@ -76,7 +76,6 @@ static char * get_string_response(char * initial_string)
/* I won't use a scanf/%s since I also want the null string to be accepted -- also, I want the initial_string */
char s[500];
int i = 0;
- char buf[10];
int b_index = 0;
char b;
@@ -89,7 +88,7 @@ static char * get_string_response(char * initial_string)
strcpy(s, initial_string);
i = strlen(s);
}
-
+
/* from ncurses/tinfo/lib_raw.c:(cbreak) */
tcgetattr(0, &t);
t.c_lflag &= ~ICANON;
@@ -108,7 +107,6 @@ static char * get_string_response(char * initial_string)
if (read(0, &b, 1) > 0) {
if (b_index == 1) {
if (b == 91) {
- buf[b_index] = b;
b_index++;
continue;
}
@@ -131,7 +129,7 @@ static char * get_string_response(char * initial_string)
b_index = 0;
continue;
}
-
+
if (b == 13)
break;
if (b == 127) {
@@ -146,7 +144,6 @@ static char * get_string_response(char * initial_string)
i--;
}
} else if (b == 27) {
- buf[b_index] = b;
b_index++;
} else {
printf("%c", b);
@@ -200,7 +197,7 @@ void remove_wait_message(void)
static int size_progress;
static int actually_drawn;
#define PROGRESS_SIZE 45
-void init_progression(char *msg, int size)
+void init_progression_raw(char *msg, int size)
{
int i;
size_progress = size;
@@ -215,7 +212,7 @@ void init_progression(char *msg, int size)
printf("\n");
}
-void update_progression(int current_size)
+void update_progression_raw(int current_size)
{
if (size_progress) {
if (current_size > size_progress)
@@ -226,21 +223,21 @@ void update_progression(int current_size)
}
} else
printf("\033[GStatus: [%8d] bytes loaded...", current_size);
-
+
fflush(stdout);
}
-void end_progression(void)
+void end_progression_raw(void)
{
if (size_progress) {
- update_progression(size_progress);
+ update_progression_raw(size_progress);
printf("]\n");
} else
printf(" done.\n");
}
-enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_comments, char ** choice)
+enum return_type ask_from_list_index(char *msg, char ** elems, char ** elems_comments, int *answer)
{
int justify_number = 1;
void print_choice_number(int i) {
@@ -248,18 +245,12 @@ enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_
snprintf(tmp, sizeof(tmp), "[%%%dd]", justify_number);
printf(tmp, i);
}
- char ** sav_elems = elems;
int i = 1;
int j = 0;
- while (elems && *elems) {
- elems++;
- i++;
- }
- if (i >= 10)
+ if (string_array_length(elems) >= 10)
justify_number = 2;
- elems = sav_elems;
i = 1;
printf("> %s\n", msg);
@@ -281,7 +272,7 @@ enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_
}
if (j == 4)
j = 0;
-
+
if (elems_comments)
elems_comments++;
i++;
@@ -296,7 +287,7 @@ enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_
return RETURN_BACK;
if (j >= 1 && j <= i) {
- *choice = strdup(sav_elems[j-1]);
+ *answer = j - 1;
return RETURN_OK;
}
@@ -304,12 +295,6 @@ enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_
}
-enum return_type ask_from_list(char *msg, char ** elems, char ** choice)
-{
- return ask_from_list_comments(msg, elems, NULL, choice);
-}
-
-
enum return_type ask_yes_no(char *msg)
{
int j;
@@ -340,7 +325,7 @@ enum return_type ask_from_entries(char *msg, char ** questions, char *** answers
}
if (*answers == NULL)
- *answers = (char **) malloc(sizeof(char *) * i);
+ *answers = (char **) calloc(1, sizeof(char *) * i);
else
already_answers = *answers;