Hint added.
[AROS.git] / workbench / c / iprefs / trackdiskprefs.c
bloba8fc8b7ad93df232abd46fb94275c3fc01721974
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <devices/trackdisk.h>
7 #include <dos/dos.h>
8 #include <prefs/trackdisk.h>
9 #include <utility/tagitem.h>
10 #include <proto/dos.h>
11 #include <proto/exec.h>
13 #include "global.h"
14 #include "trackdiskprefs.h"
16 struct td_UnitPrefs TDPrefs[TD_NUMUNITS];
17 struct IORequest TDIO;
19 void LoadPrefs(void)
21 BPTR cf;
22 ULONG PrefsBuf[2];
23 ULONG Unit;
25 cf = Open(TRACKDISK_PREFS_NAME, MODE_OLDFILE);
26 if (cf) {
27 Unit = 0;
28 while (FRead(cf, &PrefsBuf, sizeof(PrefsBuf), 1)) {
30 if (PrefsBuf[0] == TDPR_UnitNum)
31 Unit = PrefsBuf[1];
32 else {
33 if (Unit < TD_NUMUNITS) {
34 switch (PrefsBuf[0])
36 case TDPR_PubFlags:
37 TDPrefs[Unit].PubFlags = PrefsBuf[1];
38 break;
39 case TDPR_RetryCnt:
40 TDPrefs[Unit].RetryCnt = PrefsBuf[1];
41 break;
45 if (PrefsBuf[0] == TAG_DONE)
46 break;
48 Close(cf);
52 void ReadTDPrefs(void)
54 int i;
55 struct TDU_PublicUnit *tdu;
57 if (FindResident(TD_NAME)) {
58 for (i = 0; i < TD_NUMUNITS; i++) {
59 TDPrefs[i].PubFlags = 0;
60 TDPrefs[i].RetryCnt = 3;
62 LoadPrefs();
63 for (i = 0; i < TD_NUMUNITS; i++) {
64 if (!OpenDevice(TD_NAME, i, &TDIO, 0)) {
65 tdu = (struct TDU_PublicUnit *)TDIO.io_Unit;
66 tdu->tdu_PubFlags = TDPrefs[i].PubFlags;
67 tdu->tdu_RetryCnt = TDPrefs[i].RetryCnt;
68 CloseDevice(&TDIO);