gtty.c revision 1.3
11.1Scgd/* 21.1Scgd * Copyright (c) 1994 Christopher G. Demetriou 31.1Scgd * All rights reserved. 41.1Scgd * 51.1Scgd * Redistribution and use in source and binary forms, with or without 61.1Scgd * modification, are permitted provided that the following conditions 71.1Scgd * are met: 81.1Scgd * 1. Redistributions of source code must retain the above copyright 91.1Scgd * notice, this list of conditions and the following disclaimer. 101.1Scgd * 2. Redistributions in binary form must reproduce the above copyright 111.1Scgd * notice, this list of conditions and the following disclaimer in the 121.1Scgd * documentation and/or other materials provided with the distribution. 131.1Scgd * 3. All advertising materials mentioning features or use of this software 141.1Scgd * must display the following acknowledgement: 151.1Scgd * This product includes software developed by Christopher G. Demetriou. 161.1Scgd * 4. The name of the author may not be used to endorse or promote products 171.1Scgd * derived from this software without specific prior written permission 181.1Scgd * 191.1Scgd * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 201.1Scgd * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 211.1Scgd * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 221.1Scgd * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 231.1Scgd * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 241.1Scgd * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 251.1Scgd * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 261.1Scgd * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 271.1Scgd * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 281.1Scgd * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 291.1Scgd */ 301.1Scgd 311.2Slukem#include <sys/cdefs.h> 321.1Scgd#ifndef lint 331.3Slukem__RCSID("$NetBSD: gtty.c,v 1.3 1999/09/16 11:45:46 lukem Exp $"); 341.1Scgd#endif /* not lint */ 351.1Scgd 361.3Slukem#include <assert.h> 371.3Slukem#include <errno.h> 381.1Scgd#include <sgtty.h> 391.1Scgd 401.1Scgd/* 411.1Scgd * Get tty modes. 421.1Scgd * This was defined in ioctl_compat.h as: 431.1Scgd * #define gtty(fd, tty) ioctl(fd, TIOCGETP, tty) 441.1Scgd */ 451.1Scgdint 461.1Scgdgtty(fd, tty) 471.1Scgd int fd; 481.1Scgd struct sgttyb *tty; 491.1Scgd{ 501.3Slukem 511.3Slukem _DIAGASSERT(fd != -1); 521.3Slukem _DIAGASSERT(tty != 0); 531.3Slukem#ifdef _DIAGNOSTIC 541.3Slukem if (fd == -1) { 551.3Slukem errno = EBADF; 561.3Slukem return (-1); 571.3Slukem } 581.3Slukem if (tty == 0) { 591.3Slukem errno = EINVAL; 601.3Slukem return (-1); 611.3Slukem } 621.3Slukem#endif 631.1Scgd 641.1Scgd return (ioctl(fd, TIOCGETP, tty)); 651.1Scgd} 66