2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
9 /*********************************************************************************************/
13 #include <prefs/prefhdr.h>
14 #include <aros/macros.h>
17 #include <aros/debug.h>
23 #define CHECK_PRHD_VERSION 1
24 #define CHECK_PRHD_SIZE 1
26 /*********************************************************************************************/
35 /*********************************************************************************************/
37 struct IFFHandle
*CreateIFF(STRPTR filename
, LONG
*stopchunks
, LONG numstopchunks
)
39 struct IFFHandle
*iff
;
41 D(bug("CreateIFF: filename = \"%s\"\n", filename
));
43 if ((iff
= AllocIFF()))
45 D(bug("CreateIFF: AllocIFF okay.\n"));
46 if ((iff
->iff_Stream
= (IPTR
)Open(filename
, MODE_OLDFILE
)))
48 D(bug("CreateIFF: Open() okay.\n"));
51 if (OpenIFF(iff
, IFFF_READ
) == 0)
55 D(bug("CreateIFF: OpenIFF okay.\n"));
57 if ((StopChunk(iff
, ID_PREF
, ID_PRHD
) == 0) &&
58 (StopChunks(iff
, stopchunks
, numstopchunks
) == 0))
60 D(bug("CreateIFF: StopChunk(PRHD) okay.\n"));
62 if (ParseIFF(iff
, IFFPARSE_SCAN
) == 0)
64 struct ContextNode
*cn
;
66 cn
= CurrentChunk(iff
);
68 D(bug("CreateIFF: ParseIFF okay. Chunk Type = %c%c%c%c ChunkID = %c%c%c%c\n",
78 if ((cn
->cn_ID
== ID_PRHD
)
80 && (cn
->cn_Size
== sizeof(struct FilePrefHeader
))
84 struct FilePrefHeader h
;
86 D(bug("CreateIFF: PRHD chunk okay.\n"));
88 if (ReadChunkBytes(iff
, &h
, sizeof(h
)) == sizeof(h
))
90 D(bug("CreateIFF: Reading PRHD chunk okay.\n"));
92 #if CHECK_PRHD_VERSION
93 if (h
.ph_Version
== PHV_CURRENT
)
95 D(bug("CreateIFF: PrefHeader version is correct.\n"));
106 } /* if (ParseIFF(iff, IFFPARSE_SCAN) == 0) */
108 } /* if ((StopChunk(iff, ID_PREF, ID_PRHD) == 0) && (StopChunks(... */
113 Close((BPTR
)iff
->iff_Stream
);
118 } /* if (OpenIFF(iff, IFFF_READ) == 0) */
121 Close((BPTR
)iff
->iff_Stream
);
126 } /* if ((iff->iff_Stream = (IPTR)Open(filename, MODE_OLDFILE))) */
133 } /* if ((iff = AllocIFF())) */
139 /*********************************************************************************************/
141 void KillIFF(struct IFFHandle
*iff
)
146 Close((BPTR
)iff
->iff_Stream
);
151 /*********************************************************************************************/