/* read.c - Command to read variables from user. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
GRUB_MOD_LICENSE ("GPLv3+");
static char *
{
int i;
char *line;
char *tmp;
char c;
i = 0;
if (! line)
return NULL;
while (1)
{
if (noblock && grub_checkkey() <= 0)
break;
c = grub_getkey ();
if ((c == '\n') || (c == '\r'))
break;
line[i] = c;
if (!noecho && grub_isprint (c))
grub_printf ("%c", c);
i++;
if (! tmp)
{
return NULL;
}
}
line[i] = '\0';
return line;
}
static grub_err_t
{
char *line;
noblock = 1;
noecho = 1;
if (! line)
return grub_errno;
return 0;
}
{
{"noblock", 'd', 0, "don't block on the read; use whatever "
"input is available", 0, 0},
{"noecho", 'n', 0, "don't echo input as it's read", 0, 0},
{0, 0, 0, 0, 0, 0}
};
{
N_("[-dn] [ENVVAR]"),
N_("Set variable with user input."),
options);
}
{
}