Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get error in the iffw library when trying to write chunk

When I am trying to use the EA iffw.c library to write an IFF file, I can't get past the StartWGroup() call. It fails in IFFWriteBytes() because context->ckHdr.ckSize is zero. Inside IFFWriteBytes() there is an if() which checks that (size) != szNotYetKnown. (szNotYetKnown is a constant.) The example seems to indicate it should work, but I can't see how. IFFWriteBytes() returns CLIENT_ERROR because nBytes is 4 - I am trying to save a 32 bit int.

My failing code:

outfp = fopen(outfile, "wb");

ifferr = OpenWIFF(outfp, &filec, szNotYetKnown);

if (ifferr) {
    return 2;
}

ifferr = StartWGroup(&filec, LIST, sizeof (ID_NATAMI_FLASH), ID_NATAMI_FLASH, &listc);

if (ifferr) {
    printf("ifferr: %d\n", ifferr);
    return 3;
}

The last fails, StartWGroup().

IFF is, like XML, simple enough that I could just generate it without a library, but it would be nice to make use a of once common and well tested library.

Question is not really about Amiga, but this file format was popular on Amiga. By the way, did you know DjVU, RMFF, AIFF, RIFF and many other formats are IFF or slight variations?

Update: easy to read IFF description.

like image 956
Prof. Falken Avatar asked Jan 19 '12 00:01

Prof. Falken


1 Answers

Not claiming to know anything about this particular library but looking at the function arguments I think you may have entered the wrong size into StartWGroup.

From iifw.cpp: IFFP StartWGroup( GroupContext* parent, int groupType,int groupSize,int subtype, GroupContext * newtmp), the third argument name of StartWGroup is groupSize indicating the size of the group LIST and not the subgroup size sizeof(ID_NATAMI_FLASH).

like image 89
snugglo Avatar answered Sep 21 '22 00:09

snugglo