"P.J.M._Verbruggen.ven1RX"@XEROX.COM (02/24/88)
The isatty (check if file is a terminal) function is not in the libraries of
both
MWC and Lattice. The related function getfc is mentioned in the Lattice manual
but not incorporated. I produced a poorman's isatty but would like
to know if someone did a real isatty for the mentioned compilers.
isatty(fh)
int fh;
{
if(fh>2)
return(0);
else
return(1);
}
Thanks
Peter
leo@sunybcs.uucp (Leo Wilson) (02/27/88)
In article <880224-080441-2553@Xerox> "P.J.M._Verbruggen.ven1RX"@XEROX.COM writes: >The isatty (check if file is a terminal) function is not in the libraries of >both MWC and Lattice. [rest deleted...] When I needed an isatty (to get a reasonable mail interface from the uupc stuff) I looked in the manual and there was no isatty mentioned, but libc.a for MWC v2.0 contained an isatty() function. Um, other undocumented stuff, too. Seems to work, but only for what I've tried to do with it... -L Leo E. Wilson 364 West Delavan Avenue Buffalo, NY 14213 (716)883-7573 (leo@gort.cs.Buffalo.EDU) ...!sunybcs[!leow]!leo leo@sunybcs.bitnet
dag@chinet.UUCP (Daniel A. Glasser) (02/27/88)
In article <880224-080441-2553@Xerox> "P.J.M._Verbruggen.ven1RX"@XEROX.COM writes: >The isatty (check if file is a terminal) function is not in the libraries of >both MWC and Lattice. The related function getfc is mentioned in the >Lattice manual but not incorporated. I produced a poorman's isatty but >would like to know if someone did a real isatty for the mentioned compilers. homebrew isatty delete] The MWC library does have the "isatty()" function... I just checked. I believe it has had that function since version 1.0, but I can't be sure. It may not be documented, but it is there. You may find doing an "nm -g libc.a" some time -- You'd be suprised to see how many functions are there. If you want a full list of the functions available in the MWC library posted, I'd be happy to do so, but as I work for MWC, some may find the posting to be a commercial use of the net, and I might get zapped for it.
apratt@atari.UUCP (Allan Pratt) (03/01/88)
From article <880224-080441-2553@Xerox>, by "P.J.M._Verbruggen.ven1RX"@XEROX.COM: > The isatty (check if file is a terminal) function is not in the > libraries of both MWC and Lattice. The related function getfc is > mentioned in the Lattice manual but not incorporated. I produced a > poorman's isatty but would like to know if someone did a real isatty for > the mentioned compilers. > > isatty(fh) > int fh; > { > if(fh>2) > return(0); > else > return(1); > } > > Thanks > > Peter There is a better isatty. It uses the property of tty's that seeking always returns zero, while seeking forward in a file file either returns an error code or a new (nonzero) offset in the file. This code works for "standard" handles which have been redirected to files or other tty's, and for "nonstandard" handles which are files or dup'ed copies of tty handles. This function returns EIHNDL if the handle is invalid, 0 if it's a file, or 1 if it's a tty. #define ERANGE -64L #define EIHNDL -37L isatty(h) int h; { int rc; long oldloc, seekval; oldloc = Fseek(h,0L,1); /* seek zero bytes from current loc */ if (seekval = Fseek(h,1L,1)) /* try to seek ahead one byte */ if (seekval > 0 || seekval == ERANGE) rc = 0; /* file, not a tty */ else rc = EIHNDL; /* EIHNDL, for instance: invalid handle */ else rc = 1; Fseek(h,oldloc,0); /* seek back to original location */ return rc; /* return true or false. */ } ============================================ Opinions expressed above do not necessarily -- Allan Pratt, Atari Corp. reflect those of Atari Corp. or anyone else. ...ames!atari!apratt