|
|
|
@ -46,26 +46,39 @@ VOID ConfigFileFree(CONFIGFILEPTR abstractConfigFile) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CONFIGFILEPTR ConfigFileRead(CONST_STRPTR filename) |
|
|
|
|
CONFIGFILEPTR ConfigFileReadName(CONST_STRPTR filename) |
|
|
|
|
{ |
|
|
|
|
struct ConfigFile* result = NULL; |
|
|
|
|
BPTR configFile = Open(filename, MODE_OLDFILE); |
|
|
|
|
if( configFile != ZERO ) |
|
|
|
|
{ |
|
|
|
|
result = ConfigFileRead(configFile); |
|
|
|
|
Close(configFile); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
LINEPTR line = NULL; |
|
|
|
|
result = AllocVec(sizeof(struct ConfigFile), MEMF_CLEAR); |
|
|
|
|
result->sectionStore = SectionStoreNew(); |
|
|
|
|
result->filename = AllocVec(strlen(filename)+1, MEMF_CLEAR); |
|
|
|
|
CopyMem(filename, result->filename, strlen(filename)); |
|
|
|
|
while( (line = configFileReadLine(configFile)) != NULL ) |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CONFIGFILEPTR ConfigFileRead(BPTR configFile) |
|
|
|
|
{
|
|
|
|
|
struct ConfigFile* result = NULL; |
|
|
|
|
LINEPTR line = NULL; |
|
|
|
|
if( configFile != 0 ) |
|
|
|
|
{ |
|
|
|
|
UBYTE buffer[256]; |
|
|
|
|
if(NameFromFH(configFile, buffer, 256))// if we opened with a filename this is a waste, if not its necessary
|
|
|
|
|
{ |
|
|
|
|
SectionStoreAddLineToCurrentSection(result->sectionStore, line); |
|
|
|
|
//LineDump(line);
|
|
|
|
|
result = AllocVec(sizeof(struct ConfigFile), MEMF_CLEAR); |
|
|
|
|
result->sectionStore = SectionStoreNew(); |
|
|
|
|
result->filename = AllocVec(strlen(buffer)+1, MEMF_CLEAR); |
|
|
|
|
CopyMem(buffer, result->filename, strlen(buffer)); |
|
|
|
|
while( (line = configFileReadLine(configFile)) != NULL ) |
|
|
|
|
{ |
|
|
|
|
SectionStoreAddLineToCurrentSection(result->sectionStore, line); |
|
|
|
|
//LineDump(line);
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Close(configFile); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|