intr_char.c 811 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include <grass/gis.h>
  2. #include <grass/config.h>
  3. #ifndef __MINGW32__
  4. #if defined(HAVE_TERMIOS_H)
  5. # include <termios.h>
  6. # define TYPE termios
  7. # define C c_cc[VINTR]
  8. #elif defined(HAVE_TERMIO_H)
  9. # include <termio.h>
  10. # define TYPE termio
  11. # define C c_cc[VINTR]
  12. # define GET TCGETA
  13. #else
  14. # include <sgtty.h>
  15. # define TYPE tchars
  16. # define C t_intrc
  17. # define GET TIOCGETC
  18. #endif
  19. #endif
  20. /*!
  21. * \brief return interrupt char
  22. *
  23. * This routine returns the
  24. * user's keyboard interrupt character. This is the character that generates the
  25. * SIGINT signal from the keyboard.
  26. *
  27. * \param ~
  28. * \return char
  29. */
  30. char G_intr_char(void)
  31. {
  32. char c = 0;
  33. #ifndef __MINGW32__
  34. struct TYPE buf;
  35. #ifdef HAVE_TERMIOS_H
  36. tcgetattr(2, &buf);
  37. #else
  38. ioctl(2, GET, &buf);
  39. #endif
  40. c = buf.C;
  41. #endif
  42. return c;
  43. }