aaio.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * AAIO Advanced I/O
  3. * -----------------
  4. *
  5. * Many people moving from Windows programming to UNIX program have problems
  6. * with the missing non-blocking getch() and getche() functions provided by
  7. * conio.h. This library provides the functionality of getch(), getche() and
  8. * kbhit(). It does not require an initialization (like curses) and does
  9. * not abuse the terminal (i.e. whenever the mode of the terminal is
  10. * changed its state is stored so it can be restored). For increased
  11. * efficiency there exists funcionality to allow abuse of the terminal as well
  12. * as functions to restore or reset the terminal when the application exits.
  13. */
  14. /*
  15. * Copyright (c) 2004-2005 by Daniel Aarno - <[email protected], [email protected]>
  16. * M. Sc. Electrical Engineering * http://www.nada.kth.se/~bishop
  17. *
  18. * This library is free software; you can redistribute it and/or
  19. * modify it under the terms of the GNU Lesser General Public
  20. * License as published by the Free Software Foundation; either
  21. * version 2.1 of the License, or (at your option) any later version.
  22. * * Relicensed from Attribution Assurance License to LGPLv2 with
  23. * permission from the original author (received 2025-01-09).
  24. */
  25. #ifndef _L_AAIO_
  26. #define _L_AAIO_
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /**
  31. * Get a character from stdin. Block until a character is available
  32. * but does not wait for a new line. Characters are not echoed on to
  33. * screen.
  34. *
  35. * @return The first character available cast to an int or -1 on error.
  36. * @see getche
  37. */
  38. int getch(void);
  39. /**
  40. * Get a character from stdin. Block until a character is available
  41. * but does not wait for a new line. Characters are echoed on to
  42. * screen.
  43. *
  44. * @return The first character available cast to an int or -1 on error.
  45. * @see getch
  46. */
  47. int getche(void);
  48. /**
  49. * Get the number of characters available on stdin.
  50. *
  51. * @return The number of characters that can be read from stdin without
  52. * blocking, -1 on error.
  53. * @see getch
  54. * @see getche
  55. */
  56. int kbhit(void);
  57. int aaio_hard_reset(void);
  58. /**
  59. * Flush any remaining characters from the stdandard input.
  60. *
  61. * @return The number of charactes removed.
  62. */
  63. int aaio_flush(void);
  64. #ifdef __cplusplus
  65. }
  66. #endif
  67. #endif //_L_AAIO_