*
* Copyright (C) Arne Bernin <arne@matrix.loopback.org>
*
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
*
*/
/* no options, no getopt */
+//usage:#define dumpkmap_trivial_usage
+//usage: "> keymap"
+//usage:#define dumpkmap_full_usage "\n\n"
+//usage: "Print a binary keyboard translation table to stdout"
+//usage:
+//usage:#define dumpkmap_example_usage
+//usage: "$ dumpkmap > keymap\n"
+
#include "libbb.h"
/* From <linux/kd.h> */
#define MAX_NR_KEYMAPS 256
int dumpkmap_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int dumpkmap_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
+int dumpkmap_main(int argc UNUSED_PARAM, char **argv)
{
struct kbentry ke;
int i, j, fd;
- RESERVE_CONFIG_BUFFER(flags,MAX_NR_KEYMAPS);
+ RESERVE_CONFIG_BUFFER(flags, MAX_NR_KEYMAPS);
-/* bb_warn_ignoring_args(argc>=2);*/
+ /* When user accidentally runs "dumpkmap FILE"
+ * instead of "dumpkmap >FILE", we'd dump binary stuff to tty.
+ * Let's prevent it: */
+ if (argv[1])
+ bb_show_usage();
+/* bb_warn_ignoring_args(argv[1]);*/
- fd = xopen(CURRENT_VC, O_RDWR);
+ fd = get_console_fd_or_die();
write(STDOUT_FILENO, "bkeymap", 7);