added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / c / iprefs / screenmodeprefs.c
blob50cd105588a172d901de828974ffab67a5cc8858
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 /*********************************************************************************************/
11 #include "global.h"
13 #define DEBUG 1
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[] =
25 512,
26 1024,
27 2048,
28 4096,
29 8000,
30 16000,
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;
60 BOOL retval = FALSE;
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"));
70 InitIFFasDOS(iff);
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"));
98 retval = TRUE;
102 } /* if (!ParseIFF(iff, IFFPARSE_SCAN)) */
104 } /* if (!StopChunk(iff, ID_PREF, ID_SERL)) */
106 CloseIFF(iff);
108 } /* if (!OpenIFF(iff, IFFF_READ)) */
110 Close((BPTR)iff->iff_Stream);
112 } /* if ((iff->iff_Stream = (IPTR)Open(filename, MODE_OLDFILE))) */
114 FreeIFF(iff);
116 } /* if ((iff = AllocIFF())) */
118 return retval;