distribution by Mark Nudleman
[unix-history] / usr / src / usr.bin / more / ttyin.c
/*
* Copyright (c) 1988 Mark Nudleman
* Copyright (c) 1988 Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Mark Nudleman.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef lint
static char sccsid[] = "@(#)ttyin.c 5.1 (Berkeley) %G%";
#endif /* not lint */
/*
* Routines dealing with getting input from the keyboard (i.e. from the user).
*/
#include "less.h"
static int tty;
/*
* Open keyboard for input.
* (Just use file descriptor 2.)
*/
public void
open_getchr()
{
tty = 2;
}
/*
* Get a character from the keyboard.
*/
public int
getchr()
{
char c;
int result;
do
{
result = iread(tty, &c, 1);
if (result == READ_INTR)
return (READ_INTR);
if (result < 0)
{
/*
* Don't call error() here,
* because error calls getchr!
*/
quit();
}
} while (result != 1);
return (c & 0177);
}