~ubuntu-branches/ubuntu/wily/gargoyle-free/wily-proposed

« back to all changes in this revision

Viewing changes to terps/alan2/chartest.c

  • Committer: Package Import Robot
  • Author(s): Sylvain Beucler
  • Date: 2013-07-28 13:38:56 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20130728133856-4k6uc864wzsnrx04
Tags: 2011.1a-1
* New upstream release
* Alan 2 interpreter is now Free Software, include it
* Update fonts package names in dependencies (Closes: #715160)
* Bump Standards-Version to 3.9.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdlib.h>
 
2
#include <stdio.h>
 
3
#include <ctype.h>
 
4
#include <unistd.h>
 
5
#include <termios.h>
 
6
 
 
7
static struct termios term;
 
8
 
 
9
static void newtermio()
 
10
{
 
11
  struct termios newterm;
 
12
  tcgetattr(0, &term);
 
13
  newterm=term;
 
14
  newterm.c_lflag&=~(ECHO|ICANON);
 
15
  newterm.c_cc[VMIN]=1;
 
16
  newterm.c_cc[VTIME]=0;
 
17
  tcsetattr(0, TCSANOW, &newterm);
 
18
}
 
19
 
 
20
static void restoretermio()
 
21
{
 
22
  tcsetattr(0, TCSANOW, &term);
 
23
}
 
24
 
 
25
 
 
26
void main()
 
27
{
 
28
  int endOfInput = 0;
 
29
  char ch;
 
30
 
 
31
  while (!endOfInput) {
 
32
    fflush(stdout);
 
33
    if (read(0, &ch, 1) != 1) {
 
34
      return;
 
35
    }
 
36
    printf("%d %x '%c'\n", (int)ch, (int)ch, ch);
 
37
  }
 
38
  return;
 
39
}