summaryrefslogtreecommitdiffstats
path: root/ini
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2009-04-15 11:58:39 -0400
committerStephen Gallagher <sgallagh@redhat.com>2009-04-15 12:34:50 -0400
commitbd644c0a73932702aafe188c0cb98b271b494715 (patch)
tree3e5bee4681d6fb3b52b6041ce877b5951c066c0a /ini
parent62a6ee4a83f90015d69645b72e7878c2febd7e00 (diff)
downloadding-libs-bd644c0a73932702aafe188c0cb98b271b494715.tar.gz
ding-libs-bd644c0a73932702aafe188c0cb98b271b494715.tar.xz
ding-libs-bd644c0a73932702aafe188c0cb98b271b494715.zip
INI parser. Better error handling if something bad happens.
Tried to use the INI interface and saw that the list of parsing errors can be not NULL but the actual data is cleaned.
Diffstat (limited to 'ini')
-rw-r--r--ini/ini_config.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/ini/ini_config.c b/ini/ini_config.c
index fd1efb0..7effc04 100644
--- a/ini/ini_config.c
+++ b/ini/ini_config.c
@@ -163,7 +163,7 @@ static int ini_to_collection(const char *filename,
if (error) {
TRACE_ERROR_NUMBER("Failed to create error collection", error);
fclose(file);
- return EOK;
+ return error;
}
created = 1;
}
@@ -195,7 +195,10 @@ static int ini_to_collection(const char *filename,
TRACE_ERROR_NUMBER("Failed to create collection", error);
fclose(file);
destroy_collection(current_section);
- if (created) destroy_collection(*error_list);
+ if (created) {
+ destroy_collection(*error_list);
+ *error_list = NULL;
+ }
return error;
}
}
@@ -209,7 +212,10 @@ static int ini_to_collection(const char *filename,
TRACE_ERROR_NUMBER("Failed to add pair to collection", error);
fclose(file);
destroy_collection(current_section);
- if (created) destroy_collection(*error_list);
+ if (created) {
+ destroy_collection(*error_list);
+ *error_list = NULL;
+ }
return error;
}
break;
@@ -231,7 +237,10 @@ static int ini_to_collection(const char *filename,
TRACE_ERROR_NUMBER("Failed to add collection", error);
fclose(file);
destroy_collection(current_section);
- if (created) destroy_collection(*error_list);
+ if (created) {
+ destroy_collection(*error_list);
+ *error_list = NULL;
+ }
return error;
}
}
@@ -255,7 +264,10 @@ static int ini_to_collection(const char *filename,
TRACE_ERROR_NUMBER("Failed to add error to collection", error);
fclose(file);
destroy_collection(current_section);
- if (created) destroy_collection(*error_list);
+ if (created) {
+ destroy_collection(*error_list);
+ *error_list = NULL;
+ }
return error;
}
/* Exit if there was an error parsing file */
@@ -277,7 +289,10 @@ static int ini_to_collection(const char *filename,
TRACE_ERROR_NUMBER("Failed to add warning to collection", error);
fclose(file);
destroy_collection(current_section);
- if (created) destroy_collection(*error_list);
+ if (created) {
+ destroy_collection(*error_list);
+ *error_list = NULL;
+ }
return error;
}
/* Exit if we are told to exit on warnings */