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 * readchunkheader.c - read the header of the actual chunk
18 /****** c_iff/ReadChunkHeader ***********************************************
21 * ReadChunkHeader -- Read the header of the current chunk
24 * Success = ReadChunkData( TheHandle )
26 * int ReadChunkData( struct IFFHandle * )
29 * Reads the header of the current chunk. Fills out TheHandle->ChunkID.
30 * TheHandle->BytesLeftInChunk contains the size of the entire chunk.
33 * TheHandle - IFFHandle to read from
36 * Success - TRUE when the header was successfully read
42 * Attention!! Chunks are stored WORD-aligned. This means, when
43 * chunksize is odd one padding-byte is appended.
44 * TheHandle->BytesLeftInChunk shows the even size with the pad.
45 * The previous chunk must have read completely!
51 *****************************************************************************
56 int ReadChunkHeader(struct IFFHandle
*TheHandle
)
65 if(!(fread((void *) Buffer
, sizeof(uint32_t), 2, TheHandle
->TheFile
)==2))
70 Buffer
[0]=Swap32IfLE(Buffer
[0]);
71 Buffer
[1]=Swap32IfLE(Buffer
[1]);
73 TheHandle
->ChunkID
=Buffer
[0];
74 TheHandle
->BytesLeftInChunk
=(((Buffer
[1]+1)>>1)<<1);