|
|
|
@ -5,6 +5,7 @@ |
|
|
|
|
|
|
|
|
|
#include "containers/stringarray.h" |
|
|
|
|
#include "containers/sectionarray.h" |
|
|
|
|
#include "containers/linearray.h" |
|
|
|
|
#include <proto/exec.h> |
|
|
|
|
#include <proto/dos.h> |
|
|
|
|
#include <string.h> |
|
|
|
@ -193,7 +194,7 @@ StringArray ConfigFileGetAll(CONFIGFILEPTR abstractConfigFile, CONST_STRPTR comp |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
VOID ConfigFileAdd(CONFIGFILEPTR abstractConfigFile, CONST_STRPTR compoundKey, CONST_STRPTR stringValue) |
|
|
|
|
VOID ConfigFileAddVariable(CONFIGFILEPTR abstractConfigFile, CONST_STRPTR compoundKey, CONST_STRPTR stringValue) |
|
|
|
|
{ |
|
|
|
|
struct ConfigFile* configFile = (struct ConfigFile*)abstractConfigFile; |
|
|
|
|
if( configFile != NULL ) |
|
|
|
@ -218,15 +219,40 @@ VOID ConfigFileAdd(CONFIGFILEPTR abstractConfigFile, CONST_STRPTR compoundKey, C |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
VOID ConfigFileSet(CONFIGFILEPTR abstractConfigFile, CONST_STRPTR compoundKey, CONST_STRPTR stringValue) |
|
|
|
|
BOOL ConfigFileSet(CONFIGFILEPTR abstractConfigFile, CONST_STRPTR compoundKey, CONST_STRPTR stringValue) |
|
|
|
|
{ |
|
|
|
|
BOOL result = FALSE; |
|
|
|
|
struct ConfigFile* configFile = (struct ConfigFile*)abstractConfigFile; |
|
|
|
|
if( configFile != NULL ) |
|
|
|
|
{ |
|
|
|
|
StringArray parts = ConfigFileSplitKeyCompletely(compoundKey); |
|
|
|
|
|
|
|
|
|
StringArray parts = ConfigFileSplitKeyForVar(compoundKey); |
|
|
|
|
LineArray lines = SectionStoreFindLines(configFile->sectionStore, StringArrayValues(parts)[0], StringArrayValues(parts)[1]); |
|
|
|
|
if( SizeOfArray(lines) == 0 ) |
|
|
|
|
{ |
|
|
|
|
ConfigFileAddVariable(abstractConfigFile, compoundKey, stringValue); |
|
|
|
|
result = TRUE; |
|
|
|
|
} |
|
|
|
|
else if( SizeOfArray(lines) == 1 ) |
|
|
|
|
{ |
|
|
|
|
LINEPTR line = (LINEPTR)ArrayBackValue(LINEPTR, lines); |
|
|
|
|
if( line ) |
|
|
|
|
{ |
|
|
|
|
VARIABLEPTR var = VariableCreate(StringArrayValues(parts)[1], stringValue); |
|
|
|
|
if( var ) |
|
|
|
|
{ |
|
|
|
|
LineSetVariable(line, var); |
|
|
|
|
result = TRUE; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else // more than one line, we error.
|
|
|
|
|
{ |
|
|
|
|
result = FALSE; |
|
|
|
|
} |
|
|
|
|
StringArrayFree(parts, TRUE); |
|
|
|
|
LineArrayFree(lines, FALSE); |
|
|
|
|
} |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
VOID ConfigFileReplaceAll(CONFIGFILEPTR abstractConfigFile, CONST_STRPTR compoundKey, CONST_STRPTR stringValue) |
|
|
|
|