|
|
|
@ -18,24 +18,11 @@ struct Section |
|
|
|
|
ULONG insertPos; // we want to add new entries at end, but before any blanks
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
enum VariableType
|
|
|
|
|
{ |
|
|
|
|
TypeBool=0, |
|
|
|
|
TypeInteger=1, |
|
|
|
|
TypeString=2, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
struct Variable |
|
|
|
|
{ |
|
|
|
|
enum VariableType type; |
|
|
|
|
CONST_STRPTR key; |
|
|
|
|
CONST_STRPTR normalizedKey; |
|
|
|
|
struct
|
|
|
|
|
{ |
|
|
|
|
CONST_STRPTR stringValue; |
|
|
|
|
BOOL boolValue; |
|
|
|
|
LONG longValue; |
|
|
|
|
} value; |
|
|
|
|
CONST_STRPTR stringValue; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
struct Line |
|
|
|
@ -301,18 +288,12 @@ VOID SectionAddLine(SECTIONPTR abstractSection, LINEPTR abstractLine, BOOL addBe |
|
|
|
|
if(!LineIsEmpty(abstractLine) ) |
|
|
|
|
{ |
|
|
|
|
section->insertPos = SizeOfArray(section->lines); |
|
|
|
|
printf("xx (%s) insertpos = %lu\n", SectionCanonicalName(abstractSection), section->insertPos); |
|
|
|
|
LineDump(abstractLine); |
|
|
|
|
printf("xx\n"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
LineArrayInsert(section->lines, abstractLine, section->insertPos); |
|
|
|
|
section->insertPos += 1;
|
|
|
|
|
printf("yy (%s) insertpos = %lu\n", SectionCanonicalName(abstractSection), section->insertPos); |
|
|
|
|
LineDump(abstractLine); |
|
|
|
|
printf("yy\n"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -501,12 +482,11 @@ VARIABLEPTR VariableCreate(CONST_STRPTR key, CONST_STRPTR rawValue) |
|
|
|
|
CopyMem(key, (STRPTR)result->normalizedKey, length); |
|
|
|
|
downcaseString((STRPTR)result->normalizedKey); |
|
|
|
|
} |
|
|
|
|
result->type = TypeString; |
|
|
|
|
if( rawValue != NULL ) |
|
|
|
|
{ |
|
|
|
|
ULONG length = strlen(rawValue); |
|
|
|
|
result->value.stringValue = AllocVec(length+1, MEMF_CLEAR); |
|
|
|
|
CopyMem(rawValue, (STRPTR)result->value.stringValue, length); |
|
|
|
|
result->stringValue = AllocVec(length+1, MEMF_CLEAR); |
|
|
|
|
CopyMem(rawValue, (STRPTR)result->stringValue, length); |
|
|
|
|
} |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
@ -516,7 +496,7 @@ CONST_STRPTR VariableGetRawValue(VARIABLEPTR abstractVariable) |
|
|
|
|
struct Variable* variable = (struct Variable*)abstractVariable; |
|
|
|
|
if( variable != NULL ) |
|
|
|
|
{ |
|
|
|
|
return variable->value.stringValue; |
|
|
|
|
return variable->stringValue; |
|
|
|
|
} |
|
|
|
|
return NULL; |
|
|
|
|
} |
|
|
|
@ -547,9 +527,9 @@ VOID VariableFree(VARIABLEPTR abstractVariable) |
|
|
|
|
{ |
|
|
|
|
FreeVec((STRPTR)variable->normalizedKey); |
|
|
|
|
} |
|
|
|
|
if( variable->type == TypeString && variable->value.stringValue != NULL ) |
|
|
|
|
if( variable->stringValue != NULL ) |
|
|
|
|
{ |
|
|
|
|
FreeVec((STRPTR)variable->value.stringValue); |
|
|
|
|
FreeVec((STRPTR)variable->stringValue); |
|
|
|
|
} |
|
|
|
|
FreeVec(variable); |
|
|
|
|
|
|
|
|
@ -560,11 +540,11 @@ CONST_STRPTR VariableSerialize(VARIABLEPTR abstractVariable) |
|
|
|
|
{ |
|
|
|
|
STRPTR result = NULL; |
|
|
|
|
struct Variable* variable = (struct Variable*)abstractVariable; |
|
|
|
|
if( variable != NULL && variable->normalizedKey != NULL && variable->value.stringValue != NULL ) |
|
|
|
|
if( variable != NULL && variable->normalizedKey != NULL && variable->stringValue != NULL ) |
|
|
|
|
{ |
|
|
|
|
ULONG size = 1 + strlen(variable->normalizedKey) + 3 + strlen(variable->value.stringValue) + 1 + 1; |
|
|
|
|
ULONG size = 1 + strlen(variable->normalizedKey) + 3 + strlen(variable->stringValue) + 1 + 1; |
|
|
|
|
result = AllocVec(size, MEMF_CLEAR); |
|
|
|
|
sprintf(result, "\t%s = %s\n", variable->normalizedKey, variable->value.stringValue); |
|
|
|
|
sprintf(result, "\t%s = %s\n", variable->normalizedKey, variable->stringValue); |
|
|
|
|
} |
|
|
|
|
return (CONST_STRPTR)result; |
|
|
|
|
} |
|
|
|
|