1. Different DLL wrapping question(s)
- Posted by ags <eu at 531pi.co.nz> Oct 24, 2005
- 489 views
- Last edited Oct 25, 2005
Hi All I'm about 70% through wrapping ming.dll (the SWF output library ("gee I hope that hasn't been done already" :)) and am a bit stuck on what to do about FILE * pointers. There is only one place so far where that needs to be done (loadSWFFontFromFile) but that's a fairly important routine IMHO. So what to the rest of you dll wrapping guru's recommend? The exact C header is: SWFFont loadSWFFontFromFile(FILE *file); Should I allocate a chunk of memory sizeof(struct FILE) and poke the file number into it? Or would that mess with the whole purpose of the FILE struct? Should I write an fopen.dll and wrap fopen()? BTW I hope Euphoria's open() returns the actual OS file number? In other functions someone kindly provided file descriptor versions as well... ags
2. Re: Different DLL wrapping question(s)
- Posted by Al Getz <Xaxo at aol.com> Oct 26, 2005
- 491 views
ags wrote: > > > Hi All > > I'm about 70% through wrapping ming.dll (the SWF output library > ("gee I hope that hasn't been done already" :)) and am a bit stuck on what > to do about FILE * pointers. > > There is only one place so far where that needs to be done > (loadSWFFontFromFile) > but that's a fairly important routine IMHO. > > So what to the rest of you dll wrapping guru's recommend? The exact C header > is: > > SWFFont loadSWFFontFromFile(FILE *file); > > Should I allocate a chunk of memory sizeof(struct FILE) and poke the file > number > into it? Or would that mess with the whole purpose of the FILE struct? > > Should I write an fopen.dll and wrap fopen()? > > BTW I hope Euphoria's open() returns the actual OS file number? In other > functions someone kindly provided file descriptor versions as well... > > ags Hi there, If you want to duplicate the FILE* you have to have it point to a FILE struct, which means you have to create your own struct first and then populate it with the identical data that appears in fopen's internal struct, but you should ask Rob how he gets the handle. You can poke the values in yourself, but unfortunately the last time i did this was over 5 years ago so i dont remember the details of what you have to poke. To find out, you could always create your own FILE pointer in C, open a file, and then print the initial values of the struct out to a text file so you can inspect them. Once done, you can figure out what these values are and then you'll know what to poke. It doesnt matter which FILE struct the disk driver uses, as long as it has the correct initial values and the driver that opened the file is using the same kind of struct. The internal one will think the file wasnt used so when the file is closed no problem. An easier way is your idea to wrap fopen() in a C dll so you can call it to get your required FILE pointer. Sorry i cant be more help here, memory doesnt last 5 years anymore :) Take care, Al And, good luck with your Euphoria programming! My bumper sticker: "I brake for LED's"