wok annotate busybox/stuff/busybox-1.10.3-vcsa2txt.u @ rev 890

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