Exemplo n.º 1
0
const char* Config::GetListValue(const char* name, int num, const char* defval)
{
    ConfigVar* var;
    
    var = GetVar(name);
    if (!var)
        return defval;
    
    return var->GetListValue(num, defval);
}
Exemplo n.º 2
0
bool Config::Save()
{
    FILE*       fp;
    ConfigVar*  var;
    
    
    fp = fopen(filename, "w");
    if (!fp)
        return false;
    
    fprintf(fp, "# Automatically generated configuration file. DO NOT EDIT!\n\n");
    
    for (var = vars.First(); var != NULL; var = var->next)
    {
        fprintf(fp, "%s = \"%s", var->name.GetBuffer(), var->GetListValue(0, ""));
        for (int i = 1; i < var->numelem; i++)
            fprintf(fp, "\",\"%s", var->GetListValue(i, ""));

        fprintf(fp, "\"\n");
    }
    
    fclose(fp);
    return true;
}