N_("set input filename. Default is STDIN"), 0},
{"output", 'o', N_("FILE"), 0,
N_("set output filename. Default is STDOUT"), 0},
- {"verbose", 'v', 0, 0, N_("Print verbose messages."), 0},
+ {"verbose", 'v', 0, 0, N_("print verbose messages."), 0},
{ 0, 0, 0, 0, 0, 0 }
};
struct console_grub_equivalence
{
- char *layout;
+ const char *layout;
grub_uint32_t grub;
};
/* 0x52 */ GRUB_KEYBOARD_KEY_NUMDOT, GRUB_KEYBOARD_KEY_NUMDOT,
/* 0x54 */ 0, 0,
/* 0x56 */ GRUB_KEYBOARD_KEY_102ND, GRUB_KEYBOARD_KEY_F11,
- /* 0x58 */ GRUB_KEYBOARD_KEY_F12, 0,
+ /* 0x58 */ GRUB_KEYBOARD_KEY_F12, GRUB_KEYBOARD_KEY_JP_RO,
/* 0x5a */ 0, 0,
/* 0x5c */ 0, 0,
/* 0x5e */ 0, 0,
/* 0x68 */ GRUB_KEYBOARD_KEY_PPAGE, GRUB_KEYBOARD_KEY_LEFT,
/* 0x6a */ GRUB_KEYBOARD_KEY_RIGHT, GRUB_KEYBOARD_KEY_END,
/* 0x6c */ GRUB_KEYBOARD_KEY_DOWN, GRUB_KEYBOARD_KEY_NPAGE,
- /* 0x6e */ GRUB_KEYBOARD_KEY_INSERT, GRUB_KEYBOARD_KEY_DELETE
+ /* 0x6e */ GRUB_KEYBOARD_KEY_INSERT, GRUB_KEYBOARD_KEY_DELETE,
+ /* 0x70 */ 0, 0,
+ /* 0x72 */ 0, GRUB_KEYBOARD_KEY_JP_RO,
+ /* 0x74 */ 0, 0,
+ /* 0x76 */ 0, 0,
+ /* 0x78 */ 0, GRUB_KEYBOARD_KEY_KPCOMMA,
+ /* 0x7a */ 0, 0,
+ /* 0x7c */ GRUB_KEYBOARD_KEY_JP_YEN,
};
static void
if (strcmp (code, console_grub_equivalences_common[i].layout) == 0)
return console_grub_equivalences_common[i].grub;
- fprintf (stderr, _("Unknown key %s\n"), code);
+ /* TRANSLATORS: scan identifier is keyboard key symbolic name. */
+ fprintf (stderr, _("Unknown keyboard scan identifier %s\n"), code);
return '\0';
}
}
static void
-write_file (FILE *out, struct grub_keyboard_layout *layout)
+write_file (FILE *out, const char *fname, struct grub_keyboard_layout *layout)
{
grub_uint32_t version;
unsigned i;
layout->keyboard_map_shift_l3[i]
= grub_cpu_to_le32(layout->keyboard_map_shift_l3[i]);
- fwrite (GRUB_KEYBOARD_LAYOUTS_FILEMAGIC, 1,
- GRUB_KEYBOARD_LAYOUTS_FILEMAGIC_SIZE, out);
- fwrite (&version, sizeof (version), 1, out);
- fwrite (layout, 1, sizeof (*layout), out);
+ if (fwrite (GRUB_KEYBOARD_LAYOUTS_FILEMAGIC, 1,
+ GRUB_KEYBOARD_LAYOUTS_FILEMAGIC_SIZE, out)
+ != GRUB_KEYBOARD_LAYOUTS_FILEMAGIC_SIZE
+ || fwrite (&version, sizeof (version), 1, out) != 1
+ || fwrite (layout, 1, sizeof (*layout), out) != sizeof (*layout))
+ {
+ if (fname)
+ grub_util_error ("cannot write to `%s': %s", fname, strerror (errno));
+ else
+ grub_util_error ("cannot write to the stdout: %s", strerror (errno));
+ }
}
static void
-write_keymaps (FILE *in, FILE *out)
+write_keymaps (FILE *in, FILE *out, const char *out_filename)
{
struct grub_keyboard_layout layout;
char line[2048];
if (keycode_usb == 0
|| keycode_usb >= GRUB_KEYBOARD_LAYOUTS_ARRAY_SIZE)
{
- fprintf (stderr, _("Unknown keycode 0x%02x\n"), keycode_linux);
+ /* TRANSLATORS: scan code is keyboard key numeric identifier. */
+ fprintf (stderr, _("Unknown keyboard scan code 0x%02x\n"), keycode_linux);
continue;
}
if (keycode_usb < GRUB_KEYBOARD_LAYOUTS_ARRAY_SIZE)
if (ok == 0)
{
- fprintf (stderr, "%s", _("ERROR: no keycodes found. Check the input.\n"));
+ /* TRANSLATORS: this error is triggered when input doesn't contain any
+ key descriptions. */
+ fprintf (stderr, "%s", _("ERROR: no valid keyboard layout found. Check the input.\n"));
exit (1);
}
add_special_keys (&layout);
- write_file (out, &layout);
+ write_file (out, out_filename, &layout);
}
static error_t
know is a pointer to our arguments structure. */
struct arguments *arguments = state->input;
- char *p;
-
switch (key)
{
case 'i':
static struct argp argp = {
options, argp_parser, N_("[OPTIONS]"),
+ /* TRANSLATORS: "one" is a shortcut for "keyboard layout". */
N_("Generate GRUB keyboard layout from Linux console one."),
NULL, NULL, NULL
};
FILE *in, *out;
struct arguments arguments;
- set_program_name (argv[0]);
+ grub_util_host_init (&argc, &argv);
/* Check for options. */
memset (&arguments, 0, sizeof (struct arguments));
}
if (arguments.input)
- in = fopen (arguments.input, "r");
+ in = grub_util_fopen (arguments.input, "r");
else
in = stdin;
strerror (errno));
if (arguments.output)
- out = fopen (arguments.output, "wb");
+ out = grub_util_fopen (arguments.output, "wb");
else
out = stdout;
strerror (errno));
}
- write_keymaps (in, out);
+ write_keymaps (in, out, arguments.output);
if (in != stdin)
fclose (in);