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 * checkiff.c - check if it's a valid IFF
18 /****** c_iff/CheckIFF ******************************************************
21 * CheckIFF -- Check the file, if it's a valid IFF
24 * Success = CheckIFF( TheHandle )
26 * int CheckIFF( struct IFFHandle * )
29 * This internal function scans a file freshly opened with OpenIFF(),
30 * if it is a valid IFF-file.
33 * TheHandle - IFFHandle to scan
36 * Success - TRUE when it's a valid IFF, otherwise FALSE
41 * Sets TheHandle->IFFType to the value found in the IFF-file.
42 * This function only recognises 'FORM'-IFFs.
43 * The "EA IFF 85" standard specifies several other IFFs.
44 * But these are very rarly used.
45 * The file-position-indicator must point to offset 0 when entering
46 * this function. It points to offset 12 after leaving the function.
53 *****************************************************************************
58 int CheckIFF(struct IFFHandle
*TheHandle
)
67 if(!(fread((void *) Buffer
, sizeof(uint32_t), 3, TheHandle
->TheFile
)==3))
72 Buffer
[0]=Swap32IfLE(Buffer
[0]);
73 Buffer
[1]=Swap32IfLE(Buffer
[1]);
74 Buffer
[2]=Swap32IfLE(Buffer
[2]);
76 if(!(Buffer
[0]==ID_FORM
))
81 if(!((Buffer
[1] + 2*sizeof(uint32_t))==FileSize(TheHandle
->TheFile
)))
86 TheHandle
->IFFType
=Buffer
[2];