home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / gdb-4.9 / gdb / nindy-share / ttyflush.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-12  |  2.2 KB  |  56 lines

  1. /*****************************************************************************
  2.  * Copyright 1990, 1992 Free Software Foundation, Inc.
  3.  *
  4.  * This code was donated by Intel Corp.
  5.  *
  6.  * Intel hereby grants you permission to copy, modify, and 
  7.  * distribute this software and its documentation.  Intel grants
  8.  * this permission provided that the above copyright notice 
  9.  * appears in all copies and that both the copyright notice and
  10.  * this permission notice appear in supporting documentation.  In
  11.  * addition, Intel grants this permission provided that you
  12.  * prominently mark as not part of the original any modifications
  13.  * made to this software or documentation, and that the name of 
  14.  * Intel Corporation not be used in advertising or publicity 
  15.  * pertaining to distribution of the software or the documentation 
  16.  * without specific, written prior permission.  
  17.  *
  18.  * Intel Corporation does not warrant, guarantee or make any 
  19.  * representations regarding the use of, or the results of the use
  20.  * of, the software and documentation in terms of correctness, 
  21.  * accuracy, reliability, currentness, or otherwise; and you rely
  22.  * on the software, documentation and results solely at your own risk.
  23.  *****************************************************************************/
  24.  
  25. static char rcsid[] =
  26.     "Id: ttyflush.c,v 1.1.1.1 1991/03/28 16:21:03 rich Exp $";
  27.  
  28. #include <stdio.h>
  29. #include <fcntl.h>    /* Needed on Sys V */
  30. #include "ttycntl.h"
  31.  
  32. /******************************************************************************
  33.  * tty_flush:
  34.  *
  35.  *    This routine puts the specified tty into a quiescent state by flushing
  36.  *    all pending input and output.
  37.  *
  38.  *    The tty is assumed to be connected to an i960 board containing a
  39.  *    a NINDY ROM;  since the 960 may be generating output, we wait until
  40.  *    at least one second goes by without anything new arriving.
  41.  ******************************************************************************/
  42.  
  43. tty_flush( fd )
  44.     int fd;    /* File descriptor of tty line */
  45. {
  46.     int n;    /* Number of characters of pending input */
  47.     char c;    /* Next character of input (discarded) */
  48.  
  49.     do {
  50.         TTY_FLUSH( fd );
  51.         sleep(1);
  52.         n = 1;
  53.         TTY_NBREAD( fd, n, &c );    /* Non-blocking read */
  54.     } while ( n > 0 );
  55. }
  56.