Added support for password feature.

This commit is contained in:
erich 1998-08-20 21:14:21 +00:00
parent 23e6ed1deb
commit ae8a5f8069

View file

@ -131,7 +131,7 @@ set_line(int y, int attr)
}
int timeout = -1;
int timeout;
void
@ -158,6 +158,13 @@ restart:
printf("\n
Use the \x18 and \x19 keys for selecting which entry is highlighted.\n");
if (password)
{
printf(" Press enter to boot the selected OS or \'p\' to enter a
password to unlock the next set of features.");
}
else
{
if (config_entries)
printf(" Press enter to boot the selected OS, \'e\' to edit the
commands before booting, or \'c\' for a command-line.");
@ -167,6 +174,7 @@ restart:
boot sequence, \'c\' for a command-line, \'o\' to open a new line
after (\'O\' for before) the selected line, \'d\' to remove the
selected line, or escape to go back to the main menu.");
}
print_entries(3, 12, first_entry, menu_entries);
@ -301,6 +309,33 @@ restart:
break;
}
if (password)
{
if (c == 'p')
{
/* Do password check here! */
char *ptr = password;
gotoxy(2, 22);
printf("Entering password... ");
do
{
if (isspace(*ptr))
{
char *new_file = config_file;
while (isspace(*ptr)) ptr++;
while (*(new_file++) = *(ptr++));
return;
}
c = ASCII_CHAR(getkey());
}
while (*(ptr++) == c);
printf("Failed!\n Press any key to continue...");
getkey();
goto restart;
}
}
else
{
if ((config_entries && (c == 'e'))
|| (!config_entries && ((c == '\n') || (c == '\r'))))
{
@ -317,7 +352,8 @@ restart:
{
/* safe area! */
new_heap = heap+1501;
cur_entry = get_entry(menu_entries, first_entry+entryno, 0);
cur_entry = get_entry(menu_entries,
first_entry+entryno, 0);
}
do
@ -378,6 +414,7 @@ restart:
}
}
}
}
/*
* Attempt to boot an entry.
@ -462,10 +499,15 @@ get_line_from_config(char *cmdline, int maxlen)
void
cmain(void)
{
int config_len = 0, menu_len = 0;
int num_entries = 0, default_entry = 0;
char *config_entries = (char *)(mbi.mmap_addr + mbi.mmap_length);
char *menu_entries = (char *)(BUFFERADDR + (32 * 1024));
int config_len, menu_len, num_entries, default_entry;
char *config_entries, *menu_entries;
for (;;)
{
config_len = 0; menu_len = 0; num_entries = 0; default_entry = 0;
config_entries = (char *)(mbi.mmap_addr + mbi.mmap_length);
menu_entries = (char *)(BUFFERADDR + (32 * 1024));
password = NULL; fallback = -1; timeout = -1;
/*
* Here load the configuration file.
@ -508,6 +550,12 @@ cmain(void)
safe_parse_maxint(&ptr, &fallback);
if (strcmp("default", cmdline) < 1)
safe_parse_maxint(&ptr, &default_entry);
if (strcmp("password", cmdline) < 1)
{
char *ptrend = ptr;
password = config_entries;
while (*(config_entries++) = *(ptr++));
}
errnum = 0;
}
@ -535,9 +583,7 @@ cmain(void)
menu_entries[menu_len++] = 0;
config_entries[config_len++] = 0;
bcopy(menu_entries, config_entries+config_len, menu_len);
menu_entries = config_entries+config_len;
}
@ -557,5 +603,4 @@ cmain(void)
run_menu(menu_entries, config_entries, num_entries,
menu_entries+menu_len, default_entry);
}
}