Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / c / iprefs / trackdiskprefs.c
blob14097ef8b096b21852e986696139f68a523d2520
1 #include <devices/trackdisk.h>
2 #include <dos/dos.h>
3 #include <prefs/trackdisk.h>
4 #include <utility/tagitem.h>
5 #include <proto/dos.h>
6 #include <proto/exec.h>
8 #include "trackdiskprefs.h"
10 struct td_UnitPrefs TDPrefs[TD_NUMUNITS];
11 struct IORequest TDIO;
13 void LoadPrefs(void)
15 BPTR cf;
16 struct TagItem PrefsBuf;
17 ULONG Unit;
19 cf = Open(TRACKDISK_PREFS_NAME, MODE_OLDFILE);
20 if (cf) {
21 Unit = 0;
22 while (FRead(cf, &PrefsBuf, sizeof(PrefsBuf), 1)) {
23 if (PrefsBuf.ti_Tag == TDPR_UnitNum)
24 Unit = PrefsBuf.ti_Data;
25 else {
26 if (Unit < TD_NUMUNITS) {
27 switch (PrefsBuf.ti_Tag)
29 case TDPR_PubFlags:
30 TDPrefs[Unit].PubFlags = PrefsBuf.ti_Data;
31 break;
32 case TDPR_RetryCnt:
33 TDPrefs[Unit].RetryCnt = PrefsBuf.ti_Data;
34 break;
38 if (PrefsBuf.ti_Tag == TAG_DONE)
39 break;
41 Close(cf);
45 void ReadTDPrefs(void)
47 int i;
48 struct TDU_PublicUnit *tdu;
50 for (i = 0; i < TD_NUMUNITS; i++) {
51 TDPrefs[i].PubFlags = 0;
52 TDPrefs[i].RetryCnt = 3;
54 LoadPrefs();
55 for (i = 0; i < TD_NUMUNITS; i++) {
56 if (!OpenDevice("trackdisk.device", i, &TDIO, 0)) {
57 tdu = (struct TDU_PublicUnit *)TDIO.io_Unit;
58 tdu->tdu_PubFlags = TDPrefs[i].PubFlags;
59 tdu->tdu_RetryCnt = TDPrefs[i].RetryCnt;
60 CloseDevice(&TDIO);