summaryrefslogtreecommitdiffstats
path: root/konsole/tests/audit.c
blob: 7a98e9b3088afa393b391f394b295232ddc92406 (plain)
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
/*
 
   This is a tiny test program that can be used to track down
   strange effects of the emulation.

   Make:

   - gcc -o audit audit.c

   Usage:

   - In TEShell.C let syslog be stdout.
   - konsole > ttt
   - produce the effect in question.
   - run this program.
     pressing any key advances the audit
     ^C terminates.

   You need to make sure that the size of the screen matches
   the one being debugged.
 
*/


#include <stdio.h>
#include <termios.h>
#include <unistd.h>

struct termios save;
struct termios curr;

#define HERE fprintf(stderr,"%s(%d): here.\n",__FILE__,__LINE__)

main()
{ int cc;
  FILE* sysin = fopen("ttt","r");
  tcgetattr(0, &save);
  tcgetattr(0, &curr);
  cfmakeraw(&curr);
  tcsetattr(0, TCSANOW, &curr);
  cc = fgetc(sysin);
  while( cc > 0 )
  { int tmp;
    while (cc > 0)
    {
      fputc(cc,stdout); cc = fgetc(sysin);
      if (cc == 0x1b) break;
    }
    tmp = fgetc(stdin);
    if (tmp == 3) break;
  }
  tcsetattr(0, TCSANOW, &save);
}