wok-next diff busybox/stuff/busybox-1.11.0-vcsa2txt.u @ rev 1900

emacs: typo fix in receipt
author Dominique Corbex <domcox@users.sourceforge.net>
date Sat Dec 20 18:45:42 2008 +0100 (2008-12-20)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/busybox/stuff/busybox-1.11.0-vcsa2txt.u	Sat Dec 20 18:45:42 2008 +0100
     1.3 @@ -0,0 +1,134 @@
     1.4 +--- busybox-1.11.0/include/applets.h
     1.5 ++++ busybox-1.11.0/include/applets.h
     1.6 +@@ -380,6 +380,7 @@
     1.7 + USE_UUDECODE(APPLET(uudecode, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
     1.8 + USE_UUENCODE(APPLET(uuencode, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
     1.9 + USE_VCONFIG(APPLET(vconfig, _BB_DIR_SBIN, _BB_SUID_NEVER))
    1.10 ++USE_VCSA2TXT(APPLET(vcsa2txt, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
    1.11 + USE_VI(APPLET(vi, _BB_DIR_BIN, _BB_SUID_NEVER))
    1.12 + USE_VLOCK(APPLET(vlock, _BB_DIR_USR_BIN, _BB_SUID_ALWAYS))
    1.13 + USE_WATCH(APPLET(watch, _BB_DIR_BIN, _BB_SUID_NEVER))
    1.14 + 
    1.15 +--- busybox-1.11.0/include/usage.h
    1.16 ++++ busybox-1.11.0/include/usage.h
    1.17 +@@ -4455,6 +4455,13 @@
    1.18 +      "\n	set_ingress_map	[vlan-name] [skb_priority] [vlan_qos]" \
    1.19 +      "\n	set_name_type	[name-type]" \
    1.20 + 
    1.21 ++#define vcsa2txt_trivial_usage \
    1.22 ++       "stdin"
    1.23 ++#define vcsa2txt_full_usage \
    1.24 ++       "Filter /dev/vcsa* to ansi escape sequences"
    1.25 ++#define vcsa2txt_example_usage \
    1.26 ++       "# vcsa2txt < /dev/vcsa1\n"
    1.27 ++
    1.28 + #define vi_trivial_usage \
    1.29 +        "[OPTION] [FILE]..."
    1.30 + #define vi_full_usage "\n\n" \
    1.31 + 
    1.32 +--- busybox-1.11.0/miscutils/Config.in
    1.33 ++++ busybox-1.11.0/miscutils/Config.in
    1.34 +@@ -506,6 +506,12 @@
    1.35 + 	  only height, or both, in any order. It also does not complain on error,
    1.36 + 	  but returns default 80x24. Usage in shell scripts: width=`ttysize w`.
    1.37 + 
    1.38 ++config VCSA2TXT
    1.39 ++	bool "vcsa2txt"
    1.40 ++	default n
    1.41 ++	help
    1.42 ++	  Filter /dev/vcsa* output to ansi escape sequences.
    1.43 ++
    1.44 + config WATCHDOG
    1.45 + 	bool "watchdog"
    1.46 + 	default n
    1.47 +	
    1.48 +--- busybox-1.11.0/util-linux/Kbuild
    1.49 ++++ busybox-1.11.0/util-linux/Kbuild
    1.50 +@@ -33,3 +33,4 @@
    1.51 + lib-$(CONFIG_SWAPONOFF)         += swaponoff.o
    1.52 + lib-$(CONFIG_SWITCH_ROOT)       += switch_root.o
    1.53 + lib-$(CONFIG_UMOUNT)            += umount.o
    1.54 ++lib-$(CONFIG_VCSA2TXT)          += vcsa2txt.o
    1.55 +
    1.56 +--- busybox-1.11.0/util-linux/vcsa2txt.c
    1.57 ++++ busybox-1.11.0/util-linux/vcsa2txt.c
    1.58 +@@ -0,0 +1,79 @@
    1.59 ++/* vi: set sw=4 ts=4: */
    1.60 ++/*
    1.61 ++ * /dev/vcsa* filter for busybox
    1.62 ++ *
    1.63 ++ * pascal.bellard@ads-lu.com
    1.64 ++ *
    1.65 ++ * Licensed under GPLv2 or later, see file License in this tarball for details.
    1.66 ++ */
    1.67 ++ 
    1.68 ++#include "libbb.h"
    1.69 ++
    1.70 ++int vcsa2txt_main(int argc) MAIN_EXTERNALLY_VISIBLE;
    1.71 ++int vcsa2txt_main(int argc)
    1.72 ++{
    1.73 ++    struct {
    1.74 ++	unsigned char l, c, x, y; // man 4 console_codes
    1.75 ++    } scrn;
    1.76 ++    unsigned char last = 0, ch[2];                     // BLGCRMOW
    1.77 ++    static  unsigned char end[5] = "\e[0m\n", color[8] = "04261537";
    1.78 ++    int sp, lf, x;
    1.79 ++    
    1.80 ++    if (safe_read(0, &scrn, 4) < 0) return 1;
    1.81 ++    for (lf = 0; scrn.l; lf++, scrn.l--) {
    1.82 ++	for (sp = x = 0; ++x <= scrn.c;) {
    1.83 ++	    if (safe_read(0, &ch[0], 2) < 0) return 1;
    1.84 ++	    if (argc > 1) ch[1] = 0;
    1.85 ++	    sp++;
    1.86 ++	    if (last == ch[1] && ch[0] == ' ') continue;
    1.87 ++	    for (lf++; --lf;) bb_putchar('\n');
    1.88 ++	    while (--sp) bb_putchar(' ');
    1.89 ++#define ENABLE_VCSA_PACKED 1
    1.90 ++#if ENABLE_VCSA_PACKED
    1.91 ++	    if (last ^= ch[1]) {
    1.92 ++		char esc[16],*s;
    1.93 ++		struct offsets {
    1.94 ++		    char mask, type, shr;
    1.95 ++		} *p;
    1.96 ++		static struct offsets offset[3] = {
    1.97 ++		    {8,0,1}, {0x70,'4',4}, {7,'3',0}
    1.98 ++		};
    1.99 ++		static char init = 0x7F;
   1.100 ++		
   1.101 ++		s = esc+2;
   1.102 ++		*(short *)esc = ntohs(256*'\e'+'[');
   1.103 ++		p = offset;
   1.104 ++		do {
   1.105 ++		    if ((init|last) & p->mask) {
   1.106 ++			int c = (ch[1] & p->mask) >> p->shr;
   1.107 ++		    
   1.108 ++			if ((*s = p->type) != 0) s++;
   1.109 ++			else if (c == 0) {
   1.110 ++			    c = 2;
   1.111 ++			    *s++ = '2'; /* normal */
   1.112 ++			}
   1.113 ++			*s++ = color[c];
   1.114 ++			*s++ = ';'; 
   1.115 ++		    }
   1.116 ++		} while (p++->shr);
   1.117 ++		s[-1] = 'm';
   1.118 ++		init = 0;
   1.119 ++		fwrite(esc,s-esc,1,stdout);
   1.120 ++	    }
   1.121 ++	    last = ch[1];
   1.122 ++#else
   1.123 ++	    if (last != ch[1]) {
   1.124 ++		static char esc[10] = "\e[0;47;37m";
   1.125 ++		
   1.126 ++		esc[2] = ((last = ch[1]) & 8) ? '1' /* bold */ : '0' /* defaults */;
   1.127 ++		esc[sizeof(esc)-5] = color[(ch[1] >> 4) & 7];
   1.128 ++		esc[sizeof(esc)-2] = color[ch[1] & 7];
   1.129 ++		fwrite(esc,sizeof(esc),1,stdout);
   1.130 ++	    }
   1.131 ++#endif
   1.132 ++	    bb_putchar(ch[0]);
   1.133 ++	}
   1.134 ++    }
   1.135 ++    fwrite(end,sizeof(end),1,stdout);
   1.136 ++    return 0;
   1.137 ++}