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.

Prof. Falken
  • 24,226
  • 19
  • 100
  • 173
  • 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? – John3136 Feb 06 '12 at 01:26
  • 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.) – Prof. Falken Feb 06 '12 at 07:31
  • Isn't this cpp question? Link points to iifw.cpp not iifw.c. – Tomas Pruzina Mar 06 '12 at 11:31
  • No, it's not, it's just a .cpp extension on the file, but the language is C. @AoeAoe – Prof. Falken Mar 06 '12 at 12:39

1 Answers1

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

snugglo
  • 259
  • 1
  • 5