diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-11-08 21:39:06 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-11-08 21:39:06 +0000 |
commit | dc70069a466a62c7a8392c576423be2d5c22bbcf (patch) | |
tree | ad26e9d1485a4ee17a841b34274554ab2109b115 | |
parent | 2a8329e0e9d1d6dcbcec27f01b0affef67a33554 (diff) | |
download | busybox-w32-dc70069a466a62c7a8392c576423be2d5c22bbcf.tar.gz busybox-w32-dc70069a466a62c7a8392c576423be2d5c22bbcf.tar.bz2 busybox-w32-dc70069a466a62c7a8392c576423be2d5c22bbcf.zip |
kbd_mode: support -C TTY option
function old new delta
packed_usage 25334 25361 +27
kbd_mode_main 146 173 +27
-rw-r--r-- | console-tools/kbd_mode.c | 17 | ||||
-rw-r--r-- | console-tools/loadfont.c | 5 | ||||
-rw-r--r-- | console-tools/loadkmap.c | 10 | ||||
-rw-r--r-- | include/usage.h | 18 |
4 files changed, 31 insertions, 19 deletions
diff --git a/console-tools/kbd_mode.c b/console-tools/kbd_mode.c index 13a82d7fa..c8451e72d 100644 --- a/console-tools/kbd_mode.c +++ b/console-tools/kbd_mode.c | |||
@@ -7,26 +7,26 @@ | |||
7 | * console-utils v0.2.3, licensed under GNU GPLv2 | 7 | * console-utils v0.2.3, licensed under GNU GPLv2 |
8 | * | 8 | * |
9 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 9 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
10 | * | ||
11 | */ | 10 | */ |
12 | |||
13 | #include "libbb.h" | 11 | #include "libbb.h" |
14 | #include <linux/kd.h> | 12 | #include <linux/kd.h> |
15 | 13 | ||
16 | int kbd_mode_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 14 | int kbd_mode_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
17 | int kbd_mode_main(int argc UNUSED_PARAM, char **argv) | 15 | int kbd_mode_main(int argc UNUSED_PARAM, char **argv) |
18 | { | 16 | { |
19 | int fd; | ||
20 | unsigned opt; | ||
21 | enum { | 17 | enum { |
22 | SCANCODE = (1 << 0), | 18 | SCANCODE = (1 << 0), |
23 | ASCII = (1 << 1), | 19 | ASCII = (1 << 1), |
24 | MEDIUMRAW = (1 << 2), | 20 | MEDIUMRAW = (1 << 2), |
25 | UNICODE = (1 << 3) | 21 | UNICODE = (1 << 3), |
26 | }; | 22 | }; |
27 | static const char KD_xxx[] ALIGN1 = "saku"; | 23 | int fd; |
28 | opt = getopt32(argv, KD_xxx); | 24 | unsigned opt; |
29 | fd = get_console_fd_or_die(); | 25 | const char *tty_name = CURRENT_TTY; |
26 | |||
27 | opt = getopt32(argv, "sakuC:", &tty_name); | ||
28 | fd = xopen(tty_name, O_NONBLOCK); | ||
29 | opt &= 0xf; /* clear -C bit, see (*) */ | ||
30 | 30 | ||
31 | if (!opt) { /* print current setting */ | 31 | if (!opt) { /* print current setting */ |
32 | const char *mode = "unknown"; | 32 | const char *mode = "unknown"; |
@@ -43,6 +43,7 @@ int kbd_mode_main(int argc UNUSED_PARAM, char **argv) | |||
43 | mode = "Unicode (UTF-8)"; | 43 | mode = "Unicode (UTF-8)"; |
44 | printf("The keyboard is in %s mode\n", mode); | 44 | printf("The keyboard is in %s mode\n", mode); |
45 | } else { | 45 | } else { |
46 | /* here we depend on specific bits assigned to options (*) */ | ||
46 | opt = opt & UNICODE ? 3 : opt >> 1; | 47 | opt = opt & UNICODE ? 3 : opt >> 1; |
47 | /* double cast prevents warnings about widening conversion */ | 48 | /* double cast prevents warnings about widening conversion */ |
48 | xioctl(fd, KDSKBMODE, (void*)(ptrdiff_t)opt); | 49 | xioctl(fd, KDSKBMODE, (void*)(ptrdiff_t)opt); |
diff --git a/console-tools/loadfont.c b/console-tools/loadfont.c index c6a3a4cd8..863c6efcd 100644 --- a/console-tools/loadfont.c +++ b/console-tools/loadfont.c | |||
@@ -80,7 +80,10 @@ static void do_loadfont(int fd, unsigned char *inbuf, int unit, int fontsize) | |||
80 | } | 80 | } |
81 | 81 | ||
82 | #if 0 | 82 | #if 0 |
83 | /* These ones do not honour -C tty (they set font on current tty regardless) */ | 83 | /* These ones do not honour -C tty (they set font on current tty regardless) |
84 | * On x86, this distinction is visible on framebuffer consoles | ||
85 | * (regular character consoles may have only one shared font anyway) | ||
86 | */ | ||
84 | #if defined(PIO_FONTX) && !defined(__sparc__) | 87 | #if defined(PIO_FONTX) && !defined(__sparc__) |
85 | { | 88 | { |
86 | struct consolefontdesc cfd; | 89 | struct consolefontdesc cfd; |
diff --git a/console-tools/loadkmap.c b/console-tools/loadkmap.c index 56948e0d0..ac2c0a6e0 100644 --- a/console-tools/loadkmap.c +++ b/console-tools/loadkmap.c | |||
@@ -5,9 +5,7 @@ | |||
5 | * Copyright (C) 1998 Enrique Zanardi <ezanardi@ull.es> | 5 | * Copyright (C) 1998 Enrique Zanardi <ezanardi@ull.es> |
6 | * | 6 | * |
7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
8 | * | ||
9 | */ | 8 | */ |
10 | |||
11 | #include "libbb.h" | 9 | #include "libbb.h" |
12 | 10 | ||
13 | #define BINARY_KEYMAP_MAGIC "bkeymap" | 11 | #define BINARY_KEYMAP_MAGIC "bkeymap" |
@@ -31,11 +29,15 @@ int loadkmap_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
31 | struct kbentry ke; | 29 | struct kbentry ke; |
32 | int i, j, fd; | 30 | int i, j, fd; |
33 | uint16_t ibuff[NR_KEYS]; | 31 | uint16_t ibuff[NR_KEYS]; |
32 | /* const char *tty_name = CURRENT_TTY; */ | ||
34 | RESERVE_CONFIG_BUFFER(flags,MAX_NR_KEYMAPS); | 33 | RESERVE_CONFIG_BUFFER(flags,MAX_NR_KEYMAPS); |
35 | 34 | ||
36 | /* bb_warn_ignoring_args(argc>=2);*/ | 35 | /* bb_warn_ignoring_args(argc >= 2); */ |
37 | |||
38 | fd = get_console_fd_or_die(); | 36 | fd = get_console_fd_or_die(); |
37 | /* or maybe: | ||
38 | opt = getopt32(argv, "C:", &tty_name); | ||
39 | fd = xopen(tty_name, O_NONBLOCK); | ||
40 | */ | ||
39 | 41 | ||
40 | xread(STDIN_FILENO, flags, 7); | 42 | xread(STDIN_FILENO, flags, 7); |
41 | if (strncmp(flags, BINARY_KEYMAP_MAGIC, 7)) | 43 | if (strncmp(flags, BINARY_KEYMAP_MAGIC, 7)) |
diff --git a/include/usage.h b/include/usage.h index 19af3486a..63aff315b 100644 --- a/include/usage.h +++ b/include/usage.h | |||
@@ -2019,7 +2019,7 @@ | |||
2019 | " [ttl TTL] [tos TOS] [[no]pmtudisc] [dev PHYS_DEV]" \ | 2019 | " [ttl TTL] [tos TOS] [[no]pmtudisc] [dev PHYS_DEV]" \ |
2020 | 2020 | ||
2021 | #define kbd_mode_trivial_usage \ | 2021 | #define kbd_mode_trivial_usage \ |
2022 | "[-a|k|s|u]" | 2022 | "[-a|k|s|u] [-C TTY]" |
2023 | #define kbd_mode_full_usage "\n\n" \ | 2023 | #define kbd_mode_full_usage "\n\n" \ |
2024 | "Report or set the keyboard mode\n" \ | 2024 | "Report or set the keyboard mode\n" \ |
2025 | "\nOptions set mode:" \ | 2025 | "\nOptions set mode:" \ |
@@ -2027,6 +2027,7 @@ | |||
2027 | "\n -k Medium-raw (keyboard)" \ | 2027 | "\n -k Medium-raw (keyboard)" \ |
2028 | "\n -s Raw (scancode)" \ | 2028 | "\n -s Raw (scancode)" \ |
2029 | "\n -u Unicode (utf-8)" \ | 2029 | "\n -u Unicode (utf-8)" \ |
2030 | "\n -C TTY Affect TTY instead of /dev/tty" \ | ||
2030 | 2031 | ||
2031 | #define kill_trivial_usage \ | 2032 | #define kill_trivial_usage \ |
2032 | "[-l] [-SIG] PID..." | 2033 | "[-l] [-SIG] PID..." |
@@ -2129,20 +2130,23 @@ | |||
2129 | "lrwxrwxrwx 1 root root 7 Apr 12 18:39 ls -> BusyBox*\n" | 2130 | "lrwxrwxrwx 1 root root 7 Apr 12 18:39 ls -> BusyBox*\n" |
2130 | 2131 | ||
2131 | #define load_policy_trivial_usage NOUSAGE_STR | 2132 | #define load_policy_trivial_usage NOUSAGE_STR |
2132 | |||
2133 | #define load_policy_full_usage "" | 2133 | #define load_policy_full_usage "" |
2134 | 2134 | ||
2135 | #define loadfont_trivial_usage \ | 2135 | #define loadfont_trivial_usage \ |
2136 | "< font" | 2136 | "< font" |
2137 | #define loadfont_full_usage "\n\n" \ | 2137 | #define loadfont_full_usage "\n\n" \ |
2138 | "Load a console font from standard input" | 2138 | "Load a console font from standard input" \ |
2139 | /* "\n -C TTY Affect TTY instead of /dev/tty" */ \ | ||
2140 | |||
2139 | #define loadfont_example_usage \ | 2141 | #define loadfont_example_usage \ |
2140 | "$ loadfont < /etc/i18n/fontname\n" | 2142 | "$ loadfont < /etc/i18n/fontname\n" |
2141 | 2143 | ||
2142 | #define loadkmap_trivial_usage \ | 2144 | #define loadkmap_trivial_usage \ |
2143 | "< keymap" | 2145 | "< keymap" |
2144 | #define loadkmap_full_usage "\n\n" \ | 2146 | #define loadkmap_full_usage "\n\n" \ |
2145 | "Load a binary keyboard translation table from standard input" | 2147 | "Load a binary keyboard translation table from standard input\n" \ |
2148 | /* "\n -C TTY Affect TTY instead of /dev/tty" */ \ | ||
2149 | |||
2146 | #define loadkmap_example_usage \ | 2150 | #define loadkmap_example_usage \ |
2147 | "$ loadkmap < /etc/i18n/lang-keymap\n" | 2151 | "$ loadkmap < /etc/i18n/lang-keymap\n" |
2148 | 2152 | ||
@@ -3476,9 +3480,11 @@ | |||
3476 | "Start and monitor a service and optionally an appendant log service" | 3480 | "Start and monitor a service and optionally an appendant log service" |
3477 | 3481 | ||
3478 | #define runsvdir_trivial_usage \ | 3482 | #define runsvdir_trivial_usage \ |
3479 | "[-P] dir" | 3483 | "[-P] [-s SCRIPT] dir" |
3480 | #define runsvdir_full_usage "\n\n" \ | 3484 | #define runsvdir_full_usage "\n\n" \ |
3481 | "Start a runsv process for each subdirectory" | 3485 | "Start a runsv process for each subdirectory. If it exits, restart it.\n" \ |
3486 | "\n -P Put each runsv in a new session" \ | ||
3487 | "\n -s SCRIPT Run SCRIPT <signo> after signal is processed" \ | ||
3482 | 3488 | ||
3483 | #define rx_trivial_usage \ | 3489 | #define rx_trivial_usage \ |
3484 | "FILE" | 3490 | "FILE" |