// cfgdata.inc - Registers static data used by the config dlls.

#include "digicfg.src"

//
//	Write config map to registry
//
//		$R0 = Boolean value (TRUE = success)
//
[WriteConfigData]

	_Enter("WriteConfigData", "")

	StartWait

	DeleteRegTree $(!REG_H_LOCAL) WANLINKS_CONFIG_REGKEY_QUOT

#define CFGDATA_NUM_COLUMN    0
#define CFGDATA_PATH_COLUMN   1
#define CFGDATA_NAME_COLUMN   2
#define CFGDATA_TYPE_COLUMN   3
#define CFGDATA_DATA_COLUMN   4

   set CfgDataList = ^(DigiCfg.AddReg, CFGDATA_NUM_COLUMN)

   ForListDo $(CfgDataList)

      set Num = $($)
      set Path = WANLINKS_CONFIG_REGKEY_QUOT\\#(DigiCfg.AddReg, $(Num), CFGDATA_PATH_COLUMN)
      set Name = #(DigiCfg.AddReg, $(Num), CFGDATA_NAME_COLUMN)
      set Type = #(DigiCfg.AddReg, $(Num), CFGDATA_TYPE_COLUMN)
      set Data = #(DigiCfg.AddReg, $(Num), CFGDATA_DATA_COLUMN)

      _Trace("Writing config data ", _Show(Num)_Show(Path)_Show(Name)_Show(Type)_Show(Data))

           ifstr(i) $(Type) == FLG_ADDREG_TYPE_SZ
			      _SetRegSzByName $(Path) $(Name) $(Data)
      else-ifstr(i) $(Type) == FLG_ADDREG_TYPE_MULTI_SZ
			      _SetRegMultiSzByName $(Path) $(Name) $(Data)
      else-ifstr(i) $(Type) == FLG_ADDREG_TYPE_EXPAND_SZ
			      _SetRegExpandSzByName $(Path) $(Name) $(Data)
      else-ifstr(i) $(Type) == FLG_ADDREG_TYPE_DWORD
			      _SetRegDwordByName $(Path) $(Name) $(Data)
      endif

		_Assert($($R0))

   EndForListDo

   set Success = TRUE

Exit = +

	EndWait

	_Exit("WriteConfigData", _Show(Success))
	Return $(Success)

