From ed8883d2df07e7f3b75ce58924ccddcc286a9c23 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Wed, 27 Apr 2016 15:54:49 +0200 Subject: [PATCH] Re-enabled libzakconfi. --- .gitignore | 1 + configure.ac | 16 +++++++-------- src/Makefile.am | 8 ++++---- src/aute_db.c | 24 ++++++++++++---------- tests/Makefile.am | 9 ++++++-- tests/test_confi.c | 48 +++++++++++++++++++++++++++++++++++++++++++ tests/test_confi.conf | 5 +++++ 7 files changed, 86 insertions(+), 25 deletions(-) create mode 100644 tests/test_confi.c create mode 100644 tests/test_confi.conf diff --git a/.gitignore b/.gitignore index 93e51ac..dc11495 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ missing config.h stamp-h1 tests/test +tests/test_confi tests/test_nogui tools/zakauthedb-mkpwd *.tar.gz diff --git a/configure.ac b/configure.ac index e43a6b7..9fa6692 100644 --- a/configure.ac +++ b/configure.ac @@ -21,17 +21,17 @@ AC_PROG_CC AC_PROG_LIBTOOL # Checks for libraries. -PKG_CHECK_MODULES(LIBAUTEDB, [libzakauthe >= 0.5.0 - libgtkform >= 0.5.0]) +PKG_CHECK_MODULES(LIBZAKAUTHEDB, [libzakauthe >= 0.5.0 + libgtkform >= 0.5.0]) -AC_SUBST(LIBAUTEDB_CFLAGS) -AC_SUBST(LIBAUTEDB_LIBS) +AC_SUBST(LIBZAKAUTHEDB_CFLAGS) +AC_SUBST(LIBZAKAUTHEDB_LIBS) -PKG_CHECK_MODULES(LIBCONFI, [libconfi >= 0.0.2], [AC_DEFINE(HAVE_LIBCONFI, [1], [libconfi is present]), have_libconfi=yes], have_libconfi=no) +PKG_CHECK_MODULES(LIBZAKCONFI, [libzakconfi >= 0.0.2], [AC_DEFINE(HAVE_LIBZAKCONFI, [1], [libzakconfi is present]), have_libzakconfi=yes], have_libzakconfi=no) -AM_CONDITIONAL(HAVE_LIBCONFI, test x"$have_libconfi" = "xyes") -AC_SUBST(LIBCONFI_CFLAGS) -AC_SUBST(LIBCONFI_LIBS) +AM_CONDITIONAL(HAVE_LIBZAKCONFI, test x"$have_libzakconfi" = "xyes") +AC_SUBST(LIBZAKCONFI_CFLAGS) +AC_SUBST(LIBZAKCONFI_LIBS) AM_PATH_LIBGCRYPT(1.2.1, :, [AC_MSG_ERROR([libgcrypt >= 1.2.1 not found.])]) diff --git a/src/Makefile.am b/src/Makefile.am index 47ecae4..0bf5786 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,17 +1,17 @@ guidir = $(datadir)/libzakauthedb/gui formdir = $(datadir)/libzakauthedb/form -AM_CPPFLAGS = $(LIBAUTEDB_CFLAGS) \ +AM_CPPFLAGS = $(LIBZAKAUTHEDB_CFLAGS) \ $(LIBGCRYPT_CFLAGS) \ $(GPG_ERROR_CFLAGS) \ - $(LIBCONFI_CFLAGS) \ + $(LIBZAKCONFI_CFLAGS) \ -DGUIDIR=\""$(guidir)"\" \ -DFORMDIR=\""$(formdir)"\" -LIBS = $(LIBAUTEDB_LIBS) \ +LIBS = $(LIBZAKAUTHEDB_LIBS) \ $(LIBGCRYPT_LIBS) \ $(GPG_ERROR_LIBS) \ - $(LIBCONFI_LIBS) + $(LIBZAKCONFI_LIBS) libzakauthe_pluginsdir = $(libdir)/libzakauthe/plugins libzakauthe_plugins_LTLIBRARIES = libzakauthedb.la diff --git a/src/aute_db.c b/src/aute_db.c index 14c205e..ece9c4e 100644 --- a/src/aute_db.c +++ b/src/aute_db.c @@ -26,8 +26,8 @@ #include #include -#ifdef HAVE_LIBCONFI - #include +#ifdef HAVE_LIBZAKCONFI + #include #endif #include "user.h" @@ -84,13 +84,13 @@ DllMain (HINSTANCE hinstDLL, } #endif -#ifdef HAVE_LIBCONFI +#ifdef HAVE_LIBZAKCONFI static gboolean -get_connection_parameters_from_confi (Confi *confi, gchar **cnc_string) +get_connection_parameters_from_confi (ZakConfi *confi, gchar **cnc_string) { gboolean ret = TRUE; - *cnc_string = confi_path_get_value (confi, "libzakauthe/libzakauthedb/db/cnc_string"); + *cnc_string = zak_confi_path_get_value (confi, "libzakauthe/libzakauthedb/db/cnc_string"); if (*cnc_string == NULL || strcmp (g_strstrip (*cnc_string), "") == 0) @@ -109,14 +109,16 @@ get_gdaex (GSList *parameters) cnc_string = NULL; -#ifdef HAVE_LIBCONFI - /* the first and only parameters must be a Confi object */ - /* leggo i parametri di connessione dalla configurazione */ - if (IS_CONFI (parameters->data)) +#ifdef HAVE_LIBZAKCONFI + /* the first and only parameters must be a ZakConfi object */ + if (g_strcmp0 ((gchar *)parameters->data, "{libzakconfi}") == 0) { - if (!get_connection_parameters_from_confi (CONFI (parameters->data), &cnc_string)) + if (ZAK_IS_CONFI ((ZakConfi *)g_slist_nth_data (parameters, 1))) { - cnc_string = NULL; + if (!get_connection_parameters_from_confi (ZAK_CONFI ((ZakConfi *)g_slist_nth_data (parameters, 1)), &cnc_string)) + { + cnc_string = NULL; + } } } #endif diff --git a/tests/Makefile.am b/tests/Makefile.am index 9cda210..e3c4da2 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,12 +1,17 @@ AM_CPPFLAGS = $(WARN_CFLAGS) \ $(DISABLE_DEPRECATED_CFLAGS) \ - $(LIBAUTEDB_CFLAGS) \ + $(LIBZAKAUTHEDB_CFLAGS) \ + $(LIBZAKCONFI_CFLAGS) \ -I../src LIBS = $(GTK_LIBS) \ - $(LIBAUTEDB_LIBS) + $(LIBZAKAUTHEDB_LIBS) \ + $(LIBZAKCONFI_LIBS) LDADD = ../src/libzakauthedb.la noinst_PROGRAMS = test \ + test_confi \ test_nogui + +EXTRA_DIST = test_confi.conf diff --git a/tests/test_confi.c b/tests/test_confi.c new file mode 100644 index 0000000..a90a356 --- /dev/null +++ b/tests/test_confi.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2016 Andrea Zagli + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include + +#include + +#include + +int +main (int argc, char **argv) +{ + ZakAuthe *aute; + ZakConfi *confi; + GSList *params; + + gtk_init (&argc, &argv); + + aute = zak_authe_new (); + + params = NULL; + + confi = zak_confi_new (argv[1]); + + params = g_slist_append (params, "{libzakconfi}"); + params = g_slist_append (params, confi); + + zak_authe_set_config (aute, params); + + g_message ("User %s\n", zak_authe_authe (aute)); + + return 0; +} diff --git a/tests/test_confi.conf b/tests/test_confi.conf new file mode 100644 index 0000000..3fe6263 --- /dev/null +++ b/tests/test_confi.conf @@ -0,0 +1,5 @@ +[libzakauthe] +plugin=/usr/local/lib/libzakauthe/plugins/libzakauthedb.so + +[libzakauthe/libzakauthedb/db] +cnc_string=PostgreSql://postgres:postgres@HOST=localhost;DB_NAME=autedb \ No newline at end of file -- 2.49.0