summaryrefslogtreecommitdiffstats
path: root/common/ini/ini_metadata.c
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2010-03-29 16:58:29 -0400
committerStephen Gallagher <sgallagh@redhat.com>2010-04-14 12:15:54 -0400
commite4956873b0ca4ec732e009f88be43549506f7819 (patch)
treeddef1a00bc399d5070487d05f9f30ba54706bbdb /common/ini/ini_metadata.c
parentd675db76493ab9dcf8ccb0422b1477b780df8bc3 (diff)
downloadsssd-e4956873b0ca4ec732e009f88be43549506f7819.tar.gz
sssd-e4956873b0ca4ec732e009f88be43549506f7819.tar.xz
sssd-e4956873b0ca4ec732e009f88be43549506f7819.zip
Adding metadata interface
This patch: 1) Adds the definition of the metadata interface to the header file. The functions that were exposed for no good reason are now hidden. 2) Previously exposed functions and their descriptions are removed from the public header and placed into the source code for now. 3) The function that reads the config file no longer tries to close file in case of error. 4) Lines collection is still passed in into the reading function but as a collection itself not as a pointer to it. 5) All the parts related to processing lines are currently ifdefed using HAVE_VALIDATION that is currently is not defined. This is done to disable creation of the lines collection utill it is actually needed. I did not want to blindly remove it though and loose already done work that will be useful in future. 6) Version of the library and interface is updated 7) New header and source modules are introduced to hold functions related to the meta data. They are mostly stubbed out. This is incomplete patch. It builds and make check runs. It is created just to simplify the review a bit.
Diffstat (limited to 'common/ini/ini_metadata.c')
-rw-r--r--common/ini/ini_metadata.c104
1 files changed, 104 insertions, 0 deletions
diff --git a/common/ini/ini_metadata.c b/common/ini/ini_metadata.c
new file mode 100644
index 000000000..630de699b
--- /dev/null
+++ b/common/ini/ini_metadata.c
@@ -0,0 +1,104 @@
+/*
+ INI LIBRARY
+
+ Functions to process metadata.
+
+ Copyright (C) Dmitri Pal <dpal@redhat.com> 2010
+
+ INI Library is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ INI Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with INI Library. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#define _GNU_SOURCE
+#include "config.h"
+#include "collection.h"
+#include "collection_tools.h"
+#include "trace.h"
+#include "ini_config.h"
+#include "ini_metadata.h"
+
+#define INI_METADATA "meta"
+
+/* Prepare metadata */
+int prepare_metadata(uint32_t metaflags,
+ struct collection_item **metadata,
+ int *save_error)
+{
+ int error = EOK;
+ struct collection_item *metasec = NULL;
+
+ TRACE_FLOW_STRING("prepare_metadata", "Entry");
+
+ /* Are we supposed to collect or process meta data ? */
+ if (!metadata) {
+ TRACE_FLOW_STRING("No meta data", "Exit");
+ return EOK;
+ }
+
+ /* Allocate metadata */
+ error = col_create_collection(metadata,
+ INI_METADATA,
+ COL_CLASS_INI_META);
+ if (error) {
+ TRACE_ERROR_NUMBER("Failed to create meta data", error);
+ return error;
+ }
+
+ /* Check and create section for file error if needed */
+ if (metaflags & INI_META_SEC_ERROR_FLAG) {
+ /* Create ERROR collection */
+ if ((error = col_create_collection(&metasec,
+ INI_META_SEC_ERROR,
+ COL_CLASS_INI_SECTION)) ||
+ (error = col_add_collection_to_collection(
+ *metadata,
+ NULL,
+ NULL,
+ metasec,
+ COL_ADD_MODE_REFERENCE))) {
+ TRACE_ERROR_NUMBER("Failed to create error section", error);
+ col_destroy_collection(metasec);
+ col_destroy_collection(*metadata);
+ return error;
+ }
+ /* If we are here we would have to save file open error */
+ *save_error = 1;
+ col_destroy_collection(metasec);
+ }
+
+ TRACE_FLOW_STRING("prepare_metadata", "Exit");
+ return error;
+}
+
+
+
+/* Collect metadata for the file */
+int collect_metadata(uint32_t metaflags,
+ struct collection_item **metadata,
+ FILE *config_file)
+{
+ int error = EOK;
+
+ TRACE_FLOW_STRING("collect_metadata", "Entry");
+
+ TRACE_FLOW_STRING("collect_metadata", "Exit");
+ return error;
+}
+
+/* Function to free metadata */
+void free_ini_config_metadata(struct collection_item *metadata)
+{
+ TRACE_FLOW_STRING("free_ini_config_metadata", "Entry");
+ col_destroy_collection(metadata);
+ TRACE_FLOW_STRING("free_ini_config_metadata", "Exit");
+}