DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T g

⟦224df569b⟧ TextFile

    Length: 768 (0x300)
    Types: TextFile
    Names: »getkey.c«

Derivation

└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
    └─⟦this⟧ »EUUGD18/General/Snake2/getkey.c« 

TextFile

/* getkey.c - Don Libes
getkey() - return the last key struck by the user or -1.
If user has struct multiple keys, ignore all but the last.
*/

#include "snake2.h"

#include <stdio.h>
#if BSD42 || BSD41 || EUNICE
#include <sys/ioctl.h>
#endif
#if SYSV
#include <sys/termio.h>
#endif

#ifdef FIONREAD
int
getkey()
{
	long chars = 0;

	if (-1 == ioctl(fileno(stdin),FIONREAD,&chars)) {
		cleanup();
		perror("ioctl in getkey");
		exit(0);
	}
	
	if (chars == 0) return(-1);

	while (chars-- > 1) getchar();

	return(getchar() & 0x7f);		/* strip parity */
}
#else
makehalfdelay()
{
	struct termio curtty;
	ioctl(1, TCGETA, &curtty);
	curtty.c_cc[VMIN] = 0;
	curtty.c_cc[VTIME] = TIMEOUT;
	ioctl(1, TCSETAW, &curtty);
}

int
getkey()
{
	return getchar();
}
#endif FIONREAD