aboutsummaryrefslogtreecommitdiff
path: root/console-tools
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-11-08 21:39:06 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-11-08 21:39:06 +0000
commitdc70069a466a62c7a8392c576423be2d5c22bbcf (patch)
treead26e9d1485a4ee17a841b34274554ab2109b115 /console-tools
parent2a8329e0e9d1d6dcbcec27f01b0affef67a33554 (diff)
downloadbusybox-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
Diffstat (limited to 'console-tools')
-rw-r--r--console-tools/kbd_mode.c17
-rw-r--r--console-tools/loadfont.c5
-rw-r--r--console-tools/loadkmap.c10
3 files changed, 19 insertions, 13 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
16int kbd_mode_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 14int kbd_mode_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
17int kbd_mode_main(int argc UNUSED_PARAM, char **argv) 15int 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))