flushinp.c revision 2
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe/*
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * CDDL HEADER START
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe *
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * The contents of this file are subject to the terms of the
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * Common Development and Distribution License, Version 1.0 only
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * (the "License"). You may not use this file except in compliance
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * with the License.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe *
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * or http://www.opensolaris.org/os/licensing.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * See the License for the specific language governing permissions
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * and limitations under the License.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe *
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * When distributing Covered Code, include this CDDL HEADER in each
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * If applicable, add the following below this CDDL HEADER, with the
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * fields enclosed by brackets "[]" replaced with your own identifying
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * information: Portions Copyright [yyyy] [name of copyright owner]
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe *
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * CDDL HEADER END
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe */
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe/*
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * Use is subject to license terms.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe */
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe/* Copyright (c) 1988 AT&T */
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe/* All Rights Reserved */
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe/*
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * University Copyright- Copyright (c) 1982, 1986, 1988
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * The Regents of the University of California
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * All Rights Reserved
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe *
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * University Acknowledgment- Portions of this document are derived from
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * software developed by the University of California, Berkeley, and its
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * contributors.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe */
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#pragma ident "%Z%%M% %I% %E% SMI"
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe/*LINTLIBRARY*/
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#include <unistd.h>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#include <sys/types.h>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#include "curses_inc.h"
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Loweint
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Loweflushinp(void)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe{
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#ifdef DEBUG
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (outf)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe fprintf(outf, "flushinp(), file %x, SP %x\n",
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe cur_term->Filedes, SP);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#endif /* DEBUG */
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#ifdef SYSV
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe (void) ioctl(cur_term -> Filedes, TCFLSH, 0);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#else /* SYSV */
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe /* for insurance against someone using their own buffer: */
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe (void) ioctl(cur_term -> Filedes, TIOCGETP, &(PROGTTY));
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe /*
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * SETP waits on output and flushes input as side effect.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * Really want an ioctl like TCFLSH but Berkeley doesn't have one.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe */
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe (void) ioctl(cur_term -> Filedes, TIOCSETP, &(PROGTTY));
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#endif /* SYSV */
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe /*
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * Get rid of any typeahead which was read().
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * Leave characters which were ungetch()'d.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe */
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe cur_term->_chars_on_queue = cur_term->_ungotten;
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe /*
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * Have to doupdate() because, if we have stopped output due to
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * typeahead, now that typeahead is gone, so we had better catch up.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe */
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (_INPUTPENDING)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe (void) doupdate();
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe return (OK);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe}
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe