Newsgroups: comp.lang.c
Path: utzoo!henry
From: henry@utzoo.uucp (Henry Spencer)
Subject: Re: a couple of random questions (lseek)
Message-ID: <1988Apr15.021937.6675@utzoo.uucp>
Organization: U of Toronto Zoology
References: <530@vsi.UUCP>
Date: Fri, 15 Apr 88 02:19:37 GMT

>      Second, what is the portable way to rewind a Unix file
> descriptor?  On almost every machine I have ever used:
> 
>         lseek(fd, (off_t)0, SEEK_SET);
> 
> works because the offset is a byte count, but it is inevitable
> that on some machine, off_t is the pointer to some kind of
> struct, or at least is *not* simply a byte count...

Not on a *Unix* machine.  There is no portable way to rewind a Unix
file descriptor, because Unix file descriptors are not portable!
On a Unix system, (off_t)0 is fine.  On a seriously non-Unix system,
you have to use stdio streams instead, in which case rewind() is
available.  For vaguely Unix-like systems, all bets are off.
-- 
"Noalias must go.  This is           |  Henry Spencer @ U of Toronto Zoology
non-negotiable."  --DMR              | {allegra,ihnp4,decvax,utai}!utzoo!henry
