summaryrefslogtreecommitdiffstats
path: root/ini/ini_parse.c
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2012-12-24 17:45:00 -0500
committerOndrej Kos <okos@redhat.com>2013-01-24 08:34:51 +0100
commit6823d7104cca0f8ac22ed9432ee8a2f1a0d9124a (patch)
tree51c9c817e8335c0001f3c012819760bfcf6a1681 /ini/ini_parse.c
parentfa00e2e16e5c1d3ac56f1bbd3a84875642d0bb39 (diff)
downloadding-libs-6823d7104cca0f8ac22ed9432ee8a2f1a0d9124a.tar.gz
ding-libs-6823d7104cca0f8ac22ed9432ee8a2f1a0d9124a.tar.xz
ding-libs-6823d7104cca0f8ac22ed9432ee8a2f1a0d9124a.zip
More interface refactoring
I also realized that error list processing should not be bound to the file object. This patch corrects that by moving the error_list and corresponding count from file object to the config object. Things updated by the patch: 1. The internal variables are moved from file obj to config obj. 2. The external header is updated to reflect the change 3. Functions are moved from file obj module to config obj module. 4. Parser code is updated because error validation was in the wrong place 5. Unit test is adjusted to get error list from the right object. I had to adjust the copy function for the config object. Copy function does not copy over the error list.
Diffstat (limited to 'ini/ini_parse.c')
-rw-r--r--ini/ini_parse.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/ini/ini_parse.c b/ini/ini_parse.c
index d009914..60ef116 100644
--- a/ini/ini_parse.c
+++ b/ini/ini_parse.c
@@ -202,7 +202,6 @@ static int parser_create(struct ini_cfgobj *co,
int error_level,
uint32_t collision_flags,
uint32_t parse_flags,
- struct collection_item *error_list,
struct parser_obj **po)
{
int error = EOK;
@@ -216,15 +215,7 @@ static int parser_create(struct ini_cfgobj *co,
(!co) ||
(!(co->cfg)) ||
(!file) ||
- (!config_filename) ||
- (!error_list)) {
- TRACE_ERROR_NUMBER("Invalid argument", EINVAL);
- return EINVAL;
- }
-
- if ((error_level != INI_STOP_ON_ANY) &&
- (error_level != INI_STOP_ON_NONE) &&
- (error_level != INI_STOP_ON_ERROR)) {
+ (!config_filename)) {
TRACE_ERROR_NUMBER("Invalid argument", EINVAL);
return EINVAL;
}
@@ -248,7 +239,7 @@ static int parser_create(struct ini_cfgobj *co,
/* Save external data */
new_po->file = file;
- new_po->el = error_list;
+ new_po->el = co->error_list;
new_po->filename = config_filename;
new_po->error_level = error_level;
new_po->collision_flags = collision_flags;
@@ -1618,10 +1609,11 @@ int ini_config_parse(struct ini_cfgfile *file_ctx,
return EINVAL;
}
- if ((error_level < INI_STOP_ON_ANY) ||
- (error_level > INI_STOP_ON_ERROR)) {
- /* Any other error mode is equivalent stopping on any error */
- error_level = INI_STOP_ON_ANY;
+ if ((error_level != INI_STOP_ON_ANY) &&
+ (error_level != INI_STOP_ON_NONE) &&
+ (error_level != INI_STOP_ON_ERROR)) {
+ TRACE_ERROR_NUMBER("Invalid argument", EINVAL);
+ return EINVAL;
}
error = parser_create(ini_config,
@@ -1630,7 +1622,6 @@ int ini_config_parse(struct ini_cfgfile *file_ctx,
error_level,
collision_flags,
parse_flags,
- file_ctx->error_list,
&po);
if (error) {
TRACE_ERROR_NUMBER("Failed to perform an action", error);
@@ -1658,8 +1649,8 @@ int ini_config_parse(struct ini_cfgfile *file_ctx,
else {
TRACE_ERROR_NUMBER("Failed to parse file", error);
TRACE_ERROR_NUMBER("Mode", collision_flags);
- col_get_collection_count(file_ctx->error_list, &(file_ctx->count));
- if(file_ctx->count) (file_ctx->count)--;
+ col_get_collection_count(ini_config->error_list, &(ini_config->count));
+ if(ini_config->count) (ini_config->count)--;
parser_destroy(po);
return error;
}