The beginnings of the website.
[super-star-trek.git] / linux.c
1 #include <stdlib.h>
2 #include <time.h>
3 #include <sys/ioctl.h>
4
5 void randomize(void) {
6         srand((int)time(NULL));
7 }
8
9
10 int max(int a, int b) {
11         if (a > b) return a;
12         return b;
13 }
14
15 int min(int a, int b) {
16         if (a < b) return a;
17         return b;
18 }
19
20 int getch(void) {
21         char chbuf[1];
22         struct termio oldstate, newstate;
23     ioctl(0,TCGETA,&oldstate);
24         newstate = oldstate;
25         newstate.c_iflag = 0;
26         newstate.c_lflag = 0;
27         ioctl(0,TCSETA,&newstate);
28         read(0, &chbuf, 1);
29     ioctl(0,TCSETA,&oldstate);
30 }
31