1995-10-04 07:55:05 +00:00
|
|
|
/*
|
|
|
|
* The new sysinstall program.
|
|
|
|
*
|
|
|
|
* This is probably the last attempt in the `sysinstall' line, the next
|
|
|
|
* generation being slated for what's essentially a complete rewrite.
|
|
|
|
*
|
1995-10-26 08:11:24 +00:00
|
|
|
* $Id: options.c,v 1.23 1995/10/22 01:32:57 jkh Exp $
|
1995-10-04 07:55:05 +00:00
|
|
|
*
|
|
|
|
* Copyright (c) 1995
|
|
|
|
* Jordan Hubbard. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer,
|
|
|
|
* verbatim and that no modifications are made prior to this
|
|
|
|
* point in the file.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Jordan Hubbard
|
|
|
|
* for the FreeBSD Project.
|
|
|
|
* 4. The name of Jordan Hubbard or the FreeBSD project may not be used to
|
|
|
|
* endorse or promote products derived from this software without specific
|
|
|
|
* prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "sysinstall.h"
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
static char *
|
1995-10-16 15:14:28 +00:00
|
|
|
varCheck(Option opt)
|
1995-10-04 07:55:05 +00:00
|
|
|
{
|
1995-10-21 16:44:24 +00:00
|
|
|
char *cp = NULL;
|
|
|
|
|
1995-10-16 15:14:28 +00:00
|
|
|
if (opt.aux)
|
1995-10-21 16:44:24 +00:00
|
|
|
cp = variable_get((char *)opt.aux);
|
|
|
|
if (!cp)
|
|
|
|
return "NO";
|
|
|
|
return cp;
|
1995-10-04 07:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Show our little logo */
|
|
|
|
static char *
|
|
|
|
resetLogo(char *str)
|
|
|
|
{
|
1995-10-18 00:12:55 +00:00
|
|
|
return "[WHAP!]";
|
1995-10-04 07:55:05 +00:00
|
|
|
}
|
|
|
|
|
1995-10-19 18:37:50 +00:00
|
|
|
static char *
|
|
|
|
mediaCheck(Option opt)
|
|
|
|
{
|
|
|
|
if (mediaDevice) {
|
|
|
|
switch(mediaDevice->type) {
|
|
|
|
case DEVICE_TYPE_UFS:
|
|
|
|
case DEVICE_TYPE_DISK:
|
|
|
|
return "File system";
|
|
|
|
|
|
|
|
case DEVICE_TYPE_FLOPPY:
|
|
|
|
return "Floppy";
|
|
|
|
|
|
|
|
case DEVICE_TYPE_FTP:
|
|
|
|
return "FTP";
|
|
|
|
|
|
|
|
case DEVICE_TYPE_CDROM:
|
|
|
|
return "CDROM";
|
|
|
|
|
|
|
|
case DEVICE_TYPE_TAPE:
|
|
|
|
return "Tape";
|
|
|
|
|
|
|
|
case DEVICE_TYPE_DOS:
|
|
|
|
return "DOS";
|
|
|
|
|
|
|
|
case DEVICE_TYPE_NFS:
|
|
|
|
return "NFS";
|
1995-10-20 07:02:53 +00:00
|
|
|
|
|
|
|
case DEVICE_TYPE_NONE:
|
|
|
|
case DEVICE_TYPE_NETWORK:
|
|
|
|
case DEVICE_TYPE_ANY:
|
|
|
|
default:
|
|
|
|
return "<unknown>";
|
1995-10-19 18:37:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return "<unset>";
|
|
|
|
}
|
|
|
|
|
1995-10-21 16:44:24 +00:00
|
|
|
#define TAPE_PROMPT "Please enter the tape block size in 512 byte blocks"
|
|
|
|
#define RELNAME_PROMPT "Please specify the release you wish to load"
|
|
|
|
#define BPKG_PROMPT "Please specify the name of the HTML browser package:"
|
|
|
|
#define BBIN_PROMPT "Please specify a full pathname to the HTML browser binary:"
|
|
|
|
#define CONFIG_PROMPT "Please specify the name of a configuration file"
|
|
|
|
|
1995-10-04 07:55:05 +00:00
|
|
|
static Option Options[] = {
|
|
|
|
{ "NFS Secure", "NFS server talks only on a secure port",
|
1995-10-22 01:33:02 +00:00
|
|
|
OPT_IS_VAR, NULL, VAR_NFS_SECURE, varCheck },
|
1995-10-04 07:55:05 +00:00
|
|
|
{ "NFS Slow", "User is using a slow PC or ethernet card",
|
1995-10-22 01:33:02 +00:00
|
|
|
OPT_IS_VAR, NULL, VAR_SLOW_ETHER, varCheck },
|
1995-10-18 00:12:55 +00:00
|
|
|
{ "Debugging", "Emit extra debugging output on VTY2 (ALT-F2)",
|
1995-10-22 01:33:02 +00:00
|
|
|
OPT_IS_VAR, NULL, VAR_DEBUG, varCheck },
|
1995-10-04 07:55:05 +00:00
|
|
|
{ "Yes to All", "Assume \"Yes\" answers to all non-critical dialogs",
|
1995-10-22 01:33:02 +00:00
|
|
|
OPT_IS_VAR, NULL, VAR_NO_CONFIRM, varCheck },
|
1995-10-21 14:07:02 +00:00
|
|
|
{ "FTP OnError", "What to do when FTP requests fail: abort, retry, reselect.",
|
1995-10-22 01:33:02 +00:00
|
|
|
OPT_IS_FUNC, mediaSetFtpOnError, VAR_FTP_ONERROR, varCheck },
|
1995-10-26 08:11:24 +00:00
|
|
|
{ "FTP Retries", "If FTP OnError == retry, this is the number of times to try.",
|
|
|
|
OPT_IS_VAR, NULL, VAR_FTP_RETRIES, varCheck },
|
1995-10-04 07:55:05 +00:00
|
|
|
{ "FTP username", "Username and password to use instead of anonymous",
|
1995-10-22 01:33:02 +00:00
|
|
|
OPT_IS_FUNC, mediaSetFtpUserPass, VAR_FTP_USER, varCheck },
|
1995-10-04 07:55:05 +00:00
|
|
|
{ "Tape Blocksize", "Tape media block size in 512 byte blocks",
|
1995-10-22 01:33:02 +00:00
|
|
|
OPT_IS_VAR, TAPE_PROMPT, VAR_TAPE_BLOCKSIZE, varCheck },
|
1995-10-18 00:12:55 +00:00
|
|
|
{ "Extract Detail", "How verbosely to display file name information during extractions",
|
1995-10-22 01:33:02 +00:00
|
|
|
OPT_IS_FUNC, mediaSetCPIOVerbosity, VAR_CPIO_VERBOSITY, varCheck },
|
1995-10-04 07:55:05 +00:00
|
|
|
{ "Release Name", "Which release to attempt to load from installation media",
|
1995-10-22 01:33:02 +00:00
|
|
|
OPT_IS_VAR, RELNAME_PROMPT, VAR_RELNAME, varCheck },
|
1995-10-17 02:57:11 +00:00
|
|
|
{ "Browser Pkg", "This is the browser package that will be used for viewing HTML",
|
1995-10-22 01:33:02 +00:00
|
|
|
OPT_IS_VAR, BPKG_PROMPT, VAR_BROWSER_PACKAGE, varCheck },
|
1995-10-17 02:57:11 +00:00
|
|
|
{ "Browser Exec", "This is the path to the main binary of the browser package",
|
1995-10-22 01:33:02 +00:00
|
|
|
OPT_IS_VAR, BBIN_PROMPT, VAR_BROWSER_BINARY, varCheck },
|
1995-10-18 00:12:55 +00:00
|
|
|
{ "Config File", "Name of default configuration file for Load command (top menu)",
|
1995-10-22 01:33:02 +00:00
|
|
|
OPT_IS_VAR, CONFIG_PROMPT, VAR_CONFIG_FILE, varCheck },
|
1995-10-20 07:02:53 +00:00
|
|
|
{ "Media Type", "The current installation media type.",
|
1995-10-22 01:33:02 +00:00
|
|
|
OPT_IS_FUNC, mediaGetType, VAR_MEDIA_TYPE, mediaCheck },
|
1995-10-18 05:02:02 +00:00
|
|
|
{ "Use Defaults", "Reset all values to startup defaults",
|
1995-10-18 00:12:55 +00:00
|
|
|
OPT_IS_FUNC, installVarDefaults, 0, resetLogo },
|
1995-10-04 07:55:05 +00:00
|
|
|
{ NULL },
|
|
|
|
};
|
|
|
|
|
|
|
|
#define OPT_START_ROW 4
|
|
|
|
#define OPT_END_ROW 20
|
|
|
|
#define OPT_NAME_COL 0
|
|
|
|
#define OPT_VALUE_COL 16
|
1995-10-04 10:34:08 +00:00
|
|
|
#define GROUP_OFFSET 40
|
1995-10-04 07:55:05 +00:00
|
|
|
|
|
|
|
static char *
|
|
|
|
value_of(Option opt)
|
|
|
|
{
|
|
|
|
static char ival[40];
|
|
|
|
|
|
|
|
switch (opt.type) {
|
|
|
|
case OPT_IS_STRING:
|
|
|
|
return (char *)opt.data;
|
|
|
|
|
|
|
|
case OPT_IS_INT:
|
|
|
|
sprintf(ival, "%d", (int)opt.data);
|
|
|
|
return ival;
|
|
|
|
|
|
|
|
case OPT_IS_FUNC:
|
1995-10-18 00:12:55 +00:00
|
|
|
case OPT_IS_VAR:
|
1995-10-04 07:55:05 +00:00
|
|
|
if (opt.check)
|
|
|
|
return opt.check(opt);
|
|
|
|
else
|
|
|
|
return "<*>";
|
|
|
|
}
|
|
|
|
return "<unknown>";
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
fire(Option opt)
|
|
|
|
{
|
1995-10-21 16:44:24 +00:00
|
|
|
if (opt.type == OPT_IS_FUNC) {
|
1995-10-04 07:55:05 +00:00
|
|
|
int (*cp)(char *) = opt.data;
|
|
|
|
|
|
|
|
cp(NULL);
|
|
|
|
}
|
1995-10-18 00:12:55 +00:00
|
|
|
else if (opt.type == OPT_IS_VAR) {
|
1995-10-21 16:44:24 +00:00
|
|
|
if (opt.data) {
|
|
|
|
(void)variable_get_value(opt.aux, opt.data);
|
|
|
|
dialog_clear();
|
|
|
|
}
|
|
|
|
else if (variable_get(opt.aux))
|
|
|
|
variable_unset(opt.aux);
|
|
|
|
else
|
|
|
|
variable_set2(opt.aux, "YES");
|
1995-10-18 00:12:55 +00:00
|
|
|
}
|
1995-10-04 07:55:05 +00:00
|
|
|
if (opt.check)
|
|
|
|
opt.check(opt);
|
1995-10-19 18:37:50 +00:00
|
|
|
clear();
|
|
|
|
refresh();
|
1995-10-04 07:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
optionsEditor(char *str)
|
|
|
|
{
|
|
|
|
int i, optcol, optrow, key;
|
|
|
|
static int currOpt = 0;
|
|
|
|
|
1995-10-11 00:54:01 +00:00
|
|
|
dialog_clear();
|
1995-10-04 07:55:05 +00:00
|
|
|
clear();
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
/* Whap up the header */
|
1995-10-04 10:34:08 +00:00
|
|
|
attrset(A_REVERSE); mvaddstr(0, 0, "Options Editor"); attrset(A_NORMAL);
|
1995-10-04 07:55:05 +00:00
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
mvaddstr(OPT_START_ROW - 2, OPT_NAME_COL + (i * GROUP_OFFSET), "Name");
|
|
|
|
mvaddstr(OPT_START_ROW - 1, OPT_NAME_COL + (i * GROUP_OFFSET), "----");
|
|
|
|
|
|
|
|
mvaddstr(OPT_START_ROW - 2, OPT_VALUE_COL + (i * GROUP_OFFSET), "Value");
|
|
|
|
mvaddstr(OPT_START_ROW - 1, OPT_VALUE_COL + (i * GROUP_OFFSET), "-----");
|
|
|
|
}
|
|
|
|
/* And the footer */
|
|
|
|
mvprintw(OPT_END_ROW + 0, 0, "Use SPACE to select/toggle an option, arrow keys to move,");
|
|
|
|
mvprintw(OPT_END_ROW + 1, 0, "? or F1 for more help. When you're done, type Q to Quit.");
|
|
|
|
|
|
|
|
optrow = OPT_START_ROW;
|
|
|
|
optcol = OPT_NAME_COL;
|
|
|
|
for (i = 0; Options[i].name; i++) {
|
|
|
|
/* Names are painted somewhat gratuitously each time, but it's easier this way */
|
|
|
|
mvprintw(optrow, OPT_NAME_COL + optcol, Options[i].name);
|
|
|
|
if (currOpt == i) standout();
|
|
|
|
mvprintw(optrow++, OPT_VALUE_COL + optcol, value_of(Options[i]));
|
|
|
|
if (currOpt == i) standend();
|
|
|
|
if (optrow == OPT_END_ROW) {
|
|
|
|
optrow = OPT_START_ROW;
|
|
|
|
optcol += GROUP_OFFSET;
|
|
|
|
}
|
|
|
|
clrtoeol();
|
|
|
|
}
|
1995-10-06 08:47:40 +00:00
|
|
|
standout();
|
1995-10-04 07:55:05 +00:00
|
|
|
mvaddstr(OPT_END_ROW + 3, 0, Options[currOpt].desc);
|
1995-10-06 08:47:40 +00:00
|
|
|
standend();
|
1995-10-04 07:55:05 +00:00
|
|
|
clrtoeol();
|
1995-10-04 10:34:08 +00:00
|
|
|
move(0, 14);
|
1995-10-06 08:47:40 +00:00
|
|
|
|
1995-10-04 07:55:05 +00:00
|
|
|
/* Start the edit loop */
|
|
|
|
key = toupper(getch());
|
|
|
|
switch (key) {
|
|
|
|
case KEY_F(1):
|
|
|
|
case '?':
|
1995-10-19 15:57:23 +00:00
|
|
|
systemDisplayHelp("options");
|
1995-10-04 07:55:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case KEY_UP:
|
|
|
|
if (currOpt)
|
|
|
|
--currOpt;
|
|
|
|
else
|
|
|
|
beep();
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case KEY_DOWN:
|
|
|
|
if (Options[currOpt + 1].name)
|
|
|
|
++currOpt;
|
|
|
|
else
|
|
|
|
beep();
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case KEY_HOME:
|
|
|
|
currOpt = 0;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case KEY_END:
|
|
|
|
while (Options[currOpt + 1].name)
|
|
|
|
++currOpt;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case ' ':
|
1995-10-20 07:02:53 +00:00
|
|
|
dialog_clear();
|
1995-10-04 07:55:05 +00:00
|
|
|
fire(Options[currOpt]);
|
1995-10-19 15:57:23 +00:00
|
|
|
dialog_clear();
|
1995-10-20 07:02:53 +00:00
|
|
|
clear();
|
1995-10-04 07:55:05 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
case 'Q':
|
1995-10-11 00:54:01 +00:00
|
|
|
clear();
|
1995-10-19 15:57:23 +00:00
|
|
|
dialog_clear();
|
1995-10-07 11:55:37 +00:00
|
|
|
return RET_SUCCESS;
|
1995-10-04 07:55:05 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
beep();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* NOTREACHED */
|
1995-10-07 11:55:37 +00:00
|
|
|
return RET_SUCCESS;
|
1995-10-04 07:55:05 +00:00
|
|
|
}
|