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

Timo Aaltonen tjaalton at moszumanska.debian.org
Sat Aug 15 22:30:19 UTC 2015


 Makefile.am                      |   63 +
 collection/collection.c          |  266 +++++-
 collection/collection.h          |  180 ++++
 collection/collection_ut.c       |  338 +++++++
 collection/libcollection.sym     |    8 
 contrib/ding-libs.spec.in        |   13 
 debian/changelog                 |    9 
 debian/control                   |    2 
 debian/libcollection4.symbols    |    4 
 debian/libini-config-dev.install |    1 
 debian/libini-config5.symbols    |   32 
 ini/ini.d/merge.validator        |   60 +
 ini/ini.d/real.conf              |    2 
 ini/ini2.d/real16be.conf         |binary
 ini/ini2.d/real16le.conf         |binary
 ini/ini2.d/real32be.conf         |binary
 ini/ini2.d/real32le.conf         |binary
 ini/ini2.d/real8.conf            |   54 +
 ini/ini_augment.c                |  972 ++++++++++++++++++++++
 ini/ini_augment_ut.c             |  390 ++++++++
 ini/ini_comment.c                |   59 +
 ini/ini_comment.h                |   13 
 ini/ini_comment_ut.c             |   38 
 ini/ini_config.cfg.doxy.in       |    2 
 ini/ini_config_priv.h            |    9 
 ini/ini_config_ut.c              |    5 
 ini/ini_configmod.c              | 1607 ++++++++++++++++++++++++++++++++++++
 ini/ini_configmod.h              |  767 +++++++++++++++++
 ini/ini_configmod_ut.c           | 1153 ++++++++++++++++++++++++++
 ini/ini_configmod_ut_check.c     | 1695 +++++++++++++++++++++++++++++++++++++++
 ini/ini_configobj.h              |  306 ++++++-
 ini/ini_defines.h                |    9 
 ini/ini_fileobj.c                |  879 +++++++++++++++++++-
 ini/ini_get_valueobj.c           |    2 
 ini/ini_parse.c                  |   13 
 ini/ini_print.c                  |    2 
 ini/ini_save_ut.c                |  259 +++++
 ini/ini_valueobj.c               |    7 
 ini/libini_config.sym            |   42 
 refarray/ref_array.c             |    5 
 version.m4                       |    8 
 41 files changed, 9137 insertions(+), 137 deletions(-)

New commits:
commit 3688579dfc52e3aa21e2156ebc9da4d516916d61
Author: Timo Aaltonen <tjaalton at debian.org>
Date:   Sun Aug 16 01:30:07 2015 +0300

    releasing package ding-libs version 0.5.0-1

diff --git a/debian/changelog b/debian/changelog
index 504f0d3..bb6894a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,11 +1,11 @@
-ding-libs (0.5.0-1) UNRELEASED; urgency=medium
+ding-libs (0.5.0-1) unstable; urgency=medium
 
   * New upstream release.
   * libini-config-dev.install: Add ini_configmod.h.
   * libcollection4.symbols, libini-config5.symbols: Updated.
   * control: Bump policy to 3.9.6, no changes.
 
- -- Timo Aaltonen <tjaalton at debian.org>  Sun, 16 Aug 2015 01:17:12 +0300
+ -- Timo Aaltonen <tjaalton at debian.org>  Sun, 16 Aug 2015 01:26:53 +0300
 
 ding-libs (0.4.0-1) unstable; urgency=medium
 

commit 346385bc10cea031ddc9b985a0c0728c36775bdf
Author: Timo Aaltonen <tjaalton at debian.org>
Date:   Sun Aug 16 01:26:47 2015 +0300

    control: Bump policy to 3.9.6, no changes.

diff --git a/debian/changelog b/debian/changelog
index b570741..504f0d3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,7 @@ ding-libs (0.5.0-1) UNRELEASED; urgency=medium
   * New upstream release.
   * libini-config-dev.install: Add ini_configmod.h.
   * libcollection4.symbols, libini-config5.symbols: Updated.
+  * control: Bump policy to 3.9.6, no changes.
 
  -- Timo Aaltonen <tjaalton at debian.org>  Sun, 16 Aug 2015 01:17:12 +0300
 
diff --git a/debian/control b/debian/control
index 02d07fa..2f6063d 100644
--- a/debian/control
+++ b/debian/control
@@ -8,7 +8,7 @@ Build-Depends: debhelper (>= 9),
  quilt,
  check,
  pkg-config,
-Standards-Version: 3.9.5
+Standards-Version: 3.9.6
 Homepage: https://fedorahosted.org/sssd/
 Vcs-Git: git://git.debian.org/pkg-sssd/ding-libs.git
 Vcs-Browser: http://git.debian.org/?p=pkg-sssd/ding-libs.git;a=summary

commit 9fb15824b47ca6ba1c16e822a5db44d6381a0ad2
Author: Timo Aaltonen <tjaalton at debian.org>
Date:   Sun Aug 16 01:26:09 2015 +0300

    libcollection4.symbols, libini-config5.symbols: Updated.

diff --git a/debian/changelog b/debian/changelog
index 19da5c5..b570741 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,7 @@ ding-libs (0.5.0-1) UNRELEASED; urgency=medium
 
   * New upstream release.
   * libini-config-dev.install: Add ini_configmod.h.
+  * libcollection4.symbols, libini-config5.symbols: Updated.
 
  -- Timo Aaltonen <tjaalton at debian.org>  Sun, 16 Aug 2015 01:17:12 +0300
 
diff --git a/debian/libcollection4.symbols b/debian/libcollection4.symbols
index 0faff56..85a411d 100644
--- a/debian/libcollection4.symbols
+++ b/debian/libcollection4.symbols
@@ -1,5 +1,6 @@
 libcollection.so.4 libcollection4 #MINVER#
  COLLECTION_0.6.2 at COLLECTION_0.6.2 0.4.0
+ COLLECTION_0.7 at COLLECTION_0.7 0.5.0
  col_add_any_property at COLLECTION_0.6.2 0.4.0
  col_add_any_property_with_ref at COLLECTION_0.6.2 0.4.0
  col_add_binary_property at COLLECTION_0.6.2 0.4.0
@@ -31,6 +32,7 @@ libcollection.so.4 libcollection4 #MINVER#
  col_debug_handle at COLLECTION_0.6.2 0.4.0
  col_debug_item at COLLECTION_0.6.2 0.4.0
  col_delete_item at COLLECTION_0.6.2 0.4.0
+ col_delete_item_with_cb at COLLECTION_0.7 0.5.0
  col_delete_property at COLLECTION_0.6.2 0.4.0
  col_dequeue_item at COLLECTION_0.6.2 0.4.0
  col_destroy_collection at COLLECTION_0.6.2 0.4.0
@@ -54,6 +56,7 @@ libcollection.so.4 libcollection4 #MINVER#
  col_get_collection_count at COLLECTION_0.6.2 0.4.0
  col_get_collection_reference at COLLECTION_0.6.2 0.4.0
  col_get_data_len at COLLECTION_0.6.2 0.4.0
+ col_get_dup_item at COLLECTION_0.7 0.5.0
  col_get_item at COLLECTION_0.6.2 0.4.0
  col_get_item_and_do at COLLECTION_0.6.2 0.4.0
  col_get_item_data at COLLECTION_0.6.2 0.4.0
@@ -117,6 +120,7 @@ libcollection.so.4 libcollection4 #MINVER#
  col_put_marker at COLLECTION_0.6.2 0.4.0
  col_remove_item at COLLECTION_0.6.2 0.4.0
  col_remove_item_from_current at COLLECTION_0.6.2 0.4.0
+ col_remove_item_with_cb at COLLECTION_0.7 0.5.0
  col_rewind_iterator at COLLECTION_0.6.2 0.4.0
  col_serialize at COLLECTION_0.6.2 0.4.0
  col_set_collection_class at COLLECTION_0.6.2 0.4.0
diff --git a/debian/libini-config5.symbols b/debian/libini-config5.symbols
index 4a6de98..40144e5 100644
--- a/debian/libini-config5.symbols
+++ b/debian/libini-config5.symbols
@@ -1,5 +1,6 @@
 libini_config.so.5 libini-config5 #MINVER#
  INI_CONFIG_1.1.0 at INI_CONFIG_1.1.0 0.4.0
+ INI_CONFIG_1.2.0 at INI_CONFIG_1.2.0 0.5.0
  config_access_check at INI_CONFIG_1.1.0 0.4.0
  config_changed at INI_CONFIG_1.1.0 0.4.0
  config_for_app at INI_CONFIG_1.1.0 0.4.0
@@ -42,6 +43,7 @@ libini_config.so.5 libini-config5 #MINVER#
  ini_comment_build at INI_CONFIG_1.1.0 0.4.0
  ini_comment_build_wl at INI_CONFIG_1.1.0 0.4.0
  ini_comment_clear at INI_CONFIG_1.1.0 0.4.0
+ ini_comment_construct at INI_CONFIG_1.2.0 0.5.0
  ini_comment_copy at INI_CONFIG_1.1.0 0.4.0
  ini_comment_create at INI_CONFIG_1.1.0 0.4.0
  ini_comment_destroy at INI_CONFIG_1.1.0 0.4.0
@@ -55,12 +57,36 @@ libini_config.so.5 libini-config5 #MINVER#
  ini_comment_serialize at INI_CONFIG_1.1.0 0.4.0
  ini_comment_swap at INI_CONFIG_1.1.0 0.4.0
  ini_config_access_check at INI_CONFIG_1.1.0 0.4.0
+ ini_config_add_bin_value at INI_CONFIG_1.2.0 0.5.0
+ ini_config_add_const_str_arr_value at INI_CONFIG_1.2.0 0.5.0
+ ini_config_add_double_arr_value at INI_CONFIG_1.2.0 0.5.0
+ ini_config_add_double_value at INI_CONFIG_1.2.0 0.5.0
+ ini_config_add_int32_value at INI_CONFIG_1.2.0 0.5.0
+ ini_config_add_int64_value at INI_CONFIG_1.2.0 0.5.0
+ ini_config_add_int_arr_value at INI_CONFIG_1.2.0 0.5.0
+ ini_config_add_int_value at INI_CONFIG_1.2.0 0.5.0
+ ini_config_add_long_arr_value at INI_CONFIG_1.2.0 0.5.0
+ ini_config_add_long_value at INI_CONFIG_1.2.0 0.5.0
+ ini_config_add_section at INI_CONFIG_1.2.0 0.5.0
+ ini_config_add_str_arr_value at INI_CONFIG_1.2.0 0.5.0
+ ini_config_add_str_value at INI_CONFIG_1.2.0 0.5.0
+ ini_config_add_uint32_value at INI_CONFIG_1.2.0 0.5.0
+ ini_config_add_uint64_value at INI_CONFIG_1.2.0 0.5.0
+ ini_config_add_ulong_value at INI_CONFIG_1.2.0 0.5.0
+ ini_config_add_unsigned_value at INI_CONFIG_1.2.0 0.5.0
+ ini_config_augment at INI_CONFIG_1.2.0 0.5.0
+ ini_config_change_access at INI_CONFIG_1.2.0 0.5.0
  ini_config_changed at INI_CONFIG_1.1.0 0.4.0
  ini_config_clean_state at INI_CONFIG_1.1.0 0.4.0
+ ini_config_comment_section at INI_CONFIG_1.2.0 0.5.0
  ini_config_copy at INI_CONFIG_1.1.0 0.4.0
  ini_config_create at INI_CONFIG_1.1.0 0.4.0
+ ini_config_delete_section_by_name at INI_CONFIG_1.2.0 0.5.0
+ ini_config_delete_section_by_position at INI_CONFIG_1.2.0 0.5.0
+ ini_config_delete_value at INI_CONFIG_1.2.0 0.5.0
  ini_config_destroy at INI_CONFIG_1.1.0 0.4.0
  ini_config_error_count at INI_CONFIG_1.1.0 0.4.0
+ ini_config_file_backup at INI_CONFIG_1.2.0 0.5.0
  ini_config_file_close at INI_CONFIG_1.1.0 0.4.0
  ini_config_file_destroy at INI_CONFIG_1.1.0 0.4.0
  ini_config_file_from_mem at INI_CONFIG_1.1.0 0.4.0
@@ -68,14 +94,20 @@ libini_config.so.5 libini-config5 #MINVER#
  ini_config_file_print at INI_CONFIG_1.1.0 0.4.0
  ini_config_file_reopen at INI_CONFIG_1.1.0 0.4.0
  ini_config_free_errors at INI_CONFIG_1.1.0 0.4.0
+ ini_config_get_bom at INI_CONFIG_1.2.0 0.5.0
  ini_config_get_errors at INI_CONFIG_1.1.0 0.4.0
  ini_config_get_filename at INI_CONFIG_1.1.0 0.4.0
  ini_config_get_stat at INI_CONFIG_1.1.0 0.4.0
  ini_config_merge at INI_CONFIG_1.1.0 0.4.0
  ini_config_parse at INI_CONFIG_1.1.0 0.4.0
  ini_config_print_errors at INI_CONFIG_1.1.0 0.4.0
+ ini_config_rename_section at INI_CONFIG_1.2.0 0.5.0
+ ini_config_save at INI_CONFIG_1.2.0 0.5.0
+ ini_config_save_as at INI_CONFIG_1.2.0 0.5.0
  ini_config_serialize at INI_CONFIG_1.1.0 0.4.0
+ ini_config_set_bom at INI_CONFIG_1.2.0 0.5.0
  ini_config_set_wrap at INI_CONFIG_1.1.0 0.4.0
+ ini_config_update_comment at INI_CONFIG_1.2.0 0.5.0
  ini_free_attribute_list at INI_CONFIG_1.1.0 0.4.0
  ini_free_bin_config_value at INI_CONFIG_1.1.0 0.4.0
  ini_free_double_config_array at INI_CONFIG_1.1.0 0.4.0

commit 30180368f921c395fa8af4f37f0d5cdf29963dec
Author: Timo Aaltonen <tjaalton at debian.org>
Date:   Sun Aug 16 01:20:13 2015 +0300

    libini-config-dev.install: Add ini_configmod.h.

diff --git a/debian/changelog b/debian/changelog
index e2b91f3..19da5c5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,7 @@
 ding-libs (0.5.0-1) UNRELEASED; urgency=medium
 
   * New upstream release.
+  * libini-config-dev.install: Add ini_configmod.h.
 
  -- Timo Aaltonen <tjaalton at debian.org>  Sun, 16 Aug 2015 01:17:12 +0300
 
diff --git a/debian/libini-config-dev.install b/debian/libini-config-dev.install
index a87d1fa..1aab609 100644
--- a/debian/libini-config-dev.install
+++ b/debian/libini-config-dev.install
@@ -1,5 +1,6 @@
 usr/include/ini_comment.h
 usr/include/ini_config.h
+usr/include/ini_configmod.h
 usr/include/ini_configobj.h
 usr/include/ini_valueobj.h
 usr/lib/*/libini_config.a

commit fc7da09724f7a09a816f26d30f1a2688033b7f9f
Author: Timo Aaltonen <tjaalton at debian.org>
Date:   Sun Aug 16 01:17:43 2015 +0300

    update the changelog

diff --git a/debian/changelog b/debian/changelog
index 5b2247d..e2b91f3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+ding-libs (0.5.0-1) UNRELEASED; urgency=medium
+
+  * New upstream release.
+
+ -- Timo Aaltonen <tjaalton at debian.org>  Sun, 16 Aug 2015 01:17:12 +0300
+
 ding-libs (0.4.0-1) unstable; urgency=medium
 
   * New upstream release.

commit 4b3c284e3978ad569deed38489e57041dca604c0
Author: Lukas Slebodnik <lslebodn at redhat.com>
Date:   Tue Jun 23 12:51:13 2015 +0200

    Update versions before 0.5.0 release
    
    Version for libcollection was already updated
    with patch:
        df4d87161410bb6ab11105e74d2232cca6730f8b
        Function to return one of the dups
    
    Reviewed-by: Jakub Hrozek <jhrozek at redhat.com>

diff --git a/version.m4 b/version.m4
index 45ff9e2..8f4ce54 100644
--- a/version.m4
+++ b/version.m4
@@ -1,5 +1,5 @@
 # Primary version number
-m4_define([VERSION_NUMBER], [0.4.0])
+m4_define([VERSION_NUMBER], [0.5.0])
 
 # If the PRERELEASE_VERSION_NUMBER is set, we'll append
 # it to the release tag when creating an RPM or SRPM
@@ -13,6 +13,6 @@ m4_define([PRERELEASE_VERSION_NUMBER], [])
 m4_define([PATH_UTILS_VERSION_NUMBER], [0.2.1])
 m4_define([DHASH_VERSION_NUMBER], [0.4.3])
 m4_define([COLLECTION_VERSION_NUMBER], [0.7.0])
-m4_define([REF_ARRAY_VERSION_NUMBER], [0.1.4])
+m4_define([REF_ARRAY_VERSION_NUMBER], [0.1.5])
 m4_define([BASICOBJECTS_VERSION_NUMBER], [0.1.1])
-m4_define([INI_CONFIG_VERSION_NUMBER], [1.1.0])
+m4_define([INI_CONFIG_VERSION_NUMBER], [1.2.0])

commit 7689460153b056b4064af6ed06a34915530b11a7
Author: Lukas Slebodnik <lslebodn at redhat.com>
Date:   Tue Jun 23 12:50:53 2015 +0200

    Bump version-info
    
    The function ref_array_debug was updated. There wasn't any other
    changes to ref_array.
    
    New functions were added to collections:
       col_get_dup_item, col_delete_item_with_cb, col_remove_item_with_cb
    
    New functions were added to ini_config:
       ini_config_augment, ini_comment_construct and many functions
       from ini_configmod.h
    
    Reviewed-by: Jakub Hrozek <jhrozek at redhat.com>

diff --git a/Makefile.am b/Makefile.am
index e37884e..5b1da33 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -142,7 +142,7 @@ libcollection_la_SOURCES = \
     trace/trace.h
 libcollection_la_DEPENDENCIES = collection/libcollection.sym
 libcollection_la_LDFLAGS = \
-    -version-info 4:0:0 \
+    -version-info 5:0:1 \
     -Wl,--version-script=$(top_srcdir)/collection/libcollection.sym
 
 check_PROGRAMS += \
@@ -180,7 +180,7 @@ libref_array_la_SOURCES = \
     trace/trace.h
 libref_array_la_DEPENDENCIES = refarray/libref_array.sym
 libref_array_la_LDFLAGS = \
-    -version-info 3:0:2 \
+    -version-info 3:1:2 \
     -Wl,--version-script=$(top_srcdir)/refarray/libref_array.sym
 
 check_PROGRAMS += ref_array_ut
@@ -268,7 +268,7 @@ libini_config_la_LIBADD = \
     libref_array.la \
     libbasicobjects.la
 libini_config_la_LDFLAGS = \
-    -version-info 5:0:0 \
+    -version-info 6:0:1 \
     -Wl,--version-script=$(top_srcdir)/ini/libini_config.sym
 
 dist_noinst_DATA += \
diff --git a/contrib/ding-libs.spec.in b/contrib/ding-libs.spec.in
index 54d8b97..fe180ff 100644
--- a/contrib/ding-libs.spec.in
+++ b/contrib/ding-libs.spec.in
@@ -174,7 +174,7 @@ and serialization
 %doc COPYING
 %doc COPYING.LESSER
 %{_libdir}/libcollection.so.4
-%{_libdir}/libcollection.so.4.0.0
+%{_libdir}/libcollection.so.4.1.0
 
 %files -n libcollection-devel
 %defattr(-,root,root,-)
@@ -218,7 +218,7 @@ A dynamically-growing, reference-counted array
 %doc COPYING
 %doc COPYING.LESSER
 %{_libdir}/libref_array.so.1
-%{_libdir}/libref_array.so.1.2.0
+%{_libdir}/libref_array.so.1.2.1
 
 %files -n libref_array-devel
 %defattr(-,root,root,-)
@@ -303,7 +303,7 @@ structure
 %doc COPYING
 %doc COPYING.LESSER
 %{_libdir}/libini_config.so.5
-%{_libdir}/libini_config.so.5.0.0
+%{_libdir}/libini_config.so.5.1.0
 
 %files -n libini_config-devel
 %defattr(-,root,root,-)

commit 4d7e92836d8582a8af2f2885d4fcae34fd14b662
Author: Lukas Slebodnik <lslebodn at redhat.com>
Date:   Tue Jun 23 10:16:34 2015 +0200

    INI: Add check based test ini_configmod_ut_check
    
    Signed-off-by: Lukas Slebodnik <lslebodn at redhat.com>
    
    Reviewed-by: Jakub Hrozek <jhrozek at redhat.com>

diff --git a/Makefile.am b/Makefile.am
index a3bbbb7..e37884e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -69,8 +69,8 @@ libpath_utils_la_LDFLAGS = \
     -Wl,--version-script=$(top_srcdir)/path_utils/libpath_utils.sym
 
 if HAVE_CHECK
-    check_PROGRAMS += path_utils_ut
-    TESTS += path_utils_ut
+    check_PROGRAMS += path_utils_ut ini_configmod_ut_check
+    TESTS += path_utils_ut ini_configmod_ut_check
 endif
 
 path_utils_ut_SOURCES = path_utils/path_utils_ut.c
@@ -341,6 +341,13 @@ ini_configmod_ut_SOURCES = ini/ini_configmod_ut.c
 ini_configmod_ut_LDADD = libini_config.la libcollection.la \
                          libbasicobjects.la libpath_utils.la libref_array.la
 
+ini_configmod_ut_check_SOURCES = ini/ini_configmod_ut_check.c
+ini_configmod_ut_check_CFLAGS = $(AM_CFLAGS) $(CHECK_CFLAGS)
+ini_configmod_ut_check_LDADD = libini_config.la libcollection.la \
+                               libbasicobjects.la libpath_utils.la \
+                               libref_array.la \
+                               $(CHECK_LIBS)
+
 ini_save_ut_SOURCES = ini/ini_save_ut.c
 ini_save_ut_LDADD = libini_config.la libcollection.la \
                          libbasicobjects.la libpath_utils.la libref_array.la
diff --git a/ini/ini_configmod_ut_check.c b/ini/ini_configmod_ut_check.c
new file mode 100644
index 0000000..75d6874
--- /dev/null
+++ b/ini/ini_configmod_ut_check.c
@@ -0,0 +1,1695 @@
+/*
+    INI LIBRARY
+
+    Unit test for the configuration object modification API.
+
+    Copyright (C) Lukas Slebodnik <lslebodn at redhat.com> 2015
+
+    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/>.
+*/
+
+#include "config.h"
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <check.h>
+
+/* #define TRACE_LEVEL 7 */
+#define TRACE_HOME
+#include "trace.h"
+#include "ini_configobj.h"
+#include "ini_config_priv.h"
+#include "collection_tools.h"
+#include "ini_configmod.h"
+#include "path_utils.h"
+#include "../basicobjects/simplebuffer.h"
+
+int verbose = 0;
+
+#define WRAP_SIZE 80
+
+static void dump_configuration(struct ini_cfgobj *in_cfg,
+                               FILE *file)
+{
+    int ret;
+    struct simplebuffer *sbobj = NULL;
+    void *buff;
+    uint32_t len;
+
+    ret = simplebuffer_alloc(&sbobj);
+    fail_unless(ret == EOK,
+                "Failed to allocate buffer. Error %d.\n", ret);
+
+    ret = ini_config_serialize(in_cfg, sbobj);
+    fail_unless(ret == EOK,
+                "Failed to serialize. Error %d.\n", ret);
+
+    buff = simplebuffer_get_vbuf(sbobj);
+    len = simplebuffer_get_len(sbobj);
+    ret = fwrite(buff, 1, len, file);
+    fail_if(ret == -1,
+            "Failed to write to file. Error: %d %s\n", ret, strerror(ret));
+
+    simplebuffer_free(sbobj);
+    return;
+}
+
+static int call_diff(const char *function,
+                     const char *expected_cfg,
+                     size_t expected_cfg_len,
+                     const char *res_cfg,
+                     size_t res_cfg_len)
+{
+    char expected_fn[PATH_MAX];
+    char res_fn[PATH_MAX];
+    char command[PATH_MAX * 3];
+    char *builddir;
+    int ret;
+    int expected_fd;
+    int res_fd;
+
+    builddir = getenv("builddir");
+
+    snprintf(expected_fn, PATH_MAX, "%s/expected.conf_%s_XXXXXX",
+             (builddir == NULL) ? "." : builddir, function);
+    snprintf(res_fn, PATH_MAX, "%s/result.conf_%s_XXXXXX",
+             (builddir == NULL) ? "." : builddir, function);
+
+    expected_fd = mkstemp(expected_fn);
+    fail_if(expected_fd == -1, "mkstemp failed: %s\n", strerror(errno));
+
+    ret = write(expected_fd, expected_cfg, expected_cfg_len);
+    fail_if(ret == -1,
+            "Failed write to %s. Error %s\n",
+            expected_fn, strerror(errno));
+
+    close(expected_fd);
+
+    res_fd = mkstemp(res_fn);
+    fail_if(res_fd == -1, "mkstemp failed: %s\n", strerror(errno));
+
+    ret = write(res_fd, res_cfg, res_cfg_len);
+    fail_if(ret == -1,
+            "Failed write to %s. Error %s\n",
+            expected_fn, strerror(errno));
+    close(res_fd);
+
+    snprintf(command, PATH_MAX * 3, "diff -wi %s %s", expected_fn, res_fn);
+    ret = system(command);
+    fail_if(ret == -1,
+            "Failed to execute command:%s. Erorr %s\n",
+            command, strerror(errno));
+
+    return EOK;
+}
+
+#define assert_configuration_equal(expected_cfg, expected_cfg_len, res_cfg) \
+    _assert_configuration_equal(expected_cfg, expected_cfg_len, res_cfg, \
+                                __func__, __FILE__, __LINE__)
+static void _assert_configuration_equal(const char *expected_cfg,
+                                        size_t expected_cfg_len,
+                                        struct ini_cfgobj *res_cfg,
+                                        const char *function,
+                                        const char *file,
+                                        int line)
+{
+    char *res_buffer = NULL;
+    size_t res_buffer_size;
+    FILE *f_memstream;
+    int ret;
+
+    --expected_cfg_len; /* do not use trailing zero */
+
+    f_memstream = open_memstream(&res_buffer, &res_buffer_size);
+    fail_if(f_memstream == NULL,
+            "\n\t[%s:%d] open_memstream failed.", file, line);
+
+    dump_configuration(res_cfg, f_memstream);
+    fclose(f_memstream);
+
+    fail_unless(expected_cfg_len == res_buffer_size,
+                "\n\t[%s:%d] Size of expected config %zu and result config %d "
+                "does not match. Res:%d\n",
+                file, line, expected_cfg_len, res_buffer_size,
+                call_diff(function, expected_cfg, expected_cfg_len,
+                          res_buffer, res_buffer_size));
+
+    ret = memcmp(res_buffer, expected_cfg, expected_cfg_len);
+    fail_unless(ret == EOK,
+                "\n\t[%s:%d] Configurations are not identical. Res:%d\n",
+                file, line,
+                call_diff(function, expected_cfg, expected_cfg_len,
+                          res_buffer, res_buffer_size));
+
+    free(res_buffer);
+}
+
+static struct ini_cfgobj *get_ini_config_from_str(char input_data[],
+                                                  size_t input_data_len)
+{
+    struct ini_cfgobj *in_cfg;
+    struct ini_cfgfile *file_ctx;
+    int ret;
+
+    ret = ini_config_create(&in_cfg);
+    fail_unless(ret == EOK, "Failed to create config. Error %d.\n", ret);
+
+    ret = ini_config_file_from_mem(input_data, input_data_len, &file_ctx);
+    fail_unless(ret == EOK, "Failed to load config. Error %d.\n", ret);
+
+    ret = ini_config_parse(file_ctx, INI_STOP_ON_NONE, INI_MV1S_ALLOW, 0,
+                           in_cfg);
+    fail_unless(ret == EOK, "Failed to parse config. Error %d.\n", ret);
+
+    ini_config_file_destroy(file_ctx);
+
+    return in_cfg;
+}
+
+START_TEST(test_delete_value_wrong_arguments)
+{
+    int ret = EOK;
+    struct ini_cfgobj *in_cfg = NULL;
+
+    char exp_data[] =
+        "[zero]\n"
+        "[one]\n"
+        "key1 = value1a\n";
+
+    in_cfg = get_ini_config_from_str(exp_data, sizeof(exp_data));
+    assert_configuration_equal(exp_data, sizeof(exp_data), in_cfg);
+
+    /* missing ini_config */
+    ret = ini_config_delete_value(NULL, "one", COL_DSP_NDUP, "key1", 0);
+    fail_unless(ret == EINVAL, "delete value should fail. Error: %d", ret);
+    assert_configuration_equal(exp_data, sizeof(exp_data), in_cfg);
+
+    /* missing section */
+    ret = ini_config_delete_value(in_cfg, NULL, COL_DSP_NDUP, "key1", 0);
+    fail_unless(ret == EINVAL, "delete value should fail. Error: %d", ret);
+    assert_configuration_equal(exp_data, sizeof(exp_data), in_cfg);
+
+    /* missing key */
+    ret = ini_config_delete_value(in_cfg, "one", COL_DSP_NDUP, NULL, 0);
+    fail_unless(ret == EINVAL, "delete value should fail. Error: %d", ret);
+    assert_configuration_equal(exp_data, sizeof(exp_data), in_cfg);
+
+    /* value index is too low */
+    ret = ini_config_delete_value(in_cfg, "one", COL_DSP_NDUP, "key1", -1);
+    fail_unless(ret == EINVAL, "delete value should fail. Error: %d", ret);
+    assert_configuration_equal(exp_data, sizeof(exp_data), in_cfg);
+
+    /* value index is too high */
+    ret = ini_config_delete_value(in_cfg, "one", COL_DSP_NDUP, "key1", 1);
+    fail_unless(ret == ENOENT, "delete value should fail. Error: %d", ret);
+    assert_configuration_equal(exp_data, sizeof(exp_data), in_cfg);
+
+    ini_config_destroy(in_cfg);
+}
+END_TEST
+
+START_TEST(test_delete_value)
+{
+    int ret = EOK;
+    struct ini_cfgobj *in_cfg;
+
+    char input_data[] =
+        "[zero]\n"
+        "[one]\n"
+        "key1 = first\n"
+        "key1 = second\n"
+        "key1 = third\n"
+        "key1 = last\n";
+
+    char delete_first[] =
+        "[zero]\n"
+        "[one]\n"
+        "key1 = first\n"
+        "key1 = second\n"
+        "key1 = third\n";
+
+    in_cfg = get_ini_config_from_str(input_data, sizeof(input_data));
+    assert_configuration_equal(input_data, sizeof(input_data), in_cfg);
+
+    ret = ini_config_delete_value(in_cfg, "one", COL_DSP_NDUP, "key1", 3);
+    fail_unless(ret == EOK, "delete value should fail. Error: %d", ret);
+    assert_configuration_equal(delete_first, sizeof(delete_first), in_cfg);
+
+    ini_config_destroy(in_cfg);
+}
+END_TEST
+
+START_TEST(test_update_comments_wrong_arguments)
+{
+    int ret = EOK;
+    struct ini_cfgobj *in_cfg;
+
+    char input_data[] =
+        "[one]\n"
+        "key1 = value1\n"
+        "key1 = value1a\n"
+        "key1 = value1a_bis\n"
+        "// This is a test\n"
+        "key1 = value1b\n"
+        "key1 = value1c\n"
+        "key2 = value2\n"
+        "key3 = value3\n";
+
+    const char *comment[] = { "// This is a test", NULL };
+
+    in_cfg = get_ini_config_from_str(input_data, sizeof(input_data));
+    assert_configuration_equal(input_data, sizeof(input_data), in_cfg);
+
+    /* missing ini_config */
+    ret = ini_config_update_comment(NULL, "one", "key1", comment, 1, 3);
+    fail_unless(ret == EINVAL, "update commants should fail. Error: %d", ret);
+    assert_configuration_equal(input_data, sizeof(input_data), in_cfg);
+
+    /* missing section */
+    ret = ini_config_update_comment(in_cfg, NULL, "key1", comment, 1, 3);
+    fail_unless(ret == EINVAL, "update commants should fail. Error: %d", ret);
+    assert_configuration_equal(input_data, sizeof(input_data), in_cfg);
+
+    /* missing key */
+    ret = ini_config_update_comment(in_cfg, "one", NULL, comment, 1, 3);
+    fail_unless(ret == EINVAL, "update commants should fail. Error: %d", ret);
+    assert_configuration_equal(input_data, sizeof(input_data), in_cfg);
+
+    /* wrong section */
+    ret = ini_config_update_comment(in_cfg, "noexist", "key1", comment, 1, 3);
+    fail_unless(ret == ENOENT, "update commants should fail. Error: %d", ret);
+    assert_configuration_equal(input_data, sizeof(input_data), in_cfg);
+
+    /* wrong key */
+    ret = ini_config_update_comment(in_cfg, "one", "noexist", comment, 1, 3);
+    fail_unless(ret == ENOENT, "update commants should fail. Error: %d", ret);
+    assert_configuration_equal(input_data, sizeof(input_data), in_cfg);
+
+    /* value index is too low */
+    ret = ini_config_update_comment(in_cfg, "one", "key1", comment, 1, -1);
+    fail_unless(ret == EINVAL, "update commants should fail. Error: %d", ret);
+    assert_configuration_equal(input_data, sizeof(input_data), in_cfg);
+
+    /* value index is too high */
+    ret = ini_config_update_comment(in_cfg, "one", "key1", comment, 1, 5);
+    fail_unless(ret == ENOENT, "update commants should fail. Error: %d", ret);
+    assert_configuration_equal(input_data, sizeof(input_data), in_cfg);
+
+    ini_config_destroy(in_cfg);
+}
+END_TEST
+
+START_TEST(test_update_comments)
+{
+    int ret = EOK;
+    struct ini_cfgobj *in_cfg;
+
+    char input_data[] =
+        "[one]\n"
+        "key1 = value1\n"
+        "key1 = value1a\n"
+        "key1 = value1a_bis\n"
+        "key1 = value1b\n"
+        "// this is a comment\n"
+        "key1 = value1c\n"
+        "key2 = value2\n"
+        "key3 = value3\n";
+
+    char exp_data_1comment[] =
+        "[one]\n"
+        "// This is a test1\n"
+        "key1 = value1\n"
+        "key1 = value1a\n"
+        "key1 = value1a_bis\n"
+        "key1 = value1b\n"
+        "// this is a comment\n"
+        "key1 = value1c\n"
+        "key2 = value2\n"
+        "key3 = value3\n";
+
+    char exp_data_2comments[] =
+        "[one]\n"
+        "// This is a test1\n"
+        "// This is a test2\n"
+        "key1 = value1\n"
+        "key1 = value1a\n"
+        "key1 = value1a_bis\n"
+        "key1 = value1b\n"
+        "// this is a comment\n"
+        "key1 = value1c\n"
+        "key2 = value2\n"
+        "key3 = value3\n";
+
+    char exp_data_1comment_after2[] =
+        "[one]\n"
+        "key1 = value1\n"
+        "key1 = value1a\n"
+        "// This is a test1\n"
+        "key1 = value1a_bis\n"
+        "key1 = value1b\n"
+        "// this is a comment\n"
+        "key1 = value1c\n"
+        "key2 = value2\n"
+        "key3 = value3\n";
+
+    char exp_replaced[] =
+        "[one]\n"
+        "key1 = value1\n"
+        "key1 = value1a\n"
+        "key1 = value1a_bis\n"
+        "key1 = value1b\n"
+        "// This is a test1\n"
+        "// This is a test2\n"
+        "key1 = value1c\n"
+        "key2 = value2\n"
+        "key3 = value3\n";
+
+    char exp_removed_comment[] =
+        "[one]\n"
+        "key1 = value1\n"
+        "key1 = value1a\n"
+        "key1 = value1a_bis\n"
+        "key1 = value1b\n"
+        "key1 = value1c\n"
+        "key2 = value2\n"
+        "key3 = value3\n";
+
+    const char *comments[] = { "// This is a test1", "// This is a test2",
+                               NULL };
+
+    const char *empty_comment[] = { NULL };
+
+    in_cfg = get_ini_config_from_str(input_data, sizeof(input_data));
+    assert_configuration_equal(input_data, sizeof(input_data), in_cfg);
+
+    /* add comments with size */
+    ret = ini_config_update_comment(in_cfg, "one", "key1", comments, 1, 0);
+    fail_unless(ret == EOK, "update commants should fail. Error: %d", ret);
+    assert_configuration_equal(exp_data_1comment, sizeof(exp_data_1comment),
+                               in_cfg);
+    ini_config_destroy(in_cfg);
+
+
+    in_cfg = get_ini_config_from_str(input_data, sizeof(input_data));
+    assert_configuration_equal(input_data, sizeof(input_data), in_cfg);
+
+    /* add comments with size */
+    ret = ini_config_update_comment(in_cfg, "one", "key1", comments, 2, 0);
+    fail_unless(ret == EOK, "update commants should fail. Error: %d", ret);
+    assert_configuration_equal(exp_data_2comments, sizeof(exp_data_2comments),
+                               in_cfg);
+    ini_config_destroy(in_cfg);
+
+    in_cfg = get_ini_config_from_str(input_data, sizeof(input_data));
+    assert_configuration_equal(input_data, sizeof(input_data), in_cfg);
+
+    /* add comments (NULL terminated array), size is 0 */
+    ret = ini_config_update_comment(in_cfg, "one", "key1", comments, 0, 0);
+    fail_unless(ret == EOK, "update commants should fail. Error: %d", ret);
+    assert_configuration_equal(exp_data_2comments, sizeof(exp_data_2comments),
+                               in_cfg);
+    ini_config_destroy(in_cfg);
+
+    in_cfg = get_ini_config_from_str(input_data, sizeof(input_data));
+    assert_configuration_equal(input_data, sizeof(input_data), in_cfg);
+
+    /* add comments (NULL terminated array), size is 0 */
+    ret = ini_config_update_comment(in_cfg, "one", "key1", comments, 1, 2);
+    fail_unless(ret == EOK, "update commants should fail. Error: %d", ret);
+    assert_configuration_equal(exp_data_1comment_after2,
+                               sizeof(exp_data_1comment_after2),
+                               in_cfg);
+    ini_config_destroy(in_cfg);
+
+    in_cfg = get_ini_config_from_str(input_data, sizeof(input_data));
+    assert_configuration_equal(input_data, sizeof(input_data), in_cfg);
+
+    /* replace comment */
+    ret = ini_config_update_comment(in_cfg, "one", "key1", comments, 0, 4);
+    fail_unless(ret == EOK, "update commants should fail. Error: %d", ret);
+    assert_configuration_equal(exp_replaced, sizeof(exp_replaced),
+                               in_cfg);
+    ini_config_destroy(in_cfg);
+
+    in_cfg = get_ini_config_from_str(input_data, sizeof(input_data));
+    assert_configuration_equal(input_data, sizeof(input_data), in_cfg);
+
+    /* remove comment */
+    ret = ini_config_update_comment(in_cfg, "one", "key1",
+                                    empty_comment, 0, 4);
+    fail_unless(ret == EOK, "update commants should fail. Error: %d", ret);
+    assert_configuration_equal(exp_removed_comment,
+                               sizeof(exp_removed_comment),
+                               in_cfg);
+    ini_config_destroy(in_cfg);
+
+    in_cfg = get_ini_config_from_str(input_data, sizeof(input_data));
+    assert_configuration_equal(input_data, sizeof(input_data), in_cfg);
+
+    /* remove comment (2nd way; argument is NULL) */
+    ret = ini_config_update_comment(in_cfg, "one", "key1",
+                                    NULL, 0, 4);
+    fail_unless(ret == EOK, "update commants should fail. Error: %d", ret);
+    assert_configuration_equal(exp_removed_comment,
+                               sizeof(exp_removed_comment),
+                               in_cfg);
+    ini_config_destroy(in_cfg);
+}
+END_TEST
+
+START_TEST(test_add_str_wrong_arguments)
+{
+    int ret = EOK;
+    struct ini_cfgobj *in_cfg;
+
+    char input_data[] =
+        "[zero]\n"
+        "[one]\n"
+        "key1 = value1a\n";
+
+    const char *comments[] = { "// This is a test1", "// This is a test2",
+                               NULL };
+
+    in_cfg = get_ini_config_from_str(input_data, sizeof(input_data));
+    assert_configuration_equal(input_data, sizeof(input_data), in_cfg);
+
+    /* missing ini_config */
+    ret = ini_config_add_str_value(NULL, "one", "newkey", "newvalue",
+                                   comments, 2, WRAP_SIZE, COL_DSP_END, "key1",
+                                   0, INI_VA_NOCHECK);
+    fail_unless(ret == EINVAL, "Add str should fail. Error: %d", ret);
+    assert_configuration_equal(input_data, sizeof(input_data), in_cfg);
+
+    /* missing section */
+    ret = ini_config_add_str_value(in_cfg, NULL, "newkey", "newvalue",
+                                   comments, 2, WRAP_SIZE, COL_DSP_END, "key1",
+                                   0, INI_VA_NOCHECK);
+    fail_unless(ret == EINVAL, "Add str should fail. Error: %d", ret);
+    assert_configuration_equal(input_data, sizeof(input_data), in_cfg);
+
+    /* missing key */
+    ret = ini_config_add_str_value(in_cfg, "one", NULL, "newvalue",
+                                   comments, 2, WRAP_SIZE, COL_DSP_END, "key1",
+                                   0, INI_VA_NOCHECK);
+    fail_unless(ret == EINVAL, "Add str should fail. Error: %d", ret);
+    assert_configuration_equal(input_data, sizeof(input_data), in_cfg);
+
+    /* missing value */
+    ret = ini_config_add_str_value(in_cfg, "one", "newkey", NULL,
+                                   comments, 2, WRAP_SIZE, COL_DSP_END, "key1",
+                                   0, INI_VA_NOCHECK);
+    fail_unless(ret == EINVAL, "Add str should fail. Error: %d", ret);
+    assert_configuration_equal(input_data, sizeof(input_data), in_cfg);
+
+    /* wrong index */
+    ret = ini_config_add_str_value(in_cfg, "one", "newkey", "newvalue",
+                                   comments, 2, WRAP_SIZE, COL_DSP_END, "key1",
+                                   -1, INI_VA_NOCHECK);
+    fail_unless(ret == EINVAL, "Add str should fail. Error: %d", ret);
+    assert_configuration_equal(input_data, sizeof(input_data), in_cfg);
+
+    /* wrong flag */
+    ret = ini_config_add_str_value(in_cfg, "one", "newkey", "newvalue",
+                                   comments, 2, WRAP_SIZE, COL_DSP_END, "key1",
+                                   0, 0xff);
+    fail_unless(ret == ENOSYS, "Add str should fail. Error: %d", ret);
+    assert_configuration_equal(input_data, sizeof(input_data), in_cfg);
+
+    /* add duplicate for missing key */
+    ret = ini_config_add_str_value(in_cfg, "one", "newkey", "newvalue",
+                                   comments, 2, WRAP_SIZE, COL_DSP_NDUP,
+                                   "key1", 0, INI_VA_NOCHECK);
+    fail_unless(ret == ENOENT, "Add str should fail. Error: %d", ret);
+    assert_configuration_equal(input_data, sizeof(input_data), in_cfg);
+
+    ini_config_destroy(in_cfg);
+}
+END_TEST
+
+START_TEST(test_add_str_simple)
+{
+    int ret = EOK;
+    struct ini_cfgobj *in_cfg;
+
+    char input_data[] =
+        "[zero]\n"
+        "[one]\n"
+        "key1 = value1a\n"
+        "key1 = value1b\n"
+        "key2 = value2a\n";
+
+    const char *comments[] = { "// This is a test1", "// This is a test2",
+                               NULL };
+
+    char add_new_value_to_end[] =



More information about the Pkg-sssd-devel mailing list