closing brace is only needed on smp build.
[AROS.git] / tools / dtdesc / c_iff / openiff.c
blob8c91d621dc7769dd4f03130b4c97787a982738fb
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 * openiff.c - open an existing IFF
16 #include "c_iff.h"
18 /****** c_iff/OpenIFF *******************************************************
20 * NAME
21 * OpenIFF -- Open an existing IFF-file for reading
23 * SYNOPSIS
24 * TheHandle = NewIFF( Name )
26 * struct IFFHandle *NewIFF( char * )
28 * FUNCTION
29 * This is your function, if you want to read an existing IFF-file.
30 * It opens the existing file, allocates the IFFHandle and reads
31 * and confirms the IFF-header.
33 * INPUTS
34 * Name - name of the IFF-file to be opened
36 * RESULT
37 * TheHandle - IFFHandle to read from
39 * EXAMPLE
41 * NOTES
42 * IFF-files opened with OpenIFF() must be closed with CloseIFF() .
44 * BUGS
46 * SEE ALSO
47 * CloseIFF()
49 *****************************************************************************
51 * Private notes:
54 struct IFFHandle *OpenIFF(char *Name)
56 struct IFFHandle *Ret;
58 if(!Name)
60 return(NULL);
63 Ret=(struct IFFHandle *) malloc(sizeof(struct IFFHandle));
64 if(!Ret)
66 return(NULL);
69 Ret->TheFile=NULL;
70 Ret->TheFile=fopen(Name, "rb");
71 if(!Ret->TheFile)
73 free((void *) Ret);
74 return(NULL);
77 Ret->IFFType=0;
78 if(!CheckIFF(Ret))
80 fclose(Ret->TheFile);
81 free((void *) Ret);
82 return(NULL);
85 Ret->ChunkID=INVALID_ID;
86 Ret->BytesLeftInChunk=0;
87 Ret->NewIFF=FALSE;
88 Ret->IFFSize=0;
89 Ret->LastNode=NULL;
91 return(Ret);