closing brace is only needed on smp build.
[AROS.git] / tools / dtdesc / c_iff / readchunkheader.c
blob18f0345ce28d961b040eac37c24823b8eae43ce3
1 /*
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
16 #include "c_iff.h"
18 /****** c_iff/ReadChunkHeader ***********************************************
20 * NAME
21 * ReadChunkHeader -- Read the header of the current chunk
23 * SYNOPSIS
24 * Success = ReadChunkData( TheHandle )
26 * int ReadChunkData( struct IFFHandle * )
28 * FUNCTION
29 * Reads the header of the current chunk. Fills out TheHandle->ChunkID.
30 * TheHandle->BytesLeftInChunk contains the size of the entire chunk.
32 * INPUTS
33 * TheHandle - IFFHandle to read from
35 * RESULT
36 * Success - TRUE when the header was successfully read
37 * otherwise FALSE
39 * EXAMPLE
41 * NOTES
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!
47 * BUGS
49 * SEE ALSO
51 *****************************************************************************
53 * Private notes:
56 int ReadChunkHeader(struct IFFHandle *TheHandle)
58 uint32_t Buffer[2];
60 if(!TheHandle)
62 return(FALSE);
65 if(!(fread((void *) Buffer, sizeof(uint32_t), 2, TheHandle->TheFile)==2))
67 return(FALSE);
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);
76 return(TRUE);