[Pkg-sssd-devel] ding-libs: Changes to 'upstream-unstable'

Timo Aaltonen tjaalton-guest at alioth.debian.org
Mon Apr 29 13:07:25 UTC 2013


Rebased ref, commits from common ancestor:
commit 69bcbaba75172b2bcb9292237092e206147dce8d
Author: Ondrej Kos <okos at redhat.com>
Date:   Fri Mar 29 10:22:11 2013 +0100

    Bump version for 0.3.0.1 release

diff --git a/version.m4 b/version.m4
index 02af987..76b8a0d 100644
--- a/version.m4
+++ b/version.m4
@@ -1,5 +1,5 @@
 # Primary version number
-m4_define([VERSION_NUMBER], [0.3.0])
+m4_define([VERSION_NUMBER], [0.3.0.1])
 
 # If the PRERELEASE_VERSION_NUMBER is set, we'll append
 # it to the release tag when creating an RPM or SRPM
@@ -15,4 +15,4 @@ m4_define([DHASH_VERSION_NUMBER], [0.4.3])
 m4_define([COLLECTION_VERSION_NUMBER], [0.6.2])
 m4_define([REF_ARRAY_VERSION_NUMBER], [0.1.3])
 m4_define([BASICOBJECTS_VERSION_NUMBER], [0.1.0])
-m4_define([INI_CONFIG_VERSION_NUMBER], [1.0.0])
+m4_define([INI_CONFIG_VERSION_NUMBER], [1.0.0.1])

commit ff863970210e07383b6ffd9e5000b5d07d3a359b
Author: Jakub Hrozek <jhrozek at redhat.com>
Date:   Thu Mar 28 15:09:29 2013 -0400

    Remove spurious cast

diff --git a/ini/ini_get_valueobj.c b/ini/ini_get_valueobj.c
index a7efe95..dad9932 100644
--- a/ini/ini_get_valueobj.c
+++ b/ini/ini_get_valueobj.c
@@ -224,7 +224,7 @@ int ini_get_config_valueobj(const char *section,
             return EOK;
         }
 
-        if ((hash == (unsigned long int)col_get_item_hash(item)) &&
+        if ((hash == col_get_item_hash(item)) &&
             (strncasecmp(col_get_item_property(item, &len), name, name_len) == 0) &&
             (len == name_len)) {
                 TRACE_INFO_STRING("Item is found", name);

commit 6ae982f110aa4c0d1e842b61d62fd3015973c8ee
Author: Ondrej Kos <okos at redhat.com>
Date:   Thu Mar 28 17:56:34 2013 +0100

    Bump version for 0.3.0 release

diff --git a/version.m4 b/version.m4
index 1f5f8f4..02af987 100644
--- a/version.m4
+++ b/version.m4
@@ -1,5 +1,5 @@
 # Primary version number
-m4_define([VERSION_NUMBER], [0.2.91])
+m4_define([VERSION_NUMBER], [0.3.0])
 
 # If the PRERELEASE_VERSION_NUMBER is set, we'll append
 # it to the release tag when creating an RPM or SRPM
@@ -15,4 +15,4 @@ m4_define([DHASH_VERSION_NUMBER], [0.4.3])
 m4_define([COLLECTION_VERSION_NUMBER], [0.6.2])
 m4_define([REF_ARRAY_VERSION_NUMBER], [0.1.3])
 m4_define([BASICOBJECTS_VERSION_NUMBER], [0.1.0])
-m4_define([INI_CONFIG_VERSION_NUMBER], [0.7.0])
+m4_define([INI_CONFIG_VERSION_NUMBER], [1.0.0])

commit 3889914c2c915eb28e4bb92a7e388a33d1b0af97
Author: Jakub Hrozek <jhrozek at redhat.com>
Date:   Thu Mar 28 16:31:03 2013 +0100

    Add a release script

diff --git a/scripts/release.sh b/scripts/release.sh
new file mode 100755
index 0000000..4730cda
--- /dev/null
+++ b/scripts/release.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+function config()
+{
+    autoreconf -i -f || return $?
+    ./configure
+}
+
+SAVED_PWD=$PWD
+version=`grep '\[VERSION_NUMBER], \[.*\]' version.m4 |grep '[0-9]\+\.[0-9]\+\.[0-9]\+' -o`
+tag=$(echo ${version} | tr "." "_")
+
+trap "cd $SAVED_PWD; rm -rf ding-libs-${version} ding-libs-${version}.tar" EXIT
+
+git archive --format=tar --prefix=ding-libs-${version}/ ding_libs-${tag} > ding-libs-${version}.tar
+if [ $? -ne 0 ]; then
+    echo "Cannot perform git-archive, check if tag ding_libs-$tag is present in git tree"
+    exit 1
+fi
+tar xf ding-libs-${version}.tar
+
+pushd ding-libs-${version}
+config || exit 1
+make dist-gzip || exit 1  # also builds docs
+popd
+
+mv ding-libs-${version}/ding-libs-${version}.tar.gz .
+gpg --detach-sign --armor ding-libs-${version}.tar.gz
+

commit 826b5d57dfb6ca529a8c857a515ad3ab115dab87
Author: Jakub Hrozek <jhrozek at redhat.com>
Date:   Mon Mar 25 10:56:23 2013 +0100

    Run autoreconf before configure in the specfile

diff --git a/contrib/ding-libs.spec.in b/contrib/ding-libs.spec.in
index 03a4ee7..070bb0d 100644
--- a/contrib/ding-libs.spec.in
+++ b/contrib/ding-libs.spec.in
@@ -320,6 +320,7 @@ structure
 %setup -q
 
 %build
+autoreconf -ivf
 %configure \
     --disable-static
 

commit 6d109eb648640f4dc10599c3f262f0ca4b028315
Author: Jakub Hrozek <jhrozek at redhat.com>
Date:   Mon Mar 25 11:03:19 2013 +0100

    Include AM_PROG_AR in configure.ac to get rid of warnings

diff --git a/configure.ac b/configure.ac
index 902ed86..021cb34 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6,7 +6,9 @@ AC_CONFIG_SRCDIR([README])
 AC_CONFIG_AUX_DIR([build])
 AC_GNU_SOURCE
 AM_INIT_AUTOMAKE([-Wall -Werror foreign])
-AC_PROG_CC
+AM_PROG_CC_C_O
+m4_pattern_allow([AM_PROG_AR])
+AM_PROG_AR
 AC_PROG_LIBTOOL
 AC_CONFIG_MACRO_DIR([m4])
 AC_PROG_INSTALL

commit 3aaeadef1f5a867e8fe5258921ad0e97cc6ab3c0
Author: Günther Deschner <gdeschner at redhat.com>
Date:   Wed Oct 24 12:48:27 2012 +0000

    ini_comment.h needs to be installed as well for the new ini interface.
    
    Guenther

diff --git a/Makefile.am b/Makefile.am
index 4a50c84..3045ac5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -213,7 +213,7 @@ endif
 
 lib_LTLIBRARIES += libini_config.la
 dist_pkgconfig_DATA += ini/ini_config.pc
-dist_include_HEADERS += ini/ini_config.h ini/ini_configobj.h ini/ini_valueobj.h
+dist_include_HEADERS += ini/ini_config.h ini/ini_configobj.h ini/ini_valueobj.h ini/ini_comment.h
 
 libini_config_la_SOURCES = \
     ini/ini_config.c \
diff --git a/contrib/ding-libs.spec.in b/contrib/ding-libs.spec.in
index 85d3663..03a4ee7 100644
--- a/contrib/ding-libs.spec.in
+++ b/contrib/ding-libs.spec.in
@@ -306,6 +306,7 @@ structure
 %{_includedir}/ini_config.h
 %{_includedir}/ini_configobj.h
 %{_includedir}/ini_valueobj.h
+%{_includedir}/ini_comment.h
 %{_libdir}/libini_config.so
 %{_libdir}/pkgconfig/ini_config.pc
 %doc ini/doc/html/

commit 44174288111e9715ccbb96e8a8283e99a721ba7b
Author: Dmitri Pal <dpal at redhat.com>
Date:   Sat Jan 26 20:07:48 2013 -0500

    Expose collected stat data
    
    Added a new top level interface funtion
    and a unit test for it.

diff --git a/ini/ini_configobj.h b/ini/ini_configobj.h
index 16f6499..ac85ba7 100644
--- a/ini/ini_configobj.h
+++ b/ini/ini_configobj.h
@@ -587,6 +587,20 @@ void ini_config_print_errors(FILE *file, char **error_list);
  */
 const char *ini_config_get_filename(struct ini_cfgfile *file_ctx);
 
+/**
+ * @brief Get pointer to collected stat data
+ *
+ * Returns the pointer to the internal stat structure.
+ * If stat data was not collected when the file was open
+ * function would return NULL.
+ *
+ * @param[in]  file_ctx         Configuration file object.
+ *
+ * @return Pointer to the stat structure.
+ */
+const struct stat *ini_config_get_stat(struct ini_cfgfile *file_ctx);
+
+
 
 /**
  * @brief Print file context
diff --git a/ini/ini_fileobj.c b/ini/ini_fileobj.c
index 7d2011a..7ac9dc6 100644
--- a/ini/ini_fileobj.c
+++ b/ini/ini_fileobj.c
@@ -215,6 +215,20 @@ const char *ini_config_get_filename(struct ini_cfgfile *file_ctx)
     return ret;
 }
 
+/* Get pointer to stat structure */
+const struct stat *ini_config_get_stat(struct ini_cfgfile *file_ctx)
+{
+    const struct stat *ret;
+    TRACE_FLOW_ENTRY();
+
+    if (file_ctx->stats_read) ret = &(file_ctx->file_stats);
+    else ret = NULL;
+
+    TRACE_FLOW_EXIT();
+    return ret;
+}
+
+
 /* Check access */
 int ini_config_access_check(struct ini_cfgfile *file_ctx,
                             uint32_t flags,
diff --git a/ini/ini_parse_ut.c b/ini/ini_parse_ut.c
index c5e9166..32c59e7 100644
--- a/ini/ini_parse_ut.c
+++ b/ini/ini_parse_ut.c
@@ -1057,6 +1057,7 @@ int startup_test(void)
     char command[PATH_MAX * 3];
     char *srcdir = NULL;
     char *builddir;
+    const struct stat *file_stat;
 
     INIOUT(printf("<==== Startup test ====>\n"));
 
@@ -1095,6 +1096,12 @@ int startup_test(void)
         return error;
     }
 
+    file_stat = ini_config_get_stat(file_ctx);
+    if (file_stat) {
+        printf("Expected NULL got not NULL!\n");
+        return EINVAL;
+    }
+
     /* We will check just permissions here. */
     error = ini_config_access_check(file_ctx,
                                 INI_ACCESS_CHECK_MODE, /* add uid & gui flags
@@ -1125,6 +1132,16 @@ int startup_test(void)
         return error;
     }
 
+    /* Get stats */
+    file_stat = ini_config_get_stat(file_ctx);
+    if (!file_stat) {
+        printf("Expected not NULL got NULL!\n");
+        return EINVAL;
+    }
+
+    INIOUT(printf("File was modified at: %d seconds since Jan 1 1970.\n",
+                  (int)(file_stat->st_mtime)));
+
     /* We will check just permissions here. */
     error = ini_config_access_check(file_ctx,
                                 INI_ACCESS_CHECK_MODE, /* add uid & gui flags

commit 059519fb2a8d056eba5f61cde98ed8b5292195d4
Author: Dmitri Pal <dpal at redhat.com>
Date:   Sat Jan 26 16:47:56 2013 -0500

    Check is the stats we collected
    
    This patch corrects a problem related to stats being accessed
    and evaluated without being initialized.

diff --git a/ini/ini_config_priv.h b/ini/ini_config_priv.h
index 31cee84..89ad8a9 100644
--- a/ini/ini_config_priv.h
+++ b/ini/ini_config_priv.h
@@ -69,6 +69,8 @@ struct ini_cfgfile {
     /**********************/
     /* File stats */
     struct stat file_stats;
+    /* Were stats read ? */
+    int stats_read;
 };
 
 /* Parsing error */
diff --git a/ini/ini_fileobj.c b/ini/ini_fileobj.c
index 677383c..7d2011a 100644
--- a/ini/ini_fileobj.c
+++ b/ini/ini_fileobj.c
@@ -76,6 +76,8 @@ static int common_file_init(struct ini_cfgfile *file_ctx)
         return error;
     }
 
+    file_ctx->stats_read = 0;
+
     /* Collect stats */
     if (file_ctx->metadata_flags & INI_META_STATS) {
         errno = 0;
@@ -85,6 +87,7 @@ static int common_file_init(struct ini_cfgfile *file_ctx)
             TRACE_ERROR_NUMBER("Failed to get file stats.", error);
             return error;
         }
+        file_ctx->stats_read = 1;
     }
     else memset(&(file_ctx->file_stats), 0, sizeof(struct stat));
 
@@ -231,7 +234,11 @@ int ini_config_access_check(struct ini_cfgfile *file_ctx,
     if ((file_ctx == NULL) || (flags == 0)) {
         TRACE_ERROR_NUMBER("Invalid parameter.", EINVAL);
         return EINVAL;
+    }
 
+    if (file_ctx->stats_read == 0) {
+        TRACE_ERROR_NUMBER("Stats were not collected.", EINVAL);
+        return EINVAL;
     }
 
     /* Check mode */
@@ -304,6 +311,12 @@ int ini_config_changed(struct ini_cfgfile *file_ctx1,
         return EINVAL;
     }
 
+    if ((file_ctx1->stats_read == 0) ||
+        (file_ctx2->stats_read == 0)) {
+        TRACE_ERROR_NUMBER("Stats were not collected.", EINVAL);
+        return EINVAL;
+    }
+
     *changed = 0;
 
     /* Unfortunately the time is not granular enough
diff --git a/ini/ini_parse_ut.c b/ini/ini_parse_ut.c
index 002fdd5..c5e9166 100644
--- a/ini/ini_parse_ut.c
+++ b/ini/ini_parse_ut.c
@@ -1085,6 +1085,36 @@ int startup_test(void)
         return error;
     }
 
+    /* Open config file not collecting stats */
+    error = ini_config_file_open(outfile,
+                                 0,
+                                 &file_ctx);
+    if (error) {
+        printf("Failed to open file %s for reading. Error %d.\n",
+               outfile, error);
+        return error;
+    }
+
+    /* We will check just permissions here. */
+    error = ini_config_access_check(file_ctx,
+                                INI_ACCESS_CHECK_MODE, /* add uid & gui flags
+                                                        * in real case
+                                                        */
+                                0, /* <- will be real uid in real case */
+                                0, /* <- will be real gid in real case */
+                                0440, /* Checking for r--r----- */
+                                0);
+    /* This check is expected to fail since
+     * we did not collect stats
+     */
+    ini_config_file_destroy(file_ctx);
+
+    if (!error) {
+        printf("Expected error got success!\n");
+        return EACCES;
+    }
+
+
     /* Open config file */
     error = ini_config_file_open(outfile,
                                  INI_META_STATS,

commit 66e30c2f3862093505a8497744207d2812c95be3
Author: Dmitri Pal <dpal at redhat.com>
Date:   Tue Dec 25 09:31:07 2012 -0500

    Unit test for parsing flags.
    
    Added unit test.

diff --git a/Makefile.am b/Makefile.am
index 2b30cdc..4a50c84 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -258,6 +258,7 @@ dist_noinst_DATA += \
     ini/ini.d/sexpect.conf \
     ini/ini.d/first.conf \
     ini/ini.d/second.conf \
+    ini/ini.d/space.conf \
     ini/ini.d/mergecheck.conf
 
 check_PROGRAMS += \
diff --git a/ini/ini.d/space.conf b/ini/ini.d/space.conf
new file mode 100644
index 0000000..1ac58c3
--- /dev/null
+++ b/ini/ini.d/space.conf
@@ -0,0 +1,5 @@
+    spaces = value
+	tab = value
+	 	 	 tab_and_space = value
+ 	 	 	 space_and_tab = value
+
diff --git a/ini/ini_parse_ut.c b/ini/ini_parse_ut.c
index e31b356..002fdd5 100644
--- a/ini/ini_parse_ut.c
+++ b/ini/ini_parse_ut.c
@@ -2520,6 +2520,88 @@ int get_test(void)
     return EOK;
 }
 
+int space_test(void)
+{
+
+    int error;
+    struct ini_cfgfile *file_ctx = NULL;
+    struct ini_cfgobj *ini_config = NULL;
+    char **error_list = NULL;
+    char infile[PATH_MAX];
+    char *srcdir = NULL;
+    unsigned errnum;
+    int i;
+    uint32_t flags[] = { INI_PARSE_NOWRAP,
+                         INI_PARSE_NOWRAP |
+                         INI_PARSE_NOSPACE,
+                         INI_PARSE_NOWRAP |
+                         INI_PARSE_NOTAB,
+                         INI_PARSE_NOWRAP |
+                         INI_PARSE_NOSPACE |
+                         INI_PARSE_NOTAB };
+
+    INIOUT(printf("\n\n<==== SPACE TEST START =====>\n"));
+
+    srcdir = getenv("srcdir");
+    snprintf(infile, PATH_MAX, "%s/ini/ini.d/space.conf",
+             (srcdir == NULL) ? "." : srcdir);
+
+
+    for (i = 0; i < 4; i++ ) {
+
+        INIOUT(printf("Reading file %s\n", infile));
+        error = ini_config_file_open(infile,
+                                        0,
+                                        &file_ctx);
+        if (error) {
+            printf("Failed to open file for reading. Error %d.\n",  error);
+            return error;
+        }
+
+        INIOUT(printf("Creating configuration object\n"));
+        error = ini_config_create(&ini_config);
+        if (error) {
+            printf("Failed to create object. Error %d.\n", error);
+            ini_config_file_destroy(file_ctx);
+            return error;
+        }
+        INIOUT(printf("Parsing\n"));
+        error = ini_config_parse(file_ctx,
+                                 INI_STOP_ON_NONE,
+                                 0,
+                                 flags[i],
+                                 ini_config);
+        if (error) {
+            INIOUT(printf("Failed to parse configuration. Error %d.\n", error));
+
+            errnum = ini_config_error_count(ini_config);
+            if (errnum) {
+                INIOUT(printf("Errors detected while parsing: %s\n",
+                       ini_config_get_filename(file_ctx)));
+                ini_config_get_errors(ini_config, &error_list);
+                INIOUT(ini_config_print_errors(stdout, error_list));
+                ini_config_free_errors(error_list);
+            }
+            if (((i == 0) && (errnum != 0)) ||
+                ((i == 1) && (errnum != 3)) ||
+                ((i == 2) && (errnum != 3)) ||
+                ((i == 3) && (errnum != 4))) {
+                printf("Failed to open file for reading. Error %d.\n",  error);
+                ini_config_file_destroy(file_ctx);
+                ini_config_destroy(ini_config);
+                return -1;
+            }
+            /* We do not return here intentionally */
+        }
+
+        INIOUT(col_debug_collection(ini_config->cfg, COL_TRAVERSE_DEFAULT));
+        ini_config_destroy(ini_config);
+        ini_config_file_destroy(file_ctx);
+    }
+
+    INIOUT(printf("\n<==== SPACE TEST END =====>\n\n"));
+    return EOK;
+}
 
 /* Main function of the unit test */
 int main(int argc, char *argv[])
@@ -2533,6 +2615,7 @@ int main(int argc, char *argv[])
                         startup_test,
                         reload_test,
                         get_test,
+                        space_test,
                         NULL };
     test_fn t;
     int i = 0;

commit 6823d7104cca0f8ac22ed9432ee8a2f1a0d9124a
Author: Dmitri Pal <dpal at redhat.com>
Date:   Mon Dec 24 17:45:00 2012 -0500

    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.

diff --git a/ini/ini_config_priv.h b/ini/ini_config_priv.h
index ee6a4d7..31cee84 100644
--- a/ini/ini_config_priv.h
+++ b/ini/ini_config_priv.h
@@ -42,6 +42,10 @@ struct ini_cfgobj {
     int section_len;
     int name_len;
     struct collection_iterator *iterator;
+    /* Collection of errors detected during parsing */
+    struct collection_item *error_list;
+    /* Count of error lines */
+    unsigned count;
 
     /*...         */
     /* Statistics? Timestamps? When created? Modified? - TBD */
@@ -63,12 +67,8 @@ struct ini_cfgfile {
     /**********************/
     /* Internal variables */
     /**********************/
-    /* Collection of errors detected during parsing */
-    struct collection_item *error_list;
     /* File stats */
     struct stat file_stats;
-    /* Count of error lines */
-    unsigned count;
 };
 
 /* Parsing error */
diff --git a/ini/ini_configobj.c b/ini/ini_configobj.c
index 4a3e96d..603aaf4 100644
--- a/ini/ini_configobj.c
+++ b/ini/ini_configobj.c
@@ -24,8 +24,14 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdint.h>
+#include <stdlib.h>
+/* For error text */
+#include <libintl.h>
+#define _(String) gettext (String)
 #include "trace.h"
 #include "collection.h"
+#include "collection_tools.h"
+#include "ini_configobj.h"
 #include "ini_config_priv.h"
 #include "ini_defines.h"
 #include "ini_valueobj.h"
@@ -99,6 +105,11 @@ void ini_config_destroy(struct ini_cfgobj *ini_config)
         if (ini_config->last_comment) {
             ini_comment_destroy(ini_config->last_comment);
         }
+
+        if (ini_config->error_list) {
+            col_destroy_collection(ini_config->error_list);
+        }
+
         free(ini_config);
     }
 
@@ -132,6 +143,8 @@ int ini_config_create(struct ini_cfgobj **ini_config)
     new_co->section_len = 0;
     new_co->name_len = 0;
     new_co->iterator = NULL;
+    new_co->error_list = NULL;
+    new_co->count = 0;
 
     /* Create a collection to hold configuration data */
     error = col_create_collection(&(new_co->cfg),
@@ -143,6 +156,16 @@ int ini_config_create(struct ini_cfgobj **ini_config)
         return error;
     }
 
+    /* Create error list collection */
+    error = col_create_collection(&(new_co->error_list),
+                                  INI_ERROR,
+                                  COL_CLASS_INI_PERROR);
+    if (error) {
+        TRACE_ERROR_NUMBER("Failed to create error list", error);
+        ini_config_destroy(new_co);
+        return error;
+    }
+
     *ini_config = new_co;
 
     TRACE_FLOW_EXIT();
@@ -274,6 +297,8 @@ int ini_config_copy(struct ini_cfgobj *ini_config,
     new_co->section_len = 0;
     new_co->name_len = 0;
     new_co->iterator = NULL;
+    new_co->error_list = NULL;
+    new_co->count = 0;
 
     error = col_copy_collection_with_cb(&(new_co->cfg),
                                         ini_config->cfg,
@@ -898,3 +923,119 @@ int ini_config_merge(struct ini_cfgobj *first,
     return error;
 
 }
+
+/* How many errors do we have in the list ? */
+unsigned ini_config_error_count(struct ini_cfgobj *cfg_ctx)
+{
+    unsigned count = 0;
+
+    TRACE_FLOW_ENTRY();
+
+    count = cfg_ctx->count;
+
+    TRACE_FLOW_EXIT();
+    return count;
+
+}
+
+/* Free error strings */
+void ini_config_free_errors(char **errors)
+{
+    TRACE_FLOW_ENTRY();
+
+    col_free_property_list(errors);
+
+    TRACE_FLOW_EXIT();
+}
+
+/* Get the list of error strings */
+int ini_config_get_errors(struct ini_cfgobj *cfg_ctx,
+                          char ***errors)
+{
+    char **errlist = NULL;
+    struct collection_iterator *iterator = NULL;
+    int error;
+    struct collection_item *item = NULL;
+    struct ini_parse_error *pe;
+    unsigned int count = 0;
+    char *line;
+
+    TRACE_FLOW_ENTRY();
+
+    /* If we have something to print print it */
+    if ((!errors) || (!cfg_ctx)) {
+        TRACE_ERROR_NUMBER("Invalid parameter.", EINVAL);
+        return EINVAL;
+    }
+
+    errlist = calloc(cfg_ctx->count + 1, sizeof(char *));
+    if (!errlist) {
+        TRACE_ERROR_NUMBER("Failed to allocate memory for errors.", ENOMEM);
+        return ENOMEM;
+    }
+
+    /* Bind iterator */
+    error =  col_bind_iterator(&iterator,
+                               cfg_ctx->error_list,
+                               COL_TRAVERSE_DEFAULT);
+    if (error) {
+        TRACE_ERROR_NUMBER("Faile to bind iterator:", error);
+        ini_config_free_errors(errlist);
+        return error;
+    }
+
+    while(1) {
+        /* Loop through a collection */
+        error = col_iterate_collection(iterator, &item);
+        if (error) {
+            TRACE_ERROR_NUMBER("Error iterating collection", error);
+            col_unbind_iterator(iterator);
+            ini_config_free_errors(errlist);
+            return error;
+        }
+
+        /* Are we done ? */
+        if (item == NULL) break;
+
+        /* Process collection header */
+        if (col_get_item_type(item) == COL_TYPE_COLLECTION) {
+            continue;
+        }
+        else {
+            /* Put error into provided format */
+            pe = (struct ini_parse_error *)(col_get_item_data(item));
+
+            /* Would be nice to have asprintf function...
+             * ...but for now we know that all the errors
+             * are pretty short and will fir into the predefined
+             * error length buffer.
+             */
+            line = malloc(MAX_ERROR_LINE + 1);
+            if (!line) {
+                TRACE_ERROR_NUMBER("Failed to get memory for error.", ENOMEM);
+                col_unbind_iterator(iterator);
+                ini_config_free_errors(errlist);
+                return ENOMEM;
+            }
+
+            snprintf(line, MAX_ERROR_LINE, LINE_FORMAT,
+                     col_get_item_property(item, NULL),
+                     pe->error,
+                     pe->line,
+                     ini_get_error_str(pe->error,
+                                       INI_FAMILY_PARSING));
+
+            errlist[count] = line;
+            count++;
+        }
+
+    }
+
+    /* Do not forget to unbind iterator - otherwise there will be a leak */
+    col_unbind_iterator(iterator);
+
+    *errors = errlist;
+
+    TRACE_FLOW_EXIT();
+    return error;
+}
diff --git a/ini/ini_configobj.h b/ini/ini_configobj.h
index 5e8d95b..16f6499 100644
--- a/ini/ini_configobj.h
+++ b/ini/ini_configobj.h
@@ -526,11 +526,11 @@ void ini_config_file_destroy(struct ini_cfgfile *file_ctx);
  * how many parsing errors were found during last
  * parsing operation.
  *
- * @param[in]  file_ctx         Configuration file object.
+ * @param[in]  ini_config       Configuration object.
  *
  * @return Number of errors.
  */
-unsigned ini_config_error_count(struct ini_cfgfile *file_ctx);
+unsigned ini_config_error_count(struct ini_cfgobj *ini_config);
 
 /**
  * @brief Get array of parsing errors
@@ -541,14 +541,14 @@ unsigned ini_config_error_count(struct ini_cfgfile *file_ctx);
  * Array can be referenced as a normal array of strings.
  * The NULL entry indicates the end of the array.
  *
- * @param[in]  file_ctx         Configuration file object.
+ * @param[in]  ini_config       Configuration object.
  * @param[out] errors           Array of error strings.
  *
  * @return 0 - Success.
  * @return EINVAL - Invalid parameter.
  * @return ENOMEM - No memory.
  */
-int ini_config_get_errors(struct ini_cfgfile *file_ctx,
+int ini_config_get_errors(struct ini_cfgobj *ini_config,
                           char ***errors);
 
 /**
@@ -693,6 +693,7 @@ int ini_config_parse(struct ini_cfgfile *file_ctx,
  * @brief Create a copy of the configuration object
  *
  * Function creates a deep copy of all the configuration data.
+ * Error list created during parsing is not copied over.
  *
  * @param[in]  ini_config       Original configuration object.
  * @param[out] ini_new          A new configuration object.
diff --git a/ini/ini_fileobj.c b/ini/ini_fileobj.c
index 6773465..677383c 100644
--- a/ini/ini_fileobj.c
+++ b/ini/ini_fileobj.c
@@ -27,9 +27,7 @@
 #include "ini_defines.h"
 #include "ini_configobj.h"
 #include "ini_config_priv.h"
-#include "collection.h"
 #include "path_utils.h"
-#include "collection_tools.h"
 
 
 /* Close file but not destroy the object */
@@ -54,7 +52,6 @@ void ini_config_file_destroy(struct ini_cfgfile *file_ctx)
 
     if(file_ctx) {
         free(file_ctx->filename);
-        col_destroy_collection(file_ctx->error_list);
         if(file_ctx->file) fclose(file_ctx->file);
         free(file_ctx);
     }
@@ -79,15 +76,6 @@ static int common_file_init(struct ini_cfgfile *file_ctx)
         return error;
     }
 
-    /* Create internal collections */
-    error = col_create_collection(&(file_ctx->error_list),
-                                  INI_ERROR,
-                                  COL_CLASS_INI_PERROR);
-    if (error) {
-        TRACE_ERROR_NUMBER("Failed to create error list", error);
-        return error;
-    }
-
     /* Collect stats */
     if (file_ctx->metadata_flags & INI_META_STATS) {
         errno = 0;
@@ -128,11 +116,9 @@ int ini_config_file_open(const char *filename,
 
     new_ctx->filename = NULL;
     new_ctx->file = NULL;
-    new_ctx->error_list = NULL;
 
     /* Store flags */
     new_ctx->metadata_flags = metadata_flags;
-    new_ctx->count = 0;
 
     /* Construct the full file path */
     new_ctx->filename = malloc(PATH_MAX + 1);
@@ -187,11 +173,9 @@ int ini_config_file_reopen(struct ini_cfgfile *file_ctx_in,
     }
 
     new_ctx->file = NULL;
-    new_ctx->error_list = NULL;
 
     /* Store flags */
     new_ctx->metadata_flags = file_ctx_in->metadata_flags;
-    new_ctx->count = 0;
 
     /* Copy full file path */
     errno = 0;
@@ -216,122 +200,6 @@ int ini_config_file_reopen(struct ini_cfgfile *file_ctx_in,
     return error;
 }
 
-/* How many errors do we have in the list ? */
-unsigned ini_config_error_count(struct ini_cfgfile *file_ctx)
-{
-    unsigned count = 0;
-
-    TRACE_FLOW_ENTRY();
-
-    count = file_ctx->count;
-
-    TRACE_FLOW_EXIT();
-    return count;
-
-}
-
-/* Free error strings */
-void ini_config_free_errors(char **errors)
-{
-    TRACE_FLOW_ENTRY();
-
-    col_free_property_list(errors);
-
-    TRACE_FLOW_EXIT();
-}
-
-/* Get the list of error strings */
-int ini_config_get_errors(struct ini_cfgfile *file_ctx,
-                          char ***errors)
-{
-    char **errlist = NULL;
-    struct collection_iterator *iterator = NULL;
-    int error;
-    struct collection_item *item = NULL;
-    struct ini_parse_error *pe;
-    unsigned int count = 0;
-    char *line;
-
-    TRACE_FLOW_ENTRY();
-
-    /* If we have something to print print it */
-    if ((!errors) || (!file_ctx)) {
-        TRACE_ERROR_NUMBER("Invalid parameter.", EINVAL);
-        return EINVAL;
-    }
-
-    errlist = calloc(file_ctx->count + 1, sizeof(char *));
-    if (!errlist) {
-        TRACE_ERROR_NUMBER("Failed to allocate memory for errors.", ENOMEM);
-        return ENOMEM;
-    }
-
-    /* Bind iterator */
-    error =  col_bind_iterator(&iterator,
-                               file_ctx->error_list,
-                               COL_TRAVERSE_DEFAULT);
-    if (error) {
-        TRACE_ERROR_NUMBER("Faile to bind iterator:", error);
-        ini_config_free_errors(errlist);
-        return error;
-    }
-
-    while(1) {
-        /* Loop through a collection */
-        error = col_iterate_collection(iterator, &item);
-        if (error) {
-            TRACE_ERROR_NUMBER("Error iterating collection", error);
-            col_unbind_iterator(iterator);
-            ini_config_free_errors(errlist);
-            return error;
-        }
-
-        /* Are we done ? */
-        if (item == NULL) break;
-
-        /* Process collection header */
-        if (col_get_item_type(item) == COL_TYPE_COLLECTION) {
-            continue;
-        }
-        else {
-            /* Put error into provided format */
-            pe = (struct ini_parse_error *)(col_get_item_data(item));
-
-            /* Would be nice to have asprintf function...
-             * ...but for now we know that all the errors
-             * are pretty short and will fir into the predefined
-             * error length buffer.
-             */
-            line = malloc(MAX_ERROR_LINE + 1);
-            if (!line) {
-                TRACE_ERROR_NUMBER("Failed to get memory for error.", ENOMEM);
-                col_unbind_iterator(iterator);
-                ini_config_free_errors(errlist);
-                return ENOMEM;
-            }
-
-            snprintf(line, MAX_ERROR_LINE, LINE_FORMAT,
-                     col_get_item_property(item, NULL),
-                     pe->error,
-                     pe->line,
-                     ini_get_error_str(pe->error,
-                                       INI_FAMILY_PARSING));
-
-            errlist[count] = line;
-            count++;
-        }
-
-    }
-
-    /* Do not forget to unbind iterator - otherwise there will be a leak */
-    col_unbind_iterator(iterator);
-
-    *errors = errlist;
-
-    TRACE_FLOW_EXIT();
-    return error;
-}
-
 /* Get the fully resolved file name */
 const char *ini_config_get_filename(struct ini_cfgfile *file_ctx)
 {
@@ -344,7 +212,6 @@ const char *ini_config_get_filename(struct ini_cfgfile *file_ctx)
     return ret;
 }
 
-
 /* Check access */



More information about the Pkg-sssd-devel mailing list