File pointer to a memory location?
Ulf Reimann
reimann at uniol.UUCP
Wed Sep 12 21:30:58 AEST 1990
rtidd at ccels3.mitre.org (Randy Tidd) writes:
>So what I have is a block of memory, having exactly the same size and
>contents of a file. What I have to do is pass my image processing
>routines a file pointer that points to this block of memory. If the
>routines used file *descriptors*, it wouldn't be a problem because I
>could just use pipes and be done with it.
Hi,
one way to do it is to set up a FILE structure (see /usr/include/stdio.h for
details, it's struct _iobuf) and pass it's address to the routine expecting
the file pointer.
I once saw that trick in some source to sscanf(). The routine creates
an iobuf structure, puts the pointer to the passed string in it (for the
buffer) and calls doscanf() which does the desired processing, but with
a file pointer.
If you have problems doing that, maybe I can write some example code for you,
but I'm short on time now...
Hope that helps...
Ulf
#include <disclaim.h>
Ulf Reimann, Hummelweg 30, 2900 Oldenburg, W-Germany, phone +49 (441) 5704245
e-mail: "reimann at faramir.informatik.uni-oldenburg.de" or "reimann at uniol.uucp"
More information about the Comp.unix.programmer
mailing list