home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c070 / 4.ddi / TOOLS.4 / TCTSRC1.EXE / KBFLUSH.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  800 b   |  38 lines

  1. /**
  2. *
  3. * Name        KBFLUSH -- Discard all keystrokes waiting in the
  4. *               keyboard buffer.
  5. *
  6. * Synopsis    num_found = kbflush();
  7. *
  8. *        int num_found      Number of waiting keystrokes discarded.
  9. *
  10. * Description    This function discards and clears all keystrokes waiting
  11. *        in the BIOS type-ahead buffer.
  12. *
  13. * Returns    num_found      Number of waiting keystrokes discarded.
  14. *
  15. * Version    5.00 (C)Copyright Blaise Computing Inc.  1986,1987,1989
  16. *
  17. **/
  18.  
  19.  
  20. #include <bkeybrd.h>
  21.  
  22.  
  23. int kbflush()
  24. {
  25.     int  num_found, scan;
  26.     char ch;
  27.  
  28.     num_found = 0;              /* None found yet.          */
  29.  
  30.     while (kbready (&ch, &scan) != 0)
  31.     {
  32.     ++num_found;              /* Found a waiting character.   */
  33.     (void) kbgetkey (&scan);      /* Read and discard it.          */
  34.     }
  35.  
  36.     return (num_found);
  37. }
  38.