🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #835

Re: File pointer to a memory location?

#835
From: Steve Watt
Date: Tue, 11 Sep 1990 05:22
49 lines
1917 bytes
In article <119609@linus.mitre.org> rtidd@ccels3.mitre.org (Randy Tidd) writes:
>With all these new comp.unix.* groups coming out, I hope it's
>appropriate to cross-post to .programmer and .internals...

I'm not actually sure which is right, either.  .programmer is probably closer.

>Anyhow, in the application i'm working on I have a series of routines
>that were written by someone else that do image processing (the fbm
[ slurp! ]

[ he doesn't have a file, but just a large block of RAM ]

>Can anyone help me out?

I just hacked this little piece of code together, you might find it amenable
to your application:  Just set f._cnt to the size of the image block.

NOTE:  This is terribly dependent on stdio being implemented in the
"standard unix" way...  Or at least how it looks on my SCO box and my
DECStation.

-----  ugh.c  -----
#include <stdio.h>

char *buf = "This is a test of the emergency broadcast system.  In the event\
of a real emergency, you would never have heard this signal.  Seriously.\n";

main() {
	FILE f;
	int c;

	f._cnt = strlen(buf);
	f._ptr = f._base = buf;
	f._flag = _IOEOF;
	f._file = 0;

	while ((c = getc(&f)) != EOF) {
		putchar(c);
		fflush(stdout);
	}
}

-----  end  -----

Note also that you could just as easily have passed &f to some other function.
-- 
Steve Watt
...!claris!wattres!steve		wattres!steve@claris.com also works
Don't let your schooling get in the way of your education.
Technical Details
Message-ID: <598@wattres.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!julius.cs.uiuc.edu!apple!voder!zok!wattres!steve
References: <119609@linus.mitre.org>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!julius.cs.uiuc.edu!apple!voder!zok!wattres!steve
From: steve@wattres.UUCP (Steve Watt)
Newsgroups: comp.unix.programmer
Subject: Re: File pointer to a memory location?
Message-ID: <598@wattres.UUCP>
Date: 11 Sep 90 05:22:33 GMT
References: <119609@linus.mitre.org>
Reply-To: steve@wattres.UUCP (Steve Watt)
Organization: Steven Watt, Consultant
Lines: 49