diff options
Diffstat (limited to 'mdk-stage1/stdio-frontend.c')
| -rw-r--r-- | mdk-stage1/stdio-frontend.c | 59 | 
1 files changed, 19 insertions, 40 deletions
| diff --git a/mdk-stage1/stdio-frontend.c b/mdk-stage1/stdio-frontend.c index 3fbed999a..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,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); @@ -75,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; @@ -88,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; @@ -107,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;  				} @@ -130,7 +129,7 @@ static char * get_string_response(char * initial_string)  				b_index = 0;  				continue;  			} -				 +  			if (b == 13)  				break;  			if (b == 127) { @@ -145,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); @@ -199,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; @@ -214,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) @@ -225,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) { @@ -247,20 +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; -	probe_that_type(USB_CONTROLLERS, BUS_USB); // we'd need the keyboard for interactions so... - -	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); @@ -282,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++; @@ -297,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;  	} @@ -305,19 +295,10 @@ 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) -{ -	probe_that_type(USB_CONTROLLERS, BUS_USB); // we'd need the keyboard for interactions so... -	return ask_from_list_comments(msg, elems, NULL, choice); -} - -  enum return_type ask_yes_no(char *msg)  {  	int j; -	probe_that_type(USB_CONTROLLERS, BUS_USB); // we'd need the keyboard for interactions so... -  	printf("> %s\n[0] Yes  [1] No  [2] Back\n? ", msg);  	j = get_int_response(); @@ -330,13 +311,11 @@ 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; -	probe_that_type(USB_CONTROLLERS, BUS_USB); // we'd need the keyboard for interactions so... -  	printf("> %s\n", msg);  	while (questions && *questions) { @@ -346,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; | 
