2 * c_iff - a portable IFF-parser
4 * Copyright (C) 2000, 2001 Joerg Dietrich
6 * This is the AROS-version of c_iff.
7 * It is distributed under the AROS Public License.
8 * But I reserve the right to distribute
9 * my own version under other licenses.
13 * endchunk.c - finish writing a chunk
18 /****** c_iff/EndChunk ******************************************************
21 * EndChunk -- Finish writing a chunk
24 * EndChunk( TheHandle )
26 * void EndChunk( struct IFFHandle * )
29 * Finishes the actual chunk startet with NewChunk() .
30 * Mainly this means writing the chunksize.
33 * TheHandle - the IFFHandle to write to
46 *****************************************************************************
51 void EndChunk(struct IFFHandle
*TheHandle
)
55 struct ChunkNode
*CN
, *PN
;
62 CN
=TheHandle
->LastNode
;
69 Buffer
=Swap32IfLE(Buffer
);
71 CurPos
=ftell(TheHandle
->TheFile
);
77 if(fseek(TheHandle
->TheFile
, TheHandle
->LastNode
->FilePos
, SEEK_SET
))
82 if(!(fwrite((void *) &Buffer
, sizeof(uint32_t), 1, TheHandle
->TheFile
)==1))
87 if(fseek(TheHandle
->TheFile
, CurPos
, SEEK_SET
))
94 if(!(fwrite("\0", 1, 1, TheHandle
->TheFile
)==1))
108 TheHandle
->IFFSize
++;
111 TheHandle
->LastNode
=CN
->Previous
;