Changed expected test result: we expect a text file without a custom icon
[AROS.git] / tools / dtdesc / c_iff / endchunk.c
blob0c794c46c238464c2eb5a6893909d684c27399e0
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 * endchunk.c - finish writing a chunk
16 #include "c_iff.h"
18 /****** c_iff/EndChunk ******************************************************
20 * NAME
21 * EndChunk -- Finish writing a chunk
23 * SYNOPSIS
24 * EndChunk( TheHandle )
26 * void EndChunk( struct IFFHandle * )
28 * FUNCTION
29 * Finishes the actual chunk startet with NewChunk() .
30 * Mainly this means writing the chunksize.
32 * INPUTS
33 * TheHandle - the IFFHandle to write to
35 * RESULT
37 * EXAMPLE
39 * NOTES
41 * BUGS
43 * SEE ALSO
44 * NewChunk()
46 *****************************************************************************
48 * Private notes:
51 void EndChunk(struct IFFHandle *TheHandle)
53 uint32_t Buffer;
54 long CurPos;
55 struct ChunkNode *CN, *PN;
57 if(!TheHandle)
59 return;
62 CN=TheHandle->LastNode;
63 if(!CN)
65 return;
68 Buffer=CN->Size;
69 Buffer=Swap32IfLE(Buffer);
71 CurPos=ftell(TheHandle->TheFile);
72 if(CurPos<0)
74 return;
77 if(fseek(TheHandle->TheFile, TheHandle->LastNode->FilePos, SEEK_SET))
79 return;
82 if(!(fwrite((void *) &Buffer, sizeof(uint32_t), 1, TheHandle->TheFile)==1))
84 return;
87 if(fseek(TheHandle->TheFile, CurPos, SEEK_SET))
89 return;
92 if(CN->Size&0x1)
94 if(!(fwrite("\0", 1, 1, TheHandle->TheFile)==1))
96 return;
99 PN=CN->Previous;
101 while(PN)
103 PN->Size++;
105 PN=PN->Previous;
108 TheHandle->IFFSize++;
111 TheHandle->LastNode=CN->Previous;
112 free((void *) CN);