Added a test for MUIA_Listview_SelectChange.
[AROS.git] / tools / dtdesc / c_iff / newiff.c
bloba44ec1b9e48d5e28352690d38fbc7db6d684500f
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 * newiff.c - open a new IFF
16 #include "c_iff.h"
18 /****** c_iff/NewIFF ********************************************************
20 * NAME
21 * NewIFF -- Open a new IFF-file for writing
23 * SYNOPSIS
24 * TheHandle = NewIFF( Name,IFFType )
26 * struct IFFHandle *NewIFF( char *,uint32_t )
28 * FUNCTION
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.
33 * INPUTS
34 * Name - name of the IFF-file to be created
35 * IFFType - Type of the IFF (offset 8)
37 * RESULT
38 * TheHandle - IFFHandle to write to
40 * EXAMPLE
42 * NOTES
43 * IFF-files created with NewIFF() must be closed with CloseIFF() .
45 * BUGS
47 * SEE ALSO
48 * CloseIFF()
50 *****************************************************************************
52 * Private notes:
55 struct IFFHandle *NewIFF(char *Name, uint32_t IFFType)
57 struct IFFHandle *Ret;
58 uint32_t Buffer[3];
60 if(!Name)
62 return(NULL);
65 Ret=(struct IFFHandle *) malloc(sizeof(struct IFFHandle));
66 if(!Ret)
68 return(NULL);
71 Ret->TheFile=fopen(Name, "wb");
72 if(!Ret->TheFile)
74 free((void *) Ret);
75 return(NULL);
78 Ret->IFFType=IFFType;
79 Ret->ChunkID=INVALID_ID;
80 Ret->BytesLeftInChunk=0;
81 Ret->NewIFF=TRUE;
82 Ret->IFFSize=sizeof(uint32_t);
83 Ret->LastNode=NULL;
85 Buffer[0]=ID_FORM;
86 Buffer[1]=0;
87 Buffer[2]=IFFType;
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))
95 fclose(Ret->TheFile);
96 free((void *) Ret);
97 return(NULL);
100 return(Ret);