1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#include "libbb.h"
22
23int ascii_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
24int ascii_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
25{
26 const char *ctrl =
27 "NUL""SOH""STX""ETX""EOT""ENQ""ACK""BEL"
28 "BS ""HT ""NL ""VT ""FF ""CR ""SO ""SI "
29 "DLE""DC1""DC2""DC3""DC4""NAK""SYN""ETB"
30 "CAN""EM ""SUB""ESC""FS ""GS ""RS ""US "
31 ;
32
33 char last[2];
34 unsigned i;
35
36 last[1] = '\0';
37 printf("Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex\n");
38 for (i = 0; i < 16; i++) {
39 printf("%3u %02x %.3s%4u %02x %.3s%4u %02x %c%4u %02x %c%4u %02x %c%4u %02x %c%5u %02x %c%5u %02x %s\n",
40 i+0x00, i+0x00, ctrl + i*3,
41 i+0x10, i+0x10, ctrl + i*3 + 16*3,
42 i+0x20, i+0x20, i+0x20,
43 i+0x30, i+0x30, i+0x30,
44 i+0x40, i+0x40, i+0x40,
45 i+0x50, i+0x50, i+0x50,
46 i+0x60, i+0x60, i+0x60,
47 i+0x70, i+0x70, (i+0x70 == 0x7f ? "DEL" : (last[0] = i+0x70, last))
48 );
49 }
50 return EXIT_SUCCESS;
51}
52