summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2010-12-25 23:24:35 -0500
committerStephen Gallagher <sgallagh@redhat.com>2012-04-05 11:20:08 -0700
commit142396b25e68e254f7bc3478d9467158f0fb0eb7 (patch)
treefaac7a19949ac9291617b52447b75ed9f76126fd
parentcf667071bab4673468b10c837a024aae30f3f9af (diff)
downloadding-libs-142396b25e68e254f7bc3478d9467158f0fb0eb7.tar.gz
ding-libs-142396b25e68e254f7bc3478d9467158f0fb0eb7.tar.xz
ding-libs-142396b25e68e254f7bc3478d9467158f0fb0eb7.zip
New error codes and messages
Patch consists of two parts: * Adding new constants for error messages to ini_configobj.h file * Making ini_print.c use this header file instead of the old one. Converting this to enums is tracked as a separate ticket.
-rw-r--r--ini/ini_configobj.h12
-rw-r--r--ini/ini_print.c54
2 files changed, 57 insertions, 9 deletions
diff --git a/ini/ini_configobj.h b/ini/ini_configobj.h
index 88a8704..36558a7 100644
--- a/ini/ini_configobj.h
+++ b/ini/ini_configobj.h
@@ -72,13 +72,15 @@
#define ERR_READ 8
/** @brief Line starts with space when it should not (Error). */
#define ERR_SPACE 9
+/** @brief Duplicate key is not allowed (Error). */
+#define ERR_DUPKEY 10
+/** @brief Duplicate key is detected while merging sections (Error). */
+#define ERR_DUPKEYSEC 11
+/** @brief Duplicate section is not allowed (Error). */
+#define ERR_DUPSECTION 12
/** @brief Size of the error array. */
-#define ERR_MAXPARSE ERR_SPACE
-
-/**
- * @}
- */
+#define ERR_MAXPARSE ERR_DUPSECTION
/**
diff --git a/ini/ini_print.c b/ini/ini_print.c
index 0430976..1dcfa54 100644
--- a/ini/ini_print.c
+++ b/ini/ini_print.c
@@ -31,7 +31,8 @@
#include "collection.h"
#include "collection_tools.h"
#include "ini_defines.h"
-#include "ini_config.h"
+#include "ini_config_priv.h"
+#include "ini_configobj.h"
/*============================================================*/
@@ -42,6 +43,16 @@
* check that the class IDs did not get reused over time by
* other classes.
*/
+/**
+ * @brief Collection of error collections.
+ *
+ * When multiple files are read during one call
+ * each file has its own set of parsing errors
+ * and warnings. This is the collection
+ * of such sets.
+ */
+#define COL_CLASS_INI_PESET COL_CLASS_INI_BASE + 3
+
/** @brief Collection of grammar errors.
*
* Reserved for future use.
@@ -53,6 +64,37 @@
*/
#define COL_CLASS_INI_VERROR COL_CLASS_INI_BASE + 6
+/**
+ * @}
+ */
+
+/**
+ * @defgroup gramerr Grammar errors and warnings
+ *
+ * Placeholder for now. Reserved for future use.
+ *
+ * @{
+ */
+#define ERR_MAXGRAMMAR 0
+/**
+ * @}
+ */
+
+/**
+ * @defgroup valerr Validation errors and warnings
+ *
+ * Placeholder for now. Reserved for future use.
+ *
+ * @{
+ */
+#define ERR_MAXVALID 0
+
+
+/**
+ * @}
+ */
+
+
#ifdef HAVE_VALIDATION
/** @brief Collection of lines from the INI file.
@@ -78,7 +120,11 @@ static const char *parsing_error_str(int parsing_error)
_("Property name is too long."),
_("Failed to read line."),
_("Invalid space character at the "
- "beginning of the line.")
+ "beginning of the line."),
+ _("Duplicate key is not allowed."),
+ _("Duplicate key is detected while "
+ "merging sections."),
+ _("Duplicate section is not allowed.")
};
/* Check the range */
@@ -208,7 +254,7 @@ static void print_error_list(FILE *file,
struct collection_iterator *iterator;
int error;
struct collection_item *item = NULL;
- struct parse_error *pe;
+ struct ini_parse_error *pe;
unsigned int count;
TRACE_FLOW_STRING("print_error_list", "Entry");
@@ -256,7 +302,7 @@ static void print_error_list(FILE *file,
}
else {
/* Put error into provided format */
- pe = (struct parse_error *)(col_get_item_data(item));
+ pe = (struct ini_parse_error *)(col_get_item_data(item));
fprintf(file, line_format,
col_get_item_property(item, NULL), /* Error or warning */
pe->error, /* Error */