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 * newiff.c - open a new IFF
18 /****** c_iff/NewIFF ********************************************************
21 * NewIFF -- Open a new IFF-file for writing
24 * TheHandle = NewIFF( Name,IFFType )
26 * struct IFFHandle *NewIFF( char *,uint32_t )
29 * This is your function, if you want to write an IFF-file.
30 * It opens a new IFF-file allocates the IFFHandle and writes
31 * an IFF-header to the file.
34 * Name - name of the IFF-file to be created
35 * IFFType - Type of the IFF (offset 8)
38 * TheHandle - IFFHandle to write to
43 * IFF-files created with NewIFF() must be closed with CloseIFF() .
50 *****************************************************************************
55 struct IFFHandle
*NewIFF(char *Name
, uint32_t IFFType
)
57 struct IFFHandle
*Ret
;
65 Ret
=(struct IFFHandle
*) malloc(sizeof(struct IFFHandle
));
71 Ret
->TheFile
=fopen(Name
, "wb");
79 Ret
->ChunkID
=INVALID_ID
;
80 Ret
->BytesLeftInChunk
=0;
82 Ret
->IFFSize
=sizeof(uint32_t);
89 Buffer
[0]=Swap32IfLE(Buffer
[0]);
90 Buffer
[1]=Swap32IfLE(Buffer
[1]);
91 Buffer
[2]=Swap32IfLE(Buffer
[2]);
93 if(!(fwrite((void *) Buffer
, sizeof(uint32_t), 3, Ret
->TheFile
)==3))