File: vtgen.c

package info (click to toggle)
termrec 0.19-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,148 kB
  • sloc: ansic: 8,430; makefile: 181; perl: 16; sh: 15
file content (55 lines) | stat: -rw-r--r-- 1,058 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static int rnd(int x)
{
    if (x<=1)
        return 0;
    return rand()%x;
}

static char rndchar(const char *s)
{
    return s[rnd(strlen(s))];
}

#define ARRAYSZ(x) (sizeof(x)/sizeof(x[0]))

static const char *misc[]=
{
    "\n", "\r", "\b", "\x0c", "\t",
    "\e[?7h", "\e[?7l",
    "\e(0", "\e)0", "\e(B", "\e)B", "\x0e", "\x0f",
};

int main(void)
{
    while (1)
    {
        switch (rnd(4))
        {
        case 0:
            printf("a");
            break;
        case 1:
            printf("@");
            break;
        case 2:
            printf("\xcc\x80");
            break;
        case 3:
            switch (rnd(12))
            {
            case 0:
                printf("\e%c", rndchar("78DEM"));
                break;
            case 1: case 2: case 3:
                puts(misc[rnd(ARRAYSZ(misc))]);
                break;
            default:
                printf("\e[%d;%d%c", rnd(5), rnd(5), rndchar("mDCFAEBrJKLM@PXfGdc"));
            }
        }
    }
}