Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!aplcen!haven!adm!smoke!gwyn
From: gwyn@smoke.BRL.MIL (Doug Gwyn)
Newsgroups: comp.unix.questions
Subject: Re: freopen - no file name available
Message-ID: <11151@smoke.BRL.MIL>
Date: 25 Sep 89 01:33:40 GMT
References: <206@vsserv.scri.fsu.edu>
Reply-To: gwyn@brl.arpa (Doug Gwyn)
Organization: Ballistic Research Lab (BRL), APG, MD.
Lines: 14

In article <206@vsserv.scri.fsu.edu> nall@loligo.cc.fsu.edu (John Nall) writes:
>If one uses freopen to temporarily use a file for which only the
>stream pointer is available  (freopen(filename,access,FILE *)
>is there any way to subsequently use freopen to go BACK to using
>the original stream?  (This can probably be rephrased as "is there
>a way to go from a stream pointer to the original file name").  

I don't understand your first clause -- freopen() CLOSES the open
stream, then reuses its data area for the new stream that it opens
by name.

On UNIX, you could first dup(fileno(fp)) and later use fdopen() to
reassociate another stdio stream with the file handle, without
having to know how to open it by name (assuming it even had a name).