Get error in the iffw library when trying to write chunk
Asked Answered
O

1

8

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.

Olnton answered 19/1, 2012 at 0:6 Comment(4)
Not sure I quite get it. StartWGroup seems to suggest you are starting a group (like an XML element?) that needs to be "closed" with EndWGroup(). You seem to be saying that you are using StartWGroup () to write a 32 bit int which seems "wrong" - am I missing something?Cnossus
EndWGroup closes, like you say. But the program fails without it even getting very far. (EndWGroup also does not write an end tag, it goes back and updates the chunk length instead. So EAs library basically creates an XML-like API for writing end tag, where in fact there are no end tags.)Olnton
Isn't this cpp question? Link points to iifw.cpp not iifw.c.Lynsey
No, it's not, it's just a .cpp extension on the file, but the language is C. @AoeAoeOlnton
G
2

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).

Goldie answered 12/4, 2012 at 7:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.