Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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