grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / devs / AHI / Examples / Extras / CheckAHIPrefs / CheckAHIPrefs.c
blob74ddb1b365e75ee15183e14f87bf46f56c74b33c
2 /* Just a small example how to read the settings file. */
4 #include <devices/ahi.h>
5 #include <dos/dos.h>
6 #include <libraries/iffparse.h>
7 #include <prefs/prefhdr.h>
9 #include <proto/dos.h>
10 #include <proto/iffparse.h>
12 int main(int argc, char *argv[])
14 struct IFFHandle *iff;
15 struct StoredProperty *ahig;
16 struct CollectionItem *ci;
17 LONG unit = 0;
18 int rc = RETURN_OK;
20 if(argc != 3) {
21 Printf("Usage: %s FILE UNIT\n", argv[0]);
22 return RETURN_FAIL;
25 StrToLong(argv[2], &unit);
27 if(iff = AllocIFF())
29 iff->iff_Stream = Open(argv[1], MODE_OLDFILE);
30 if(iff->iff_Stream)
32 InitIFFasDOS(iff);
33 if(!OpenIFF(iff, IFFF_READ))
35 if(!(PropChunk(iff,ID_PREF,ID_AHIG)
36 || CollectionChunk(iff,ID_PREF,ID_AHIU)
37 || StopOnExit(iff,ID_PREF,ID_FORM)))
39 if(ParseIFF(iff, IFFPARSE_SCAN) == IFFERR_EOC)
42 ahig = FindProp(iff,ID_PREF,ID_AHIG);
43 if(ahig)
45 struct AHIGlobalPrefs *globalprefs;
46 globalprefs = (struct AHIGlobalPrefs *)ahig->sp_Data;
48 if(globalprefs->ahigp_DebugLevel != AHI_DEBUG_NONE)
50 Printf("Debugging is turned on.\n");
51 rc = RETURN_WARN;
55 ci = FindCollection(iff,ID_PREF,ID_AHIU);
56 while(ci)
58 struct AHIUnitPrefs *unitprefs;
59 unitprefs = (struct AHIUnitPrefs *)ci->ci_Data;
61 if(unitprefs->ahiup_Unit == unit)
63 if(unitprefs->ahiup_Channels < 2)
65 Printf("There are less than 2 channels selected for unit %ld.\n", unit);
66 rc = RETURN_WARN;
69 ci=ci->ci_Next;
74 CloseIFF(iff);
76 Close(iff->iff_Stream);
78 FreeIFF(iff);
81 return rc;