rem: *p, u->prefs, ci->ci_Size ); CopyIfValid( struct AHIUnitPrefs, ahiup_ScaleMode,
context: struct List *GetUnits(char *name) {  struct List *list;  struct IFFHandle *iff;  BOOL devnodes[UNITNODES] = { FALSE, FALSE, FALSE, FALSE } ;  BOOL lownode = FALSE;  int i;  // Reasonable defaults  globalprefs.ahigp_DebugLevel       = AHI_DEBUG_NONE;  globalprefs.ahigp_DisableSurround  = FALSE;  globalprefs.ahigp_DisableEcho      = FALSE;  globalprefs.ahigp_FastEcho         = FALSE;  globalprefs.ahigp_MaxCPU           = (90 << 16) / 100;  globalprefs.ahigp_ClipMasterVolume = FALSE;  globalprefs.ahigp_Pad              = 0;  globalprefs.ahigp_AntiClickTime    = 0;  list = AllocVec(sizeof(struct List), MEMF_CLEAR);    if(list) {    NewList(list);        if(name && (iff = AllocIFF())) {      iff->iff_Stream = (ULONG) Open(name, MODE_OLDFILE);      if(iff->iff_Stream) {        InitIFFasDOS(iff);        if(!OpenIFF(iff, IFFF_READ)) {          if(!(PropChunk      (iff, ID_PREF, ID_AHIG) ||               CollectionChunk(iff, ID_PREF, ID_AHIU) ||               StopOnExit     (iff, ID_PREF, ID_FORM))) {            if(ParseIFF(iff, IFFPARSE_SCAN) == IFFERR_EOC) {              struct StoredProperty *global = FindProp(iff, ID_PREF, ID_AHIG);              struct CollectionItem *ci = FindCollection(iff, ID_PREF, ID_AHIU);	      int ci_cnt = 0;              if(global != NULL) {		struct AHIGlobalPrefs *p = global->sp_Data;		CopyIfValid( struct AHIGlobalPrefs, ahigp_DebugLevel,			     *p, globalprefs, global->sp_Size );		CopyIfValid( struct AHIGlobalPrefs, ahigp_DisableSurround,			     *p, globalprefs, global->sp_Size );		CopyIfValid( struct AHIGlobalPrefs, ahigp_DisableEcho,			     *p, globalprefs, global->sp_Size );		CopyIfValid( struct AHIGlobalPrefs, ahigp_FastEcho,			     *p, globalprefs, global->sp_Size );		CopyIfValid( struct AHIGlobalPrefs, ahigp_MaxCPU,			     *p, globalprefs, global->sp_Size );		CopyIfValid( struct AHIGlobalPrefs, ahigp_ClipMasterVolume, 			     *p, globalprefs, global->sp_Size );		CopyIfValid( struct AHIGlobalPrefs, ahigp_Pad,			     *p, globalprefs, global->sp_Size );		CopyIfValid( struct AHIGlobalPrefs, ahigp_AntiClickTime,			     *p, globalprefs, global->sp_Size );		/* Set upsupported options to their defaults */		if( AHIBase->lib_Version <= 4 )		{		  globalprefs.ahigp_AntiClickTime = 0;		}				if( AHIBase->lib_Version >= 5 )		{		  globalprefs.ahigp_DisableSurround  = FALSE;		  globalprefs.ahigp_DisableEcho      = FALSE;		  globalprefs.ahigp_FastEcho         = FALSE;		  globalprefs.ahigp_ClipMasterVolume = TRUE;		}              }              while(ci) {                struct AHIUnitPrefs *p = ci->ci_Data;                struct UnitNode     *u;                u = AllocVec(sizeof(struct UnitNode), MEMF_CLEAR);                if(u == NULL)                  break;		u->prefs.ahiup_Unit          = ci_cnt;		u->prefs.ahiup_ScaleMode     = AHI_SCALE_FIXED_SAFE;		u->prefs.ahiup_Channels      = 1;		u->prefs.ahiup_AudioMode     = AHI_DEFAULT_ID;		u->prefs.ahiup_Frequency     = AHI_DEFAULT_FREQ;		u->prefs.ahiup_MonitorVolume = 0;		u->prefs.ahiup_InputGain     = 0;		u->prefs.ahiup_OutputVolume  = 0x10000;		u->prefs.ahiup_Input         = 0;		u->prefs.ahiup_Output        = 0;		++ci_cnt;				CopyIfValid( struct AHIUnitPrefs, ahiup_Unit,			     *p, u->prefs, ci->ci_Size );		CopyIfValid( struct AHIUnitPrefs, ahiup_ScaleMode,			     *p, u->prefs, ci->ci_Size );		CopyIfValid( struct AHIUnitPrefs, ahiup_Channels,			     *p, u->prefs, ci->ci_Size );		CopyIfValid( struct AHIUnitPrefs, ahiup_AudioMode,			     *p, u->prefs, ci->ci_Size );		CopyIfValid( struct AHIUnitPrefs, ahiup_Frequency,			     *p, u->prefs, ci->ci_Size );		CopyIfValid( struct AHIUnitPrefs, ahiup_MonitorVolume,			     *p, u->prefs, ci->ci_Size );		CopyIfValid( struct AHIUnitPrefs, ahiup_InputGain,			     *p, u->prefs, ci->ci_Size );		CopyIfValid( struct AHIUnitPrefs, ahiup_OutputVolume,			     *p, u->prefs, ci->ci_Size );		CopyIfValid( struct AHIUnitPrefs, ahiup_Input,			     *p, u->prefs, ci->ci_Size );		CopyIfValid( struct AHIUnitPrefs, ahiup_Output,			     *p, u->prefs, ci->ci_Size );		                FillUnitName(u);                                u->node.ln_Pri = -(u->prefs.ahiup_Unit);                Enqueue(list, (struct Node *) u);                                if(u->prefs.ahiup_Unit == AHI_NO_UNIT) {                  lownode = TRUE;                }                else if(u->prefs.ahiup_Unit < UNITNODES) {                  devnodes[u->prefs.ahiup_Unit] = TRUE;                }                                ci=ci->ci_Next;              }            }          }          CloseIFF(iff);        }        Close((BPTR) iff->iff_Stream);      }      FreeIFF(iff);    }    // Fill up to lowlevel + UNITNODES device nodes, if not found in prefs file    if(!lownode) AddUnit(list, AHI_NO_UNIT);    for(i = 0; i < UNITNODES; i++) {      if(!devnodes[i]) AddUnit(list, i);    }  }  return list;}