unsigned char c = buf[i];
if ((grub_isprint (c) || grub_isspace (c)) && c != '\r')
- grub_putchar (c);
+ grub_printf ("%c", c);
+ else if (dos && c == '\r' && i + 1 < size && buf[i + 1] == '\n')
+ {
- grub_putchar ('\n');
++ grub_printf ("\n");
+ i++;
+ }
else
{
grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
int cnt = 0;
char *currarg;
- auto int print_command_info (grub_command_t cmd);
- auto int print_command_help (grub_command_t cmd);
-
- int print_command_info (grub_command_t cmd)
+ if (argc == 0)
{
- if ((cmd->prio & GRUB_PRIO_LIST_FLAG_ACTIVE) &&
- (cmd->flags & GRUB_COMMAND_FLAG_CMDLINE))
- {
- struct grub_term_output *term;
- const char *summary_translated = _(cmd->summary);
- char *command_help;
- grub_uint32_t *unicode_command_help;
- grub_uint32_t *unicode_last_position;
+ grub_command_t cmd;
+ FOR_COMMANDS(cmd)
+ {
+ if ((cmd->prio & GRUB_PRIO_LIST_FLAG_ACTIVE) &&
+ (cmd->flags & GRUB_COMMAND_FLAG_CMDLINE))
+ {
+ struct grub_term_output *term;
+ const char *summary_translated = _(cmd->summary);
+ char *command_help;
+ grub_uint32_t *unicode_command_help;
+ grub_uint32_t *unicode_last_position;
- command_help = grub_xasprintf ("%s %s", cmd->name, summary_translated);
- if (!command_help)
- return 1;
+ command_help = grub_xasprintf ("%s %s", cmd->name, summary_translated);
+ if (!command_help)
- break;
++ return 1;
- grub_utf8_to_ucs4_alloc (command_help, &unicode_command_help,
- &unicode_last_position);
- FOR_ACTIVE_TERM_OUTPUTS(term)
- {
- unsigned stringwidth;
- grub_uint32_t *unicode_last_screen_position;
+ grub_utf8_to_ucs4_alloc (command_help, &unicode_command_help,
+ &unicode_last_position);
-
+ FOR_ACTIVE_TERM_OUTPUTS(term)
+ {
+ unsigned stringwidth;
+ grub_uint32_t *unicode_last_screen_position;
-
+
- unicode_last_screen_position = unicode_command_help;
+ unicode_last_screen_position = unicode_command_help;
-
+
- stringwidth = 0;
+ stringwidth = 0;
-
+
- while (unicode_last_screen_position < unicode_last_position &&
- stringwidth < ((grub_term_width (term) / 2) - 2))
- {
- struct grub_unicode_glyph glyph;
- unicode_last_screen_position
- += grub_unicode_aglomerate_comb (unicode_last_screen_position,
- unicode_last_position
- - unicode_last_screen_position,
- &glyph);
+ while (unicode_last_screen_position < unicode_last_position &&
+ stringwidth < ((grub_term_width (term) / 2) - 2))
+ {
++ struct grub_unicode_glyph glyph;
++ unicode_last_screen_position
++ += grub_unicode_aglomerate_comb (unicode_last_screen_position,
++ unicode_last_position
++ - unicode_last_screen_position,
++ &glyph);
+
- stringwidth
- += grub_term_getcharwidth (term, &glyph);
- }
+ stringwidth
- += grub_term_getcharwidth (term,
- *unicode_last_screen_position);
- unicode_last_screen_position++;
++ += grub_term_getcharwidth (term, &glyph);
+ }
- grub_print_ucs4 (unicode_command_help,
- unicode_last_screen_position, 0, 0, term);
- if (!(cnt % 2))
- grub_print_spaces (term, grub_term_width (term) / 2
- - stringwidth);
- }
-
- if (cnt % 2)
- grub_printf ("\n");
- cnt++;
-
- grub_free (command_help);
- grub_free (unicode_command_help);
- }
- return 0;
- }
-
- int print_command_help (grub_command_t cmd)
- {
- if (cmd->prio & GRUB_PRIO_LIST_FLAG_ACTIVE)
- {
- if (! grub_strncmp (cmd->name, currarg, grub_strlen (currarg)))
- {
- if (cnt++ > 0)
- grub_printf ("\n\n");
-
- if (cmd->flags & GRUB_COMMAND_FLAG_EXTCMD)
- grub_arg_show_help ((grub_extcmd_t) cmd->data);
- else
- grub_printf ("%s %s %s\n%s\n", _("Usage:"), cmd->name, _(cmd->summary),
- _(cmd->description));
+ grub_print_ucs4 (unicode_command_help,
- unicode_last_screen_position, term);
++ unicode_last_screen_position, 0, 0, term);
+ if (!(cnt % 2))
+ grub_print_spaces (term, grub_term_width (term) / 2
+ - stringwidth);
}
- }
- return 0;
- }
+
- if (argc == 0)
- {
- grub_command_iterate (print_command_info);
+ if (cnt % 2)
+ grub_printf ("\n");
+ cnt++;
+
+ grub_free (command_help);
+ grub_free (unicode_command_help);
+ }
+ }
if (!(cnt % 2))
grub_printf ("\n");
}
int argc __attribute__ ((unused)),
char *argv[] __attribute__ ((unused)))
{
- auto int print_module (grub_dl_t mod);
-
- int print_module (grub_dl_t mod)
- {
- grub_dl_dep_t dep;
-
- grub_printf ("%s\t%d\t\t", mod->name, mod->ref_count);
- for (dep = mod->dep; dep; dep = dep->next)
- {
- if (dep != mod->dep)
- grub_xputs (",");
-
- grub_printf ("%s", dep->mod->name);
- }
- grub_xputs ("\n");
-
- return 0;
- }
+ grub_dl_t mod;
grub_printf ("Name\tRef Count\tDependencies\n");
- grub_dl_iterate (print_module);
+ FOR_DL_MODULES (mod)
+ {
+ grub_dl_dep_t dep;
+
+ grub_printf ("%s\t%d\t\t", mod->name, mod->ref_count);
+ for (dep = mod->dep; dep; dep = dep->next)
+ {
+ if (dep != mod->dep)
- grub_putchar (',');
++ grub_xputs (",");
+
+ grub_printf ("%s", dep->mod->name);
+ }
- grub_putchar ('\n');
++ grub_xputs ("\n");
+ }
return 0;
}
# For grub-mkfont.
ifeq ($(enable_grub_mkfont), yes)
bin_UTILITIES += grub-mkfont
- grub_mkfont_SOURCES = gnulib/progname.c util/grub-mkfont.c util/misc.c unidata.c
-grub_mkfont_SOURCES = gnulib/progname.c util/grub-mkfont.c util/misc.c kern/emu/misc.c
++grub_mkfont_SOURCES = gnulib/progname.c util/grub-mkfont.c util/misc.c \
++ unidata.c kern/emu/misc.c
grub_mkfont_CFLAGS = $(freetype_cflags)
grub_mkfont_LDFLAGS = $(freetype_libs)
endif
scsi_mod_LDFLAGS = $(COMMON_LDFLAGS)
# Commands.
- pkglib_MODULES += minicmd.mod extcmd.mod hello.mod handler.mod \
+ pkglib_MODULES += minicmd.mod extcmd.mod hello.mod \
ls.mod cmp.mod cat.mod help.mod search.mod loopback.mod \
configfile.mod echo.mod \
- terminfo.mod test.mod blocklist.mod hexdump.mod \
+ test.mod blocklist.mod hexdump.mod \
read.mod sleep.mod loadenv.mod crc.mod parttool.mod \
- msdospart.mod memrw.mod normal.mod sh.mod \
+ msdospart.mod memrw.mod normal.mod \
gptsync.mod true.mod probe.mod password.mod \
keystatus.mod
keystatus_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For normal.mod.
+ifneq (, $(FONT_SOURCE))
+normal/charset.c_DEPENDENCIES = widthspec.h
+endif
normal_mod_SOURCES = normal/main.c normal/cmdline.c normal/dyncmd.c \
- normal/auth.c normal/autofs.c normal/handler.c \
+ normal/auth.c normal/autofs.c \
normal/color.c normal/completion.c normal/datetime.c normal/menu.c \
- normal/menu_entry.c normal/menu_text.c \
+ normal/menu_entry.c normal/menu_text.c normal/charset.c \
normal/misc.c normal/crypto.c normal/term.c normal/context.c \
- unidata.c
-
- normal_mod_CFLAGS = $(COMMON_CFLAGS)
- normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
- # For sh.mod.
- sh_mod_SOURCES = script/main.c script/script.c script/execute.c \
- script/main.c script/script.c script/execute.c \
++ script/main.c script/script.c script/execute.c unidata.c \
script/function.c script/lexer.c grub_script.tab.c grub_script.yy.c
- sh_mod_CFLAGS = $(COMMON_CFLAGS) $(POSIX_CFLAGS) -Wno-error
- sh_mod_LDFLAGS = $(COMMON_LDFLAGS)
+ normal_mod_CFLAGS = $(COMMON_CFLAGS) $(POSIX_CFLAGS) -Wno-error
+ normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
ifneq (, $(FONT_SOURCE))
font/font.c_DEPENDENCIES = ascii.h
kern/disk.c kern/dl.c kern/err.c kern/file.c kern/fs.c \
kern/misc.c kern/mm.c kern/term.c \
kern/rescue_parser.c kern/rescue_reader.c \
- kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
+ kern/list.c kern/command.c kern/corecmd.c \
kern/ieee1275/init.c \
kern/ieee1275/mmap.c \
- term/ieee1275/ofconsole.c \
+ term/ieee1275/ofconsole.c term/terminfo.c term/tparm.c \
kern/ieee1275/openfw.c disk/ieee1275/ofdisk.c \
kern/parser.c kern/partition.c kern/env.c kern/$(target_cpu)/dl.c \
kern/generic/millisleep.c kern/time.c \
#include <grub/err.h>
#include <grub/symbol.h>
#include <grub/types.h>
- #include <grub/handler.h>
+#include <grub/unicode.h>
+ #include <grub/list.h>
/* These are used to represent the various color states we use. */
typedef enum
}
}
- if (! term->init || term->init () == GRUB_ERR_NONE)
+ static inline void
+ grub_term_register_input_active (const char *name __attribute__ ((unused)),
+ grub_term_input_t term)
+ {
++ if (! term->init || term->init (term) == GRUB_ERR_NONE)
+ grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term));
+ }
+
static inline void
grub_term_register_output (const char *name __attribute__ ((unused)),
grub_term_output_t term)
}
}
- if (! term->init || term->init () == GRUB_ERR_NONE)
+ static inline void
+ grub_term_register_output_active (const char *name __attribute__ ((unused)),
+ grub_term_output_t term)
+ {
++ if (! term->init || term->init (term) == GRUB_ERR_NONE)
+ grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs),
+ GRUB_AS_LIST (term));
+ }
+
static inline void
grub_term_unregister_input (grub_term_input_t term)
{
GRUB_AS_LIST (term));
}
- #define FOR_ACTIVE_TERM_INPUTS(var) for (var = grub_term_inputs; var; var = var->next)
- #define FOR_DISABLED_TERM_INPUTS(var) for (var = grub_term_inputs_disabled; var; var = var->next)
- #define FOR_ACTIVE_TERM_OUTPUTS(var) for (var = grub_term_outputs; var; var = var->next)
- #define FOR_DISABLED_TERM_OUTPUTS(var) for (var = grub_term_outputs_disabled; var; var = var->next)
+ #define FOR_ACTIVE_TERM_INPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_inputs))
+ #define FOR_DISABLED_TERM_INPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_inputs_disabled))
+ #define FOR_ACTIVE_TERM_OUTPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_outputs))
+ #define FOR_DISABLED_TERM_OUTPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_outputs_disabled))
-void EXPORT_FUNC(grub_putchar) (int c);
-void EXPORT_FUNC(grub_putcode) (grub_uint32_t code,
- struct grub_term_output *term);
+void grub_putcode (grub_uint32_t code, struct grub_term_output *term);
int EXPORT_FUNC(grub_getkey) (void);
int EXPORT_FUNC(grub_checkkey) (void);
int EXPORT_FUNC(grub_getkeystatus) (void);
grub_set_history (0);
grub_register_variable_hook ("pager", 0, 0);
grub_fs_autoload_hook = 0;
- free_handler_list ();
-
+ grub_unregister_command (cmd_clear);
}
#include <grub/loader.h>
#include <grub/command.h>
#include <grub/parser.h>
+ #include <grub/script_sh.h>
#include <grub/auth.h>
#include <grub/i18n.h>
+#include <grub/charset.h>
enum update_mode
{
}
static void
-grub_vga_text_setcursor (int on)
+grub_vga_text_setcursor (struct grub_term_output *term __attribute__ ((unused)),
+ int on)
{
grub_uint8_t old;
- grub_outb (CRTC_CURSOR, CRTC_ADDR_PORT);
- old = grub_inb (CRTC_DATA_PORT);
+ old = grub_vga_cr_read (GRUB_VGA_CR_CURSOR_START);
if (on)
- grub_outb (old & ~CRTC_CURSOR_DISABLE, CRTC_DATA_PORT);
+ grub_vga_cr_write (old & ~GRUB_VGA_CR_CURSOR_START_DISABLE,
+ GRUB_VGA_CR_CURSOR_START);
else
- grub_outb (old | CRTC_CURSOR_DISABLE, CRTC_DATA_PORT);
+ grub_vga_cr_write (old | GRUB_VGA_CR_CURSOR_START_DISABLE,
+ GRUB_VGA_CR_CURSOR_START);
}
static grub_err_t
#include "progname.h"
-void
-grub_putchar (int c)
++void
++grub_xputs_real (const char *str)
+ {
- putchar (c);
++ fputs (str, stdout);
+ }
+
++void (*grub_xputs) (const char *str) = grub_xputs_real;
++
+ int
+ grub_getkey (void)
+ {
+ return -1;
+ }
+
+ void
+ grub_refresh (void)
+ {
+ fflush (stdout);
+ }
+
static void
make_device_map (const char *device_map, int floppy_disks)
{
#define DEFAULT_BOOT_FILE "boot.img"
#define DEFAULT_CORE_FILE "core.img"
-void
-grub_putchar (int c)
+ #define grub_target_to_host16(x) grub_le_to_cpu16(x)
+ #define grub_target_to_host32(x) grub_le_to_cpu32(x)
+ #define grub_target_to_host64(x) grub_le_to_cpu64(x)
+ #define grub_host_to_target16(x) grub_cpu_to_le16(x)
+ #define grub_host_to_target32(x) grub_cpu_to_le32(x)
+ #define grub_host_to_target64(x) grub_cpu_to_le64(x)
+
+void
+grub_xputs_real (const char *str)
{
- putchar (c);
+ fputs (str, stdout);
}
+void (*grub_xputs) (const char *str) = grub_xputs_real;
+
int
grub_getkey (void)
{