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.c59
1 files changed, 26 insertions, 33 deletions
diff --git a/mdk-stage1/stdio-frontend.c b/mdk-stage1/stdio-frontend.c
index 5b37eafcd..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.
@@ -27,12 +27,15 @@
#include <sys/ioctl.h>
#include <termios.h>
-#include "frontend.h"
+#include <probing.h>
+#include "frontend.h"
+#include "utils.h"
void init_frontend(char * welcome_msg)
{
printf(welcome_msg);
+ printf("\n");
}
@@ -50,11 +53,12 @@ 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];
- int j = 0, i = 0; /* (0) tied to Cancel */
+ int j = 0;
+ unsigned int i = 0; /* (0) tied to Cancel */
fflush(stdout);
read(0, &(s[i++]), 1);
fcntl(0, F_SETFL, O_NONBLOCK);
@@ -72,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;
@@ -85,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;
@@ -104,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;
}
@@ -127,7 +129,7 @@ static char * get_string_response(char * initial_string)
b_index = 0;
continue;
}
-
+
if (b == 13)
break;
if (b == 127) {
@@ -142,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);
@@ -196,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;
@@ -211,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)
@@ -222,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) {
@@ -244,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);
@@ -277,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++;
@@ -292,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;
}
@@ -300,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;
@@ -322,7 +311,7 @@ enum return_type ask_yes_no(char *msg)
}
-enum return_type ask_from_entries(char *msg, char ** questions, char *** answers, int entry_size, void (*callback_func)(char ** strings))
+enum return_type ask_from_entries(char *msg, char ** questions, char *** answers, int entry_size UNUSED, void (*callback_func)(char ** strings) UNUSED)
{
int j, i = 0;
char ** already_answers = NULL;
@@ -336,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;
@@ -359,3 +348,7 @@ enum return_type ask_from_entries(char *msg, char ** questions, char *** answers
return RETURN_OK;
}
}
+
+
+void suspend_to_console(void) {}
+void resume_from_suspend(void) {}