x11gfx.hidd: support 32 bit modes
[AROS.git] / tools / dtdesc / c_iff / checkiff.c
blob65c4c8a52a5e9372d89d3bebb60485d164cc944d
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 * checkiff.c - check if it's a valid IFF
16 #include "c_iff.h"
18 /****** c_iff/CheckIFF ******************************************************
20 * NAME
21 * CheckIFF -- Check the file, if it's a valid IFF
23 * SYNOPSIS
24 * Success = CheckIFF( TheHandle )
26 * int CheckIFF( struct IFFHandle * )
28 * FUNCTION
29 * This internal function scans a file freshly opened with OpenIFF(),
30 * if it is a valid IFF-file.
32 * INPUTS
33 * TheHandle - IFFHandle to scan
35 * RESULT
36 * Success - TRUE when it's a valid IFF, otherwise FALSE
38 * EXAMPLE
40 * NOTES
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.
48 * BUGS
50 * SEE ALSO
51 * OpenIFF()
53 *****************************************************************************
55 * Private notes:
58 int CheckIFF(struct IFFHandle *TheHandle)
60 uint32_t Buffer[3];
62 if(!TheHandle)
64 return(FALSE);
67 if(!(fread((void *) Buffer, sizeof(uint32_t), 3, TheHandle->TheFile)==3))
69 return(FALSE);
72 Buffer[0]=Swap32IfLE(Buffer[0]);
73 Buffer[1]=Swap32IfLE(Buffer[1]);
74 Buffer[2]=Swap32IfLE(Buffer[2]);
76 if(!(Buffer[0]==ID_FORM))
78 return(FALSE);
81 if(!((Buffer[1] + 2*sizeof(uint32_t))==FileSize(TheHandle->TheFile)))
83 return(FALSE);
86 TheHandle->IFFType=Buffer[2];
88 return(TRUE);