2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
9 /*********************************************************************************************/
14 #include <aros/debug.h>
16 #include <prefs/prefhdr.h>
17 #include <prefs/screenmode.h>
19 #include <intuition/iprefs.h>
21 static BOOL
LoadScreenModePrefs(STRPTR filename
, struct ScreenModePrefs
* serialprefs
);
23 static const ULONG buffersizes
[] =
34 /*********************************************************************************************/
36 void ScreenModePrefs_Handler(STRPTR filename
)
38 static struct ScreenModePrefs smp
;
39 D(bug("In IPrefs:ScreenModePrefs_Handler\n"));
40 D(bug("filename=%s\n",filename
));
42 if (TRUE
== LoadScreenModePrefs(filename
, &smp
))
44 struct IScreenModePrefs i
;
46 i
.smp_DisplayID
= smp
.smp_DisplayID
;
47 i
.smp_Width
= smp
.smp_Width
;
48 i
.smp_Height
= smp
.smp_Height
;
49 i
.smp_Depth
= smp
.smp_Depth
;
50 i
.smp_Control
= smp
.smp_Control
;
52 SetIPrefs(&i
, sizeof(struct IScreenModePrefs
), IPREFS_TYPE_SCREENMODE
);
55 /*********************************************************************************************/
57 static BOOL
LoadScreenModePrefs(STRPTR filename
, struct ScreenModePrefs
* serialprefs
)
59 struct IFFHandle
*iff
;
62 D(bug("LoadPrefs: Trying to open \"%s\"\n", filename
));
64 if ((iff
= AllocIFF()))
66 if ((iff
->iff_Stream
= (IPTR
)Open(filename
, MODE_OLDFILE
)))
68 D(bug("LoadPrefs: stream opened.\n"));
72 if (!OpenIFF(iff
, IFFF_READ
))
74 D(bug("LoadPrefs: OpenIFF okay.\n"));
76 if (!StopChunk(iff
, ID_PREF
, ID_SCRM
))
78 D(bug("LoadPrefs: StopChunk okay.\n"));
80 if (!ParseIFF(iff
, IFFPARSE_SCAN
))
82 struct ContextNode
*cn
;
84 D(bug("LoadPrefs: ParseIFF okay.\n"));
86 cn
= CurrentChunk(iff
);
88 if (cn
->cn_Size
== sizeof(struct ScreenModePrefs
))
90 D(bug("LoadPrefs: ID_SERL chunk size okay.\n"));
92 if (ReadChunkBytes(iff
, serialprefs
, sizeof(struct ScreenModePrefs
)) == sizeof(struct ScreenModePrefs
))
94 D(bug("LoadScreenModePrefs: Reading chunk successful.\n"));
96 D(bug("LoadScreenModePrefs: Everything okay :-)\n"));
102 } /* if (!ParseIFF(iff, IFFPARSE_SCAN)) */
104 } /* if (!StopChunk(iff, ID_PREF, ID_SERL)) */
108 } /* if (!OpenIFF(iff, IFFF_READ)) */
110 Close((BPTR
)iff
->iff_Stream
);
112 } /* if ((iff->iff_Stream = (IPTR)Open(filename, MODE_OLDFILE))) */
116 } /* if ((iff = AllocIFF())) */