/*
 * NAME:
 *	tiocompat - tc{get,set}attr for seriously old SunOS
 */
/*
 *      @(#)Copyright (c) 1993, Simon J. Gerraty.
 *      
 *      This is free software.  It comes with NO WARRANTY.
 *      Permission to use, modify and distribute this source code 
 *      is granted subject to the following conditions.
 *      1/ that the above copyright notice and this notice 
 *      are preserved in all copies and that due credit be given 
 *      to the author.  
 *      2/ that any changes to this code are clearly commented 
 *      as such so that the author does not get blamed for bugs 
 *      other than his own.
 *      
 *      Please send copies of changes and bug-fixes to:
 *      sjg@quick.com.au
 */
#ifndef lint
static char *RCSid = "$Id: tiocompat.c,v 1.3 1997/02/08 07:10:19 sjg Exp $";
#endif
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifndef HAVE_TCGETATTR
#include <sys/types.h>
#include <termios.h>
#include <errno.h>

#ifndef TIOCGETA
# define TIOCGETA TCGETS
#endif

int
tcgetattr(fd, t)
	int fd;
	struct termios *t;
{

	return (ioctl(fd, TIOCGETA, t));
}

#ifndef TIOCSETA
# define TIOCSETA TCSETS
#endif
#ifndef TIOCSETAW
# define TIOCSETAW TCSETSW
#endif
#ifndef TIOCSETAF
# define TIOCSETAF TCSETSF
#endif

int
tcsetattr(fd, opt, t)
	int fd, opt;
	const struct termios *t;
{
	struct termios localterm;

#ifdef CIGNORE
	if (opt & TCSASOFT) {
		localterm = *t;
		localterm.c_cflag |= CIGNORE;
		t = &localterm;
	}
#endif
	switch (opt & ~TCSASOFT) {
	case TCSANOW:
		return (ioctl(fd, TIOCSETA, t));
	case TCSADRAIN:
		return (ioctl(fd, TIOCSETAW, t));
	case TCSAFLUSH:
		return (ioctl(fd, TIOCSETAF, t));
	default:
		errno = EINVAL;
		return (-1);
	}
}
#endif
