Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!nbires!hao!hplabs!ucbvax!CITHEX.CALTECH.EDU!carl From: carl@CITHEX.CALTECH.EDU (Carl J Lydick) Newsgroups: mod.computers.vax Subject: Re: VAX C problem (?) - reading single characters with VAX C Message-ID: <860721065936.00c@CitHex.Caltech.Edu> Date: Mon, 21-Jul-86 10:00:15 EDT Article-I.D.: CitHex.860721065936.00c Posted: Mon Jul 21 10:00:15 1986 Date-Received: Tue, 22-Jul-86 07:22:51 EDT References: <8607200641.AA22528@csvax.caltech.edu> Sender: daemon@ucbvax.BERKELEY.EDU Organization: The ARPA Internet Lines: 48 Approved: info-vax@sri-kl.arpa /*****************************************************************************\ * > ...a program that does the same thing, though often much more * * > efficiently, since it buffers up typed-ahead stuff.... * * * * Not quite the same thing, Jerry; your "more efficient" implementation * * has the following rather odd properties: * * 1) An image exit may flush any, all, or none of the type-ahead. * * 2) The amount of type-ahead flushed when the image exits * * depends, in principle, on every keystroke typed since the * * first call to your _kbin(). In fact, the dependence is upon * * the number of characters typed since the last time the * * terminal's type-ahead queue was empty. * * The reason for this, of course, is that you and the terminal driver are * * both buffering typeahead, but you neither return whatever you've got * * left at image exit to the terminal data stream (which is reasonable, * * since the VMS terminal drivers don't have any provision for this) and * * you don't do anything to force a flush of the terminal's type-ahead * * buffer at image exit (which is not reasonable, since you can declare * * your own exit handler to take care of this problem. What you want is * * somthing like: * \*****************************************************************************/ /* clean up after single-character I/O software */ void flush_stream(status, chan) long *status, chan; { SYS$QIOW(0, chan, IO$_READVBLK | IO$M_TIMED | IO$M_NOFILTR | IO$M_NOECHO | IO$M_PURGE, 0, 0, 0,0, 0, 0, 0, 0, 0); SYS$DASSGN(chan); } /* exit handler descriptor block */ struct EXH$DESBLK { long exh$l_flink; void (*exh$a_handler)(); long exh$b_nargs; long *exh$a_status; long exh$l_chan; long exh$l_stat; } flush = { 0, flush_stream, 2, &(flush.exh$l_stat), 0, 0 }; /*****************************************************************************\ * Then add something like: * * * * flush.exh$l_chan = chan; * * SYS$DCLEXH(&flush); * * * * to the code that opens the channel on the first call. When your image * * exits, flush will be called, and it will flush all typeahead on the * * terminal channel and deassign the channel. * \*****************************************************************************/