Skip to content
Snippets Groups Projects
Commit a1d106cf authored by rswindell's avatar rswindell
Browse files

Fixed iniGetSection() (was returning the section header in the string list).

Created iniPopKey(), a combination of iniGetString() and iniRemoveKey().
parent 3bef9d40
Branches
Tags
No related merge requests found
...@@ -302,10 +302,7 @@ str_list_t iniGetSection(str_list_t list, const char *section) ...@@ -302,10 +302,7 @@ str_list_t iniGetSection(str_list_t list, const char *section)
if(list==NULL) if(list==NULL)
return(retval); return(retval);
if(section==ROOT_SECTION) i=find_section(list,section);
i=0;
else
i=find_section_index(list,section);
if(list[i]!=NULL) { if(list[i]!=NULL) {
strListPush(&retval, list[i]); strListPush(&retval, list[i]);
for(i++;list[i]!=NULL;i++) { for(i++;list[i]!=NULL;i++) {
...@@ -729,6 +726,18 @@ char* iniGetString(str_list_t list, const char* section, const char* key, const ...@@ -729,6 +726,18 @@ char* iniGetString(str_list_t list, const char* section, const char* key, const
return(value); return(value);
} }
char* iniPopKey(str_list_t* list, const char* section, const char* key, char* value)
{
size_t i=get_value(*list, section, key, value);
if(*value==0)
return NULL;
strListDelete(list,i);
return(value);
}
char* iniReadExistingString(FILE* fp, const char* section, const char* key, const char* deflt, char* value) char* iniReadExistingString(FILE* fp, const char* section, const char* key, const char* deflt, char* value)
{ {
if(read_value(fp,section,key,value)==NULL) if(read_value(fp,section,key,value)==NULL)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* * * *
* Copyright 2007 Rob Swindell - http://www.synchro.net/copyright.html * * Copyright 2008 Rob Swindell - http://www.synchro.net/copyright.html *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
...@@ -219,6 +219,7 @@ size_t iniAppendSection(str_list_t*, const char* section ...@@ -219,6 +219,7 @@ size_t iniAppendSection(str_list_t*, const char* section
BOOL iniSectionExists(str_list_t, const char* section); BOOL iniSectionExists(str_list_t, const char* section);
BOOL iniKeyExists(str_list_t, const char* section, const char* key); BOOL iniKeyExists(str_list_t, const char* section, const char* key);
BOOL iniValueExists(str_list_t, const char* section, const char* key); BOOL iniValueExists(str_list_t, const char* section, const char* key);
char* iniPopKey(str_list_t*, const char* section, const char* key, char* value);
BOOL iniRemoveKey(str_list_t*, const char* section, const char* key); BOOL iniRemoveKey(str_list_t*, const char* section, const char* key);
BOOL iniRemoveValue(str_list_t*, const char* section, const char* key); BOOL iniRemoveValue(str_list_t*, const char* section, const char* key);
BOOL iniRemoveSection(str_list_t*, const char* section); BOOL iniRemoveSection(str_list_t*, const char* section);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment