Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <time.h>
  4.  
  5. #ifndef WINDOWS
  6. #ifndef KOS32
  7. #include <sys/ioctl.h>
  8. #include <termios.h>
  9. #include <unistd.h>
  10. #endif
  11. #endif
  12.  
  13. void randomize(void) {
  14.         srand((int)time(NULL));
  15. }
  16.  
  17. #if !defined(KOS32) && !defined(__TINYC__)
  18. int max(int a, int b) {
  19.         if (a > b) return a;
  20.         return b;
  21. }
  22.  
  23. int min(int a, int b) {
  24.         if (a < b) return a;
  25.         return b;
  26. }
  27. #endif
  28.  
  29. #ifndef WINDOWS
  30. #ifndef KOS32
  31. int // <editor-fold defaultstate="collapsed" desc="comment">
  32. getch// </editor-fold>
  33. (void) {
  34.         char chbuf[1];
  35.     struct termios oldstate, newstate;
  36.     fflush(stdout);
  37.         tcgetattr(0, &oldstate);
  38.         newstate = oldstate;
  39.         newstate.c_lflag &= ~ICANON;
  40.         newstate.c_lflag &= ~ECHO;
  41.         tcsetattr(0, TCSANOW,  &newstate);
  42.         read(0, &chbuf, 1);
  43.         tcsetattr(0, TCSANOW, &oldstate);
  44.         return chbuf[0];
  45. }
  46. #endif
  47. #endif