wok-current view busybox/stuff/busybox-1.10.0-vcsa2txt.u @ rev 1032

linux: more crypto modules
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Jul 11 07:45:28 2008 +0000 (2008-07-11)
parents 28948d3430a1
children
line source
1 --- busybox-1.10.0/include/applets.h Sat Mar 22 02:31:50 2008
2 +++ busybox-1.10.0/include/applets.h Sat Mar 22 02:31:50 2008
3 @@ -382,6 +382,7 @@
4 USE_UUDECODE(APPLET(uudecode, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
5 USE_UUENCODE(APPLET(uuencode, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
6 USE_VCONFIG(APPLET(vconfig, _BB_DIR_SBIN, _BB_SUID_NEVER))
7 +USE_VCSA2TXT(APPLET(vcsa2txt, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
8 USE_VI(APPLET(vi, _BB_DIR_BIN, _BB_SUID_NEVER))
9 USE_VLOCK(APPLET(vlock, _BB_DIR_USR_BIN, _BB_SUID_ALWAYS))
10 USE_WATCH(APPLET(watch, _BB_DIR_BIN, _BB_SUID_NEVER))
12 --- busybox-1.10.0/include/usage.h Sat Mar 22 02:31:50 2008
13 +++ busybox-1.10.0/include/usage.h Sat Mar 22 02:31:50 2008
14 @@ -4314,6 +4314,13 @@
15 "\n set_ingress_map [vlan-name] [skb_priority] [vlan_qos]" \
16 "\n set_name_type [name-type]" \
18 +#define vcsa2txt_trivial_usage \
19 + "stdin"
20 +#define vcsa2txt_full_usage \
21 + "Filter /dev/vcsa* to ansi escape sequences"
22 +#define vcsa2txt_example_usage \
23 + "# vcsa2txt < /dev/vcsa1\n"
24 +
25 #define vi_trivial_usage \
26 "[OPTION] [FILE]..."
27 #define vi_full_usage \
29 --- busybox-1.10.0/miscutils/Config.in Sat Mar 22 02:31:50 2008
30 +++ busybox-1.10.0/miscutils/Config.in Sat Mar 22 02:31:50 2008
31 @@ -461,6 +461,12 @@
32 only height, or both, in any order. It also does not complain on error,
33 but returns default 80x24. Usage in shell scripts: width=`ttysize w`.
35 +config VCSA2TXT
36 + bool "vcsa2txt"
37 + default n
38 + help
39 + Filter /dev/vcsa* output to ansi escape sequences.
40 +
41 config WATCHDOG
42 bool "watchdog"
43 default n
45 --- busybox-1.10.0/util-linux/Kbuild Sat Mar 22 02:31:53 2008
46 +++ busybox-1.10.0/util-linux/Kbuild Sat Mar 22 02:31:53 2008
47 @@ -33,3 +33,4 @@
48 lib-$(CONFIG_SWAPONOFF) += swaponoff.o
49 lib-$(CONFIG_SWITCH_ROOT) += switch_root.o
50 lib-$(CONFIG_UMOUNT) += umount.o
51 +lib-$(CONFIG_VCSA2TXT) += vcsa2txt.o
53 --- busybox-1.10.0/util-linux/vcsa2txt.c Sat Mar 22 19:40:15 2008
54 +++ busybox-1.10.0/util-linux/vcsa2txt.c Sat Mar 22 19:40:15 2008
55 @@ -0,0 +1,79 @@
56 +/* vi: set sw=4 ts=4: */
57 +/*
58 + * /dev/vcsa* filter for busybox
59 + *
60 + * pascal.bellard@ads-lu.com
61 + *
62 + * Licensed under GPLv2 or later, see file License in this tarball for details.
63 + */
64 +
65 +#include "libbb.h"
66 +
67 +int vcsa2txt_main(int argc) MAIN_EXTERNALLY_VISIBLE;
68 +int vcsa2txt_main(int argc)
69 +{
70 + struct {
71 + unsigned char l, c, x, y; // man 4 console_codes
72 + } scrn;
73 + unsigned char last = 0, ch[2]; // BLGCRMOW
74 + static unsigned char end[5] = "\e[0m\n", color[8] = "04261537";
75 + int sp, lf, x;
76 +
77 + if (safe_read(0, &scrn, 4) < 0) return 1;
78 + for (lf = 0; scrn.l; lf++, scrn.l--) {
79 + for (sp = x = 0; ++x <= scrn.c;) {
80 + if (safe_read(0, &ch[0], 2) < 0) return 1;
81 + if (argc > 1) ch[1] = 0;
82 + sp++;
83 + if (last == ch[1] && ch[0] == ' ') continue;
84 + for (lf++; --lf;) bb_putchar('\n');
85 + while (--sp) bb_putchar(' ');
86 +#define ENABLE_VCSA_PACKED 1
87 +#if ENABLE_VCSA_PACKED
88 + if (last ^= ch[1]) {
89 + char esc[16],*s;
90 + struct offsets {
91 + char mask, type, shr;
92 + } *p;
93 + static struct offsets offset[3] = {
94 + {8,0,1}, {0x70,'4',4}, {7,'3',0}
95 + };
96 + static char init = 0x7F;
97 +
98 + s = esc+2;
99 + *(short *)esc = ntohs(256*'\e'+'[');
100 + p = offset;
101 + do {
102 + if ((init|last) & p->mask) {
103 + int c = (ch[1] & p->mask) >> p->shr;
104 +
105 + if ((*s = p->type) != 0) s++;
106 + else if (c == 0) {
107 + c = 2;
108 + *s++ = '2'; /* normal */
109 + }
110 + *s++ = color[c];
111 + *s++ = ';';
112 + }
113 + } while (p++->shr);
114 + s[-1] = 'm';
115 + init = 0;
116 + fwrite(esc,s-esc,1,stdout);
117 + }
118 + last = ch[1];
119 +#else
120 + if (last != ch[1]) {
121 + static char esc[10] = "\e[0;47;37m";
122 +
123 + esc[2] = ((last = ch[1]) & 8) ? '1' /* bold */ : '0' /* defaults */;
124 + esc[sizeof(esc)-5] = color[(ch[1] >> 4) & 7];
125 + esc[sizeof(esc)-2] = color[ch[1] & 7];
126 + fwrite(esc,sizeof(esc),1,stdout);
127 + }
128 +#endif
129 + bb_putchar(ch[0]);
130 + }
131 + }
132 + fwrite(end,sizeof(end),1,stdout);
133 + return 0;
134 +}