Backout the previous incorrect fix for PR 49440 and redo it more globaly:

get rid of the global "yesno", introduce utility functions "ask_yesno()"
and "ask_noyes()" instead, greatly simplifying a lot of code.
Pass in a pointer to the return value to various "set source" menus.
This commit is contained in:
martin 2015-05-10 10:14:02 +00:00
parent b3b23df81a
commit e21052b4e5
24 changed files with 179 additions and 189 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.3 2015/01/02 19:43:13 abs Exp $ */
/* $NetBSD: md.c,v 1.4 2015/05/10 10:14:02 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -299,8 +299,7 @@ md_pre_update(void)
if (part->mbrp_size < (MIN_FAT12_BOOT / 512)) {
msg_display(MSG_boottoosmall);
msg_display_add(MSG_nobootpart, 0);
process_menu(MENU_yesno, NULL);
if (!yesno)
if (!ask_yesno(NULL))
return 0;
nobootfs = 1;
}
@ -339,16 +338,14 @@ md_check_mbr(mbr_info_t *mbri)
if (pm->bootsize < (MIN_FAT12_BOOT / 512)) {
msg_display(MSG_boottoosmall);
msg_display_add(MSG_reeditpart, 0);
process_menu(MENU_yesno, NULL);
if (!yesno)
if (!ask_yesno(NULL))
return 0;
return 1;
}
if (pm->bootstart == 0 || pm->bootsize == 0) {
msg_display(MSG_nobootpart);
msg_display_add(MSG_reeditpart, 0);
process_menu(MENU_yesno, NULL);
if (!yesno)
if (!ask_yesno(NULL))
return 0;
return 1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.2 2014/08/03 16:09:39 martin Exp $ */
/* $NetBSD: md.c,v 1.3 2015/05/10 10:14:02 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -69,8 +69,7 @@ int
md_make_bsd_partitions(void)
{
msg_display(MSG_infoahdilabel, pm->diskdev);
process_menu(MENU_noyes, NULL);
if (yesno) {
if (ask_noyes(NULL)) {
run_program(RUN_DISPLAY, "ahdilabel /dev/r%sc", pm->diskdev);
}
if (!make_bsd_partitions())

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.3 2015/01/02 19:43:13 abs Exp $ */
/* $NetBSD: md.c,v 1.4 2015/05/10 10:14:02 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -317,8 +317,7 @@ md_pre_update(void)
if (part->mbrp_size < (MIN_EXT2FS_BOOT / 512)) {
msg_display(MSG_boottoosmall);
msg_display_add(MSG_nobootpart, 0);
process_menu(MENU_yesno, NULL);
if (!yesno)
if (!ask_yesno(NULL))
return 0;
nobootfs = 1;
}
@ -357,16 +356,14 @@ md_check_mbr(mbr_info_t *mbri)
if (pm->bootsize < (MIN_EXT2FS_BOOT / 512)) {
msg_display(MSG_boottoosmall);
msg_display_add(MSG_reeditpart, 0);
process_menu(MENU_yesno, NULL);
if (!yesno)
if (!ask_yesno(NULL))
return 0;
return 1;
}
if (pm->bootstart == 0 || pm->bootsize == 0) {
msg_display(MSG_nobootpart);
msg_display_add(MSG_reeditpart, 0);
process_menu(MENU_yesno, NULL);
if (!yesno)
if (!ask_yesno(NULL))
return 0;
return 1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.2 2014/08/03 16:09:39 martin Exp $ */
/* $NetBSD: md.c,v 1.3 2015/05/10 10:14:02 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -167,9 +167,8 @@ md_post_extract(void)
strlcpy(ldr_path, target_expand("/boot.emips"), sizeof ldr_path);
msg_display(MSG_dobootblks, "");
process_menu(MENU_noyes, NULL);
if (yesno) {
if (ask_noyes(NULL)) {
if (run_program(RUN_DISPLAY | RUN_NO_CLEAR,
"/bin/dd if=%s of=/dev/reflash0c bs=512", ldr_path))
process_menu(MENU_ok, deconst("Warning: the system "

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.3 2015/03/12 11:32:16 joerg Exp $ */
/* $NetBSD: md.c,v 1.4 2015/05/10 10:14:02 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -276,8 +276,7 @@ md_check_mbr(mbr_info_t *mbri)
if (!hasboot) {
msg_display(MSG_nomsdospart);
msg_display_add(MSG_reeditpart, 0);
process_menu(MENU_yesno, NULL);
if (!yesno)
if (!ask_yesno(NULL))
return 0;
return 1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.1 2014/12/28 11:51:11 martin Exp $ */
/* $NetBSD: md.c,v 1.2 2015/05/10 10:14:02 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -275,8 +275,7 @@ md_check_mbr(mbr_info_t *mbri)
if (!hasboot) {
msg_display(MSG_nomsdospart);
msg_display_add(MSG_reeditpart, 0);
process_menu(MENU_yesno, NULL);
if (!yesno)
if (!ask_yesno(NULL))
return 0;
return 1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.3 2015/01/02 19:43:13 abs Exp $ */
/* $NetBSD: md.c,v 1.4 2015/05/10 10:14:02 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -150,8 +150,7 @@ md_check_partitions(void)
} else {
if (start >= pm->bsdlabel[part].pi_offset) {
msg_display(MSG_ordering, part+'a');
process_menu(MENU_yesno, NULL);
if (yesno)
if (ask_yesno(NULL))
return 0;
}
start = pm->bsdlabel[part].pi_offset;

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.5 2015/01/02 19:43:13 abs Exp $ */
/* $NetBSD: md.c,v 1.6 2015/05/10 10:14:02 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -110,8 +110,7 @@ edit:
if (biosdisk != NULL && (biosdisk->bi_flags & BIFLAG_EXTINT13) == 0) {
if (mbr_root_above_chs()) {
msg_display(MSG_partabovechs);
process_menu(MENU_noyes, NULL);
if (!yesno)
if (!ask_noyes(NULL))
goto edit;
/* The user is shooting themselves in the foot here...*/
} else
@ -169,8 +168,7 @@ edit:
* don't all have bootmenu texts.
*/
msg_display(MSG_missing_bootmenu_text);
process_menu(MENU_yesno, NULL);
if (yesno)
if (ask_yesno(NULL))
goto edit;
}
@ -178,8 +176,7 @@ edit:
(biosdisk == NULL || !(biosdisk->bi_flags & BIFLAG_EXTINT13))) {
/* Need unsupported LBA reads to read boot sectors */
msg_display(MSG_no_extended_bootmenu);
process_menu(MENU_noyes, NULL);
if (!yesno)
if (!ask_noyes(NULL))
goto edit;
}
@ -215,8 +212,7 @@ edit:
/* Existing code would (probably) be ok */
msg_display(MSG_updatembr);
process_menu(MENU_yesno, NULL);
if (!yesno)
if (!ask_yesno(NULL))
/* User doesn't want to update mbr code */
return 1;
@ -226,7 +222,7 @@ edit:
/* This shouldn't happen since the files are in the floppy fs... */
msg_display("Can't find %s", bootcode);
process_menu(MENU_yesno, NULL);
ask_yesno(NULL);
return 1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.2 2014/08/03 16:09:40 martin Exp $ */
/* $NetBSD: md.c,v 1.3 2015/05/10 10:14:03 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -1141,8 +1141,7 @@ edit_diskmap(void)
if (usefull) {
if (map.usable_cnt > (map.root_cnt+map.swap_cnt+map.usr_cnt)) {
msg_display (MSG_ovrwrite);
process_menu (MENU_noyes, NULL);
if (!yesno) {
if (!ask_noyes(NULL)) {
endwin();
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.3 2015/01/02 19:43:13 abs Exp $ */
/* $NetBSD: md.c,v 1.4 2015/05/10 10:14:03 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -148,8 +148,7 @@ md_check_partitions(void)
} else {
if (start > pm->bsdlabel[part].pi_offset) {
msg_display(MSG_ordering, part+'a');
process_menu(MENU_yesno, NULL);
if (yesno)
if (ask_yesno(NULL))
return 0;
}
start = pm->bsdlabel[part].pi_offset;

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.2 2014/08/03 16:09:40 martin Exp $ */
/* $NetBSD: md.c,v 1.3 2015/05/10 10:14:03 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -433,8 +433,7 @@ md_pre_update(void)
part->mbrp_size < (MIN_FAT12_BOOT/512)) {
msg_display(MSG_boottoosmall);
msg_display_add(MSG_nobootpartdisklabel, 0);
process_menu(MENU_yesno, NULL);
if (!yesno)
if (!ask_yesno(NULL))
return 0;
nobootfix = 1;
}
@ -498,8 +497,7 @@ md_check_mbr(mbr_info_t *mbri)
bprepsize >= (MIN_PREP_BOOT/512)))) {
msg_display(MSG_bootnotright);
msg_display_add(MSG_reeditpart, 0);
process_menu(MENU_yesno, NULL);
if (!yesno)
if (!ask_yesno(NULL))
return 0;
return 1;
}
@ -510,8 +508,7 @@ md_check_mbr(mbr_info_t *mbri)
bprepsize < (MIN_PREP_BOOT/512))) {
msg_display(MSG_preptoosmall);
msg_display_add(MSG_reeditpart, 0);
process_menu(MENU_yesno, NULL);
if (!yesno)
if (!ask_yesno(NULL))
return 0;
return 1;
}
@ -520,8 +517,7 @@ md_check_mbr(mbr_info_t *mbri)
if (pm->bootsize > 0 && pm->bootsize < (MIN_FAT12_BOOT/512)) {
msg_display(MSG_boottoosmall);
msg_display_add(MSG_reeditpart, 0);
process_menu(MENU_yesno, NULL);
if (!yesno)
if (!ask_yesno(NULL))
return 0;
return 1;
}
@ -532,8 +528,7 @@ md_check_mbr(mbr_info_t *mbri)
bprepsize == 0 || bprepstart == 0)) {
msg_display(MSG_nobootpart);
msg_display_add(MSG_reeditpart, 0);
process_menu(MENU_yesno, NULL);
if (!yesno)
if (!ask_yesno(NULL))
return 0;
return 1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.2 2014/08/03 16:09:40 martin Exp $ */
/* $NetBSD: md.c,v 1.3 2015/05/10 10:14:03 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -191,8 +191,7 @@ md_pre_update(void)
if (part->mbrp_size < (MIN_PREP_BOOT/512)) {
msg_display(MSG_preptoosmall);
msg_display_add(MSG_prepnobootpart, 0);
process_menu(MENU_yesno, NULL);
if (!yesno)
if (!ask_yesno(NULL))
return 0;
prep_nobootfix = 1;
}
@ -233,16 +232,14 @@ md_check_mbr(mbr_info_t *mbri)
if (pm->bootsize < (MIN_PREP_BOOT/512)) {
msg_display(MSG_preptoosmall);
msg_display_add(MSG_reeditpart, 0);
process_menu(MENU_yesno, NULL);
if (!yesno)
if (!ask_yesno(NULL))
return 0;
return 1;
}
if (pm->bootstart == 0 || pm->bootsize == 0) {
msg_display(MSG_nopreppart);
msg_display_add(MSG_reeditpart, 0);
process_menu(MENU_yesno, NULL);
if (!yesno)
if (!ask_yesno(NULL))
return 0;
return 1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: md.c,v 1.3 2015/01/02 19:43:14 abs Exp $ */
/* $NetBSD: md.c,v 1.4 2015/05/10 10:14:03 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -176,8 +176,7 @@ md_check_partitions(void)
} else {
if (start >= pm->bsdlabel[part].pi_offset) {
msg_display(MSG_ordering, part+'a');
process_menu(MENU_yesno, NULL);
if (yesno)
if (ask_yesno(NULL))
return 0;
}
start = pm->bsdlabel[part].pi_offset;
@ -200,8 +199,7 @@ md_check_partitions(void)
break;
if (memcmp(md_disklabel.dosparts[i].dp_typename, "Human68k", 8)) {
msg_display(MSG_existing);
process_menu(MENU_noyes);
preserve = yesno;
preserve = ask_noyes(NULL);
break;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: configmenu.c,v 1.3 2015/01/20 21:51:05 snj Exp $ */
/* $NetBSD: configmenu.c,v 1.4 2015/05/10 10:14:02 martin Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@ -258,8 +258,7 @@ add_new_user(struct menudesc *menu, void *arg)
msg_prompt(MSG_addusername, NULL, username, sizeof username -1);
if (strlen(username) == 0)
return 0;
process_menu(MENU_yesno, deconst(MSG_addusertowheel));
inwheel = yesno;
inwheel = ask_yesno(deconst(MSG_addusertowheel));
ushell = "/bin/csh";
process_menu(MENU_usersh, NULL);
if (inwheel)
@ -280,8 +279,7 @@ change_root_password(struct menudesc *menu, void *arg)
configinfo **confp = arg;
msg_display(MSG_rootpw);
process_menu(MENU_yesno, NULL);
if (yesno) {
if (ask_yesno(NULL)) {
if (run_program(RUN_DISPLAY | RUN_PROGRESS | RUN_CHROOT,
"passwd -l root") == 0)
confp[menu->cursel]->setting = MSG_password_set;
@ -298,11 +296,13 @@ set_binpkg(struct menudesc *menu, void *arg)
char additional_pkgs[STRSIZE] = {0};
char pattern[STRSIZE];
int allok = 0;
arg_rv parm;
do {
yesno = -1;
process_menu(MENU_binpkg, additional_pkgs);
if (yesno == SET_SKIP) {
parm.rv = -1;
parm.arg = additional_pkgs;
process_menu(MENU_binpkg, &parm);
if (parm.rv == SET_SKIP) {
confp[menu->cursel]->setting = MSG_abandoned;
return 0;
}
@ -354,8 +354,7 @@ set_pkgsrc(struct menudesc *menu, void *arg)
confp[menu->cursel]->setting = MSG_abandoned;
return 0;
}
process_menu(MENU_yesno, deconst(MSG_retry_pkgsrc_network));
if (!yesno) {
if (!ask_yesno(deconst(MSG_retry_pkgsrc_network))) {
confp[menu->cursel]->setting = MSG_abandoned;
return 1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: defs.h,v 1.7 2015/05/09 12:06:31 martin Exp $ */
/* $NetBSD: defs.h,v 1.8 2015/05/10 10:14:02 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -188,6 +188,13 @@ enum {
#define CD_NAMES "cd0a"
/* Types */
/* pass a void* argument into a menu and also provide a int return value */
typedef struct arg_rv {
void *arg;
int rv;
} arg_rv;
typedef struct distinfo {
const char *name;
uint set;
@ -250,7 +257,6 @@ int debug; /* set by -D option */
char rel[SSTRSIZE];
char machine[SSTRSIZE];
int yesno;
int ignorerror;
int ttysig_ignore;
pid_t ttysig_forward;
@ -510,6 +516,8 @@ void do_reinstall_sets(void);
void restore_etc(void);
/* from util.c */
int ask_yesno(void*);
int ask_noyes(void*);
int dir_exists_p(const char *);
int file_exists_p(const char *);
int file_mode_match(const char *, unsigned int);

View File

@ -1,4 +1,4 @@
/* $NetBSD: disks.c,v 1.8 2015/05/09 12:06:31 martin Exp $ */
/* $NetBSD: disks.c,v 1.9 2015/05/10 10:14:02 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -1010,8 +1010,7 @@ foundffs(struct data *list, size_t num)
error = target_mount("", list[0].u.s_val, ' '-'a', list[1].u.s_val);
if (error != 0) {
msg_display(MSG_mount_failed, list[0].u.s_val);
process_menu(MENU_noyes, NULL);
if (!yesno)
if (!ask_noyes(NULL))
return error;
}
return 0;
@ -1061,8 +1060,7 @@ fsck_preen(const char *disk, int ptn, const char *fsname)
free(prog);
if (error != 0) {
msg_display(MSG_badfs, disk, ptn, error);
process_menu(MENU_noyes, NULL);
if (yesno)
if (ask_noyes(NULL))
error = 0;
/* XXX at this point maybe we should run a full fsck? */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: install.c,v 1.3 2015/01/02 19:43:13 abs Exp $ */
/* $NetBSD: install.c,v 1.4 2015/05/10 10:14:02 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -51,8 +51,7 @@ do_install(void)
#ifndef DEBUG
msg_display(MSG_installusure);
process_menu(MENU_noyes, NULL);
if (!yesno)
if (!ask_noyes(NULL))
return;
#endif
@ -95,8 +94,7 @@ do_install(void)
clear();
refresh();
msg_display(MSG_lastchance, pm->diskdev);
process_menu(MENU_noyes, NULL);
if (!yesno)
if (!ask_noyes(NULL))
return;
if (md_pre_disklabel() != 0 ||

View File

@ -1,4 +1,4 @@
/* $NetBSD: label.c,v 1.2 2014/08/03 16:09:38 martin Exp $ */
/* $NetBSD: label.c,v 1.3 2015/05/10 10:14:02 martin Exp $ */
/*
* Copyright 1997 Jonathan Stone
@ -36,7 +36,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: label.c,v 1.2 2014/08/03 16:09:38 martin Exp $");
__RCSID("$NetBSD: label.c,v 1.3 2015/05/10 10:14:02 martin Exp $");
#endif
#include <sys/types.h>
@ -672,8 +672,7 @@ edit_and_check_label(partinfo *lp, int nparts, int rawpart, int bsdpart)
/*XXX ???*/
msg_display_add(MSG_edit_partitions_again);
process_menu(MENU_yesno, NULL);
if (!yesno)
if (!ask_yesno(NULL))
return(0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mbr.c,v 1.4 2014/10/21 18:19:17 martin Exp $ */
/* $NetBSD: mbr.c,v 1.5 2015/05/10 10:14:02 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -1294,8 +1294,7 @@ edit_mbr(mbr_info_t *mbri)
/* Ask if we really want to blow away non-NetBSD stuff */
if (numbsd > 1) {
msg_display(MSG_ovrwrite);
process_menu(MENU_noyes, NULL);
if (!yesno) {
if (!ask_noyes(NULL)) {
if (logfp)
(void)fprintf(logfp, "User answered no to destroy other data, aborting.\n");
return 0;
@ -1356,16 +1355,14 @@ edit_mbr(mbr_info_t *mbri)
else
msg_display(MSG_multbsdpart, 0);
msg_display_add(MSG_reeditpart, 0);
process_menu(MENU_yesno, NULL);
if (!yesno)
if (!ask_yesno(NULL))
return 0;
continue;
}
if (activepart == 0) {
msg_display(MSG_noactivepart);
process_menu(MENU_yesno, NULL);
if (yesno)
if (ask_yesno(NULL))
continue;
}
/* the md_check_mbr function has 3 ret codes to deal with

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.mi,v 1.8 2015/05/09 12:55:06 martin Exp $ */
/* $NetBSD: menus.mi,v 1.9 2015/05/10 10:14:02 martin Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -286,14 +286,16 @@ menu colors, title MSG_Color_scheme, exit,
menu yesno, y=-10;
display action { menu->title = arg ? arg : MSG_yes_or_no; };
option MSG_Yes, exit, action {yesno = 1;};
option MSG_No, exit, action {yesno = 0;};
display action { arg_rv *p = arg;
menu->title = p->arg ? p->arg : MSG_yes_or_no; };
option MSG_Yes, exit, action { ((arg_rv*)arg)->rv = 1; };
option MSG_No, exit, action { ((arg_rv*)arg)->rv = 0; };
menu noyes, y=-10;
display action { menu->title = arg ? arg : MSG_yes_or_no; };
option MSG_No, exit, action {yesno = 0;};
option MSG_Yes, exit, action {yesno = 1;};
display action { arg_rv *p = arg;
menu->title = p->arg ? p->arg : MSG_yes_or_no; };
option MSG_No, exit, action { ((arg_rv*)arg)->rv = 0; };
option MSG_Yes, exit, action { ((arg_rv*)arg)->rv = 1; };
menu ok, no shortcut, y=-10;
display action { menu->title = arg; };
@ -345,7 +347,7 @@ menu distset, title MSG_Select_your_distribution, exit,
menu ftpsource, y=-4, x=0, w=70, no box, no clear,
exitstring MSG_Get_Distribution;
display action { msg_display(MSG_ftpsource, arg); };
display action { msg_display(MSG_ftpsource, ((arg_rv*)arg)->arg); };
option {src_legend(menu, MSG_Host, ftp.host);},
action { src_prompt(MSG_Host, ftp.host, sizeof ftp.host); };
option {src_legend(menu, MSG_Base_dir, ftp.dir);},
@ -382,16 +384,14 @@ menu ftpsource, y=-4, x=0, w=70, no box, no clear,
action { src_prompt(MSG_Xfer_dir, xfer_dir, sizeof xfer_dir); };
option {src_legend(menu, MSG_delete_xfer_file,
clean_xfer_dir ? MSG_Yes : MSG_No);},
action {process_menu(MENU_yesno, deconst(MSG_delete_xfer_file));
clean_xfer_dir = yesno; };
action {clean_xfer_dir = ask_yesno(deconst(MSG_delete_xfer_file)); };
option MSG_Configure_network,
action {
extern int network_up;
network_up = 0;
config_network();
};
option MSG_exit_menu_generic, exit, action { yesno = SET_RETRY; };
exit action { yesno = -1; };
option MSG_exit_menu_generic, exit, action { ((arg_rv*)arg)->rv = SET_RETRY; };
menu nfssource, y=-4, x=0, w=70, no box, no clear,
@ -411,7 +411,7 @@ menu nfssource, y=-4, x=0, w=70, no box, no clear,
network_up = 0;
config_network();
};
option MSG_exit_menu_generic, exit, action { yesno = SET_RETRY; };
option MSG_exit_menu_generic, exit, action { *((int*)arg) = SET_RETRY; };
menu fdremount, title MSG_What_do_you_want_to_do;
option MSG_Try_again, exit, action { *(int *)arg = SET_CONTINUE; };
@ -439,9 +439,8 @@ menu floppysource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
action { src_prompt(MSG_Xfer_dir, xfer_dir, sizeof xfer_dir); };
option {src_legend(menu, MSG_delete_xfer_file,
clean_xfer_dir ? MSG_Yes : MSG_No);},
action {process_menu(MENU_yesno, deconst(MSG_delete_xfer_file));
clean_xfer_dir = yesno; };
option MSG_exit_menu_generic, exit, action { yesno = SET_RETRY; };
action {clean_xfer_dir = ask_yesno(deconst(MSG_delete_xfer_file)); };
option MSG_exit_menu_generic, exit, action { *((int*)arg) = SET_RETRY; };
menu cdromsource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
display action { msg_display(MSG_cdromsource); };
@ -451,7 +450,7 @@ menu cdromsource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
action { src_prompt(MSG_Set_dir_bin, set_dir_bin, sizeof set_dir_bin); };
option {src_legend(menu, MSG_Set_dir_src, set_dir_src);},
action { src_prompt(MSG_Set_dir_src, set_dir_src, sizeof set_dir_src); };
option MSG_exit_menu_generic, exit, action { yesno = SET_RETRY; };
option MSG_exit_menu_generic, exit, action { *((int*)arg) = SET_RETRY; };
menu localfssource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
display action { msg_display(MSG_localfssource); };
@ -465,7 +464,7 @@ menu localfssource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
action { src_prompt(MSG_Set_dir_bin, set_dir_bin, sizeof set_dir_bin); };
option {src_legend(menu, MSG_Set_dir_src, set_dir_src);},
action { src_prompt(MSG_Set_dir_src, set_dir_src, sizeof set_dir_src); };
option MSG_exit_menu_generic, exit, action { yesno = SET_RETRY; };
option MSG_exit_menu_generic, exit, action { *((int*)arg) = SET_RETRY; };
menu localdirsource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
display action { msg_display(MSG_localdir); };
@ -475,7 +474,7 @@ menu localdirsource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
action { src_prompt(MSG_Set_dir_bin, set_dir_bin, 60); };
option {src_legend(menu, MSG_Set_dir_src, set_dir_src);},
action { src_prompt(MSG_Set_dir_src, set_dir_src, 60); };
option MSG_exit_menu_generic, exit, action { yesno = SET_RETRY; };
option MSG_exit_menu_generic, exit, action { *((int*)arg) = SET_RETRY; };
menu namesrv6, title MSG_Select_DNS_server;
option "google-public-dns-a.google.com (IPv4)", exit, action
@ -483,9 +482,9 @@ menu namesrv6, title MSG_Select_DNS_server;
#ifdef INET6
strlcpy(net_namesvr, "8.8.8.8",
sizeof(net_namesvr));
yesno = 1;
*((int*)arg) = 1;
#else
yesno = 0;
*((int*)arg) = 0;
#endif
};
option "google-public-dns-b.google.com (IPv4)", exit, action
@ -493,9 +492,9 @@ menu namesrv6, title MSG_Select_DNS_server;
#ifdef INET6
strlcpy(net_namesvr, "8.8.4.4",
sizeof(net_namesvr));
yesno = 1;
*((int*)arg) = 1;
#else
yesno = 0;
*((int*)arg) = 0;
#endif
};
option "google-public-dns-a.google.com (IPv6)", exit, action
@ -503,9 +502,9 @@ menu namesrv6, title MSG_Select_DNS_server;
#ifdef INET6
strlcpy(net_namesvr, "2001:4860:4860::8888",
sizeof(net_namesvr));
yesno = 1;
*((int*)arg) = 1;
#else
yesno = 0;
*((int*)arg) = 0;
#endif
};
option "google-public-dns-b.google.com (IPv6)", exit, action
@ -513,13 +512,13 @@ menu namesrv6, title MSG_Select_DNS_server;
#ifdef INET6
strlcpy(net_namesvr, "2001:4860:4860::8844",
sizeof(net_namesvr));
yesno = 1;
*((int*)arg) = 1;
#else
yesno = 0;
*((int*)arg) = 0;
#endif
};
option MSG_other, exit, action
{ yesno = 0; };
{ *((int*)arg) = 0; };
menu rootsh, title MSG_Root_shell, no clear;
option "/bin/sh", exit, action {*(const char **)arg = "/bin/sh";};
@ -564,8 +563,8 @@ menu binpkg, y=-4, x=0, w=70, no box, no clear,
setenv("http_proxy", pkg.proxy, 1);
}
};
option {src_legend(menu, "Additional packages", (char*)arg); }, /*TODO*/
action { src_prompt("Additional packages", (char*)arg,
option {src_legend(menu, "Additional packages", (char*)(((arg_rv*)arg)->arg)); }, /*TODO*/
action { src_prompt("Additional packages", (char*)(((arg_rv*)arg)->arg),
sizeof(char) * STRSIZE); };
option MSG_Configure_network,
action {
@ -574,7 +573,7 @@ menu binpkg, y=-4, x=0, w=70, no box, no clear,
config_network();
mnt_net_config();
};
option MSG_quit_pkgs_install, exit, action { yesno = SET_SKIP; };
option MSG_quit_pkgs_install, exit, action { ((arg_rv*)arg)->rv = SET_SKIP; };
menu pkgsrc, y=-4, x=0, w=70, no box, no clear,
exit, exitstring MSG_Install_pkgsrc;
@ -612,9 +611,8 @@ menu pkgsrc, y=-4, x=0, w=70, no box, no clear,
action { src_prompt(MSG_Xfer_dir, xfer_dir, sizeof xfer_dir); };
option {src_legend(menu, MSG_delete_xfer_file,
clean_xfer_dir ? MSG_Yes : MSG_No);},
action {process_menu(MENU_yesno, deconst(MSG_delete_xfer_file));
clean_xfer_dir = yesno; };
option MSG_quit_pkgsrc, exit, action { yesno = SET_SKIP;};
action {clean_xfer_dir = ask_yesno(deconst(MSG_delete_xfer_file)); };
option MSG_quit_pkgsrc, exit, action { *((int*)arg) = SET_SKIP;};
menu usersh, title MSG_User_shell, no clear;
option "/bin/sh", exit, action { ushell = "/bin/sh";};

View File

@ -1,4 +1,4 @@
/* $NetBSD: net.c,v 1.17 2014/10/14 16:35:20 christos Exp $ */
/* $NetBSD: net.c,v 1.18 2015/05/10 10:14:02 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -456,8 +456,7 @@ handle_license(const char *dev)
&& val != 0)
return 1;
msg_display(MSG_license, dev, licdev[i].lic);
process_menu(MENU_yesno, NULL);
if (yesno) {
if (ask_yesno(NULL)) {
val = 1;
if (sysctlbyname(buf, NULL, NULL, &val,
0) == -1)
@ -492,7 +491,7 @@ config_network(void)
int num_devs;
int selected_net;
int i;
int i, rv;
#ifdef INET6
int v6config = 1;
#endif
@ -715,8 +714,9 @@ again:
if (!(net_dhcpconf & DHCPCONF_NAMESVR)) {
#ifdef INET6
if (v6config) {
process_menu(MENU_namesrv6, NULL);
if (!yesno)
rv = 0;
process_menu(MENU_namesrv6, &rv);
if (!rv)
msg_prompt_add(MSG_net_namesrv, net_namesvr,
net_namesvr, sizeof net_namesvr);
} else
@ -748,9 +748,7 @@ again:
!is_v6kernel() ? "<not supported>" : net_ip6);
#endif
done:
process_menu(MENU_yesno, deconst(MSG_netok_ok));
if (!yesno)
if (!ask_yesno(deconst(MSG_netok_ok)))
goto again;
run_program(0, "/sbin/ifconfig lo0 127.0.0.1");
@ -962,10 +960,11 @@ do_ftp_fetch(const char *set_name, struct ftpinfo *f)
int
get_pkgsrc(void)
{
yesno = -1;
process_menu(MENU_pkgsrc, NULL);
int rv = -1;
process_menu(MENU_pkgsrc, &rv);
if (yesno == SET_SKIP)
if (rv == SET_SKIP)
return SET_SKIP;
fetch_fn = pkgsrc_fetch;
@ -978,10 +977,13 @@ get_pkgsrc(void)
int
get_via_ftp(const char *xfer_type)
{
yesno = -1;
process_menu(MENU_ftpsource, deconst(xfer_type));
arg_rv arg;
arg.rv = -1;
arg.arg = deconst(xfer_type);
process_menu(MENU_ftpsource, &arg);
if (yesno == SET_RETRY)
if (arg.rv == SET_RETRY)
return SET_RETRY;
/* We'll fetch each file just before installing it */
@ -999,6 +1001,7 @@ int
get_via_nfs(void)
{
struct statvfs sb;
int rv;
/* If root is on NFS and we have sets, skip this step. */
if (statvfs(set_dir_bin, &sb) == 0 &&
@ -1009,10 +1012,10 @@ get_via_nfs(void)
}
/* Get server and filepath */
yesno = -1;
process_menu(MENU_nfssource, NULL);
rv = -1;
process_menu(MENU_nfssource, &rv);
if (yesno == SET_RETRY)
if (rv == SET_RETRY)
return SET_RETRY;
/* Mount it */
@ -1062,8 +1065,7 @@ mnt_net_config(void)
if (!network_up)
return;
process_menu(MENU_yesno, deconst(MSG_mntnetconfig));
if (!yesno)
if (!ask_yesno(deconst(MSG_mntnetconfig)))
return;
/* Write hostname to /etc/rc.conf */
@ -1152,8 +1154,7 @@ config_dhcp(char *inter)
if (!file_mode_match(DHCPCD, S_IFREG))
return 0;
process_menu(MENU_yesno, deconst(MSG_Perform_autoconfiguration));
if (yesno) {
if (ask_yesno(deconst(MSG_Perform_autoconfiguration))) {
/* spawn off dhcpcd and wait for parent to exit */
dhcpautoconf = run_program(RUN_DISPLAY | RUN_PROGRESS,
"%s -d -n %s", DHCPCD, inter);

View File

@ -1,4 +1,4 @@
/* $NetBSD: partman.c,v 1.9 2015/05/09 12:06:31 martin Exp $ */
/* $NetBSD: partman.c,v 1.10 2015/05/10 10:14:02 martin Exp $ */
/*
* Copyright 2012 Eugene Lozovoy
@ -1695,8 +1695,7 @@ pm_gpt_convert(pm_devs_t *pm_cur)
int i, error = 0;
msg_display(MSG_removepartswarn);
process_menu(MENU_noyes, NULL);
if (! yesno)
if (!ask_noyes(NULL))
return -1;
if (! pm_cur->gpt)
@ -2266,8 +2265,7 @@ pm_needsave(void)
/* Oops, we have unsaved changes */
changed = 1;
msg_display(MSG_saveprompt);
process_menu(MENU_yesno, NULL);
return (yesno);
return ask_yesno(NULL);
}
return 0;
}
@ -2402,8 +2400,7 @@ pm_submenu(menudesc *m, void *arg)
return -1;
if (pm_cur->blocked) {
msg_display(MSG_wannaunblock);
process_menu(MENU_noyes, NULL);
if (!yesno)
if (!ask_noyes(NULL))
return -2;
pm_cur->blocked = 0;
}
@ -2804,8 +2801,7 @@ partman(void)
pm_lastcheck() != 0 ||
pm_savebootsector() != 0) {
msg_display(MSG_wannatry);
process_menu(MENU_yesno, NULL);
args[0].retvalue = (yesno) ? 1:-1;
args[0].retvalue = (ask_yesno(NULL)) ? 1:-1;
}
}
} while (args[0].retvalue > 0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: upgrade.c,v 1.3 2015/01/02 19:43:13 abs Exp $ */
/* $NetBSD: upgrade.c,v 1.4 2015/05/10 10:14:02 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -58,8 +58,7 @@ do_upgrade(void)
partman_go = 0;
msg_display(MSG_upgradeusure);
process_menu(MENU_noyes, NULL);
if (!yesno)
if (!ask_noyes(NULL))
return;
get_ramsize();
@ -182,8 +181,7 @@ do_reinstall_sets(void)
unwind_mounts();
msg_display(MSG_reinstallusure);
process_menu(MENU_noyes, NULL);
if (!yesno)
if (!ask_noyes(NULL))
return;
if (find_disks(msg_string(MSG_reinstall)) < 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: util.c,v 1.5 2014/10/14 16:35:20 christos Exp $ */
/* $NetBSD: util.c,v 1.6 2015/05/10 10:14:02 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -363,9 +363,10 @@ floppy_fetch(const char *set_name)
int
get_via_floppy(void)
{
yesno = -1;
process_menu(MENU_floppysource, NULL);
if (yesno == SET_RETRY)
int rv = -1;
process_menu(MENU_floppysource, &rv);
if (rv == SET_RETRY)
return SET_RETRY;
fetch_fn = floppy_fetch;
@ -527,7 +528,7 @@ get_via_cdrom(void)
{
menu_ent cd_menu[MAX_CD_INFOS];
struct stat sb;
int num_cds, menu_cd, i, selected_cd = 0;
int rv, num_cds, menu_cd, i, selected_cd = 0;
bool silent = false;
int mib[2];
char rootdev[SSTRSIZE] = "";
@ -584,9 +585,9 @@ get_via_cdrom(void)
}
/* ask for paths on the CD */
yesno = -1;
process_menu(MENU_cdromsource, NULL);
if (yesno == SET_RETRY)
rv = -1;
process_menu(MENU_cdromsource, &rv);
if (rv == SET_RETRY)
return SET_RETRY;
if (cd_has_sets())
@ -603,10 +604,11 @@ get_via_cdrom(void)
int
get_via_localfs(void)
{
int rv = -1;
/* Get device, filesystem, and filepath */
yesno = -1;
process_menu (MENU_localfssource, NULL);
if (yesno == SET_RETRY)
process_menu (MENU_localfssource, &rv);
if (rv == SET_RETRY)
return SET_RETRY;
/* Mount it */
@ -631,10 +633,11 @@ get_via_localfs(void)
int
get_via_localdir(void)
{
int rv = -1;
/* Get filepath */
yesno = -1;
process_menu(MENU_localdirsource, NULL);
if (yesno == SET_RETRY)
process_menu(MENU_localdirsource, &rv);
if (rv == SET_RETRY)
return SET_RETRY;
/*
@ -1084,8 +1087,7 @@ get_and_unpack_sets(int update, msg setupdone_msg, msg success_msg, msg failure_
"/usr/sbin/postinstall -s /.sysinst -d / check mailerconf");
if (oldsendmail == 1) {
msg_display(MSG_oldsendmail);
process_menu(MENU_yesno, NULL);
if (yesno) {
if (ask_yesno(NULL)) {
run_program(RUN_DISPLAY | RUN_CHROOT,
"/usr/sbin/postinstall -s /.sysinst -d / fix mailerconf");
}
@ -1560,8 +1562,7 @@ del_rc_conf(const char *value)
if (done) {
if (rename(rcconf, bakname)) {
msg_display(MSG_rcconf_backup_failed);
process_menu(MENU_noyes, NULL);
if (!yesno) {
if (!ask_noyes(NULL)) {
retval = -1;
goto done;
}
@ -1717,3 +1718,27 @@ safectime(time_t *t)
/*123456789012345678901234*/
return "preposterous clock time\n";
}
int
ask_yesno(void* arg)
{
arg_rv p;
p.arg = arg;
p.rv = -1;
process_menu(MENU_yesno, &p);
return p.rv;
}
int
ask_noyes(void* arg)
{
arg_rv p;
p.arg = arg;
p.rv = -1;
process_menu(MENU_noyes, &p);
return p.rv;
}