summaryrefslogtreecommitdiffstats
path: root/common/ini/ini_config.h
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2009-04-15 16:01:41 -0400
committerStephen Gallagher <sgallagh@redhat.com>2009-04-16 16:49:02 -0400
commit8f209f1cee137e410386b68f82a31c9ba862fe19 (patch)
tree81805eacaa2f471feeabb7fe76ba7e0d8cc1b896 /common/ini/ini_config.h
parent400204ad90917fd1d9fe63a273b9372d042fed30 (diff)
downloadsssd-8f209f1cee137e410386b68f82a31c9ba862fe19.tar.gz
sssd-8f209f1cee137e410386b68f82a31c9ba862fe19.tar.xz
sssd-8f209f1cee137e410386b68f82a31c9ba862fe19.zip
INI parser. Cleanup. Prep for INI validation.
This patch addresses several issues: a) Cleaning unit test to match coding standard b) Replace tabs with spaces - I do not know where they came but there were some. c) Allowing to read file and keep aside a collection of K-V pairs where key is the key in the INI file and value is the line number on which line the key apears. d) There will be different kinds of errors so error printing function was abstracted. g) Placeholders for other printing functions have been introduced.
Diffstat (limited to 'common/ini/ini_config.h')
-rw-r--r--common/ini/ini_config.h53
1 files changed, 51 insertions, 2 deletions
diff --git a/common/ini/ini_config.h b/common/ini/ini_config.h
index 95cd52416..fdf354382 100644
--- a/common/ini/ini_config.h
+++ b/common/ini/ini_config.h
@@ -35,6 +35,9 @@
#define COL_CLASS_INI_SECTION COL_CLASS_INI_BASE + 1 /* A one level collection of key value pairs where values are always stings */
#define COL_CLASS_INI_PERROR COL_CLASS_INI_BASE + 2 /* A one level collection of parse errors - store parse_error structs */
#define COL_CLASS_INI_PESET COL_CLASS_INI_BASE + 3 /* A one level collection of parse error collections */
+#define COL_CLASS_INI_GERROR COL_CLASS_INI_BASE + 4 /* A one level collection of grammar errors - store parse_error structs */
+#define COL_CLASS_INI_VERROR COL_CLASS_INI_BASE + 5 /* A one level collection of validation errors - store parse_error structs */
+#define COL_CLASS_INI_LINES COL_CLASS_INI_BASE + 6 /* A one level collection of lines in INI file */
/* Error levels */
@@ -54,6 +57,15 @@
#define ERR_MAXPARSE ERR_LONGKEY
+/* Grammar errors and warnings */
+/* Placeholder for now... */
+#define ERR_MAXGRAMMAR 0
+
+/* Validation errors and warnings */
+/* Placeholder for now... */
+#define ERR_MAXVALID 0
+
+
/* Internal sizes */
/* FIXME - make them configurable via config.h */
@@ -69,6 +81,19 @@ struct parse_error {
/* Function to return parsing error */
const char *parsing_error_str(int parsing_error);
+/* Function to return grammar error in template.
+ * This error is returned when the template
+ * is translated into the grammar object.
+ */
+const char *grammar_error_str(int parsing_error);
+
+/* Function to return validation error.
+ * This is the error that it is returned when
+ * the INI file is validated against the
+ * grammar object.
+ */
+const char *validation_error_str(int parsing_error);
+
/* Read configuration information from a file */
int config_from_file(const char *application, /* Name of the application - will be used as name of the collection */
const char *config_file, /* Name of the config file - if NULL the collection will be empty */
@@ -78,6 +103,17 @@ int config_from_file(const char *application, /* Name of the appli
struct collection_item **error_list); /* List of errors for a file */
+/* Read configuration information from a file with extra collection of line numbers */
+int config_from_file_with_lines(
+ const char *application, /* Name of the application - will be used as name of the collection */
+ const char *config_file, /* Name of the config file - if NULL the collection will be empty */
+ struct collection_item **ini_config, /* If *ini_config is NULL a new ini object will be allocated, */
+ /* otherwise the one that is pointed to will be updated. */
+ int error_level, /* Error level - break for errors, warnings or best effort (don't break) */
+ struct collection_item **error_list, /* List of errors for a file */
+ struct collection_item **lines); /* Collection of pairs where key is the key and value is line number */
+
+
/* Read default config file and then overwrite it with a specific one from the directory */
int config_for_app(const char *application, /* Name of the application that will be used to get config for */
const char *config_file, /* Name of the configuration file with default settings for all apps */
@@ -91,6 +127,19 @@ int config_for_app(const char *application, /* Name of the applica
void print_file_parsing_errors(FILE *file, /* File to send errors to */
struct collection_item *error_list); /* List of parsing errors */
+
+/* Print errors and warnings that were detected while
+ * checking grammar of the template.
+ */
+void print_grammar_errors(FILE *file, /* File to send errors to */
+ struct collection_item *error_list); /* List of grammar errors */
+
+/* Print errors and warnings that were detected while
+ * checking INI file against grammar object.
+ */
+void print_validation_errors(FILE *file, /* File to send errors to */
+ struct collection_item *error_list); /* List of validation errors */
+
/* Print errors and warnings that were detected parsing configuration as a whole */
/* Use this function to print results of the config_for_app() call */
void print_config_parsing_errors(FILE *file, /* File to send errors to */
@@ -118,7 +167,7 @@ int get_config_item(const char *section, /* Section. If NULL
struct collection_item *ini_config, /* Collection to search */
struct collection_item **item); /* Item returned. Will be NULL is not found. */
-/* Convertion functions for the configuration item.
+/* Conversion functions for the configuration item.
* Sets error to EINVAL if the item is bad.
* Sets error to EIO if the conversion failed.
* These functions do not allocate memory.
@@ -143,7 +192,7 @@ const char *get_const_string_config_value(struct collection_item *item, int *err
/* A get_bin_value and get_xxx_array functions allocate memory.
* It is the responsibility of the caller to free it after use.
- * free_xxx conviniece wrappers are provided for this purpose.
+ * free_xxx convenience wrappers are provided for this purpose.
* Functions will return NULL if conversion failed.
*/
/* A special hex format is assumed.