Xref: utzoo comp.lang.c:15268 comp.unix.wizards:13904 Path: utzoo!utgpu!attcan!uunet!auspex!guy From: guy@auspex.UUCP (Guy Harris) Newsgroups: comp.lang.c,comp.unix.wizards Subject: Re: printf, data presentation Keywords: printf, terminals, fixed format screens Message-ID: <808@auspex.UUCP> Date: 6 Jan 89 18:22:37 GMT References: <19@xenlink.UUCP> <731@picuxa.UUCP> <8332@ihlpl.ATT.COM> <444@marob.MASA.COM> Reply-To: guy@auspex.UUCP (Guy Harris) Followup-To: comp.unix.wizards Organization: Auspex Systems, Santa Clara Lines: 26 >If I understand your need, the fcntl VMIN and VTIM parameters "ioctl(TCSETA)" and company, not "fcntl". >may help. If you set VMIN=0 and VTIM>0, read() returns immediately >if characters are available, or in VTIM 10th-secs if the queue is dry. This works on UNIXes that have VMIN and VTIME (S3, S5, SunOS 4.0, some others). It doesn't work on older UNIXes, or non-UNIX systems; I think he wanted a routine that would, on all (or, at least, most) systems, do what was appropriate on that system (whether UNIX or not). >I use VMIN=0,VTIM=1 to grab the next char, or return immediately if >none is available. Try VTIME=0 instead (although this may not work under S3); that will return immediately, rather than after 1/10 second (which VTIME=1 does). >>Even a blocking version (that would return a char once typed, >>without waiting for a newline) would be useful. > >Try reading with VMIN=1,VTIM=0. This is akin to the Berkeley CBREAK mode. Actually, the equivalent of turning on V7 CBREAK (not Berkeley - they didn't invent CBREAK, AT&T did) is turning ICANON off and setting VMIN to 1 and VTIME to 0. VMIN and VTIME are meaningful only if ICANON is off.