4 * derived from version 0.81 - aeb@cwi.nl
12 #include <linux/types.h>
14 #include <linux/keyboard.h>
15 #include <sys/ioctl.h>
20 #include "modifiers.h"
26 static void __attribute__ ((noreturn))
28 fprintf(stderr, _("dumpkeys version %s"), PACKAGE_VERSION);
31 usage: dumpkeys [options...]\n\
35 -h --help display this help text\n\
36 -i --short-info display information about keyboard driver\n\
37 -l --long-info display above and symbols known to loadkeys\n\
38 -n --numeric display keytable in hexadecimal notation\n\
39 -f --full-table don't use short-hand notations, one row per keycode\n\
40 -1 --separate-lines one line per (modifier,keycode) pair\n\
41 --funcs-only display only the function key strings\n\
42 --keys-only display only key bindings\n\
43 --compose-only display only compose key combinations\n\
45 lk_list_charsets(stderr);
47 interpret character action codes to be from the\n\
48 specified character set\n\
54 main (int argc, char *argv[]) {
55 const char *short_opts = "hilvsnf1tkdS:c:V";
56 const struct option long_opts[] = {
57 { "help", no_argument, NULL, 'h' },
58 { "short-info", no_argument, NULL, 'i' },
59 { "long-info", no_argument, NULL, 'l' },
60 { "numeric", no_argument, NULL, 'n' },
61 { "full-table", no_argument, NULL, 'f' },
62 { "separate-lines",no_argument, NULL, '1' },
63 { "shape", required_argument, NULL, 'S' },
64 { "funcs-only", no_argument, NULL, 't' },
65 { "keys-only", no_argument, NULL, 'k' },
66 { "compose-only",no_argument, NULL, 'd' },
67 { "charset", required_argument, NULL, 'c' },
68 { "verbose", no_argument, NULL, 'v' },
69 { "version", no_argument, NULL, 'V' },
78 lk_table_shape table = LK_SHAPE_DEFAULT;
85 set_progname(argv[0]);
87 setlocale(LC_ALL, "");
88 bindtextdomain(PACKAGE_NAME, LOCALEDIR);
89 textdomain(PACKAGE_NAME);
96 while ((c = getopt_long(argc, argv,
97 short_opts, long_opts, NULL)) != -1) {
110 table = LK_SHAPE_FULL_TABLE;
113 table = LK_SHAPE_SEPARATE_LINES;
116 table = atoi(optarg);
128 lk_set_log_priority(ctx, LOG_INFO);
131 if ((lk_set_charset(ctx, optarg)) != 0) {
132 fprintf(stderr, _("unknown charset %s - ignoring charset request\n"),
136 printf("charset \"%s\"\n", optarg);
139 print_version_and_exit();
151 /* check whether the keyboard is in Unicode mode */
152 if (ioctl(fd, KDGKBMODE, &kbd_mode)) {
153 fprintf(stderr, _("%s: error reading keyboard mode: %m\n"),
158 if (kbd_mode == K_UNICODE) {
159 lk_set_parser_flags(ctx, LK_FLAG_PREFER_UNICODE);
162 if ((rc = lk_kernel_keymap(ctx, fd)) < 0)
165 if (short_info || long_info) {
166 lk_dump_summary(ctx, stdout, fd);
169 printf(_("Symbols recognized by %s:\n(numeric value, symbol)\n\n"),
171 lk_dump_symbols(ctx, stdout);
180 lk_dump_keymap(ctx, stdout, table, numeric);
185 if (!funcs_only && !keys_only)
186 lk_dump_diacs(ctx, stdout);