diff options
Diffstat (limited to 'mdk-stage1/newt-frontend.c')
| -rw-r--r-- | mdk-stage1/newt-frontend.c | 83 | 
1 files changed, 36 insertions, 47 deletions
| diff --git a/mdk-stage1/newt-frontend.c b/mdk-stage1/newt-frontend.c index 4bedda82b..c0489b58d 100644 --- a/mdk-stage1/newt-frontend.c +++ b/mdk-stage1/newt-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. @@ -24,6 +24,7 @@   * Each different frontend must implement all functions defined in frontend.h   */ +#define _GNU_SOURCE  #include <stdlib.h>  #include <unistd.h> @@ -31,7 +32,7 @@  #include <stdio.h>  #include <stdarg.h>  #include <sys/time.h> -#include "newt/newt.h" +#include <newt.h>  #include <probing.h> @@ -43,12 +44,16 @@ void init_frontend(char * welcome_msg)  	for (i=0; i<38; i++) printf("\n");  	newtInit();  	newtCls(); -	 -	newtDrawRootText(0, 0, welcome_msg); -	if (welcome_msg[0])  +	if (welcome_msg[0]) { +		char *msg; +		int cols, rows; +		newtGetScreenSize(&cols, &rows); +		asprintf(&msg, " %-*s", cols - 1, welcome_msg); +		newtDrawRootText(0, 0, msg); +		free(msg);  		newtPushHelpLine(" <Alt-F1> for here, <Alt-F3> to see the logs, <Alt-F4> for kernel msg"); - +	}  	newtRefresh();  } @@ -172,55 +177,39 @@ void end_progression_raw(void)  } -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)  { -	char * items[500]; -	int answer = 0, rc; -	char ** sav_elems = elems; -	int i; +	char * items[50000]; +	int rc; -	i = 0; -	while (elems && *elems) { -		int j = (*elems_comments) ? strlen(*elems_comments) : 0; -		items[i] = malloc(sizeof(char) * (strlen(*elems) + j + 4)); -		strcpy(items[i], *elems); -		if (*elems_comments) { -			strcat(items[i], " ("); -			strcat(items[i], *elems_comments); -			strcat(items[i], ")"); -		} -		elems_comments++; -		i++; -		elems++; +	if (elems_comments) { +	    int i; + +	    i = 0; +	    while (elems && *elems) { +		    int j = (*elems_comments) ? strlen(*elems_comments) : 0; +		    items[i] = malloc(sizeof(char) * (strlen(*elems) + j + 4)); +		    strcpy(items[i], *elems); +		    if (*elems_comments) { +			    strcat(items[i], " ("); +			    strcat(items[i], *elems_comments); +			    strcat(items[i], ")"); +		    } +		    elems_comments++; +		    i++; +		    elems++; +	    } +	    items[i] = NULL;  	} -	items[i] = NULL; - -	rc = newtWinMenu("Please choose...", msg, 52, 5, 5, 7, items, &answer, "Ok", "Cancel", NULL); - -	if (rc == 2) -		return RETURN_BACK; - -	*choice = strdup(sav_elems[answer]); - -	return RETURN_OK; -} - -enum return_type ask_from_list(char *msg, char ** elems, char ** choice) -{ -	int answer = 0, rc; - -	rc = newtWinMenu("Please choose...", msg, 52, 5, 5, 7, elems, &answer, "Ok", "Cancel", NULL); +	rc = newtWinMenu("Please choose...", msg, 52, 5, 5, 7, elems_comments ? items : elems, answer, "Ok", "Cancel", NULL);  	if (rc == 2)  		return RETURN_BACK; -	*choice = strdup(elems[answer]); -  	return RETURN_OK;  } -  enum return_type ask_yes_no(char *msg)  {  	int rc; @@ -310,7 +299,7 @@ static int mynewtWinEntries(char * title, char * text, int suggestedWidth, int f  	for (i = 0; i < numItems; i++) {  		newtComponent entr = newtEntry(-1, -1, items[i].value ?   					       *items[i].value : NULL, dataWidth, -					       items[i].value, items[i].flags); +					       (const char**)items[i].value, items[i].flags);  		newtGridSetField(subgrid, 0, i, NEWT_GRID_COMPONENT,  				 newtLabel(-1, -1, items[i].text), @@ -372,7 +361,7 @@ enum return_type ask_from_entries(char *msg, char ** questions, char *** answers  	entries[i].value = NULL;  	if (*answers == NULL) -		*answers = (char **) malloc(sizeof(char *) * i); +		*answers = (char **) calloc(1, sizeof(char *) * i);  	else  		already_answers = *answers; | 
