Preliminary non-interactive use support

This commit is contained in:
okuji committed 1999-05-02 21:30:41 +00:00
1 parent 8c2e2a840c
commit be705674e1
6 files changed
+129 -43

No files matched your search

+55 -37
View File
@@ -180,13 +180,16 @@ grub_stage2 (void)
#ifdef HAVE_LIBCURSES
/* Get into char-at-a-time mode. */
initscr ();
cbreak ();
noecho ();
nonl ();
scrollok (stdscr, TRUE);
keypad (stdscr, TRUE);
nodelay (stdscr, TRUE);
if (use_curses)
{
initscr ();
cbreak ();
noecho ();
nonl ();
scrollok (stdscr, TRUE);
keypad (stdscr, TRUE);
nodelay (stdscr, TRUE);
}
#endif
/* Set our stack, and go for it. */
@@ -194,7 +197,8 @@ grub_stage2 (void)
doit ();
#ifdef HAVE_LIBCURSES
endwin ();
if (use_curses)
endwin ();
#endif
/* Close off the file descriptors we used. */
@@ -221,7 +225,8 @@ void
stop (void)
{
#ifdef HAVE_LIBCURSES
endwin ();
if (use_curses)
endwin ();
#endif
/* FIXME: If we don't exit, then we need to free our data areas. */
fprintf (stderr, "grub: aborting...\n");
@@ -348,7 +353,8 @@ void
cls (void)
{
#ifdef HAVE_LIBCURSES
clear ();
if (use_curses)
clear ();
#endif
}
@@ -359,10 +365,11 @@ getxy (void)
{
int y, x;
#ifdef HAVE_LIBCURSES
getyx (stdscr, y, x);
#else
y = x = 0;
if (use_curses)
getyx (stdscr, y, x);
else
#endif
y = x = 0;
return (x << 8) | (y & 0xff);
}
@@ -371,7 +378,8 @@ void
gotoxy (int x, int y)
{
#ifdef HAVE_LIBCURSES
move (y, x);
if (use_curses)
move (y, x);
#endif
}
@@ -382,10 +390,11 @@ void
grub_putchar (int c)
{
#ifdef HAVE_LIBCURSES
addch (c);
#else
putchar (c);
if (use_curses)
addch (c);
else
#endif
putchar (c);
}
@@ -394,14 +403,17 @@ int
getkey (void)
{
#ifdef HAVE_LIBCURSES
int c;
nodelay (stdscr, FALSE);
c = getch ();
nodelay (stdscr, TRUE);
return c;
#else
return getchar ();
if (use_curses)
{
int c;
nodelay (stdscr, FALSE);
c = getch ();
nodelay (stdscr, TRUE);
return c;
}
#endif
return getchar ();
}
@@ -410,16 +422,19 @@ int
checkkey (void)
{
#ifdef HAVE_LIBCURSES
int c;
c = getch ();
/* If C is not ERR, then put it back in the input queue. */
if (c != ERR)
ungetch (c); /* FIXME: ncurses-1.9.9g ungetch is buggy. */
return c;
#else
if (use_curses)
{
int c;
c = getch ();
/* If C is not ERR, then put it back in the input queue. */
if (c != ERR)
ungetch (c); /* FIXME: ncurses-1.9.9g ungetch is buggy. */
return c;
}
#endif
/* Just pretend they hit the space bar. */
return ' ';
#endif
}
@@ -428,13 +443,16 @@ void
set_attrib (int attr)
{
#ifdef HAVE_LIBCURSES
/* FIXME: I don't know why, but chgat doesn't work as expected, so
use this dirty way... - okuji */
chtype ch = inch ();
addch ((ch & A_CHARTEXT) | attr);
if (use_curses)
{
/* FIXME: I don't know why, but chgat doesn't work as expected, so
use this dirty way... - okuji */
chtype ch = inch ();
addch ((ch & A_CHARTEXT) | attr);
# if 0
chgat (1, attr, 0, NULL);
chgat (1, attr, 0, NULL);
# endif
}
#endif
}
+25
View File
@@ -32,6 +32,8 @@ int grub_stage2 (void);
#include "shared.h"
char *program_name = 0;
int use_config_file = 1;
int use_curses = 1;
static int default_boot_drive;
static int default_install_partition;
static char *default_config_file;
@@ -42,6 +44,9 @@ static char *default_config_file;
#define OPT_CONFIG_FILE -5
#define OPT_INSTALL_PARTITION -6
#define OPT_BOOT_DRIVE -7
#define OPT_DISABLE_CONFIG_FILE -8
#define OPT_DISABLE_CURSES -9
#define OPT_BATCH -10
#define OPTSTRING ""
static struct option longopts[] =
@@ -52,6 +57,9 @@ static struct option longopts[] =
{"config-file", required_argument, 0, OPT_CONFIG_FILE},
{"install-partition", required_argument, 0, OPT_INSTALL_PARTITION},
{"boot-drive", required_argument, 0, OPT_BOOT_DRIVE},
{"disable-config-file", no_argument, 0, OPT_DISABLE_CONFIG_FILE},
{"disable-curses", no_argument, 0, OPT_DISABLE_CURSES},
{"batch", no_argument, 0, OPT_BATCH},
{0},
};
@@ -68,8 +76,11 @@ Usage: %s [OPTION]...\n\
\n\
Enter the GRand Unified Bootloader command shell.\n\
\n\
--batch turn on batch mode for non-interactive use\n\
--boot-drive=DRIVE specify stage2 boot_drive [default=0x%x]\n\
--config-file=FILE specify stage2 config_file [default=%s]\n\
--disable-config-file disable to use the config file\n\
--disable-curses disable to use curses\n\
--help display this message and exit\n\
--hold wait until a debugger will attach\n\
--install-partition=PAR specify stage2 install_partition [default=0x%x]\n\
@@ -140,6 +151,20 @@ main (int argc, char **argv)
}
break;
case OPT_DISABLE_CONFIG_FILE:
use_config_file = 0;
break;
case OPT_DISABLE_CURSES:
use_curses = 0;
break;
case OPT_BATCH:
/* This is the same as "--disable-config-file --disable-curses". */
use_config_file = 0;
use_curses = 0;
break;
default:
usage (1);
}