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 * newchunk.c - open a new chunk
18 /****** c_iff/NewChunk ******************************************************
21 * NewChunk -- Start a new chunk
24 * Success = NewChunk( TheHandle,ID )
26 * int NewChunk( struct IFFHandle *,uint32_t )
29 * Starts a new chunk, trough writing the chunk-header.
32 * TheHandle - IFFHandle to write to
33 * ID - ID of the chunk
36 * Success - TRUE when chunk-header is succesfully written,
42 * Chunks startet with NewChunk() must be finished with EndChunk()
43 * to correct the internal chunk-size.
50 *****************************************************************************
55 int NewChunk(struct IFFHandle
*TheHandle
, uint32_t ID
)
58 struct ChunkNode
*CN
, *PN
;
65 CN
=(struct ChunkNode
*) malloc(sizeof(struct ChunkNode
));
74 Buffer
[0]=Swap32IfLE(Buffer
[0]);
75 Buffer
[1]=Swap32IfLE(Buffer
[1]);
77 if(!(fwrite((void *) Buffer
, sizeof(uint32_t), 2, TheHandle
->TheFile
)==2))
84 CN
->FilePos
=ftell(TheHandle
->TheFile
);
85 CN
->FilePos
-=sizeof(uint32_t);
86 CN
->Previous
=TheHandle
->LastNode
;
92 PN
->Size
+=2*sizeof(uint32_t);
97 TheHandle
->IFFSize
+=2*sizeof(uint32_t);
98 TheHandle
->LastNode
=CN
;