wok-current annotate busybox/stuff/busybox-1.12.0-vcsa2txt.u @ rev 5657

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