Building giflib for PureC, missing fdopen()

C and PASCAL (or any other high-level languages) in here please

Moderators: exxos, simonsunnyboy, Mug UK, Zorro 2, Moderator Team

User avatar
lp
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2230
Joined: Wed Nov 12, 2003 11:09 pm
Location: GFA Headquarters
Contact:

Building giflib for PureC, missing fdopen()

Postby lp » Sun May 10, 2015 7:21 pm

Tried to build this: https://sourceforge.net/projects/giflib/

I get it to build with one error, function fdopen() with no prototype. Essentially because it's missing and not found in any of the libraries provided with PureC. Has anyone already built this library? Any advice how to replace this fdopen() function with equivalent code? :wink:

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4774
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Building giflib for PureC, missing fdopen()

Postby simonsunnyboy » Mon May 11, 2015 3:49 pm

This seems to be part of POSIX file access APIs: http://linux.die.net/man/3/fdopen

For a plain TOS target, it probably can easily be rewritten to use normal ANSI C functions from stdio.h instead...or for the more masochistic porter, GEMDOS calls ;)
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4774
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Building giflib for PureC, missing fdopen()

Postby simonsunnyboy » Mon May 11, 2015 3:56 pm

BTW do you need it for Pure C? I could crosscompile the downloadable tar.bz2 on my Linux box here with gcc like this:

./configure --host=m68k-atari-mint; make

There are several .o files and a hidden .a library. I don't know if it works but atleast it seems to buildable with FreeMiNT tools...
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
mfro
Atari Super Hero
Atari Super Hero
Posts: 663
Joined: Thu Aug 02, 2012 10:33 am
Location: SW Germany

Re: Building giflib for PureC, missing fdopen()

Postby mfro » Mon May 11, 2015 4:47 pm

Contrary to most modern compilers, Pure C exposes the inner workings of the FILE structure in stdio.h.

If you want to implement fdopen(), you basically need to instantiate a FILE structure, allocate an I/O buffer, initialize the buffer-related variables in your FILE structure and set the GEMDOS handle inside the structure.

I never tried this, but it should be pretty straightforward.

User avatar
lp
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2230
Joined: Wed Nov 12, 2003 11:09 pm
Location: GFA Headquarters
Contact:

Re: Building giflib for PureC, missing fdopen()

Postby lp » Tue May 12, 2015 10:12 pm

I tried a few hacks I found on the net googling, but none of them worked. Basically the giflib does this:

handle=open(...
basically checks if the file exists or not
then does this later in another subroutine:
f=fdopen(handle... /*make it a stream*/

I replaced the fdopen() with this:
close(handle)
f=fopen(... /*now its a stream*/
handle = f->Handle /*fix the handle*/

It seems to work.


Social Media

     

Return to “C / PASCAL etc.”

Who is online

Users browsing this forum: No registered users and 1 guest