From 6b104860ad5df2b135619d00b40f888d67a03b1b Mon Sep 17 00:00:00 2001
From: Roland Mainz <rmainz@redhat.com>
Date: Tue, 14 Apr 2015 16:07:18 +0200
Subject: [PATCH] Remove support for iniparse library

This library already does not support some features we need and
we want to drop its usage as the code quality is bad.

Fixes: https://fedorahosted.org/gss-proxy/ticket/139

Signed-off-by: Roland Mainz <rmainz@redhat.com>
---
 proxy/Makefile.am               |   2 -
 proxy/configure.ac              |  13 +---
 proxy/src/gp_config.c           |  52 -------------
 proxy/src/gp_config_iniparser.c | 164 ----------------------------------------
 proxy/src/gp_config_iniparser.h |  42 ----------
 6 files changed, 9 insertions(+), 274 deletions(-)
 delete mode 100644 proxy/src/gp_config_iniparser.c
 delete mode 100644 proxy/src/gp_config_iniparser.h

diff --git a/proxy/Makefile.am b/proxy/Makefile.am
index 1e7c39cf2c2d3ef2c96c1b28c76d53d378054da6..a7547e6552449fc4b0f85c72731bc20495835811 100644
--- a/proxy/Makefile.am
+++ b/proxy/Makefile.am
@@ -130,7 +130,6 @@ dist_noinst_HEADERS = \
     src/gp_export.h \
     src/gp_conv.h \
     src/gp_config.h \
-    src/gp_config_iniparser.h \
     src/gp_config_dinglibs.h \
     src/gp_debug.h \
     src/gp_rpc_creds.h \
@@ -144,7 +143,6 @@ dist_noinst_HEADERS = \
 
 gssproxy_SOURCES = \
     src/gp_config.c \
-    src/gp_config_iniparser.c \
     src/gp_config_dinglibs.c \
     src/gp_init.c \
     src/gp_socket.c \
diff --git a/proxy/configure.ac b/proxy/configure.ac
index 51979762d738e5f8e58a432d0e0db6b860eb360c..6c77cb2e81cba746f4ee09b41a1d74139fc700be 100644
--- a/proxy/configure.ac
+++ b/proxy/configure.ac
@@ -83,14 +83,6 @@ if test x$have_libverto = x; then
     AC_MSG_ERROR([Could not find VERTO headers])
 fi
 
-#Check for iniparser
-have_iniparser=
-AC_CHECK_HEADERS([iniparser.h],
-    [AC_CHECK_LIB(iniparser, iniparser_set, [ have_iniparser=1 ],
-    [AC_MSG_ERROR([Iniparser library must support iniparser_set])])],
-    [AC_MSG_WARN([Could not find Iniparser headers])]
-)
-
 #Check for libini_config
 PKG_CHECK_MODULES([LIBINI_CONFIG], [ini_config >= 1.0.0], [have_libini_config=1], [have_libini_config=])
 if test x$have_libini_config = x; then
@@ -107,11 +99,8 @@ if test x$have_libini_config = x1; then
     AC_DEFINE([WITH_DINGLIBS], [1], [Using ini_config])
     INI_CFLAGS="$INI_CONFIG_CFLAGS"
     INI_LIBS="$INI_CONFIG_LIBS"
-elif test x$have_iniparser = x1; then
-    AC_DEFINE([WITH_INIPARSER], [1], [Using iniparser])
-    INI_LIBS="-liniparser"
 else
-    AC_MSG_ERROR([Neither iniparser nor ini_config development packages available])
+    AC_MSG_ERROR([ini_config development packages not available])
 fi
 
 AC_SUBST(INI_LIBS)
diff --git a/proxy/src/gp_config.c b/proxy/src/gp_config.c
index d3af376fa43565178f80fe4fafeae54a65a0de27..71e2ca644dbdce25625732b37877e92257661c70 100644
--- a/proxy/src/gp_config.c
+++ b/proxy/src/gp_config.c
@@ -567,58 +567,6 @@ void free_config(struct gp_config **cfg)
     *cfg = NULL;
 }
 
-#ifdef WITH_INIPARSER
-#include "gp_config_iniparser.h"
-
-int gp_config_init(const char *config_file,
-                   struct gp_ini_context *ctx)
-{
-    return gp_iniparser_init(config_file, ctx);
-}
-
-int gp_config_get_string(struct gp_ini_context *ctx,
-                         const char *secname,
-                         const char *keyname,
-                         char **value)
-{
-    return gp_iniparser_get_string(ctx, secname, keyname, value);
-}
-
-int gp_config_get_string_array(struct gp_ini_context *ctx,
-                               const char *secname,
-                               const char *keyname,
-                               int *num_values,
-                               char ***values)
-{
-    return ENOENT;
-}
-
-int gp_config_get_int(struct gp_ini_context *ctx,
-                      const char *secname,
-                      const char *keyname,
-                      int *value)
-{
-    return gp_iniparser_get_int(ctx, secname, keyname, value);
-}
-
-int gp_config_get_nsec(struct gp_ini_context *ctx)
-{
-    return gp_iniparser_get_nsec(ctx);
-}
-
-char *gp_config_get_secname(struct gp_ini_context *ctx,
-                            int i)
-{
-    return gp_iniparser_get_secname(ctx, i);
-}
-
-int gp_config_close(struct gp_ini_context *ctx)
-{
-    return gp_iniparser_close(ctx);
-}
-
-#endif /* WITH_INIPARSER */
-
 #ifdef WITH_DINGLIBS
 #include "gp_config_dinglibs.h"
 
diff --git a/proxy/src/gp_config_iniparser.c b/proxy/src/gp_config_iniparser.c
deleted file mode 100644
index 45677d7b0c85847744ff5ab10945237b661f4350..0000000000000000000000000000000000000000
--- a/proxy/src/gp_config_iniparser.c
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
-   GSS-PROXY
-
-   Copyright (C) 2011 Red Hat, Inc.
-   Copyright (C) 2011 Simo Sorce <simo.sorce@redhat.com>
-   Copyright (C) 2012 Guenther Deschner <guenther.deschner@redhat.com>
-
-   Permission is hereby granted, free of charge, to any person obtaining a
-   copy of this software and associated documentation files (the "Software"),
-   to deal in the Software without restriction, including without limitation
-   the rights to use, copy, modify, merge, publish, distribute, sublicense,
-   and/or sell copies of the Software, and to permit persons to whom the
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included in
-   all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-   DEALINGS IN THE SOFTWARE.
-*/
-
-#include "config.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include "gp_proxy.h"
-#include "gp_config.h"
-#include "gp_config_iniparser.h"
-
-#ifdef WITH_INIPARSER
-
-#include <iniparser.h>
-
-int gp_iniparser_get_string(struct gp_ini_context *ctx,
-                            const char *secname,
-                            const char *key,
-                            char **value)
-{
-    dictionary *dict;
-    char *skey;
-    char *val;
-    int ret;
-
-    dict = (dictionary *)ctx->private_data;
-
-    if (!value) {
-        return EINVAL;
-    }
-
-    *value = NULL;
-
-    ret = asprintf(&skey, "%s:%s", secname, key);
-    if (ret == -1) {
-        return ENOMEM;
-    }
-
-    val = iniparser_getstring(dict, skey, NULL);
-    free(skey);
-
-    if (!val) {
-        return ENOENT;
-    }
-
-    *value = val;
-
-    return 0;
-}
-
-int gp_iniparser_get_int(struct gp_ini_context *ctx,
-                         const char *secname,
-                         const char *key,
-                         int *value)
-{
-    dictionary *dict;
-    char *skey;
-    int ret;
-
-    dict = (dictionary *)ctx->private_data;
-
-    if (!value) {
-        return EINVAL;
-    }
-
-    *value = -1;
-
-    ret = asprintf(&skey, "%s:%s", secname, key);
-    if (ret == -1) {
-        return ENOMEM;
-    }
-
-    ret = iniparser_getint(dict, skey, -1);
-    free(skey);
-
-    if (ret == -1) {
-        return ENOENT;
-    }
-
-    *value = ret;
-
-    return 0;
-}
-
-int gp_iniparser_init(const char *config_file,
-                      struct gp_ini_context *ctx)
-{
-    dictionary *d;
-
-    if (!ctx) {
-        return EINVAL;
-    }
-
-    d = iniparser_load(config_file);
-    if (!d) {
-        return ENOENT;
-    }
-
-    ctx->private_data = d;
-
-    return 0;
-}
-
-int gp_iniparser_close(struct gp_ini_context *ctx)
-{
-    dictionary *dict;
-
-    if (!ctx) {
-        return 0;
-    }
-
-    dict = (dictionary *)ctx->private_data;
-
-    iniparser_freedict(dict);
-
-    return 0;
-}
-
-int gp_iniparser_get_nsec(struct gp_ini_context *ctx)
-{
-    dictionary *dict = dict = (dictionary *)ctx->private_data;
-
-    return iniparser_getnsec(dict);
-}
-
-char *gp_iniparser_get_secname(struct gp_ini_context *ctx,
-                                      int i)
-{
-    dictionary *dict = dict = (dictionary *)ctx->private_data;
-    char *value;
-
-    value = iniparser_getsecname(dict, i);
-    if (!value) {
-        return NULL;
-    }
-
-    return strdup(value);
-}
-
-#endif /* WITH_INIPARSER */
diff --git a/proxy/src/gp_config_iniparser.h b/proxy/src/gp_config_iniparser.h
deleted file mode 100644
index 8fc32007971d7452deb31970ddfefce9049cd3aa..0000000000000000000000000000000000000000
--- a/proxy/src/gp_config_iniparser.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
-   GSS-PROXY
-
-   Copyright (C) 2011 Red Hat, Inc.
-   Copyright (C) 2011 Simo Sorce <simo.sorce@redhat.com>
-   Copyright (C) 2012 Guenther Deschner <guenther.deschner@redhat.com>
-
-   Permission is hereby granted, free of charge, to any person obtaining a
-   copy of this software and associated documentation files (the "Software"),
-   to deal in the Software without restriction, including without limitation
-   the rights to use, copy, modify, merge, publish, distribute, sublicense,
-   and/or sell copies of the Software, and to permit persons to whom the
-   Software is furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included in
-   all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-   DEALINGS IN THE SOFTWARE.
-*/
-
-#include "gp_config.h"
-
-int gp_iniparser_get_string(struct gp_ini_context *ctx,
-                            const char *secname,
-                            const char *key,
-                            char **value);
-int gp_iniparser_get_int(struct gp_ini_context *ctx,
-                         const char *secname,
-                         const char *key,
-                         int *value);
-int gp_iniparser_init(const char *config_file,
-                      struct gp_ini_context *ctx);
-int gp_iniparser_close(struct gp_ini_context *ctx);
-int gp_iniparser_get_nsec(struct gp_ini_context *ctx);
-char *gp_iniparser_get_secname(struct gp_ini_context *ctx,
-                               int i);
-- 
1.9.3

