append modtype to generated makefiles
[AROS.git] / tools / dtdesc / c_iff / fixiffsize.c
blob6559eedf4fd16b528cbe8ca6889efea90e0634ae
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 * fixiffsize.c - fix the size when closing the iff
16 #include "c_iff.h"
18 /****** c_iff/FixIFFSize ****************************************************
20 * NAME
21 * FixIFFSize -- Set the internal size of the IFF-file
23 * SYNOPSIS
24 * FixIFFSize( TheHandle )
26 * void FixIFFSize( struct IFFHandle * )
28 * FUNCTION
29 * This internal function is called shortly before closing the IFF-file.
30 * It fixes the internal size (offset 4) of the IFF-file.
32 * INPUTS
33 * TheHandle - IFFHandle to fix
35 * RESULT
37 * EXAMPLE
39 * NOTES
40 * This function ignores IFFHandles opened for reading.
42 * BUGS
44 * SEE ALSO
45 * CloseIFF()
47 *****************************************************************************
49 * Private notes:
52 void FixIFFSize(struct IFFHandle *TheHandle)
54 uint32_t Buffer;
56 if(!TheHandle)
58 return;
61 if(!TheHandle->NewIFF)
63 return;
66 if(fseek(TheHandle->TheFile, sizeof(uint32_t), SEEK_SET))
68 return;
71 Buffer=TheHandle->IFFSize;
72 Buffer=Swap32IfLE(Buffer);
74 fwrite((void *) &Buffer, sizeof(uint32_t), 1, TheHandle->TheFile);