Port to new libdialog.
This commit is contained in:
parent
246864a52b
commit
166a0ada4e
@ -19,9 +19,10 @@ WARNS?= 3
|
|||||||
.if ${MACHINE} == "pc98"
|
.if ${MACHINE} == "pc98"
|
||||||
CFLAGS+= -DPC98
|
CFLAGS+= -DPC98
|
||||||
.endif
|
.endif
|
||||||
CFLAGS+= -I${.CURDIR}/../../gnu/lib/libodialog -I.
|
CFLAGS+= -I${.CURDIR}/../../contrib/dialog -I.
|
||||||
|
DEBUG_FLAGS= -O0 -g
|
||||||
|
|
||||||
DPADD= ${LIBODIALOG} ${LIBNCURSES} ${LIBUTIL} ${LIBDISK}
|
DPADD= ${LIBDIALOG} ${LIBNCURSESW} ${LIBM} ${LIBUTIL} ${LIBDISK}
|
||||||
LDADD= -lodialog -lncurses -lutil -ldisk
|
LDADD= -ldialog -lncursesw -lm -lutil -ldisk
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
.include <bsd.prog.mk>
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sade.h"
|
|
||||||
#include <sys/fcntl.h>
|
#include <sys/fcntl.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
@ -40,6 +39,8 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <libdisk.h>
|
#include <libdisk.h>
|
||||||
|
|
||||||
|
#include "sade.h"
|
||||||
|
|
||||||
/* how much to bias minor number for a given /dev/<ct#><un#>s<s#> slice */
|
/* how much to bias minor number for a given /dev/<ct#><un#>s<s#> slice */
|
||||||
#define SLICE_DELTA (0x10000)
|
#define SLICE_DELTA (0x10000)
|
||||||
|
|
||||||
@ -247,7 +248,7 @@ deviceGetAll(void)
|
|||||||
}
|
}
|
||||||
free(names);
|
free(names);
|
||||||
}
|
}
|
||||||
dialog_clear_norefresh();
|
dlg_clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Rescan all devices, after closing previous set - convenience function */
|
/* Rescan all devices, after closing previous set - convenience function */
|
||||||
|
@ -113,7 +113,7 @@ check_geometry(Disk *d)
|
|||||||
if (d->bios_cyl > 65536 || d->bios_hd > 256 || d->bios_sect >= 64)
|
if (d->bios_cyl > 65536 || d->bios_hd > 256 || d->bios_sect >= 64)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
dialog_clear_norefresh();
|
dlg_clear();
|
||||||
sg = msgYesNo("WARNING: It is safe to use a geometry of %lu/%lu/%lu for %s on\n"
|
sg = msgYesNo("WARNING: It is safe to use a geometry of %lu/%lu/%lu for %s on\n"
|
||||||
"computers with modern BIOS versions. If this disk is to be used\n"
|
"computers with modern BIOS versions. If this disk is to be used\n"
|
||||||
"on an old machine it is recommended that it does not have more\n"
|
"on an old machine it is recommended that it does not have more\n"
|
||||||
@ -223,21 +223,21 @@ getBootMgr(char *dname, u_char **bootipl, size_t *bootipl_size,
|
|||||||
char *cp;
|
char *cp;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
dlg_clr_result();
|
||||||
cp = variable_get(VAR_BOOTMGR);
|
cp = variable_get(VAR_BOOTMGR);
|
||||||
if (!cp) {
|
if (!cp) {
|
||||||
/* Figure out what kind of IPL the user wants */
|
/* Figure out what kind of IPL the user wants */
|
||||||
sprintf(str, "Install Boot Manager for drive %s?", dname);
|
sprintf(str, "Install Boot Manager for drive %s?", dname);
|
||||||
MenuIPLType.title = str;
|
MenuIPLType.title = str;
|
||||||
i = dmenuOpenSimple(&MenuIPLType, FALSE);
|
i = dmenuOpen(&MenuIPLType);
|
||||||
} else {
|
} else {
|
||||||
if (!strncmp(cp, "boot", 4))
|
if (!strncmp(cp, "boot", 4))
|
||||||
BootMgr = 0;
|
dlg_add_result(MenuIPLType.items[0].prompt);
|
||||||
else
|
else
|
||||||
BootMgr = 1;
|
dlg_add_result(MenuIPLType.items[1].prompt);
|
||||||
}
|
}
|
||||||
if (cp || i) {
|
if (cp || i) {
|
||||||
switch (BootMgr) {
|
if (!strcmp(dialog_vars.input_result, MenuIPLType.items[0].prompt)) {
|
||||||
case 0:
|
|
||||||
if (!boot0) boot0 = bootalloc("boot0", &boot0_size);
|
if (!boot0) boot0 = bootalloc("boot0", &boot0_size);
|
||||||
*bootipl = boot0;
|
*bootipl = boot0;
|
||||||
*bootipl_size = boot0_size;
|
*bootipl_size = boot0_size;
|
||||||
@ -245,10 +245,7 @@ getBootMgr(char *dname, u_char **bootipl, size_t *bootipl_size,
|
|||||||
*bootmenu = boot05;
|
*bootmenu = boot05;
|
||||||
*bootmenu_size = boot05_size;
|
*bootmenu_size = boot05_size;
|
||||||
return;
|
return;
|
||||||
case 1:
|
}
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
*bootipl = NULL;
|
*bootipl = NULL;
|
||||||
*bootipl_size = 0;
|
*bootipl_size = 0;
|
||||||
@ -266,36 +263,33 @@ getBootMgr(char *dname, u_char **bootCode, size_t *bootCodeSize)
|
|||||||
char *cp;
|
char *cp;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
dlg_clr_result();
|
||||||
cp = variable_get(VAR_BOOTMGR);
|
cp = variable_get(VAR_BOOTMGR);
|
||||||
if (!cp) {
|
if (!cp) {
|
||||||
/* Figure out what kind of MBR the user wants */
|
/* Figure out what kind of MBR the user wants */
|
||||||
sprintf(str, "Install Boot Manager for drive %s?", dname);
|
sprintf(str, "Install Boot Manager for drive %s?", dname);
|
||||||
MenuMBRType.title = str;
|
MenuMBRType.title = str;
|
||||||
i = dmenuOpenSimple(&MenuMBRType, FALSE);
|
i = dmenuOpen(&MenuMBRType);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (!strcmp(cp, "standard"))
|
||||||
|
dlg_add_result(MenuMBRType.items[0].prompt);
|
||||||
if (!strncmp(cp, "boot", 4))
|
if (!strncmp(cp, "boot", 4))
|
||||||
BootMgr = 0;
|
dlg_add_result(MenuMBRType.items[1].prompt);
|
||||||
else if (!strcmp(cp, "standard"))
|
|
||||||
BootMgr = 1;
|
|
||||||
else
|
else
|
||||||
BootMgr = 2;
|
dlg_add_result(MenuMBRType.items[2].prompt);
|
||||||
}
|
}
|
||||||
if (cp || i) {
|
if (cp || i) {
|
||||||
switch (BootMgr) {
|
if (!strcmp(dialog_vars.input_result, MenuMBRType.items[0].prompt)) {
|
||||||
case 0:
|
|
||||||
if (!boot0) boot0 = bootalloc("boot0", &boot0_size);
|
|
||||||
*bootCode = boot0;
|
|
||||||
*bootCodeSize = boot0_size;
|
|
||||||
return;
|
|
||||||
case 1:
|
|
||||||
if (!mbr) mbr = bootalloc("mbr", &mbr_size);
|
if (!mbr) mbr = bootalloc("mbr", &mbr_size);
|
||||||
*bootCode = mbr;
|
*bootCode = mbr;
|
||||||
*bootCodeSize = mbr_size;
|
*bootCodeSize = mbr_size;
|
||||||
return;
|
return;
|
||||||
case 2:
|
} else if (!strcmp(dialog_vars.input_result, MenuMBRType.items[1].prompt)) {
|
||||||
default:
|
if (!boot0) boot0 = bootalloc("boot0", &boot0_size);
|
||||||
break;
|
*bootCode = boot0;
|
||||||
|
*bootCodeSize = boot0_size;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -333,7 +327,7 @@ diskPartition(Device *dev)
|
|||||||
|
|
||||||
/* Flush both the dialog and curses library views of the screen
|
/* Flush both the dialog and curses library views of the screen
|
||||||
since we don't always know who called us */
|
since we don't always know who called us */
|
||||||
dialog_clear_norefresh(), clear();
|
dlg_clear(), clear();
|
||||||
current_chunk = 0;
|
current_chunk = 0;
|
||||||
|
|
||||||
/* Set up the chunk array */
|
/* Set up the chunk array */
|
||||||
@ -705,12 +699,15 @@ diskPartition(Device *dev)
|
|||||||
p = CheckRules(d);
|
p = CheckRules(d);
|
||||||
if (p) {
|
if (p) {
|
||||||
char buf[FILENAME_MAX];
|
char buf[FILENAME_MAX];
|
||||||
|
DIALOG_VARS save_vars;
|
||||||
|
|
||||||
use_helpline("Press F1 to read more about disk slices.");
|
dlg_save_vars(&save_vars);
|
||||||
use_helpfile(systemHelpFile("partition", buf));
|
dialog_vars.help_line = "Press F1 to read more about disk slices.";
|
||||||
|
dialog_vars.help_file = systemHelpFile("partition", buf);
|
||||||
if (!variable_get(VAR_NO_WARN))
|
if (!variable_get(VAR_NO_WARN))
|
||||||
dialog_mesgbox("Disk slicing warning:", p, -1, -1);
|
xdialog_msgbox("Disk slicing warning:", p, -1, -1, 1);
|
||||||
free(p);
|
free(p);
|
||||||
|
dlg_restore_vars(&save_vars);
|
||||||
}
|
}
|
||||||
restorescr(w);
|
restorescr(w);
|
||||||
}
|
}
|
||||||
@ -804,7 +801,7 @@ diskPartitionEditor(dialogMenuItem *self)
|
|||||||
return DITEM_FAILURE;
|
return DITEM_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = dmenuOpenSimple(menu, FALSE) ? DITEM_SUCCESS : DITEM_FAILURE;
|
result = dmenuOpen(menu) ? DITEM_SUCCESS : DITEM_FAILURE;
|
||||||
free(menu);
|
free(menu);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -34,196 +34,6 @@
|
|||||||
|
|
||||||
#define MAX_MENU 15
|
#define MAX_MENU 15
|
||||||
|
|
||||||
static Boolean exited;
|
|
||||||
|
|
||||||
int
|
|
||||||
dmenuDisplayFile(dialogMenuItem *tmp)
|
|
||||||
{
|
|
||||||
systemDisplayHelp((char *)tmp->data);
|
|
||||||
return DITEM_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
dmenuSubmenu(dialogMenuItem *tmp)
|
|
||||||
{
|
|
||||||
return (dmenuOpenSimple((DMenu *)(tmp->data), FALSE) ? DITEM_SUCCESS : DITEM_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
dmenuSystemCommand(dialogMenuItem *self)
|
|
||||||
{
|
|
||||||
WINDOW *w = NULL; /* Keep lint happy */
|
|
||||||
|
|
||||||
/* If aux is set, the command is known not to produce any screen-spoiling output */
|
|
||||||
if (!self->aux)
|
|
||||||
w = savescr();
|
|
||||||
systemExecute((char *)self->data);
|
|
||||||
if (!self->aux)
|
|
||||||
restorescr(w);
|
|
||||||
return DITEM_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
dmenuSystemCommandBox(dialogMenuItem *tmp)
|
|
||||||
{
|
|
||||||
WINDOW *w = savescr();
|
|
||||||
|
|
||||||
use_helpfile(NULL);
|
|
||||||
use_helpline("Select OK to dismiss this dialog");
|
|
||||||
dialog_prgbox(tmp->title, (char *)tmp->data, 22, 76, 1, 1);
|
|
||||||
restorescr(w);
|
|
||||||
return DITEM_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
dmenuExit(dialogMenuItem *tmp)
|
|
||||||
{
|
|
||||||
exited = TRUE;
|
|
||||||
return DITEM_LEAVE_MENU;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
dmenuSetVariable(dialogMenuItem *tmp)
|
|
||||||
{
|
|
||||||
variable_set((char *)tmp->data, *((char *)tmp->data) != '_');
|
|
||||||
return DITEM_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
dmenuSetVariables(dialogMenuItem *tmp)
|
|
||||||
{
|
|
||||||
char *cp1, *cp2;
|
|
||||||
char *copy = strdup((char *)tmp->data);
|
|
||||||
|
|
||||||
for (cp1 = copy; cp1 != NULL;) {
|
|
||||||
cp2 = index(cp1, ',');
|
|
||||||
if (cp2 != NULL) *cp2++ = '\0';
|
|
||||||
variable_set(cp1, *cp1 != '_');
|
|
||||||
cp1 = cp2;
|
|
||||||
}
|
|
||||||
free(copy);
|
|
||||||
return DITEM_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
dmenuToggleVariable(dialogMenuItem *tmp)
|
|
||||||
{
|
|
||||||
char *var, *cp;
|
|
||||||
int status;
|
|
||||||
|
|
||||||
if (!(var = strdup((char *)tmp->data))) {
|
|
||||||
msgConfirm("Incorrect data field for `%s'!", tmp->title);
|
|
||||||
return DITEM_FAILURE;
|
|
||||||
}
|
|
||||||
if (!(cp = index(var, '='))) {
|
|
||||||
msgConfirm("Data field for %s is not in var=value format!", tmp->title);
|
|
||||||
return DITEM_FAILURE;
|
|
||||||
}
|
|
||||||
status = variable_check(var);
|
|
||||||
*cp = '\0';
|
|
||||||
variable_set2(var, status ? "NO" : "YES", *var != '_');
|
|
||||||
free(var);
|
|
||||||
return DITEM_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
dmenuISetVariable(dialogMenuItem *tmp)
|
|
||||||
{
|
|
||||||
char *ans, *var;
|
|
||||||
|
|
||||||
if (!(var = (char *)tmp->data)) {
|
|
||||||
msgConfirm("Incorrect data field for `%s'!", tmp->title);
|
|
||||||
return DITEM_FAILURE;
|
|
||||||
}
|
|
||||||
ans = msgGetInput(variable_get(var), tmp->title, 1);
|
|
||||||
if (!ans)
|
|
||||||
return DITEM_FAILURE;
|
|
||||||
else if (!*ans)
|
|
||||||
variable_unset(var);
|
|
||||||
else
|
|
||||||
variable_set2(var, ans, *var != '_');
|
|
||||||
return DITEM_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
dmenuSetFlag(dialogMenuItem *tmp)
|
|
||||||
{
|
|
||||||
if (*((unsigned int *)tmp->data) & tmp->aux)
|
|
||||||
*((unsigned int *)tmp->data) &= ~tmp->aux;
|
|
||||||
else
|
|
||||||
*((unsigned int *)tmp->data) |= tmp->aux;
|
|
||||||
return DITEM_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
dmenuSetValue(dialogMenuItem *tmp)
|
|
||||||
{
|
|
||||||
*((unsigned int *)tmp->data) = tmp->aux;
|
|
||||||
return DITEM_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Traverse menu but give user no control over positioning */
|
|
||||||
Boolean
|
|
||||||
dmenuOpenSimple(DMenu *menu, Boolean buttons)
|
|
||||||
{
|
|
||||||
int choice, scroll, curr, max;
|
|
||||||
|
|
||||||
choice = scroll = curr = max = 0;
|
|
||||||
return dmenuOpen(menu, &choice, &scroll, &curr, &max, buttons);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Work functions for the state hook */
|
|
||||||
int
|
|
||||||
dmenuFlagCheck(dialogMenuItem *item)
|
|
||||||
{
|
|
||||||
return (*((unsigned int *)item->data) & item->aux);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
dmenuVarCheck(dialogMenuItem *item)
|
|
||||||
{
|
|
||||||
char *w;
|
|
||||||
|
|
||||||
w = (char *)item->aux;
|
|
||||||
if (!w)
|
|
||||||
w = (char *)item->data;
|
|
||||||
return variable_check(w);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
dmenuVarsCheck(dialogMenuItem *item)
|
|
||||||
{
|
|
||||||
int res, init;
|
|
||||||
char *w, *cp1, *cp2;
|
|
||||||
char *copy;
|
|
||||||
|
|
||||||
w = (char *)item->aux;
|
|
||||||
if (!w)
|
|
||||||
w = (char *)item->data;
|
|
||||||
if (!w)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
copy = strdup(w);
|
|
||||||
res = TRUE;
|
|
||||||
init = FALSE;
|
|
||||||
for (cp1 = copy; cp1 != NULL;) {
|
|
||||||
init = TRUE;
|
|
||||||
cp2 = index(cp1, ',');
|
|
||||||
if (cp2 != NULL)
|
|
||||||
*cp2++ = '\0';
|
|
||||||
res = res && variable_check(cp1);
|
|
||||||
cp1 = cp2;
|
|
||||||
}
|
|
||||||
free(copy);
|
|
||||||
return res && init;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
dmenuRadioCheck(dialogMenuItem *item)
|
|
||||||
{
|
|
||||||
return (*((long *)item->data) == item->aux);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
menu_height(DMenu *menu, int n)
|
menu_height(DMenu *menu, int n)
|
||||||
{
|
{
|
||||||
@ -242,54 +52,42 @@ menu_height(DMenu *menu, int n)
|
|||||||
|
|
||||||
/* Traverse over an internal menu */
|
/* Traverse over an internal menu */
|
||||||
Boolean
|
Boolean
|
||||||
dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max, Boolean buttons)
|
dmenuOpen(DMenu *menu)
|
||||||
{
|
{
|
||||||
int n, rval = 0;
|
int n, rval = 0;
|
||||||
dialogMenuItem *items;
|
|
||||||
|
|
||||||
items = menu->items;
|
|
||||||
if (buttons)
|
|
||||||
items += 2;
|
|
||||||
/* Count up all the items */
|
/* Count up all the items */
|
||||||
for (n = 0; items[n].title; n++);
|
for (n = 0; menu->items[n].title; n++)
|
||||||
|
;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
char buf[FILENAME_MAX];
|
char buf[FILENAME_MAX];
|
||||||
|
DIALOG_VARS save_vars;
|
||||||
WINDOW *w = savescr();
|
WINDOW *w = savescr();
|
||||||
|
|
||||||
/* Any helpful hints, put 'em up! */
|
/* Any helpful hints, put 'em up! */
|
||||||
use_helpline(menu->helpline);
|
dlg_save_vars(&save_vars);
|
||||||
use_helpfile(systemHelpFile(menu->helpfile, buf));
|
dialog_vars.help_line = menu->helpline;
|
||||||
dialog_clear_norefresh();
|
dialog_vars.help_file = systemHelpFile(menu->helpfile, buf);
|
||||||
|
dlg_clear();
|
||||||
/* Pop up that dialog! */
|
/* Pop up that dialog! */
|
||||||
if (menu->type & DMENU_NORMAL_TYPE)
|
if (menu->type & DMENU_NORMAL_TYPE) {
|
||||||
rval = dialog_menu((u_char *)menu->title, (u_char *)menu->prompt,
|
rval = xdialog_menu(menu->title, menu->prompt,
|
||||||
-1, -1, menu_height(menu, n), -n, items,
|
-1, -1, menu_height(menu, n), n, menu->items);
|
||||||
(char *)(uintptr_t)buttons, choice, scroll);
|
} else if (menu->type & DMENU_RADIO_TYPE) {
|
||||||
|
rval = xdialog_radiolist(menu->title, menu->prompt,
|
||||||
else if (menu->type & DMENU_RADIO_TYPE)
|
-1, -1, menu_height(menu, n), n, menu->items);
|
||||||
rval = dialog_radiolist((u_char *)menu->title,
|
} else {
|
||||||
(u_char *)menu->prompt, -1, -1, menu_height(menu, n), -n,
|
|
||||||
items, (char *)(uintptr_t)buttons);
|
|
||||||
|
|
||||||
else if (menu->type & DMENU_CHECKLIST_TYPE)
|
|
||||||
rval = dialog_checklist((u_char *)menu->title,
|
|
||||||
(u_char *)menu->prompt, -1, -1, menu_height(menu, n), -n,
|
|
||||||
items, (char *)(uintptr_t)buttons);
|
|
||||||
else
|
|
||||||
msgFatal("Menu: `%s' is of an unknown type\n", menu->title);
|
msgFatal("Menu: `%s' is of an unknown type\n", menu->title);
|
||||||
if (exited) {
|
|
||||||
exited = FALSE;
|
|
||||||
restorescr(w);
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
else if (rval) {
|
dlg_restore_vars(&save_vars);
|
||||||
|
if (rval) {
|
||||||
restorescr(w);
|
restorescr(w);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
} else if (menu->type & DMENU_SELECTION_RETURNS) {
|
||||||
else if (menu->type & DMENU_SELECTION_RETURNS) {
|
|
||||||
restorescr(w);
|
restorescr(w);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
} else
|
||||||
|
delwin(w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sade.h"
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <sys/consio.h>
|
#include <sys/consio.h>
|
||||||
#include <sys/disklabel.h>
|
#include <sys/disklabel.h>
|
||||||
@ -51,6 +50,8 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
|
|
||||||
|
#include "sade.h"
|
||||||
|
|
||||||
#define TERMCAP_FILE "/usr/share/misc/termcap"
|
#define TERMCAP_FILE "/usr/share/misc/termcap"
|
||||||
|
|
||||||
Boolean
|
Boolean
|
||||||
@ -177,7 +178,7 @@ installFilesystems(Device *dev)
|
|||||||
sprintf(fname, "/dev/%s", c2->name);
|
sprintf(fname, "/dev/%s", c2->name);
|
||||||
i = (Fake || swapon(fname));
|
i = (Fake || swapon(fname));
|
||||||
if (!i) {
|
if (!i) {
|
||||||
dialog_clear_norefresh();
|
dlg_clear();
|
||||||
msgNotify("Added %s as an additional swap device", fname);
|
msgNotify("Added %s as an additional swap device", fname);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -209,7 +210,7 @@ installFilesystems(Device *dev)
|
|||||||
|
|
||||||
command_sort();
|
command_sort();
|
||||||
command_execute();
|
command_execute();
|
||||||
dialog_clear_norefresh();
|
dlg_clear();
|
||||||
return DITEM_SUCCESS | DITEM_RESTORE;
|
return DITEM_SUCCESS | DITEM_RESTORE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sade.h"
|
#include <sys/types.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <libdisk.h>
|
#include <libdisk.h>
|
||||||
@ -37,6 +37,8 @@
|
|||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
|
|
||||||
|
#include "sade.h"
|
||||||
|
|
||||||
#define AUTO_HOME 0 /* do not create /home automatically */
|
#define AUTO_HOME 0 /* do not create /home automatically */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -161,7 +163,7 @@ diskLabelEditor(dialogMenuItem *self)
|
|||||||
result = DITEM_FAILURE;
|
result = DITEM_FAILURE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result = dmenuOpenSimple(menu, FALSE) ? DITEM_SUCCESS : DITEM_FAILURE;
|
result = dmenuOpen(menu) ? DITEM_SUCCESS : DITEM_FAILURE;
|
||||||
free(menu);
|
free(menu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -417,9 +419,8 @@ get_mountpoint(PartType type, struct chunk *old)
|
|||||||
static PartType
|
static PartType
|
||||||
get_partition_type(void)
|
get_partition_type(void)
|
||||||
{
|
{
|
||||||
char selection[20];
|
|
||||||
int i;
|
int i;
|
||||||
static unsigned char *fs_types[] = {
|
static char *fs_types[] = {
|
||||||
#ifdef __ia64__
|
#ifdef __ia64__
|
||||||
"EFI", "An EFI system partition",
|
"EFI", "An EFI system partition",
|
||||||
#endif
|
#endif
|
||||||
@ -428,6 +429,7 @@ get_partition_type(void)
|
|||||||
};
|
};
|
||||||
WINDOW *w = savescr();
|
WINDOW *w = savescr();
|
||||||
|
|
||||||
|
dlg_clr_result();
|
||||||
i = dialog_menu("Please choose a partition type",
|
i = dialog_menu("Please choose a partition type",
|
||||||
"If you want to use this partition for swap space, select Swap.\n"
|
"If you want to use this partition for swap space, select Swap.\n"
|
||||||
"If you want to put a filesystem on it, choose FS.",
|
"If you want to put a filesystem on it, choose FS.",
|
||||||
@ -437,16 +439,16 @@ get_partition_type(void)
|
|||||||
#else
|
#else
|
||||||
2, 2,
|
2, 2,
|
||||||
#endif
|
#endif
|
||||||
fs_types, selection, NULL, NULL);
|
fs_types);
|
||||||
restorescr(w);
|
restorescr(w);
|
||||||
if (!i) {
|
if (!i) {
|
||||||
#ifdef __ia64__
|
#ifdef __ia64__
|
||||||
if (!strcmp(selection, "EFI"))
|
if (!strcmp(dialog_vars.input_result, "EFI"))
|
||||||
return PART_EFI;
|
return PART_EFI;
|
||||||
#endif
|
#endif
|
||||||
if (!strcmp(selection, "FS"))
|
if (!strcmp(dialog_vars.input_result, "FS"))
|
||||||
return PART_FILESYSTEM;
|
return PART_FILESYSTEM;
|
||||||
else if (!strcmp(selection, "Swap"))
|
else if (!strcmp(dialog_vars.input_result, "Swap"))
|
||||||
return PART_SWAP;
|
return PART_SWAP;
|
||||||
}
|
}
|
||||||
return PART_NONE;
|
return PART_NONE;
|
||||||
@ -1251,7 +1253,7 @@ diskLabel(Device *dev)
|
|||||||
if (!msgNoYes("Are you sure you want to go into Wizard mode?\n\n"
|
if (!msgNoYes("Are you sure you want to go into Wizard mode?\n\n"
|
||||||
"This is an entirely undocumented feature which you are not\n"
|
"This is an entirely undocumented feature which you are not\n"
|
||||||
"expected to understand!")) {
|
"expected to understand!")) {
|
||||||
dialog_clear();
|
dlg_clear();
|
||||||
end_dialog();
|
end_dialog();
|
||||||
DialogActive = FALSE;
|
DialogActive = FALSE;
|
||||||
if (dev->private) {
|
if (dev->private) {
|
||||||
|
@ -39,7 +39,7 @@ const char *ProgName = "sade";
|
|||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int choice, scroll, curr, max, status;
|
int status;
|
||||||
|
|
||||||
/* Record name to be able to restart */
|
/* Record name to be able to restart */
|
||||||
StartName = argv[0];
|
StartName = argv[0];
|
||||||
@ -77,7 +77,9 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
/* Try to preserve our scroll-back buffer */
|
/* Try to preserve our scroll-back buffer */
|
||||||
if (OnVTY) {
|
if (OnVTY) {
|
||||||
for (curr = 0; curr < 25; curr++)
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < 25; i++)
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
}
|
}
|
||||||
/* Move stderr aside */
|
/* Move stderr aside */
|
||||||
@ -105,10 +107,9 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Begin user dialog at outer menu */
|
/* Begin user dialog at outer menu */
|
||||||
dialog_clear();
|
dlg_clear();
|
||||||
while (1) {
|
while (1) {
|
||||||
choice = scroll = curr = max = 0;
|
dmenuOpen(&MenuMain);
|
||||||
dmenuOpen(&MenuMain, &choice, &scroll, &curr, &max, FALSE);
|
|
||||||
if (getpid() != 1
|
if (getpid() != 1
|
||||||
|| !msgNoYes("Are you sure you wish to exit?")
|
|| !msgNoYes("Are you sure you wish to exit?")
|
||||||
)
|
)
|
||||||
|
@ -53,7 +53,7 @@ DMenu MenuDiskDevices = {
|
|||||||
"Use [TAB] to get to the buttons and leave this menu.",
|
"Use [TAB] to get to the buttons and leave this menu.",
|
||||||
"Press F1 for important information regarding disk geometry!",
|
"Press F1 for important information regarding disk geometry!",
|
||||||
"drives",
|
"drives",
|
||||||
{ { NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0 } },
|
{ { NULL, NULL, NULL } },
|
||||||
};
|
};
|
||||||
|
|
||||||
DMenu MenuMain = {
|
DMenu MenuMain = {
|
||||||
@ -64,10 +64,10 @@ DMenu MenuMain = {
|
|||||||
"main",
|
"main",
|
||||||
{
|
{
|
||||||
#ifdef WITH_SLICES
|
#ifdef WITH_SLICES
|
||||||
{ "1 Partition", "Managing disk partitions", NULL, diskPartitionEditor, NULL, NULL, 0, 0, 0, 0 },
|
{ "1 Partition", "Managing disk partitions", diskPartitionEditor },
|
||||||
#endif
|
#endif
|
||||||
{ "2 Label", "Label allocated disk partitions", NULL, diskLabelEditor, NULL, NULL, 0, 0, 0, 0 },
|
{ "2 Label", "Label allocated disk partitions", diskLabelEditor },
|
||||||
{ NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0 }
|
{ NULL, NULL, NULL }
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -75,22 +75,20 @@ DMenu MenuMain = {
|
|||||||
#ifdef PC98
|
#ifdef PC98
|
||||||
/* IPL type menu */
|
/* IPL type menu */
|
||||||
DMenu MenuIPLType = {
|
DMenu MenuIPLType = {
|
||||||
DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
|
DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS,
|
||||||
"overwrite me", /* will be disk specific label */
|
"overwrite me", /* will be disk specific label */
|
||||||
"If you want a FreeBSD Boot Manager, select \"BootMgr\". If you would\n"
|
"If you want a FreeBSD Boot Manager, select \"BootMgr\". If you would\n"
|
||||||
"prefer your Boot Manager to remain untouched then select \"None\".\n\n",
|
"prefer your Boot Manager to remain untouched then select \"None\".\n\n",
|
||||||
"Press F1 to read about drive setup",
|
"Press F1 to read about drive setup",
|
||||||
"drives",
|
"drives",
|
||||||
{ { "BootMgr", "Install the FreeBSD Boot Manager",
|
{ { "BootMgr", "Install the FreeBSD Boot Manager", NULL },
|
||||||
dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, 0, 0, 0, 0 },
|
{ "None", "Leave the IPL untouched", NULL },
|
||||||
{ "None", "Leave the IPL untouched",
|
{ NULL, NULL, NULL } },
|
||||||
dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 1 },
|
|
||||||
{ NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0 } },
|
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
/* MBR type menu */
|
/* MBR type menu */
|
||||||
DMenu MenuMBRType = {
|
DMenu MenuMBRType = {
|
||||||
DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
|
DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS,
|
||||||
"overwrite me", /* will be disk specific label */
|
"overwrite me", /* will be disk specific label */
|
||||||
"FreeBSD comes with a boot manager that allows you to easily\n"
|
"FreeBSD comes with a boot manager that allows you to easily\n"
|
||||||
"select between FreeBSD and any other operating systems on your machine\n"
|
"select between FreeBSD and any other operating systems on your machine\n"
|
||||||
@ -99,18 +97,13 @@ DMenu MenuMBRType = {
|
|||||||
"to do so (limitations in the PC BIOS usually prevent this otherwise).\n"
|
"to do so (limitations in the PC BIOS usually prevent this otherwise).\n"
|
||||||
"If you have other operating systems installed and would like a choice when\n"
|
"If you have other operating systems installed and would like a choice when\n"
|
||||||
"booting, choose \"BootMgr\". If you would prefer to keep your existing\n"
|
"booting, choose \"BootMgr\". If you would prefer to keep your existing\n"
|
||||||
"boot manager, select \"None\".\n\n",
|
"boot manager, select \"None\".\n",
|
||||||
"",
|
"",
|
||||||
"drives",
|
"drives",
|
||||||
{ { "Standard", "Install a standard MBR (non-interactive boot manager)",
|
{ { "Standard", "Install a standard MBR (non-interactive boot manager)", NULL },
|
||||||
dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 1 },
|
{ "BootMgr", "Install the FreeBSD boot manager", NULL },
|
||||||
{ "BootMgr", "Install the FreeBSD boot manager",
|
{ "None", "Do not install a boot manager", NULL },
|
||||||
dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 0 },
|
{ NULL, NULL, NULL } }
|
||||||
{ "None", "Do not install a boot manager",
|
|
||||||
dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 2 },
|
|
||||||
{ NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0 } }
|
|
||||||
};
|
};
|
||||||
#endif /* PC98 */
|
#endif /* PC98 */
|
||||||
#endif /* __i386__ */
|
#endif /* __i386__ */
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sade.h"
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -47,6 +46,8 @@
|
|||||||
#include <sys/disklabel.h>
|
#include <sys/disklabel.h>
|
||||||
#include <fs/msdosfs/msdosfsmount.h>
|
#include <fs/msdosfs/msdosfsmount.h>
|
||||||
|
|
||||||
|
#include "sade.h"
|
||||||
|
|
||||||
/* Quick check to see if a file is readable */
|
/* Quick check to see if a file is readable */
|
||||||
Boolean
|
Boolean
|
||||||
file_readable(char *fname)
|
file_readable(char *fname)
|
||||||
@ -217,3 +218,192 @@ restorescr(WINDOW *w)
|
|||||||
delwin(w);
|
delwin(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
xdialog_count_rows(const char *p)
|
||||||
|
{
|
||||||
|
int rows = 0;
|
||||||
|
|
||||||
|
while ((p = strchr(p, '\n')) != NULL) {
|
||||||
|
p++;
|
||||||
|
if (*p == '\0')
|
||||||
|
break;
|
||||||
|
rows++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rows ? rows : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
xdialog_menu(const char *title, const char *cprompt, int height, int width,
|
||||||
|
int menu_height, int item_no, dialogMenuItem *ditems)
|
||||||
|
{
|
||||||
|
int i, result, choice = 0;
|
||||||
|
DIALOG_LISTITEM *listitems;
|
||||||
|
DIALOG_VARS save_vars;
|
||||||
|
|
||||||
|
dlg_save_vars(&save_vars);
|
||||||
|
|
||||||
|
/* initialize list items */
|
||||||
|
listitems = dlg_calloc(DIALOG_LISTITEM, item_no + 1);
|
||||||
|
assert_ptr(listitems, "xdialog_menu");
|
||||||
|
for (i = 0; i < item_no; i++) {
|
||||||
|
listitems[i].name = ditems[i].prompt;
|
||||||
|
listitems[i].text = ditems[i].title;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* calculate height */
|
||||||
|
if (height < 0)
|
||||||
|
height = xdialog_count_rows(cprompt) + menu_height + 4 + 2;
|
||||||
|
if (height > LINES)
|
||||||
|
height = LINES;
|
||||||
|
|
||||||
|
/* calculate width */
|
||||||
|
if (width < 0) {
|
||||||
|
int tag_x = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < item_no; i++) {
|
||||||
|
int j, l;
|
||||||
|
|
||||||
|
l = strlen(listitems[i].name);
|
||||||
|
for (j = 0; j < item_no; j++) {
|
||||||
|
int k = strlen(listitems[j].text);
|
||||||
|
tag_x = MAX(tag_x, l + k + 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
width = MAX(dlg_count_columns(cprompt), title != NULL ? dlg_count_columns(title) : 0);
|
||||||
|
width = MAX(width, tag_x + 4) + 4;
|
||||||
|
}
|
||||||
|
width = MAX(width, 24);
|
||||||
|
if (width > COLS)
|
||||||
|
width = COLS;
|
||||||
|
|
||||||
|
/* show menu */
|
||||||
|
dialog_vars.default_item = listitems[choice].name;
|
||||||
|
result = dlg_menu(title, cprompt, height, width,
|
||||||
|
menu_height, item_no, listitems, &choice, NULL);
|
||||||
|
switch (result) {
|
||||||
|
case DLG_EXIT_ESC:
|
||||||
|
result = -1;
|
||||||
|
break;
|
||||||
|
case DLG_EXIT_OK:
|
||||||
|
if (ditems[choice].fire != NULL) {
|
||||||
|
int status;
|
||||||
|
WINDOW *save;
|
||||||
|
|
||||||
|
save = savescr();
|
||||||
|
status = ditems[choice].fire(ditems + choice);
|
||||||
|
restorescr(save);
|
||||||
|
}
|
||||||
|
result = 0;
|
||||||
|
break;
|
||||||
|
case DLG_EXIT_CANCEL:
|
||||||
|
default:
|
||||||
|
result = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(listitems);
|
||||||
|
dlg_restore_vars(&save_vars);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
xdialog_radiolist(const char *title, const char *cprompt, int height, int width,
|
||||||
|
int menu_height, int item_no, dialogMenuItem *ditems)
|
||||||
|
{
|
||||||
|
int i, result, choice = 0;
|
||||||
|
DIALOG_LISTITEM *listitems;
|
||||||
|
DIALOG_VARS save_vars;
|
||||||
|
|
||||||
|
dlg_save_vars(&save_vars);
|
||||||
|
|
||||||
|
/* initialize list items */
|
||||||
|
listitems = dlg_calloc(DIALOG_LISTITEM, item_no + 1);
|
||||||
|
assert_ptr(listitems, "xdialog_menu");
|
||||||
|
for (i = 0; i < item_no; i++) {
|
||||||
|
listitems[i].name = ditems[i].prompt;
|
||||||
|
listitems[i].text = ditems[i].title;
|
||||||
|
listitems[i].state = i == choice;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* calculate height */
|
||||||
|
if (height < 0)
|
||||||
|
height = xdialog_count_rows(cprompt) + menu_height + 4 + 2;
|
||||||
|
if (height > LINES)
|
||||||
|
height = LINES;
|
||||||
|
|
||||||
|
/* calculate width */
|
||||||
|
if (width < 0) {
|
||||||
|
int check_x = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < item_no; i++) {
|
||||||
|
int j, l;
|
||||||
|
|
||||||
|
l = strlen(listitems[i].name);
|
||||||
|
for (j = 0; j < item_no; j++) {
|
||||||
|
int k = strlen(listitems[j].text);
|
||||||
|
check_x = MAX(check_x, l + k + 6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
width = MAX(dlg_count_columns(cprompt), title != NULL ? dlg_count_columns(title) : 0);
|
||||||
|
width = MAX(width, check_x + 4) + 4;
|
||||||
|
}
|
||||||
|
width = MAX(width, 24);
|
||||||
|
if (width > COLS)
|
||||||
|
width = COLS;
|
||||||
|
|
||||||
|
/* show menu */
|
||||||
|
dialog_vars.default_item = listitems[choice].name;
|
||||||
|
result = dlg_checklist(title, cprompt, height, width,
|
||||||
|
menu_height, item_no, listitems, NULL, FLAG_RADIO, &choice);
|
||||||
|
switch (result) {
|
||||||
|
case DLG_EXIT_ESC:
|
||||||
|
result = -1;
|
||||||
|
break;
|
||||||
|
case DLG_EXIT_OK:
|
||||||
|
if (ditems[choice].fire != NULL) {
|
||||||
|
int status;
|
||||||
|
WINDOW *save;
|
||||||
|
|
||||||
|
save = savescr();
|
||||||
|
status = ditems[choice].fire(ditems + choice);
|
||||||
|
restorescr(save);
|
||||||
|
}
|
||||||
|
result = 0;
|
||||||
|
break;
|
||||||
|
case DLG_EXIT_CANCEL:
|
||||||
|
default:
|
||||||
|
result = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* save result */
|
||||||
|
if (result == 0)
|
||||||
|
dlg_add_result(listitems[choice].name);
|
||||||
|
free(listitems);
|
||||||
|
dlg_restore_vars(&save_vars);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
xdialog_msgbox(const char *title, const char *cprompt,
|
||||||
|
int height, int width, int pauseopt)
|
||||||
|
{
|
||||||
|
/* calculate height */
|
||||||
|
if (height < 0)
|
||||||
|
height = 2 + xdialog_count_rows(cprompt) + 2 + !!pauseopt;
|
||||||
|
if (height > LINES)
|
||||||
|
height = LINES;
|
||||||
|
|
||||||
|
/* calculate width */
|
||||||
|
if (width < 0) {
|
||||||
|
width = title != NULL ? dlg_count_columns(title) : 0;
|
||||||
|
width = MAX(width, dlg_count_columns(cprompt)) + 4;
|
||||||
|
}
|
||||||
|
if (pauseopt)
|
||||||
|
width = MAX(width, 10);
|
||||||
|
if (width > COLS)
|
||||||
|
width = COLS;
|
||||||
|
|
||||||
|
return dialog_msgbox(title, cprompt, height, width, pauseopt);
|
||||||
|
}
|
||||||
|
@ -184,13 +184,16 @@ msgConfirm(const char *fmt, ...)
|
|||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
vsnprintf(errstr, FILENAME_MAX, fmt, args);
|
vsnprintf(errstr, FILENAME_MAX, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
use_helpline(NULL);
|
dialog_vars.help_line = NULL;
|
||||||
use_helpfile(NULL);
|
dialog_vars.help_file = NULL;
|
||||||
if (OnVTY) {
|
if (OnVTY) {
|
||||||
ioctl(0, VT_ACTIVATE, 1);
|
ioctl(0, VT_ACTIVATE, 1);
|
||||||
msgInfo(NULL);
|
msgInfo(NULL);
|
||||||
}
|
}
|
||||||
dialog_notify(errstr);
|
dialog_vars.help_line = "Press Enter or Space";
|
||||||
|
xdialog_msgbox("Message", errstr, -1, -1, 1);
|
||||||
|
dialog_vars.help_line = NULL;
|
||||||
|
|
||||||
restorescr(w);
|
restorescr(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,11 +208,11 @@ msgNotify(const char *fmt, ...)
|
|||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
vsnprintf(errstr, FILENAME_MAX, fmt, args);
|
vsnprintf(errstr, FILENAME_MAX, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
use_helpline(NULL);
|
dialog_vars.help_line = NULL;
|
||||||
use_helpfile(NULL);
|
dialog_vars.help_file = NULL;
|
||||||
if (isDebug())
|
if (isDebug())
|
||||||
msgDebug("Notify: %s\n", errstr);
|
msgDebug("Notify: %s\n", errstr);
|
||||||
dialog_msgbox(NULL, errstr, -1, -1, 0);
|
xdialog_msgbox(NULL, errstr, -1, -1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Put up a message in a popup yes/no box and return 0 for YES, 1 for NO */
|
/* Put up a message in a popup yes/no box and return 0 for YES, 1 for NO */
|
||||||
@ -225,8 +228,8 @@ msgYesNo(const char *fmt, ...)
|
|||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
vsnprintf(errstr, FILENAME_MAX, fmt, args);
|
vsnprintf(errstr, FILENAME_MAX, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
use_helpline(NULL);
|
dialog_vars.help_line = NULL;
|
||||||
use_helpfile(NULL);
|
dialog_vars.help_file = NULL;
|
||||||
if (OnVTY) {
|
if (OnVTY) {
|
||||||
ioctl(0, VT_ACTIVATE, 1); /* Switch back */
|
ioctl(0, VT_ACTIVATE, 1); /* Switch back */
|
||||||
msgInfo(NULL);
|
msgInfo(NULL);
|
||||||
@ -246,20 +249,24 @@ msgNoYes(const char *fmt, ...)
|
|||||||
char *errstr;
|
char *errstr;
|
||||||
int ret;
|
int ret;
|
||||||
WINDOW *w = savescr();
|
WINDOW *w = savescr();
|
||||||
|
DIALOG_VARS save_vars;
|
||||||
|
|
||||||
errstr = (char *)alloca(FILENAME_MAX);
|
errstr = (char *)alloca(FILENAME_MAX);
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
vsnprintf(errstr, FILENAME_MAX, fmt, args);
|
vsnprintf(errstr, FILENAME_MAX, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
use_helpline(NULL);
|
dialog_vars.help_line = NULL;
|
||||||
use_helpfile(NULL);
|
dialog_vars.help_file = NULL;
|
||||||
if (OnVTY) {
|
if (OnVTY) {
|
||||||
ioctl(0, VT_ACTIVATE, 1); /* Switch back */
|
ioctl(0, VT_ACTIVATE, 1); /* Switch back */
|
||||||
msgInfo(NULL);
|
msgInfo(NULL);
|
||||||
}
|
}
|
||||||
if (variable_get(VAR_NONINTERACTIVE))
|
if (variable_get(VAR_NONINTERACTIVE))
|
||||||
return 1; /* If non-interactive, return NO all the time */
|
return 1; /* If non-interactive, return NO all the time */
|
||||||
ret = dialog_noyes("User Confirmation Requested", errstr, -1, -1);
|
dlg_save_vars(&save_vars);
|
||||||
|
dialog_vars.defaultno = TRUE;
|
||||||
|
ret = dialog_yesno("User Confirmation Requested", errstr, -1, -1);
|
||||||
|
dlg_restore_vars(&save_vars);
|
||||||
restorescr(w);
|
restorescr(w);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -278,8 +285,8 @@ msgGetInput(char *buf, const char *fmt, ...)
|
|||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
vsnprintf(errstr, FILENAME_MAX, fmt, args);
|
vsnprintf(errstr, FILENAME_MAX, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
use_helpline(NULL);
|
dialog_vars.help_line = NULL;
|
||||||
use_helpfile(NULL);
|
dialog_vars.help_file = NULL;
|
||||||
if (buf)
|
if (buf)
|
||||||
SAFE_STRCPY(input_buffer, buf);
|
SAFE_STRCPY(input_buffer, buf);
|
||||||
else
|
else
|
||||||
@ -288,10 +295,10 @@ msgGetInput(char *buf, const char *fmt, ...)
|
|||||||
ioctl(0, VT_ACTIVATE, 1); /* Switch back */
|
ioctl(0, VT_ACTIVATE, 1); /* Switch back */
|
||||||
msgInfo(NULL);
|
msgInfo(NULL);
|
||||||
}
|
}
|
||||||
rval = dialog_inputbox("Value Required", errstr, -1, -1, input_buffer);
|
rval = dialog_inputbox("Value Required", errstr, -1, -1, input_buffer, 0);
|
||||||
restorescr(w);
|
restorescr(w);
|
||||||
if (!rval)
|
if (!rval)
|
||||||
return input_buffer;
|
return dialog_vars.input_result;
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -325,12 +332,12 @@ msgWeHaveOutput(const char *fmt, ...)
|
|||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
vsnprintf(errstr, FILENAME_MAX, fmt, args);
|
vsnprintf(errstr, FILENAME_MAX, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
use_helpline(NULL);
|
dialog_vars.help_line = NULL;
|
||||||
use_helpfile(NULL);
|
dialog_vars.help_file = NULL;
|
||||||
msgDebug("Notify: %s\n", errstr);
|
msgDebug("Notify: %s\n", errstr);
|
||||||
dialog_clear_norefresh();
|
dlg_clear();
|
||||||
sleep(2);
|
sleep(2);
|
||||||
dialog_msgbox(NULL, errstr, -1, -1, 0);
|
xdialog_msgbox(NULL, errstr, -1, -1, 0);
|
||||||
restorescr(w);
|
restorescr(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,10 +130,25 @@ typedef int Boolean;
|
|||||||
typedef struct disk Disk;
|
typedef struct disk Disk;
|
||||||
typedef struct chunk Chunk;
|
typedef struct chunk Chunk;
|
||||||
|
|
||||||
|
/* special return codes for `fire' actions */
|
||||||
|
#define DITEM_STATUS(flag) ((flag) & 0x0000FFFF)
|
||||||
|
#define DITEM_SUCCESS 0
|
||||||
|
#define DITEM_FAILURE 1
|
||||||
|
|
||||||
|
/* flags - returned in upper 16 bits of return status */
|
||||||
|
#define DITEM_LEAVE_MENU (1 << 16)
|
||||||
|
#define DITEM_RESTORE (1 << 19)
|
||||||
|
|
||||||
|
/* for use in describing more exotic behaviors */
|
||||||
|
typedef struct _dmenu_item {
|
||||||
|
char *prompt;
|
||||||
|
char *title;
|
||||||
|
int (*fire)(struct _dmenu_item *self);
|
||||||
|
} dialogMenuItem;
|
||||||
|
|
||||||
/* Bitfields for menu options */
|
/* Bitfields for menu options */
|
||||||
#define DMENU_NORMAL_TYPE 0x1 /* Normal dialog menu */
|
#define DMENU_NORMAL_TYPE 0x1 /* Normal dialog menu */
|
||||||
#define DMENU_RADIO_TYPE 0x2 /* Radio dialog menu */
|
#define DMENU_RADIO_TYPE 0x2 /* Radio dialog menu */
|
||||||
#define DMENU_CHECKLIST_TYPE 0x4 /* Multiple choice menu */
|
|
||||||
#define DMENU_SELECTION_RETURNS 0x8 /* Immediate return on item selection */
|
#define DMENU_SELECTION_RETURNS 0x8 /* Immediate return on item selection */
|
||||||
|
|
||||||
typedef struct _dmenu {
|
typedef struct _dmenu {
|
||||||
@ -332,22 +347,8 @@ extern int dispatch_load_file_int(int);
|
|||||||
extern int dispatch_load_file(dialogMenuItem *self);
|
extern int dispatch_load_file(dialogMenuItem *self);
|
||||||
|
|
||||||
/* dmenu.c */
|
/* dmenu.c */
|
||||||
extern int dmenuDisplayFile(dialogMenuItem *tmp);
|
|
||||||
extern int dmenuSubmenu(dialogMenuItem *tmp);
|
|
||||||
extern int dmenuSystemCommand(dialogMenuItem *tmp);
|
|
||||||
extern int dmenuSystemCommandBox(dialogMenuItem *tmp);
|
|
||||||
extern int dmenuExit(dialogMenuItem *tmp);
|
|
||||||
extern int dmenuISetVariable(dialogMenuItem *tmp);
|
|
||||||
extern int dmenuSetVariable(dialogMenuItem *tmp);
|
|
||||||
extern int dmenuSetVariables(dialogMenuItem *tmp);
|
|
||||||
extern int dmenuToggleVariable(dialogMenuItem *tmp);
|
|
||||||
extern int dmenuSetFlag(dialogMenuItem *tmp);
|
|
||||||
extern int dmenuSetValue(dialogMenuItem *tmp);
|
extern int dmenuSetValue(dialogMenuItem *tmp);
|
||||||
extern Boolean dmenuOpen(DMenu *menu, int *choice, int *bscroll, int *curr, int *max, Boolean buttons);
|
extern Boolean dmenuOpen(DMenu *menu);
|
||||||
extern Boolean dmenuOpenSimple(DMenu *menu, Boolean buttons);
|
|
||||||
extern int dmenuVarCheck(dialogMenuItem *item);
|
|
||||||
extern int dmenuVarsCheck(dialogMenuItem *item);
|
|
||||||
extern int dmenuFlagCheck(dialogMenuItem *item);
|
|
||||||
extern int dmenuRadioCheck(dialogMenuItem *item);
|
extern int dmenuRadioCheck(dialogMenuItem *item);
|
||||||
|
|
||||||
/* dos.c */
|
/* dos.c */
|
||||||
@ -389,6 +390,15 @@ extern WINDOW *savescr(void);
|
|||||||
extern void restorescr(WINDOW *w);
|
extern void restorescr(WINDOW *w);
|
||||||
extern char *sstrncpy(char *dst, const char *src, int size);
|
extern char *sstrncpy(char *dst, const char *src, int size);
|
||||||
|
|
||||||
|
extern int xdialog_menu(const char *title, const char *cprompt,
|
||||||
|
int height, int width, int menu_height,
|
||||||
|
int item_no, dialogMenuItem *ditems);
|
||||||
|
extern int xdialog_radiolist(const char *title, const char *cprompt,
|
||||||
|
int height, int width, int menu_height,
|
||||||
|
int item_no, dialogMenuItem *ditems);
|
||||||
|
extern int xdialog_msgbox(const char *title, const char *cprompt,
|
||||||
|
int height, int width, int pauseopt);
|
||||||
|
|
||||||
/* msg.c */
|
/* msg.c */
|
||||||
extern Boolean isDebug(void);
|
extern Boolean isDebug(void);
|
||||||
extern void msgInfo(const char *fmt, ...) __printf0like(1, 2);
|
extern void msgInfo(const char *fmt, ...) __printf0like(1, 2);
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
* Heck, get him completely drunk and send me pictures! :-)
|
* Heck, get him completely drunk and send me pictures! :-)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sade.h"
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
@ -24,6 +23,7 @@
|
|||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <ufs/ufs/ufsmount.h>
|
#include <ufs/ufs/ufsmount.h>
|
||||||
|
|
||||||
|
#include "sade.h"
|
||||||
|
|
||||||
/* Where we stick our temporary expanded doc file */
|
/* Where we stick our temporary expanded doc file */
|
||||||
#define DOC_TMP_DIR "/tmp/.doc"
|
#define DOC_TMP_DIR "/tmp/.doc"
|
||||||
@ -56,8 +56,8 @@ intr_restart(dialogMenuItem *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static dialogMenuItem intrmenu[] = {
|
static dialogMenuItem intrmenu[] = {
|
||||||
{ "Restart", "Restart the program", NULL, intr_restart, NULL, NULL, 0, 0, 0, 0 },
|
{ "Restart", "Restart the program", intr_restart },
|
||||||
{ "Continue", "Continue without restarting", NULL, intr_continue, NULL, NULL, 0, 0, 0, 0 },
|
{ "Continue", "Continue without restarting", intr_continue },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -66,15 +66,15 @@ handle_intr(int sig)
|
|||||||
{
|
{
|
||||||
WINDOW *save = savescr();
|
WINDOW *save = savescr();
|
||||||
|
|
||||||
use_helpline(NULL);
|
dialog_vars.help_line = NULL;
|
||||||
use_helpfile(NULL);
|
dialog_vars.help_file = NULL;
|
||||||
if (OnVTY) {
|
if (OnVTY) {
|
||||||
ioctl(0, VT_ACTIVATE, 1); /* Switch back */
|
ioctl(0, VT_ACTIVATE, 1); /* Switch back */
|
||||||
msgInfo(NULL);
|
msgInfo(NULL);
|
||||||
}
|
}
|
||||||
(void)dialog_menu("Installation interrupt",
|
(void)xdialog_menu("Installation interrupt",
|
||||||
"Do you want to abort the installation?",
|
"Do you want to abort the installation?",
|
||||||
-1, -1, 2, -2, intrmenu, NULL, NULL, NULL);
|
-1, -1, 2, 2, intrmenu);
|
||||||
restorescr(save);
|
restorescr(save);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ systemInitialize(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* XXX - libdialog has particularly bad return value checking */
|
/* XXX - libdialog has particularly bad return value checking */
|
||||||
init_dialog();
|
init_dialog(stdin, stdout);
|
||||||
|
|
||||||
/* If we haven't crashed I guess dialog is running ! */
|
/* If we haven't crashed I guess dialog is running ! */
|
||||||
DialogActive = TRUE;
|
DialogActive = TRUE;
|
||||||
@ -146,8 +146,7 @@ systemExecute(char *command)
|
|||||||
struct termios foo;
|
struct termios foo;
|
||||||
WINDOW *w = savescr();
|
WINDOW *w = savescr();
|
||||||
|
|
||||||
dialog_clear();
|
dlg_clear();
|
||||||
dialog_update();
|
|
||||||
end_dialog();
|
end_dialog();
|
||||||
DialogActive = FALSE;
|
DialogActive = FALSE;
|
||||||
if (tcgetattr(0, &foo) != -1) {
|
if (tcgetattr(0, &foo) != -1) {
|
||||||
@ -173,8 +172,7 @@ systemSuspendDialog(void)
|
|||||||
{
|
{
|
||||||
|
|
||||||
oldW = savescr();
|
oldW = savescr();
|
||||||
dialog_clear();
|
dlg_clear();
|
||||||
dialog_update();
|
|
||||||
end_dialog();
|
end_dialog();
|
||||||
DialogActive = FALSE;
|
DialogActive = FALSE;
|
||||||
}
|
}
|
||||||
@ -196,18 +194,17 @@ systemDisplayHelp(char *file)
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
WINDOW *w = savescr();
|
WINDOW *w = savescr();
|
||||||
|
|
||||||
printf("zzz");
|
|
||||||
fname = systemHelpFile(file, buf);
|
fname = systemHelpFile(file, buf);
|
||||||
if (!fname) {
|
if (!fname) {
|
||||||
snprintf(buf, FILENAME_MAX, "The %s file is not provided on this particular floppy image.", file);
|
snprintf(buf, FILENAME_MAX, "The %s file is not provided on this particular floppy image.", file);
|
||||||
use_helpfile(NULL);
|
dialog_vars.help_line = NULL;
|
||||||
use_helpline(NULL);
|
dialog_vars.help_file = NULL;
|
||||||
dialog_mesgbox("Sorry!", buf, -1, -1);
|
xdialog_msgbox("Sorry!", buf, -1, -1, 1);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
use_helpfile(NULL);
|
dialog_vars.help_line = NULL;
|
||||||
use_helpline(NULL);
|
dialog_vars.help_file = NULL;
|
||||||
dialog_textbox(file, fname, LINES, COLS);
|
dialog_textbox(file, fname, LINES, COLS);
|
||||||
}
|
}
|
||||||
restorescr(w);
|
restorescr(w);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user