Added support for password feature.
This commit is contained in:
parent
23e6ed1deb
commit
ae8a5f8069
1 changed files with 187 additions and 142 deletions
|
@ -131,7 +131,7 @@ set_line(int y, int attr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int timeout = -1;
|
int timeout;
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -158,6 +158,13 @@ restart:
|
||||||
printf("\n
|
printf("\n
|
||||||
Use the \x18 and \x19 keys for selecting which entry is highlighted.\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)
|
if (config_entries)
|
||||||
printf(" Press enter to boot the selected OS, \'e\' to edit the
|
printf(" Press enter to boot the selected OS, \'e\' to edit the
|
||||||
commands before booting, or \'c\' for a command-line.");
|
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
|
boot sequence, \'c\' for a command-line, \'o\' to open a new line
|
||||||
after (\'O\' for before) the selected line, \'d\' to remove the
|
after (\'O\' for before) the selected line, \'d\' to remove the
|
||||||
selected line, or escape to go back to the main menu.");
|
selected line, or escape to go back to the main menu.");
|
||||||
|
}
|
||||||
|
|
||||||
print_entries(3, 12, first_entry, menu_entries);
|
print_entries(3, 12, first_entry, menu_entries);
|
||||||
|
|
||||||
|
@ -301,6 +309,33 @@ restart:
|
||||||
break;
|
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'))
|
if ((config_entries && (c == 'e'))
|
||||||
|| (!config_entries && ((c == '\n') || (c == '\r'))))
|
|| (!config_entries && ((c == '\n') || (c == '\r'))))
|
||||||
{
|
{
|
||||||
|
@ -317,7 +352,8 @@ restart:
|
||||||
{
|
{
|
||||||
/* safe area! */
|
/* safe area! */
|
||||||
new_heap = heap+1501;
|
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
|
do
|
||||||
|
@ -378,6 +414,7 @@ restart:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Attempt to boot an entry.
|
* Attempt to boot an entry.
|
||||||
|
@ -462,10 +499,15 @@ get_line_from_config(char *cmdline, int maxlen)
|
||||||
void
|
void
|
||||||
cmain(void)
|
cmain(void)
|
||||||
{
|
{
|
||||||
int config_len = 0, menu_len = 0;
|
int config_len, menu_len, num_entries, default_entry;
|
||||||
int num_entries = 0, default_entry = 0;
|
char *config_entries, *menu_entries;
|
||||||
char *config_entries = (char *)(mbi.mmap_addr + mbi.mmap_length);
|
|
||||||
char *menu_entries = (char *)(BUFFERADDR + (32 * 1024));
|
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.
|
* Here load the configuration file.
|
||||||
|
@ -508,6 +550,12 @@ cmain(void)
|
||||||
safe_parse_maxint(&ptr, &fallback);
|
safe_parse_maxint(&ptr, &fallback);
|
||||||
if (strcmp("default", cmdline) < 1)
|
if (strcmp("default", cmdline) < 1)
|
||||||
safe_parse_maxint(&ptr, &default_entry);
|
safe_parse_maxint(&ptr, &default_entry);
|
||||||
|
if (strcmp("password", cmdline) < 1)
|
||||||
|
{
|
||||||
|
char *ptrend = ptr;
|
||||||
|
password = config_entries;
|
||||||
|
while (*(config_entries++) = *(ptr++));
|
||||||
|
}
|
||||||
|
|
||||||
errnum = 0;
|
errnum = 0;
|
||||||
}
|
}
|
||||||
|
@ -535,9 +583,7 @@ cmain(void)
|
||||||
|
|
||||||
menu_entries[menu_len++] = 0;
|
menu_entries[menu_len++] = 0;
|
||||||
config_entries[config_len++] = 0;
|
config_entries[config_len++] = 0;
|
||||||
|
|
||||||
bcopy(menu_entries, config_entries+config_len, menu_len);
|
bcopy(menu_entries, config_entries+config_len, menu_len);
|
||||||
|
|
||||||
menu_entries = config_entries+config_len;
|
menu_entries = config_entries+config_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,6 +602,5 @@ cmain(void)
|
||||||
|
|
||||||
run_menu(menu_entries, config_entries, num_entries,
|
run_menu(menu_entries, config_entries, num_entries,
|
||||||
menu_entries+menu_len, default_entry);
|
menu_entries+menu_len, default_entry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue