// (C) 1995 Hydra/TSN/LSD

// example of reading items from a config file..

/*

      FrEd=A string ;skjjshdjskjksjk
      num=83634
      list_1=fred
      list_2=sid
      list_3=moocow

      bool=YES
;      bool=NO
;      bool=ON
;      bool=OFF
;      bool=TRUE
;      bool=FALSE
*/


void LoadCFG( void )
{
  struct CfgFileData *DeviceCFG;
  V_ERROR error=TYPE_NONE;
  UBYTE *filename="RAM:Poo.cfg";

  VTYPE_STRING mystring=NULL;          // ALWAYS INITILISE VARIABLES that you pass to HBBS_GetSetting to
  VTYPE_STRINGLIST mylist=NULL;        // NULL or 0 otherwise you can expect a system crash!
  VTYPE_BIGNUM mynum=0;
  VTYPE_BOOL mybool=FALSE;

  if (DeviceCFG=(struct CfgFileData *)AllocVec(sizeof(struct CfgFileData),MEMF_PUBLIC))
  {
    if (!(error=HBBS_LoadConfig(DeviceCFG,filename)))
    {

      HBBS_GetSetting(DeviceCFG,(void *)&mystring,VTYPE_STRING,"fred"    ,OPT_SINGLE);
      HBBS_GetSetting(DeviceCFG,(void *)&mynum   ,VTYPE_BIGNUM,"num"     ,OPT_SINGLE);
      HBBS_GetSetting(DeviceCFG,(void *)&mylist  ,VTYPE_STRINGLIST,"list",OPT_MULTI);
      HBBS_GetSetting(DeviceCFG,(void *)&mybool  ,VTYPE_BOOL,"bool"      ,OPT_SINGLE);

      HBBS_FlushConfig(DeviceCFG);
    }
    FreeVec(DeviceCFG);
  }

  /*
     you can now do stuff with the variables that have been loaded gfrom the config file
     as you would with any other variable
  */

  // Not forgetting to free them after use tho...
  FreeStrList(mylist);
  FreeStr(mystring);
}
