[comp.unix.questions] Pipe / Stream / File access question

rtidd@ccels3.mitre.org (Randy Tidd) (08/22/90)

For the application i'm writing, I call a routine written by somebody
else that loads an image from a file.  This routine takes a file
pointer (FILE *) as an argument, and reads the image from there.

However, my application uses a database rather than the filesystem,
and I don't have files or filenames or file pointers that this routine
could use.  What I *can* do is get a block of memory that holds the
image i'm trying to read from the database.

This block of memory is exactly the same size and holds exactly the
same thing as the file, except that it resides in memory rather than a
file.  What I want to do is somehow point a file pointer (FILE *) to
this block of memory, and pass the file pointer into the routine to
read the image.

I'm a fairly experienced Unix systems programmer, but I can't seem to
find the right way to do this.  All this is going on in a single
process so using popen() isn't really the right way.  I thought of
dumping the image to a file then reading it in, but the images can be
very large (upwards of a meg) and for performance reasons this is
undesirable.

Please respond through e-mail to rtidd@mwunix.mitre.org or the
address(es) in the header.

Randy Tidd				GOOD
rtidd%ccels3@mwunix.mitre.org		FAST
#define DISCLAIM TRUE			CHEAP
						-pick any two