/*
 * $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred."
 *
 */
/*	Copyright (c) 1984 AT&T	*/
/*	  All Rights Reserved  	*/

/*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*/
/*	The copyright notice above does not evidence any   	*/
/*	actual or intended publication of such source code.	*/

#ident	"$Header: fixdelay.c 1.3 89/10/10 $@(#)curses:screen/fixdelay.c	1.2"
/*
 * Routines to deal with setting and resetting modes in the tty driver.
 * See also setupterm.c in the termlib part.
 */
#include "curses.ext"

/*
 * The user has just changed his notion of whether we want nodelay mode.
 * Do any system dependent processing.
 */
/* ARGSUSED */
_fixdelay(old, new)
bool old, new;
{
#ifdef SYSV
# include <fcntl.h>
	register int fl, fd;
	extern int errno;

	if (old != new) {
		fd = fileno(SP->term_file);
		fl = fcntl(fd, F_GETFL, 0);
		if (fl == -1)
		    (void) fprintf(stderr, "fcntl(F_GETFL) failed in _fixdelay\n");
		if (new)
			fl |= O_NDELAY;
		else
			fl &= ~O_NDELAY;
		(void) fcntl(fd, F_SETFL, fl);
	}
#else
	/* No system dependent processing on the V7 or Berkeley systems. */
#endif
	SP->fl_nodelay = new;
}
