Path: utzoo!utgpu!watserv1!watmath!att!rutgers!cs.utexas.edu!uunet!mcrware!jejones From: jejones@mcrware.UUCP (James Jones) Newsgroups: comp.os.os9 Subject: Re: ttyfly() for os9? (try#2) Summary: check out GS_RDY getstat call Keywords: pending input Message-ID: <2588@mcrware.UUCP> Date: 31 Aug 90 16:12:24 GMT References: <1990Aug30.152825.21217@cs.utk.edu> Reply-To: jejones@mcrware.UUCP (James Jones) Organization: Microware Systems Corp., Des Moines, Iowa Lines: 28 What you need to check out is the GS_RDY getstat call, which tells you how many characters are waiting to be read. (For historical reasons, it tech- nically thinks not having any characters waiting is an "error," but that doesn't get in the way.) For efficiency's sake, I'd seriously suggest buffer the waiting characters, so in C, you'd have something like static char mybuf[MYBUFSIZE]; /* or whatever */ static char *next; static int chleft; ttyfly() { if (--chleft < 0) { if ((chleft = _gs_rdy(0)) < 0) return 0; if (chleft > MYBUFSIZE) chleft = MYBUFSIZE; /* Code defensively! */ chleft = read(0, mybuf, chleft); if (chleft <= 0) return 0; next = mybuf; } return *next++; } James Jones