Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/console-tools
- Timestamp:
- Feb 25, 2011, 9:26:54 PM (13 years ago)
- Location:
- branches/2.2.9/mindi-busybox/console-tools
- Files:
-
- 5 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mindi-busybox/console-tools/Config.in
r1765 r2725 1 # DO NOT EDIT. This file is generated from Config.src 1 2 # 2 3 # For a description of the syntax of this configuration file, … … 6 7 menu "Console Utilities" 7 8 9 10 8 11 config CHVT 9 12 bool "chvt" 10 default n 13 default y 14 depends on PLATFORM_LINUX 11 15 help 12 16 This program is used to change to another terminal. 13 17 Example: chvt 4 (change to terminal /dev/tty4) 14 18 19 config FGCONSOLE 20 bool "fgconsole" 21 default y 22 depends on PLATFORM_LINUX 23 help 24 This program prints active (foreground) console number. 25 15 26 config CLEAR 16 27 bool "clear" 17 default n28 default y 18 29 help 19 30 This program clears the terminal screen. … … 21 32 config DEALLOCVT 22 33 bool "deallocvt" 23 default n 34 default y 35 depends on PLATFORM_LINUX 24 36 help 25 37 This program deallocates unused virtual consoles. … … 27 39 config DUMPKMAP 28 40 bool "dumpkmap" 29 default n 41 default y 42 depends on PLATFORM_LINUX 30 43 help 31 44 This program dumps the kernel's keyboard translation table to 32 45 stdout, in binary format. You can then use loadkmap to load it. 33 46 47 config KBD_MODE 48 bool "kbd_mode" 49 default y 50 depends on PLATFORM_LINUX 51 help 52 This program reports and sets keyboard mode. 53 34 54 config LOADFONT 35 55 bool "loadfont" 36 default n 56 default y 57 depends on PLATFORM_LINUX 37 58 help 38 59 This program loads a console font from standard input. … … 40 61 config LOADKMAP 41 62 bool "loadkmap" 42 default n 63 default y 64 depends on PLATFORM_LINUX 43 65 help 44 66 This program loads a keyboard translation table from … … 47 69 config OPENVT 48 70 bool "openvt" 49 default n 71 default y 72 depends on PLATFORM_LINUX 50 73 help 51 74 This program is used to start a command on an unused … … 54 77 config RESET 55 78 bool "reset" 56 default n79 default y 57 80 help 58 81 This program is used to reset the terminal screen, if it … … 61 84 config RESIZE 62 85 bool "resize" 63 default n86 default y 64 87 help 65 88 This program is used to (re)set the width and height of your current … … 67 90 68 91 config FEATURE_RESIZE_PRINT 69 bool " print environment variables"70 default n92 bool "Print environment variables" 93 default y 71 94 depends on RESIZE 72 95 help … … 78 101 config SETCONSOLE 79 102 bool "setconsole" 80 default n 103 default y 104 depends on PLATFORM_LINUX 81 105 help 82 106 This program redirects the system console to another device, … … 85 109 config FEATURE_SETCONSOLE_LONG_OPTIONS 86 110 bool "Enable long options" 87 default n88 depends on SETCONSOLE && GETOPT_LONG111 default y 112 depends on SETCONSOLE && LONG_OPTS 89 113 help 90 114 Support long options for the setconsole applet. 91 115 116 config SETFONT 117 bool "setfont" 118 default y 119 depends on PLATFORM_LINUX 120 help 121 Allows to load console screen map. Useful for i18n. 122 123 config FEATURE_SETFONT_TEXTUAL_MAP 124 bool "Support reading textual screen maps" 125 default y 126 depends on SETFONT 127 help 128 Support reading textual screen maps. 129 130 config DEFAULT_SETFONT_DIR 131 string "Default directory for console-tools files" 132 default "" 133 depends on SETFONT 134 help 135 Directory to use if setfont's params are simple filenames 136 (not /path/to/file or ./file). Default is "" (no default directory). 137 92 138 config SETKEYCODES 93 139 bool "setkeycodes" 94 default n 140 default y 141 depends on PLATFORM_LINUX 95 142 help 96 143 This program loads entries into the kernel's scancode-to-keycode … … 99 146 config SETLOGCONS 100 147 bool "setlogcons" 101 default n 148 default y 149 depends on PLATFORM_LINUX 102 150 help 103 151 This program redirects the output console of kernel messages. 104 152 153 config SHOWKEY 154 bool "showkey" 155 default y 156 depends on PLATFORM_LINUX 157 help 158 Shows keys pressed. 159 160 comment "Common options for loadfont and setfont" 161 depends on LOADFONT || SETFONT 162 163 config FEATURE_LOADFONT_PSF2 164 bool "Support for PSF2 console fonts" 165 default y 166 depends on LOADFONT || SETFONT 167 help 168 Support PSF2 console fonts. 169 170 config FEATURE_LOADFONT_RAW 171 bool "Support for old (raw) console fonts" 172 default y 173 depends on LOADFONT || SETFONT 174 help 175 Support old (raw) console fonts. 176 105 177 endmenu -
branches/2.2.9/mindi-busybox/console-tools/Kbuild
r1765 r2725 1 # DO NOT EDIT. This file is generated from Kbuild.src 1 2 # Makefile for busybox 2 3 # 3 4 # Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org> 4 5 # 5 # Licensed under the GPL v2, see the file LICENSE in this tarball.6 # Licensed under GPLv2, see file LICENSE in this source tree. 6 7 7 8 lib-y:= 9 10 8 11 lib-$(CONFIG_CHVT) += chvt.o 12 lib-$(CONFIG_FGCONSOLE) += fgconsole.o 9 13 lib-$(CONFIG_CLEAR) += clear.o 10 14 lib-$(CONFIG_DEALLOCVT) += deallocvt.o 11 15 lib-$(CONFIG_DUMPKMAP) += dumpkmap.o 12 16 lib-$(CONFIG_SETCONSOLE) += setconsole.o 17 lib-$(CONFIG_KBD_MODE) += kbd_mode.o 13 18 lib-$(CONFIG_LOADFONT) += loadfont.o 14 19 lib-$(CONFIG_LOADKMAP) += loadkmap.o … … 16 21 lib-$(CONFIG_RESET) += reset.o 17 22 lib-$(CONFIG_RESIZE) += resize.o 23 lib-$(CONFIG_SETFONT) += loadfont.o 18 24 lib-$(CONFIG_SETKEYCODES) += setkeycodes.o 19 25 lib-$(CONFIG_SETLOGCONS) += setlogcons.o 26 lib-$(CONFIG_SHOWKEY) += showkey.o -
branches/2.2.9/mindi-busybox/console-tools/chvt.c
r1765 r2725 5 5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> 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 source tree. 8 8 */ 9 10 9 #include "libbb.h" 11 10 12 /* From <linux/vt.h> */ 13 enum { 14 VT_ACTIVATE = 0x5606, /* make vt active */ 15 VT_WAITACTIVE = 0x5607 /* wait for vt active */ 16 }; 17 18 int chvt_main(int argc, char **argv); 19 int chvt_main(int argc, char **argv) 11 int chvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 12 int chvt_main(int argc UNUSED_PARAM, char **argv) 20 13 { 21 int fd, num; 22 23 if (argc != 2) { 24 bb_show_usage(); 25 } 26 27 fd = get_console_fd(); 28 num = xatou_range(argv[1], 1, 63); 29 /* double cast suppresses "cast to ptr from int of different size */ 30 xioctl(fd, VT_ACTIVATE, (void *)(ptrdiff_t)num); 31 xioctl(fd, VT_WAITACTIVE, (void *)(ptrdiff_t)num); 14 int num = xatou_range(single_argv(argv), 1, 63); 15 console_make_active(get_console_fd_or_die(), num); 32 16 return EXIT_SUCCESS; 33 17 } -
branches/2.2.9/mindi-busybox/console-tools/clear.c
r1765 r2725 5 5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> 6 6 * 7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 8 * 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 9 8 */ 10 11 /* no options, no getopt */12 13 9 #include "libbb.h" 14 10 15 int clear_main(int argc, char **argv) ;16 int clear_main(int argc , char **argv)11 int clear_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 12 int clear_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) 17 13 { 18 return printf("\033[H\033[J") != 6; 14 /* home; clear to the end of screen */ 15 return full_write1_str("\033[H""\033[J") != 6; 19 16 } -
branches/2.2.9/mindi-busybox/console-tools/deallocvt.c
r1765 r2725 6 6 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> 7 7 * 8 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.8 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 9 9 */ 10 10 … … 16 16 enum { VT_DISALLOCATE = 0x5608 }; /* free memory associated to vt */ 17 17 18 int deallocvt_main(int argc, char **argv) ;19 int deallocvt_main(int argc , char **argv)18 int deallocvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 19 int deallocvt_main(int argc UNUSED_PARAM, char **argv) 20 20 { 21 21 /* num = 0 deallocate all unused consoles */ 22 22 int num = 0; 23 23 24 switch (argc) { 25 case 2: 24 if (argv[1]) { 25 if (argv[2]) 26 bb_show_usage(); 26 27 num = xatou_range(argv[1], 1, 63); 27 /* Fallthrough */28 case 1:29 break;30 default:31 bb_show_usage();32 28 } 33 29 34 /* double cast suppresses "cast to ptr from int of different size */35 xioctl(get_console_fd (), VT_DISALLOCATE, (void *)(ptrdiff_t)num);30 /* double cast suppresses "cast to ptr from int of different size" */ 31 xioctl(get_console_fd_or_die(), VT_DISALLOCATE, (void *)(ptrdiff_t)num); 36 32 return EXIT_SUCCESS; 37 33 } -
branches/2.2.9/mindi-busybox/console-tools/dumpkmap.c
r1765 r2725 5 5 * Copyright (C) Arne Bernin <arne@matrix.loopback.org> 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 source tree. 8 8 * 9 9 */ 10 /* no options, no getopt */ 10 11 11 12 #include "libbb.h" … … 23 24 #define MAX_NR_KEYMAPS 256 24 25 25 int dumpkmap_main(int argc, char **argv) ;26 int dumpkmap_main(int argc , char **argv)26 int dumpkmap_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 27 int dumpkmap_main(int argc UNUSED_PARAM, char **argv) 27 28 { 28 29 struct kbentry ke; 29 30 int i, j, fd; 30 char flags[MAX_NR_KEYMAPS];31 RESERVE_CONFIG_BUFFER(flags, MAX_NR_KEYMAPS); 31 32 32 if (argc >= 2 && argv[1][0] == '-') 33 /* When user accidentally runs "dumpkmap FILE" 34 * instead of "dumpkmap >FILE", we'd dump binary stuff to tty. 35 * Let's prevent it: */ 36 if (argv[1]) 33 37 bb_show_usage(); 38 /* bb_warn_ignoring_args(argv[1]);*/ 34 39 35 fd = xopen(CURRENT_VC, O_RDWR);40 fd = get_console_fd_or_die(); 36 41 37 write( 1, "bkeymap", 7);42 write(STDOUT_FILENO, "bkeymap", 7); 38 43 39 44 /* Here we want to set everything to 0 except for indexes: … … 44 49 45 50 /* dump flags */ 46 write( 1, flags, MAX_NR_KEYMAPS);51 write(STDOUT_FILENO, flags, MAX_NR_KEYMAPS); 47 52 48 53 for (i = 0; i < MAX_NR_KEYMAPS; i++) { … … 57 62 &ke.kb_value) 58 63 ) { 59 write( 1, (void*)&ke.kb_value, 2);64 write(STDOUT_FILENO, (void*)&ke.kb_value, 2); 60 65 } 61 66 } 62 67 } 63 68 } 64 close(fd); 69 if (ENABLE_FEATURE_CLEAN_UP) { 70 close(fd); 71 RELEASE_CONFIG_BUFFER(flags); 72 } 65 73 return EXIT_SUCCESS; 66 74 } -
branches/2.2.9/mindi-busybox/console-tools/loadfont.c
r1765 r2725 7 7 * Loads the console font, and possibly the corresponding screen map(s). 8 8 * (Adapted for busybox by Matej Vela.) 9 * 10 * Licensed under GPLv2, see file LICENSE in this source tree. 9 11 */ 10 12 #include "libbb.h" 11 13 #include <sys/kd.h> 12 14 15 #ifndef KDFONTOP 16 # define KDFONTOP 0x4B72 17 struct console_font_op { 18 unsigned op; /* KD_FONT_OP_* */ 19 unsigned flags; /* KD_FONT_FLAG_* */ 20 unsigned width, height; 21 unsigned charcount; 22 unsigned char *data; /* font data with height fixed to 32 */ 23 }; 24 # define KD_FONT_OP_SET 0 /* Set font */ 25 # define KD_FONT_OP_GET 1 /* Get font */ 26 # define KD_FONT_OP_SET_DEFAULT 2 /* Set font to default, data points to name / NULL */ 27 # define KD_FONT_OP_COPY 3 /* Copy from another console */ 28 # define KD_FONT_FLAG_OLD 0x80000000 /* Invoked via old interface */ 29 # define KD_FONT_FLAG_DONT_RECALC 1 /* Don't call adjust_height() */ 30 /* (Used internally for PIO_FONT support) */ 31 #endif /* KDFONTOP */ 32 33 13 34 enum { 14 PSF_MAGIC1 = 0x36, 15 PSF_MAGIC2 = 0x04, 16 17 PSF_MODE512 = 0x01, 18 PSF_MODEHASTAB = 0x02, 19 PSF_MAXMODE = 0x03, 20 PSF_SEPARATOR = 0xFFFF 35 PSF1_MAGIC0 = 0x36, 36 PSF1_MAGIC1 = 0x04, 37 PSF1_MODE512 = 0x01, 38 PSF1_MODEHASTAB = 0x02, 39 PSF1_MODEHASSEQ = 0x04, 40 PSF1_MAXMODE = 0x05, 41 PSF1_STARTSEQ = 0xfffe, 42 PSF1_SEPARATOR = 0xffff, 21 43 }; 22 44 23 struct psf _header {24 unsigned char magic 1, magic2;/* Magic number */45 struct psf1_header { 46 unsigned char magic[2]; /* Magic number */ 25 47 unsigned char mode; /* PSF font mode */ 26 48 unsigned char charsize; /* Character size */ 27 49 }; 28 50 29 #define PSF_MAGIC_OK(x) ((x).magic1 == PSF_MAGIC1 && (x).magic2 == PSF_MAGIC2) 30 31 static void do_loadfont(int fd, unsigned char *inbuf, int unit, int fontsize) 32 { 33 char *buf; 51 #define psf1h(x) ((struct psf1_header*)(x)) 52 53 #define PSF1_MAGIC_OK(x) ( \ 54 (x)->magic[0] == PSF1_MAGIC0 \ 55 && (x)->magic[1] == PSF1_MAGIC1 \ 56 ) 57 58 #if ENABLE_FEATURE_LOADFONT_PSF2 59 enum { 60 PSF2_MAGIC0 = 0x72, 61 PSF2_MAGIC1 = 0xb5, 62 PSF2_MAGIC2 = 0x4a, 63 PSF2_MAGIC3 = 0x86, 64 PSF2_HAS_UNICODE_TABLE = 0x01, 65 PSF2_MAXVERSION = 0, 66 PSF2_STARTSEQ = 0xfe, 67 PSF2_SEPARATOR = 0xff 68 }; 69 70 struct psf2_header { 71 unsigned char magic[4]; 72 unsigned int version; 73 unsigned int headersize; /* offset of bitmaps in file */ 74 unsigned int flags; 75 unsigned int length; /* number of glyphs */ 76 unsigned int charsize; /* number of bytes for each character */ 77 unsigned int height; /* max dimensions of glyphs */ 78 unsigned int width; /* charsize = height * ((width + 7) / 8) */ 79 }; 80 81 #define psf2h(x) ((struct psf2_header*)(x)) 82 83 #define PSF2_MAGIC_OK(x) ( \ 84 (x)->magic[0] == PSF2_MAGIC0 \ 85 && (x)->magic[1] == PSF2_MAGIC1 \ 86 && (x)->magic[2] == PSF2_MAGIC2 \ 87 && (x)->magic[3] == PSF2_MAGIC3 \ 88 ) 89 #endif /* ENABLE_FEATURE_LOADFONT_PSF2 */ 90 91 92 static void do_loadfont(int fd, unsigned char *inbuf, int height, int width, int charsize, int fontsize) 93 { 94 unsigned char *buf; 95 int charwidth = 32 * ((width+7)/8); 34 96 int i; 35 97 36 if (unit < 1 || unit > 32) 37 bb_error_msg_and_die("bad character size %d", unit); 38 39 buf = xzalloc(16 * 1024); 40 /*memset(buf, 0, 16 * 1024);*/ 98 if (height < 1 || height > 32 || width < 1 || width > 32) 99 bb_error_msg_and_die("bad character size %dx%d", height, width); 100 101 buf = xzalloc(charwidth * ((fontsize < 128) ? 128 : fontsize)); 41 102 for (i = 0; i < fontsize; i++) 42 memcpy(buf + (32 * i), inbuf + (unit * i), unit); 43 44 #if defined(PIO_FONTX) && !defined(__sparc__) 45 { 46 struct consolefontdesc cfd; 47 48 cfd.charcount = fontsize; 49 cfd.charheight = unit; 50 cfd.chardata = buf; 51 52 if (!ioctl_or_perror(fd, PIO_FONTX, &cfd, "PIO_FONTX ioctl failed (will try PIO_FONT)")) 53 goto ret; /* success */ 54 } 55 #endif 56 xioctl(fd, PIO_FONT, buf); 57 ret: 103 memcpy(buf + (i*charwidth), inbuf + (i*charsize), charsize); 104 105 { /* KDFONTOP */ 106 struct console_font_op cfo; 107 cfo.op = KD_FONT_OP_SET; 108 cfo.flags = 0; 109 cfo.width = width; 110 cfo.height = height; 111 cfo.charcount = fontsize; 112 cfo.data = buf; 113 xioctl(fd, KDFONTOP, &cfo); 114 } 115 58 116 free(buf); 59 117 } 60 118 61 static void 62 do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize) 63 { 119 /* 120 * Format of the Unicode information: 121 * 122 * For each font position <uc>*<seq>*<term> 123 * where <uc> is a 2-byte little endian Unicode value (PSF1) 124 * or an UTF-8 coded value (PSF2), 125 * <seq> = <ss><uc><uc>*, <ss> = psf1 ? 0xFFFE : 0xFE, 126 * <term> = psf1 ? 0xFFFF : 0xFF. 127 * and * denotes zero or more occurrences of the preceding item. 128 * 129 * Semantics: 130 * The leading <uc>* part gives Unicode symbols that are all 131 * represented by this font position. The following sequences 132 * are sequences of Unicode symbols - probably a symbol 133 * together with combining accents - also represented by 134 * this font position. 135 * 136 * Example: 137 * At the font position for a capital A-ring glyph, we 138 * may have: 139 * 00C5,212B,FFFE,0041,030A,FFFF 140 * Some font positions may be described by sequences only, 141 * namely when there is no precomposed Unicode value for the glyph. 142 */ 143 #if !ENABLE_FEATURE_LOADFONT_PSF2 144 #define do_loadtable(fd, inbuf, tailsz, fontsize, psf2) \ 145 do_loadtable(fd, inbuf, tailsz, fontsize) 146 #endif 147 static void do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize, int psf2) 148 { 149 #if !ENABLE_FEATURE_LOADFONT_PSF2 150 /* gcc 4.3.1 code size: */ 151 # define psf2 0 /* +0 bytes */ 152 // const int psf2 = 0; /* +8 bytes */ 153 // enum { psf2 = 0 }; /* +13 bytes */ 154 #endif 64 155 struct unimapinit advice; 65 156 struct unimapdesc ud; … … 69 160 uint16_t unicode; 70 161 71 maxct = tailsz; 72 up = xmalloc(maxct * sizeof( struct unipair));162 maxct = tailsz; /* more than enough */ 163 up = xmalloc(maxct * sizeof(*up)); 73 164 74 165 for (glyph = 0; glyph < fontsize; glyph++) { 75 while (tailsz >= 2) { 76 unicode = (((uint16_t) inbuf[1]) << 8) + inbuf[0]; 77 tailsz -= 2; 78 inbuf += 2; 79 if (unicode == PSF_SEPARATOR) 80 break; 166 while (tailsz > 0) { 167 if (!psf2) { /* PSF1 */ 168 unicode = (((uint16_t) inbuf[1]) << 8) + inbuf[0]; 169 tailsz -= 2; 170 inbuf += 2; 171 if (unicode == PSF1_SEPARATOR) 172 break; 173 } else { /* PSF2 */ 174 #if ENABLE_FEATURE_LOADFONT_PSF2 175 --tailsz; 176 unicode = *inbuf++; 177 if (unicode == PSF2_SEPARATOR) { 178 break; 179 } else if (unicode == PSF2_STARTSEQ) { 180 bb_error_msg_and_die("unicode sequences not implemented"); 181 } else if (unicode >= 0xC0) { 182 if (unicode >= 0xFC) 183 unicode &= 0x01, maxct = 5; 184 else if (unicode >= 0xF8) 185 unicode &= 0x03, maxct = 4; 186 else if (unicode >= 0xF0) 187 unicode &= 0x07, maxct = 3; 188 else if (unicode >= 0xE0) 189 unicode &= 0x0F, maxct = 2; 190 else 191 unicode &= 0x1F, maxct = 1; 192 do { 193 if (tailsz <= 0 || *inbuf < 0x80 || *inbuf > 0xBF) 194 bb_error_msg_and_die("illegal UTF-8 character"); 195 --tailsz; 196 unicode = (unicode << 6) + (*inbuf++ & 0x3F); 197 } while (--maxct > 0); 198 } else if (unicode >= 0x80) { 199 bb_error_msg_and_die("illegal UTF-8 character"); 200 } 201 #else 202 return; 203 #endif 204 } 81 205 up[ct].unicode = unicode; 82 206 up[ct].fontpos = glyph; … … 95 219 ud.entries = up; 96 220 xioctl(fd, PIO_UNIMAP, &ud); 97 } 98 99 static void loadnewfont(int fd) 100 { 101 enum { INBUF_SIZE = 32*1024 + 1 }; 102 103 int unit; 104 unsigned inputlth, offset; 105 /* Was on stack, but 32k is a bit too much: */ 106 unsigned char *inbuf = xmalloc(INBUF_SIZE); 221 #undef psf2 222 } 223 224 static void do_load(int fd, unsigned char *buffer, size_t len) 225 { 226 int height; 227 int width = 8; 228 int charsize; 229 int fontsize = 256; 230 int has_table = 0; 231 unsigned char *font = buffer; 232 unsigned char *table; 233 234 if (len >= sizeof(struct psf1_header) && PSF1_MAGIC_OK(psf1h(buffer))) { 235 if (psf1h(buffer)->mode > PSF1_MAXMODE) 236 bb_error_msg_and_die("unsupported psf file mode"); 237 if (psf1h(buffer)->mode & PSF1_MODE512) 238 fontsize = 512; 239 if (psf1h(buffer)->mode & PSF1_MODEHASTAB) 240 has_table = 1; 241 height = charsize = psf1h(buffer)->charsize; 242 font += sizeof(struct psf1_header); 243 } else 244 #if ENABLE_FEATURE_LOADFONT_PSF2 245 if (len >= sizeof(struct psf2_header) && PSF2_MAGIC_OK(psf2h(buffer))) { 246 if (psf2h(buffer)->version > PSF2_MAXVERSION) 247 bb_error_msg_and_die("unsupported psf file version"); 248 fontsize = psf2h(buffer)->length; 249 if (psf2h(buffer)->flags & PSF2_HAS_UNICODE_TABLE) 250 has_table = 2; 251 charsize = psf2h(buffer)->charsize; 252 height = psf2h(buffer)->height; 253 width = psf2h(buffer)->width; 254 font += psf2h(buffer)->headersize; 255 } else 256 #endif 257 #if ENABLE_FEATURE_LOADFONT_RAW 258 if (len == 9780) { /* file with three code pages? */ 259 charsize = height = 16; 260 font += 40; 261 } else if ((len & 0377) == 0) { /* bare font */ 262 charsize = height = len / 256; 263 } else 264 #endif 265 { 266 bb_error_msg_and_die("input file: bad length or unsupported font type"); 267 } 268 269 #if !defined(PIO_FONTX) || defined(__sparc__) 270 if (fontsize != 256) 271 bb_error_msg_and_die("only fontsize 256 supported"); 272 #endif 273 274 table = font + fontsize * charsize; 275 buffer += len; 276 277 if (table > buffer || (!has_table && table != buffer)) 278 bb_error_msg_and_die("input file: bad length"); 279 280 do_loadfont(fd, font, height, width, charsize, fontsize); 281 282 if (has_table) 283 do_loadtable(fd, table, buffer - table, fontsize, has_table - 1); 284 } 285 286 287 #if ENABLE_LOADFONT 288 int loadfont_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 289 int loadfont_main(int argc UNUSED_PARAM, char **argv) 290 { 291 size_t len; 292 unsigned char *buffer; 293 294 // no arguments allowed! 295 opt_complementary = "=0"; 296 getopt32(argv, ""); 107 297 108 298 /* … … 111 301 * just read the entire file. 112 302 */ 113 inputlth = full_read(STDIN_FILENO, inbuf, INBUF_SIZE); 114 if (inputlth < 0) 303 len = 32*1024; // can't be larger 304 buffer = xmalloc_read(STDIN_FILENO, &len); 305 // xmalloc_open_zipped_read_close(filename, &len); 306 if (!buffer) 115 307 bb_perror_msg_and_die("error reading input font"); 116 if (inputlth >= INBUF_SIZE) 117 bb_error_msg_and_die("font too large"); 118 119 /* test for psf first */ 120 { 121 struct psf_header psfhdr; 122 int fontsize; 123 int hastable; 124 unsigned head0, head; 125 126 if (inputlth < sizeof(struct psf_header)) 127 goto no_psf; 128 129 psfhdr = *(struct psf_header *) &inbuf[0]; 130 131 if (!PSF_MAGIC_OK(psfhdr)) 132 goto no_psf; 133 134 if (psfhdr.mode > PSF_MAXMODE) 135 bb_error_msg_and_die("unsupported psf file mode"); 136 fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256); 137 #if !defined(PIO_FONTX) || defined(__sparc__) 138 if (fontsize != 256) 139 bb_error_msg_and_die("only fontsize 256 supported"); 140 #endif 141 hastable = (psfhdr.mode & PSF_MODEHASTAB); 142 unit = psfhdr.charsize; 143 head0 = sizeof(struct psf_header); 144 145 head = head0 + fontsize * unit; 146 if (head > inputlth || (!hastable && head != inputlth)) 147 bb_error_msg_and_die("input file: bad length"); 148 do_loadfont(fd, inbuf + head0, unit, fontsize); 149 if (hastable) 150 do_loadtable(fd, inbuf + head, inputlth - head, fontsize); 151 return; 152 } 153 154 no_psf: 155 /* file with three code pages? */ 156 if (inputlth == 9780) { 157 offset = 40; 158 unit = 16; 159 } else { 160 /* bare font */ 161 if (inputlth & 0377) 162 bb_error_msg_and_die("bad input file size"); 163 offset = 0; 164 unit = inputlth / 256; 165 } 166 do_loadfont(fd, inbuf + offset, unit, 256); 167 } 168 169 int loadfont_main(int argc, char **argv); 170 int loadfont_main(int argc, char **argv) 171 { 308 do_load(get_console_fd_or_die(), buffer, len); 309 310 return EXIT_SUCCESS; 311 } 312 #endif 313 314 #if ENABLE_SETFONT 315 316 /* 317 kbd-1.12: 318 319 setfont [-O font+umap.orig] [-o font.orig] [-om cmap.orig] 320 [-ou umap.orig] [-N] [font.new ...] [-m cmap] [-u umap] [-C console] 321 [-hNN] [-v] [-V] 322 323 -h NN Override font height 324 -o file 325 Save previous font in file 326 -O file 327 Save previous font and Unicode map in file 328 -om file 329 Store console map in file 330 -ou file 331 Save previous Unicode map in file 332 -m file 333 Load console map or Unicode console map from file 334 -u file 335 Load Unicode table describing the font from file 336 Example: 337 # cp866 338 0x00-0x7f idem 339 # 340 0x80 U+0410 # CYRILLIC CAPITAL LETTER A 341 0x81 U+0411 # CYRILLIC CAPITAL LETTER BE 342 0x82 U+0412 # CYRILLIC CAPITAL LETTER VE 343 -C console 344 Set the font for the indicated console 345 -v Verbose 346 -V Version 347 */ 348 349 #if ENABLE_FEATURE_SETFONT_TEXTUAL_MAP 350 static int ctoi(char *s) 351 { 352 if (s[0] == '\'' && s[1] != '\0' && s[2] == '\'' && s[3] == '\0') 353 return s[1]; 354 // U+ means 0x 355 if (s[0] == 'U' && s[1] == '+') { 356 s[0] = '0'; 357 s[1] = 'x'; 358 } 359 if (!isdigit(s[0])) 360 return -1; 361 return xstrtoul(s, 0); 362 } 363 #endif 364 365 int setfont_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 366 int setfont_main(int argc UNUSED_PARAM, char **argv) 367 { 368 size_t len; 369 unsigned opts; 172 370 int fd; 173 174 if (argc != 1) 175 bb_show_usage(); 176 177 fd = xopen(CURRENT_VC, O_RDWR); 178 loadnewfont(fd); 371 unsigned char *buffer; 372 char *mapfilename; 373 const char *tty_name = CURRENT_TTY; 374 375 opt_complementary = "=1"; 376 opts = getopt32(argv, "m:C:", &mapfilename, &tty_name); 377 argv += optind; 378 379 fd = xopen_nonblocking(tty_name); 380 381 if (sizeof(CONFIG_DEFAULT_SETFONT_DIR) > 1) { // if not "" 382 if (*argv[0] != '/') { 383 // goto default fonts location. don't die if doesn't exist 384 chdir(CONFIG_DEFAULT_SETFONT_DIR "/consolefonts"); 385 } 386 } 387 // load font 388 len = 32*1024; // can't be larger 389 buffer = xmalloc_open_zipped_read_close(*argv, &len); 390 if (!buffer) 391 bb_simple_perror_msg_and_die(*argv); 392 do_load(fd, buffer, len); 393 394 // load the screen map, if any 395 if (opts & 1) { // -m 396 unsigned mode = PIO_SCRNMAP; 397 void *map; 398 399 if (sizeof(CONFIG_DEFAULT_SETFONT_DIR) > 1) { // if not "" 400 if (mapfilename[0] != '/') { 401 // goto default keymaps location 402 chdir(CONFIG_DEFAULT_SETFONT_DIR "/consoletrans"); 403 } 404 } 405 // fetch keymap 406 map = xmalloc_open_zipped_read_close(mapfilename, &len); 407 if (!map) 408 bb_simple_perror_msg_and_die(mapfilename); 409 // file size is 256 or 512 bytes? -> assume binary map 410 if (len == E_TABSZ || len == 2*E_TABSZ) { 411 if (len == 2*E_TABSZ) 412 mode = PIO_UNISCRNMAP; 413 } 414 #if ENABLE_FEATURE_SETFONT_TEXTUAL_MAP 415 // assume textual Unicode console maps: 416 // 0x00 U+0000 # NULL (NUL) 417 // 0x01 U+0001 # START OF HEADING (SOH) 418 // 0x02 U+0002 # START OF TEXT (STX) 419 // 0x03 U+0003 # END OF TEXT (ETX) 420 else { 421 int i; 422 char *token[2]; 423 parser_t *parser; 424 425 if (ENABLE_FEATURE_CLEAN_UP) 426 free(map); 427 map = xmalloc(E_TABSZ * sizeof(unsigned short)); 428 429 #define unicodes ((unsigned short *)map) 430 // fill vanilla map 431 for (i = 0; i < E_TABSZ; i++) 432 unicodes[i] = 0xf000 + i; 433 434 parser = config_open(mapfilename); 435 while (config_read(parser, token, 2, 2, "# \t", PARSE_NORMAL | PARSE_MIN_DIE)) { 436 // parse code/value pair 437 int a = ctoi(token[0]); 438 int b = ctoi(token[1]); 439 if (a < 0 || a >= E_TABSZ 440 || b < 0 || b > 65535 441 ) { 442 bb_error_msg_and_die("map format"); 443 } 444 // patch map 445 unicodes[a] = b; 446 // unicode character is met? 447 if (b > 255) 448 mode = PIO_UNISCRNMAP; 449 } 450 if (ENABLE_FEATURE_CLEAN_UP) 451 config_close(parser); 452 453 if (mode != PIO_UNISCRNMAP) { 454 #define asciis ((unsigned char *)map) 455 for (i = 0; i < E_TABSZ; i++) 456 asciis[i] = unicodes[i]; 457 #undef asciis 458 } 459 #undef unicodes 460 } 461 #endif // ENABLE_FEATURE_SETFONT_TEXTUAL_MAP 462 463 // do set screen map 464 xioctl(fd, mode, map); 465 466 if (ENABLE_FEATURE_CLEAN_UP) 467 free(map); 468 } 179 469 180 470 return EXIT_SUCCESS; 181 471 } 472 #endif -
branches/2.2.9/mindi-busybox/console-tools/loadkmap.c
r1765 r2725 5 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. 8 * 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 9 8 */ 10 11 9 #include "libbb.h" 12 10 … … 26 24 #define MAX_NR_KEYMAPS 256 27 25 28 int loadkmap_main(int argc, char **argv) ;29 int loadkmap_main(int argc , char **argv)26 int loadkmap_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 27 int loadkmap_main(int argc UNUSED_PARAM, char **argv) 30 28 { 31 29 struct kbentry ke; 32 30 int i, j, fd; 33 31 uint16_t ibuff[NR_KEYS]; 34 char flags[MAX_NR_KEYMAPS]; 35 char buff[7];32 /* const char *tty_name = CURRENT_TTY; */ 33 RESERVE_CONFIG_BUFFER(flags, MAX_NR_KEYMAPS); 36 34 37 if (argc != 1) 35 /* When user accidentally runs "loadkmap FILE" 36 * instead of "loadkmap <FILE", we end up waiting for input from tty. 37 * Let's prevent it: */ 38 if (argv[1]) 38 39 bb_show_usage(); 40 /* bb_warn_ignoring_args(argv[1]); */ 41 fd = get_console_fd_or_die(); 42 /* or maybe: 43 opt = getopt32(argv, "C:", &tty_name); 44 fd = xopen_nonblocking(tty_name); 45 */ 39 46 40 fd = xopen(CURRENT_VC, O_RDWR); 47 xread(STDIN_FILENO, flags, 7); 48 if (strncmp(flags, BINARY_KEYMAP_MAGIC, 7)) 49 bb_error_msg_and_die("not a valid binary keymap"); 41 50 42 xread(0, buff, 7); 43 if (strncmp(buff, BINARY_KEYMAP_MAGIC, 7)) 44 bb_error_msg_and_die("this is not a valid binary keymap"); 45 46 xread(0, flags, MAX_NR_KEYMAPS); 51 xread(STDIN_FILENO, flags, MAX_NR_KEYMAPS); 47 52 48 53 for (i = 0; i < MAX_NR_KEYMAPS; i++) { 49 54 if (flags[i] == 1) { 50 xread( 0, ibuff, NR_KEYS * sizeof(uint16_t));55 xread(STDIN_FILENO, ibuff, NR_KEYS * sizeof(uint16_t)); 51 56 for (j = 0; j < NR_KEYS; j++) { 52 57 ke.kb_index = j; … … 58 63 } 59 64 60 if (ENABLE_FEATURE_CLEAN_UP) close(fd); 61 return 0; 65 if (ENABLE_FEATURE_CLEAN_UP) { 66 close(fd); 67 RELEASE_CONFIG_BUFFER(flags); 68 } 69 return EXIT_SUCCESS; 62 70 } -
branches/2.2.9/mindi-busybox/console-tools/openvt.c
r1765 r2725 6 6 * hacked by Tito <farmatito@tiscali.it> 7 7 * 8 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.8 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 9 9 */ 10 10 11 /* getopt not needed */ 12 11 #include <linux/vt.h> 13 12 #include "libbb.h" 14 13 15 int openvt_main(int argc, char **argv); 16 int openvt_main(int argc, char **argv) 14 /* "Standard" openvt's man page (we do not support all of this): 15 16 openvt [-c NUM] [-fsulv] [--] [command [args]] 17 18 Find the first available VT, and run command on it. Stdio is directed 19 to that VT. If no command is specified then $SHELL is used. 20 21 -c NUM 22 Use the given VT number, not the first free one. 23 -f 24 Force opening a VT: don't try to check if VT is already in use. 25 -s 26 Switch to the new VT when starting the command. 27 The VT of the new command will be made the new current VT. 28 -u 29 Figure out the owner of the current VT, and run login as that user. 30 Suitable to be called by init. Shouldn't be used with -c or -l. 31 -l 32 Make the command a login shell: a "-" is prepended to the argv[0] 33 when command is executed. 34 -v 35 Verbose. 36 -w 37 Wait for command to complete. If -w and -s are used together, 38 switch back to the controlling terminal when the command completes. 39 40 bbox: 41 -u: not implemented 42 -f: always in effect 43 -l: not implemented, ignored 44 -v: ignored 45 -ws: does NOT switch back 46 */ 47 48 /* Helper: does this fd understand VT_xxx? */ 49 static int not_vt_fd(int fd) 17 50 { 18 char vtname[sizeof(VC_FORMAT) + 2]; 51 struct vt_stat vtstat; 52 return ioctl(fd, VT_GETSTATE, &vtstat); /* !0: error, it's not VT fd */ 53 } 19 54 20 if (argc < 3) 21 bb_show_usage(); 55 /* Helper: get a fd suitable for VT_xxx */ 56 static int get_vt_fd(void) 57 { 58 int fd; 22 59 23 /* check for illegal vt number: < 1 or > 63 */ 24 sprintf(vtname, VC_FORMAT, (int)xatou_range(argv[1], 1, 63)); 60 /* Do we, by chance, already have it? */ 61 for (fd = 0; fd < 3; fd++) 62 if (!not_vt_fd(fd)) 63 return fd; 64 fd = open(DEV_CONSOLE, O_RDONLY | O_NONBLOCK); 65 if (fd >= 0 && !not_vt_fd(fd)) 66 return fd; 67 bb_error_msg_and_die("can't find open VT"); 68 } 25 69 26 bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS, argv); 27 /* grab new one */ 28 close(0); 70 static int find_free_vtno(void) 71 { 72 int vtno; 73 int fd = get_vt_fd(); 74 75 errno = 0; 76 /*xfunc_error_retval = 3; - do we need compat? */ 77 if (ioctl(fd, VT_OPENQRY, &vtno) != 0 || vtno <= 0) 78 bb_perror_msg_and_die("can't find open VT"); 79 // Not really needed, grep for DAEMON_ONLY_SANITIZE 80 // if (fd > 2) 81 // close(fd); 82 return vtno; 83 } 84 85 /* vfork scares gcc, it generates bigger code. 86 * Keep it away from main program. 87 * TODO: move to libbb; or adapt existing libbb's spawn(). 88 */ 89 static NOINLINE void vfork_child(char **argv) 90 { 91 if (vfork() == 0) { 92 /* CHILD */ 93 /* Try to make this VT our controlling tty */ 94 setsid(); /* lose old ctty */ 95 ioctl(STDIN_FILENO, TIOCSCTTY, 0 /* 0: don't forcibly steal */); 96 //bb_error_msg("our sid %d", getsid(0)); 97 //bb_error_msg("our pgrp %d", getpgrp()); 98 //bb_error_msg("VT's sid %d", tcgetsid(0)); 99 //bb_error_msg("VT's pgrp %d", tcgetpgrp(0)); 100 BB_EXECVP_or_die(argv); 101 } 102 } 103 104 int openvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 105 int openvt_main(int argc UNUSED_PARAM, char **argv) 106 { 107 char vtname[sizeof(VC_FORMAT) + sizeof(int)*3]; 108 struct vt_stat vtstat; 109 char *str_c; 110 int vtno; 111 int flags; 112 enum { 113 OPT_c = (1 << 0), 114 OPT_w = (1 << 1), 115 OPT_s = (1 << 2), 116 OPT_l = (1 << 3), 117 OPT_f = (1 << 4), 118 OPT_v = (1 << 5), 119 }; 120 121 /* "+" - stop on first non-option */ 122 flags = getopt32(argv, "+c:wslfv", &str_c); 123 argv += optind; 124 125 if (flags & OPT_c) { 126 /* Check for illegal vt number: < 1 or > 63 */ 127 vtno = xatou_range(str_c, 1, 63); 128 } else { 129 vtno = find_free_vtno(); 130 } 131 132 /* Grab new VT */ 133 sprintf(vtname, VC_FORMAT, vtno); 134 /* (Try to) clean up stray open fds above fd 2 */ 135 bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS | DAEMON_ONLY_SANITIZE, NULL); 136 close(STDIN_FILENO); 137 /*setsid(); - BAD IDEA: after we exit, child is SIGHUPed... */ 29 138 xopen(vtname, O_RDWR); 30 dup2(0, STDOUT_FILENO); 31 dup2(0, STDERR_FILENO); 139 xioctl(STDIN_FILENO, VT_GETSTATE, &vtstat); 32 140 33 BB_EXECVP(argv[2], &argv[2]); 34 _exit(1); 141 if (flags & OPT_s) { 142 console_make_active(STDIN_FILENO, vtno); 143 } 144 145 if (!argv[0]) { 146 argv--; 147 argv[0] = getenv("SHELL"); 148 if (!argv[0]) 149 argv[0] = (char *) DEFAULT_SHELL; 150 /*argv[1] = NULL; - already is */ 151 } 152 153 xdup2(STDIN_FILENO, STDOUT_FILENO); 154 xdup2(STDIN_FILENO, STDERR_FILENO); 155 156 #ifdef BLOAT 157 { 158 /* Handle -l (login shell) option */ 159 const char *prog = argv[0]; 160 if (flags & OPT_l) 161 argv[0] = xasprintf("-%s", argv[0]); 162 } 163 #endif 164 165 vfork_child(argv); 166 if (flags & OPT_w) { 167 /* We have only one child, wait for it */ 168 safe_waitpid(-1, NULL, 0); /* loops on EINTR */ 169 if (flags & OPT_s) { 170 console_make_active(STDIN_FILENO, vtstat.v_active); 171 // Compat: even with -c N (try to) disallocate: 172 // # /usr/app/kbd-1.12/bin/openvt -f -c 9 -ws sleep 5 173 // openvt: could not deallocate console 9 174 xioctl(STDIN_FILENO, VT_DISALLOCATE, (void*)(ptrdiff_t)vtno); 175 } 176 } 177 return EXIT_SUCCESS; 35 178 } -
branches/2.2.9/mindi-busybox/console-tools/reset.c
r1765 r2725 6 6 * Written by Erik Andersen and Kent Robotti <robotti@metconnect.com> 7 7 * 8 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.8 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 9 9 */ 10 10 11 /* no options, no getopt */ 11 /* BTW, which "standard" package has this utility? It doesn't seem 12 * to be ncurses, coreutils, console-tools... then what? */ 12 13 13 14 #include "libbb.h" 14 15 15 int reset_main(int argc, char **argv); 16 int reset_main(int argc, char **argv) 16 #define ESC "\033" 17 18 #if ENABLE_STTY 19 int stty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 20 #endif 21 22 int reset_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 23 int reset_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) 17 24 { 18 if (isatty(1)) { 25 static const char *const args[] = { 26 "stty", "sane", NULL 27 }; 28 29 /* no options, no getopt */ 30 31 if (/*isatty(STDIN_FILENO) &&*/ isatty(STDOUT_FILENO)) { 19 32 /* See 'man 4 console_codes' for details: 20 * "ESC c" 21 * "ESC ( K" 22 * "ESC [ J" -- Erase display23 * "ESC [ 0 m" -- Reset all display attributes24 * "ESC [ ? 25 h" -- Make cursor visible.33 * "ESC c" -- Reset 34 * "ESC ( K" -- Select user mapping 35 * "ESC [ 0 m" -- Reset all display attributes 36 * "ESC [ J" -- Erase to the end of screen 37 * "ESC [ ? 25 h" -- Make cursor visible 25 38 */ 26 printf("\033c\033(K\033[J\033[0m\033[?25h"); 39 printf(ESC"c" ESC"(K" ESC"[0m" ESC"[J" ESC"[?25h"); 40 /* http://bugs.busybox.net/view.php?id=1414: 41 * people want it to reset echo etc: */ 42 #if ENABLE_STTY 43 return stty_main(2, (char**)args); 44 #else 45 execvp("stty", (char**)args); 46 #endif 27 47 } 28 48 return EXIT_SUCCESS; 29 49 } 30 -
branches/2.2.9/mindi-busybox/console-tools/resize.c
r1765 r2725 3 3 * resize - set terminal width and height. 4 4 * 5 * Copyright 2006 Bernhard Fischer5 * Copyright 2006 Bernhard Reutner-Fischer 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 source tree. 8 8 */ 9 9 /* no options, no getopt */ … … 12 12 #define ESC "\033" 13 13 14 #define old_termios (*(struct termios*)&bb_common_bufsiz1)14 #define old_termios_p ((struct termios*)&bb_common_bufsiz1) 15 15 16 16 static void 17 onintr(int sig ATTRIBUTE_UNUSED)17 onintr(int sig UNUSED_PARAM) 18 18 { 19 tcsetattr(STDERR_FILENO, TCSANOW, &old_termios);20 exit(1);19 tcsetattr(STDERR_FILENO, TCSANOW, old_termios_p); 20 _exit(EXIT_FAILURE); 21 21 } 22 22 23 int resize_main(int argc, char **argv) ;24 int resize_main(int argc , char **argv)23 int resize_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 24 int resize_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) 25 25 { 26 26 struct termios new; 27 struct winsize w = { 0, 0,0,0 };27 struct winsize w = { 0, 0, 0, 0 }; 28 28 int ret; 29 29 … … 34 34 */ 35 35 36 tcgetattr(STDERR_FILENO, &old_termios); /* fiddle echo */37 new = old_termios;36 tcgetattr(STDERR_FILENO, old_termios_p); /* fiddle echo */ 37 memcpy(&new, old_termios_p, sizeof(new)); 38 38 new.c_cflag |= (CLOCAL | CREAD); 39 39 new.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); 40 signal(SIGINT, onintr); 41 signal(SIGQUIT, onintr); 42 signal(SIGTERM, onintr); 43 signal(SIGALRM, onintr); 40 bb_signals(0 41 + (1 << SIGINT) 42 + (1 << SIGQUIT) 43 + (1 << SIGTERM) 44 + (1 << SIGALRM) 45 , onintr); 44 46 tcsetattr(STDERR_FILENO, TCSANOW, &new); 45 47 … … 60 62 ret = ioctl(STDERR_FILENO, TIOCSWINSZ, &w); 61 63 62 tcsetattr(STDERR_FILENO, TCSANOW, &old_termios);64 tcsetattr(STDERR_FILENO, TCSANOW, old_termios_p); 63 65 64 66 if (ENABLE_FEATURE_RESIZE_PRINT) -
branches/2.2.9/mindi-busybox/console-tools/setconsole.c
r1765 r2725 4 4 * 5 5 * Copyright (C) 2004,2005 Enrik Berkhan <Enrik.Berkhan@inka.de> 6 * Copyright (C) 2008 Bernhard Reutner-Fischer 6 7 * 7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.8 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 8 9 */ 9 10 10 #include <getopt.h>11 11 #include "libbb.h" 12 12 13 #if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS 14 static const char setconsole_longopts[] ALIGN1 = 15 "reset\0" No_argument "r" 16 ; 17 #endif 18 19 #define OPT_SETCONS_RESET 1 20 21 int setconsole_main(int argc, char **argv); 22 int setconsole_main(int argc, char **argv) 13 int setconsole_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 14 int setconsole_main(int argc UNUSED_PARAM, char **argv) 23 15 { 24 unsigned long flags;25 16 const char *device = CURRENT_TTY; 17 bool reset; 26 18 27 19 #if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS 20 static const char setconsole_longopts[] ALIGN1 = 21 "reset\0" No_argument "r" 22 ; 28 23 applet_long_options = setconsole_longopts; 29 24 #endif 30 flags = getopt32(argv, "r"); 25 /* at most one non-option argument */ 26 opt_complementary = "?1"; 27 reset = getopt32(argv, "r"); 31 28 32 if (argc - optind > 1) 33 bb_show_usage(); 34 35 if (argc - optind == 1) { 36 if (flags & OPT_SETCONS_RESET) 37 bb_show_usage(); 38 device = argv[optind]; 29 argv += 1 + reset; 30 if (*argv) { 31 device = *argv; 39 32 } else { 40 if ( flags & OPT_SETCONS_RESET)33 if (reset) 41 34 device = DEV_CONSOLE; 42 35 } -
branches/2.2.9/mindi-busybox/console-tools/setkeycodes.c
r1765 r2725 7 7 * Adjusted for BusyBox by Erik Andersen <andersen@codepoet.org> 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 source tree. 10 10 */ 11 12 //#include <sys/ioctl.h>13 11 #include "libbb.h" 14 12 15 13 /* From <linux/kd.h> */ 16 14 struct kbkeycode { 17 unsigned intscancode, keycode;15 unsigned scancode, keycode; 18 16 }; 19 17 enum { … … 21 19 }; 22 20 23 int setkeycodes_main(int argc, char ** argv);24 int setkeycodes_main(int argc, char **argv)21 int setkeycodes_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 22 int setkeycodes_main(int argc, char **argv) 25 23 { 26 int fd , sc;24 int fd; 27 25 struct kbkeycode a; 28 26 29 if ( argc % 2 != 1|| argc < 2) {27 if (!(argc & 1) /* if even */ || argc < 2) { 30 28 bb_show_usage(); 31 29 } 32 30 33 fd = get_console_fd ();31 fd = get_console_fd_or_die(); 34 32 35 while (argc > 2) { 36 a.keycode = xatoul_range(argv[2], 0, 127); 37 a.scancode = sc = xstrtoul_range(argv[1], 16, 0, 255); 38 if (a.scancode > 127) { 39 a.scancode -= 0xe000; 40 a.scancode += 128; 33 while (argv[1]) { 34 int sc = xstrtoul_range(argv[1], 16, 0, 0xe07f); 35 if (sc >= 0xe000) { 36 sc -= 0xe000; 37 sc += 0x0080; 41 38 } 39 a.scancode = sc; 40 a.keycode = xatou_range(argv[2], 0, 255); 42 41 ioctl_or_perror_and_die(fd, KDSETKEYCODE, &a, 43 " failed toset SCANCODE %x to KEYCODE %d",42 "can't set SCANCODE %x to KEYCODE %d", 44 43 sc, a.keycode); 45 argc -= 2;46 44 argv += 2; 47 45 } -
branches/2.2.9/mindi-busybox/console-tools/setlogcons.c
r1765 r2725 7 7 * Based on setlogcons (kbd-1.12) by Andries E. Brouwer 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 source tree. 10 10 */ 11 11 12 12 #include "libbb.h" 13 13 14 int setlogcons_main(int argc, char **argv) ;15 int setlogcons_main(int argc , char **argv)14 int setlogcons_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 15 int setlogcons_main(int argc UNUSED_PARAM, char **argv) 16 16 { 17 17 struct { 18 18 char fn; 19 19 char subarg; 20 } arg; 20 } arg = { 11, /* redirect kernel messages */ 21 0 /* to specified console (current as default) */ 22 }; 21 23 22 arg.fn = 11; /* redirect kernel messages */ 23 arg.subarg = 0; /* to specified console (current as default) */ 24 25 if (argc == 2) 26 arg.subarg = xatoul_range(argv[1], 0, 63); 24 if (argv[1]) 25 arg.subarg = xatou_range(argv[1], 0, 63); 27 26 28 27 xioctl(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg); 29 28 30 return 0;29 return EXIT_SUCCESS; 31 30 }
Note:
See TracChangeset
for help on using the changeset viewer.