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 * newchunk.c - open a new chunk
18 /****** c_iff/NewSubFORM ****************************************************
21 * NewSubFORM -- Start a new sub-FORM
24 * Success = NewSubFORM( TheHandle,Type )
26 * int NewSubFORM( struct IFFHandle *,uint32_t )
29 * Some IFF's, e.g. ANIM, have cascading FORM's, this means one or
30 * more FORM's inside the main-FORM.
31 * With NewSubFORM() you can start such a child-FORM.
34 * TheHandle - IFFHandle to write to
35 * Type - type of the sub-FORM
38 * Success - TRUE when the FORM-header is succesfully written,
44 * Sub-FORM's startet with NewSubFORM() must be finished
45 * with EndChunk() to correct the internal size.
52 *****************************************************************************
57 int NewSubFORM(struct IFFHandle
*TheHandle
, uint32_t Type
)
60 struct ChunkNode
*CN
, *PN
;
67 CN
=(struct ChunkNode
*) malloc(sizeof(struct ChunkNode
));
77 Buffer
[0]=Swap32IfLE(Buffer
[0]);
78 Buffer
[1]=Swap32IfLE(Buffer
[1]);
79 Buffer
[2]=Swap32IfLE(Buffer
[2]);
81 if(!(fwrite((void *) Buffer
, sizeof(uint32_t), 3, TheHandle
->TheFile
)==3))
87 CN
->Size
=sizeof(uint32_t);
88 CN
->FilePos
=ftell(TheHandle
->TheFile
);
90 CN
->Previous
=TheHandle
->LastNode
;
96 PN
->Size
+=3*sizeof(uint32_t);
101 TheHandle
->IFFSize
+=3*sizeof(uint32_t);
102 TheHandle
->LastNode
=CN
;