diff options
| author | Dmitri Pal <dpal@redhat.com> | 2009-07-15 11:56:27 -0400 |
|---|---|---|
| committer | Stephen Gallagher <sgallagh@redhat.com> | 2009-07-16 16:29:14 -0400 |
| commit | 98451c5e9342d13129886b735cb82f7f7596f357 (patch) | |
| tree | a1e164e8b58b95c1c1aa8d398a376ec907ded6e2 /ini/ini_config.c | |
| parent | 51b3a661529f8e3fd5ada94b95d4ba393e339dd8 (diff) | |
| download | ding-libs-98451c5e9342d13129886b735cb82f7f7596f357.tar.gz ding-libs-98451c5e9342d13129886b735cb82f7f7596f357.tar.xz ding-libs-98451c5e9342d13129886b735cb82f7f7596f357.zip | |
INI Refactoring code a bit
The inefficient function from ini_config.c is
replaced with the function provided now by the
collection interface. Also the unit test is updated
to run from the local directory.
Diffstat (limited to 'ini/ini_config.c')
| -rw-r--r-- | ini/ini_config.c | 44 |
1 files changed, 9 insertions, 35 deletions
diff --git a/ini/ini_config.c b/ini/ini_config.c index 4f4ac2f..43f6d3b 100644 --- a/ini/ini_config.c +++ b/ini/ini_config.c @@ -148,39 +148,6 @@ int read_line(FILE *file, int *length, int *ext_error); -/* Add to collection or update - CONSIDER moving to the collection.c */ -static int add_or_update(struct collection_item *current_section, - char *key, - void *value, - int length, - int type) -{ - int found = COL_NOMATCH; - int error; - - TRACE_FLOW_STRING("add_or_update", "Entry"); - - error = col_is_item_in_collection(current_section, key, - COL_TYPE_ANY, - COL_TRAVERSE_IGNORE, - &found); - - if (found == COL_MATCH) { - TRACE_INFO_STRING("Updating...", ""); - error = col_update_property(current_section, - key, type, value, length, - COL_TRAVERSE_IGNORE); - } - else { - TRACE_INFO_STRING("Adding...", ""); - error = col_add_any_property(current_section, NULL, - key, type, value, length); - } - - TRACE_FLOW_NUMBER("add_or_update returning", error); - return error; -} - /***************************************************************************/ /* Function to read single ini file and pupulate * the provided collection with subcollcetions from the file */ @@ -280,8 +247,15 @@ static int ini_to_collection(const char *filename, } /* Put value into the collection */ - error = add_or_update(current_section, - key, value, length, COL_TYPE_STRING); + error = col_insert_str_property(current_section, + NULL, + COL_DSP_END, + NULL, + 0, + COL_INSERT_DUPOVER, + key, + value, + length); if (error != EOK) { TRACE_ERROR_NUMBER("Failed to add pair to collection", error); fclose(file); |
