]> saetta.ns0.it Git - zakconfi/libzakconfi/commitdiff
Changed namespace.
authorAndrea Zagli <azagli@libero.it>
Sat, 16 Apr 2016 09:36:07 +0000 (11:36 +0200)
committerAndrea Zagli <azagli@libero.it>
Sat, 16 Apr 2016 09:36:07 +0000 (11:36 +0200)
24 files changed:
Makefile.am
autogen.sh
configure.ac
libconfi.pc.in [deleted file]
libzakconfi.pc.in [new file with mode: 0644]
plugins/db/Makefile.am
plugins/db/plgdb.c
plugins/db/plgdb.h
plugins/file/Makefile.am
plugins/file/plgfile.c
plugins/file/plgfile.h
src/Makefile.am
src/commons.c
src/commons.h
src/confi.c [new file with mode: 0644]
src/confipluggable.c
src/confipluggable.h
src/libconfi.c [deleted file]
src/libconfi.h [deleted file]
src/libzakconfi.h [new file with mode: 0644]
tests/Makefile.am
tests/gir.php
tests/gir.py
tests/test.c

index cc98020d4ad90e98d4cdb4e6c6bbc03d007c8dfc..a066227af6ed602ca4fdb3e02af609757560d538 100644 (file)
@@ -2,7 +2,7 @@ DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc --enable-introspection
 
 SUBDIRS = src plugins tests data docs
 
-EXTRA_DIST = libconfi.pc.in
+EXTRA_DIST = libzakconfi.pc.in
 
 pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = libconfi.pc
+pkgconfig_DATA = libzakconfi.pc
index 5f56e036b8c5f9ec07cf458da0a5aba6787039a0..9ccfdb6a041a7d0e571601b924ddae6b489a44a4 100755 (executable)
@@ -4,13 +4,13 @@
 srcdir=`dirname $0`
 test -z "$srcdir" && srcdir=.
 
-PKG_NAME="libconfi"
+PKG_NAME="libzakconfi"
 
 (test -f $srcdir/configure.ac \
   && test -d $srcdir/src \
-  && test -f $srcdir/src/libconfi.h) || {
+  && test -f $srcdir/src/libzakconfi.h) || {
     echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
-    echo " top-level libconfi directory"
+    echo " top-level libzakconfi directory"
     exit 1
 }
 
index dfd8bce20991c07114159667871f374701c69cf1..15b4d4d83cdec168c16dfb72b2b01bcae193571a 100644 (file)
@@ -2,8 +2,8 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ(2.59)
-AC_INIT([libconfi], [0.10.0], [azagli@libero.it])
-AC_CONFIG_SRCDIR([src/libconfi.c])
+AC_INIT([libzakconfi], [0.10.0], [azagli@libero.it])
+AC_CONFIG_SRCDIR([src/confi.c])
 AC_CONFIG_HEADER([config.h])
 
 AM_INIT_AUTOMAKE(-Wall)
@@ -55,7 +55,7 @@ esac
 AM_CONDITIONAL(PLATFORM_WIN32, [test $platform_win32 = yes])
 
 AC_CONFIG_FILES([
-  libconfi.pc
+  libzakconfi.pc
   Makefile
   src/Makefile
   plugins/Makefile
diff --git a/libconfi.pc.in b/libconfi.pc.in
deleted file mode 100644 (file)
index 818ac2e..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-pluginsdir=@libdir@/@PACKAGE@/plugins
-
-Name: @PACKAGE_NAME@
-Description: Library to manage configurations based on plugins (db, file, etc.)
-Version: @PACKAGE_VERSION@
-Requires: libgdaex
-Libs: -L${libdir} -lconfi
-Cflags: -I${includedir}
diff --git a/libzakconfi.pc.in b/libzakconfi.pc.in
new file mode 100644 (file)
index 0000000..9cf3b5a
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+pluginsdir=@libdir@/@PACKAGE@/plugins
+
+Name: @PACKAGE_NAME@
+Description: Library to manage configurations based on plugins (db, file, etc.)
+Version: @PACKAGE_VERSION@
+Requires: libgdaex
+Libs: -L${libdir} -lzakconfi
+Cflags: -I${includedir}
index 8a0e0f9fc9d41e11b4c5c2b49dda4dbbf46e8b0b..2331875cafd3fe39b6d7bc5bd436142e9910d894 100644 (file)
@@ -12,7 +12,7 @@ libdb_la_SOURCES = \
 
 libdb_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS)
 libdb_la_LIBADD = \
-       $(top_builddir)/src/libconfi.la \
+       $(top_builddir)/src/libzakconfi.la \
        $(LIBCONFI_LIBS)
 
 plugins_DATA = db.plugin
index 408219af73efc8727fb902d12882019213f5ea5b..06f162e5c0bc1be7e59e7efae4db743d1ea8b05a 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * plgdb.c
- * This file is part of confi
+ * This file is part of libzakconfi
  *
- * Copyright (C) 2014 Andrea Zagli
+ * Copyright (C) 2014-2016 Andrea Zagli <azagli@libero.it>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU Library General Public License as published by
 
 #include <libgdaex/libgdaex.h>
 
-#include "../../src/libconfi.h"
+#include "../../src/libzakconfi.h"
 #include "../../src/confipluggable.h"
 
 #include "plgdb.h"
 
-static void confi_pluggable_iface_init (ConfiPluggableInterface *iface);
+static void zak_confi_pluggable_iface_init (ZakConfiPluggableInterface *iface);
 
-static GdaDataModel *confi_db_plugin_path_get_data_model (ConfiPluggable *pluggable, const gchar *path);
-static gchar *confi_db_plugin_path_get_value_from_db (ConfiPluggable *pluggable, const gchar *path);
-static void confi_db_plugin_get_children (ConfiPluggable *pluggable, GNode *parentNode, gint idParent, gchar *path);
+static GdaDataModel *zak_confi_db_plugin_path_get_data_model (ZakConfiPluggable *pluggable, const gchar *path);
+static gchar *zak_confi_db_plugin_path_get_value_from_db (ZakConfiPluggable *pluggable, const gchar *path);
+static void zak_confi_db_plugin_get_children (ZakConfiPluggable *pluggable, GNode *parentNode, gint idParent, gchar *path);
 
-#define CONFI_DB_PLUGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CONFI_TYPE_DB_PLUGIN, ConfiDBPluginPrivate))
+#define ZAK_CONFI_DB_PLUGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_CONFI_TYPE_DB_PLUGIN, ZakConfiDBPluginPrivate))
 
-typedef struct _ConfiDBPluginPrivate ConfiDBPluginPrivate;
-struct _ConfiDBPluginPrivate
+typedef struct _ZakConfiDBPluginPrivate ZakConfiDBPluginPrivate;
+struct _ZakConfiDBPluginPrivate
        {
                gchar *cnc_string;
 
@@ -61,12 +61,12 @@ struct _ConfiDBPluginPrivate
                gchar chrquot;
        };
 
-G_DEFINE_DYNAMIC_TYPE_EXTENDED (ConfiDBPlugin,
-                                confi_db_plugin,
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (ZakConfiDBPlugin,
+                                zak_confi_db_plugin,
                                 PEAS_TYPE_EXTENSION_BASE,
                                 0,
-                                G_IMPLEMENT_INTERFACE_DYNAMIC (CONFI_TYPE_PLUGGABLE,
-                                                               confi_pluggable_iface_init))
+                                G_IMPLEMENT_INTERFACE_DYNAMIC (ZAK_CONFI_TYPE_PLUGGABLE,
+                                                               zak_confi_pluggable_iface_init))
 
 enum {
        PROP_0,
@@ -77,20 +77,20 @@ enum {
 };
 
 static void
-confi_db_plugin_set_property (GObject      *object,
+zak_confi_db_plugin_set_property (GObject      *object,
                               guint         prop_id,
                               const GValue *value,
                               GParamSpec   *pspec)
 {
        gchar *sql;
 
-       ConfiDBPlugin *plugin = CONFI_DB_PLUGIN (object);
-       ConfiDBPluginPrivate *priv = CONFI_DB_PLUGIN_GET_PRIVATE (plugin);
+       ZakConfiDBPlugin *plugin = ZAK_CONFI_DB_PLUGIN (object);
+       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (plugin);
 
        switch (prop_id)
                {
                        case PROP_CNC_STRING:
-                               confi_db_plugin_initialize ((ConfiPluggable *)plugin, g_value_get_string (value));
+                               zak_confi_db_plugin_initialize ((ZakConfiPluggable *)plugin, g_value_get_string (value));
                                break;
 
                        case PROP_NAME:
@@ -116,7 +116,7 @@ confi_db_plugin_set_property (GObject      *object,
                                break;
 
                        case PROP_ROOT:
-                               priv->root = confi_normalize_root (g_value_get_string (value));
+                               priv->root = zak_confi_normalize_root (g_value_get_string (value));
                                break;
 
                        default:
@@ -126,13 +126,13 @@ confi_db_plugin_set_property (GObject      *object,
 }
 
 static void
-confi_db_plugin_get_property (GObject    *object,
+zak_confi_db_plugin_get_property (GObject    *object,
                               guint       prop_id,
                               GValue     *value,
                               GParamSpec *pspec)
 {
-       ConfiDBPlugin *plugin = CONFI_DB_PLUGIN (object);
-       ConfiDBPluginPrivate *priv = CONFI_DB_PLUGIN_GET_PRIVATE (plugin);
+       ZakConfiDBPlugin *plugin = ZAK_CONFI_DB_PLUGIN (object);
+       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (plugin);
 
        switch (prop_id)
                {
@@ -159,9 +159,9 @@ confi_db_plugin_get_property (GObject    *object,
 }
 
 static void
-confi_db_plugin_init (ConfiDBPlugin *plugin)
+zak_confi_db_plugin_init (ZakConfiDBPlugin *plugin)
 {
-       ConfiDBPluginPrivate *priv = CONFI_DB_PLUGIN_GET_PRIVATE (plugin);
+       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (plugin);
 
        priv->cnc_string = NULL;
        priv->gdaex = NULL;
@@ -170,18 +170,18 @@ confi_db_plugin_init (ConfiDBPlugin *plugin)
 }
 
 static void
-confi_db_plugin_finalize (GObject *object)
+zak_confi_db_plugin_finalize (GObject *object)
 {
-       ConfiDBPlugin *plugin = CONFI_DB_PLUGIN (object);
+       ZakConfiDBPlugin *plugin = ZAK_CONFI_DB_PLUGIN (object);
 
-       G_OBJECT_CLASS (confi_db_plugin_parent_class)->finalize (object);
+       G_OBJECT_CLASS (zak_confi_db_plugin_parent_class)->finalize (object);
 }
 
 gboolean
-confi_db_plugin_initialize (ConfiPluggable *pluggable, const gchar *cnc_string)
+zak_confi_db_plugin_initialize (ZakConfiPluggable *pluggable, const gchar *cnc_string)
 {
-       ConfiDBPlugin *plugin = CONFI_DB_PLUGIN (pluggable);
-       ConfiDBPluginPrivate *priv = CONFI_DB_PLUGIN_GET_PRIVATE (plugin);
+       ZakConfiDBPlugin *plugin = ZAK_CONFI_DB_PLUGIN (pluggable);
+       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (plugin);
 
        GString *gstr_cnc_string;
        gchar **strs;
@@ -253,7 +253,7 @@ confi_db_plugin_initialize (ConfiPluggable *pluggable, const gchar *cnc_string)
 }
 
 static GdaDataModel
-*confi_db_plugin_path_get_data_model (ConfiPluggable *pluggable, const gchar *path)
+*zak_confi_db_plugin_path_get_data_model (ZakConfiPluggable *pluggable, const gchar *path)
 {
        gchar **tokens;
        gchar *sql;
@@ -262,7 +262,7 @@ static GdaDataModel
        guint id_parent;
        GdaDataModel *dm;
 
-       ConfiDBPluginPrivate *priv = CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
+       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
 
        if (path == NULL) return NULL;
 
@@ -311,14 +311,14 @@ static GdaDataModel
 }
 
 static gchar
-*confi_db_plugin_path_get_value_from_db (ConfiPluggable *pluggable, const gchar *path)
+*zak_confi_db_plugin_path_get_value_from_db (ZakConfiPluggable *pluggable, const gchar *path)
 {
        gchar *ret;
        GdaDataModel *dm;
 
        ret = NULL;
 
-       dm = confi_db_plugin_path_get_data_model (pluggable, path);
+       dm = zak_confi_db_plugin_path_get_data_model (pluggable, path);
        if (dm != NULL)
                {
                        ret = gdaex_data_model_get_field_value_stringify_at (dm, 0, "value");
@@ -329,12 +329,12 @@ static gchar
 }
 
 static void
-confi_db_plugin_get_children (ConfiPluggable *pluggable, GNode *parentNode, gint idParent, gchar *path)
+zak_confi_db_plugin_get_children (ZakConfiPluggable *pluggable, GNode *parentNode, gint idParent, gchar *path)
 {
        gchar *sql;
        GdaDataModel *dm;
 
-       ConfiDBPluginPrivate *priv = CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
+       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
 
        sql = g_strdup_printf ("SELECT *"
                               " FROM %cvalues%c"
@@ -355,7 +355,7 @@ confi_db_plugin_get_children (ConfiPluggable *pluggable, GNode *parentNode, gint
                        for (i = 0; i < rows; i++)
                                {
                                        GNode *newNode;
-                                       ConfiKey *ck = g_new0 (ConfiKey, 1);
+                                       ZakConfiKey *ck = g_new0 (ZakConfiKey, 1);
 
                                        ck->id_config = priv->id_config;
                                        ck->id = gdaex_data_model_get_field_value_integer_at (dm, i, "id");
@@ -367,19 +367,19 @@ confi_db_plugin_get_children (ConfiPluggable *pluggable, GNode *parentNode, gint
 
                                        newNode = g_node_append_data (parentNode, ck);
 
-                                       confi_db_plugin_get_children (pluggable, newNode, ck->id, g_strconcat (path, (g_strcmp0 (path, "") == 0 ? "" : "/"), ck->key, NULL));
+                                       zak_confi_db_plugin_get_children (pluggable, newNode, ck->id, g_strconcat (path, (g_strcmp0 (path, "") == 0 ? "" : "/"), ck->key, NULL));
                                }
                        g_object_unref (dm);
                }
 }
 
 static GList
-*confi_db_plugin_get_configs_list (ConfiPluggable *pluggable,
+*zak_confi_db_plugin_get_configs_list (ZakConfiPluggable *pluggable,
                                    const gchar *filter)
 {
        GList *lst;
 
-       GdaDataModel *dmConfigs;
+       GdaDataModel *dmZakConfigs;
 
        gchar *sql;
        gchar *where;
@@ -388,7 +388,7 @@ static GList
        guint id;
        guint rows;
 
-       ConfiDBPluginPrivate *priv = CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
+       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
 
        lst = NULL;
 
@@ -409,19 +409,19 @@ static GList
        sql = g_strdup_printf ("SELECT * FROM configs%s", where);
        g_free (where);
 
-       dmConfigs = gdaex_query (priv->gdaex, sql);
+       dmZakConfigs = gdaex_query (priv->gdaex, sql);
        g_free (sql);
-       if (dmConfigs != NULL)
+       if (dmZakConfigs != NULL)
                {
-                       rows = gda_data_model_get_n_rows (dmConfigs);
+                       rows = gda_data_model_get_n_rows (dmZakConfigs);
                        if (rows > 0)
                                {
                                        for (row = 0; row < rows; row++)
                                                {
-                                                       ConfiConfi *confi;
-                                                       confi = g_new0 (ConfiConfi, 1);
-                                                       confi->name = gdaex_data_model_get_field_value_stringify_at (dmConfigs, row, "name");
-                                                       confi->description = gdaex_data_model_get_field_value_stringify_at (dmConfigs, row, "description");
+                                                       ZakConfiConfi *confi;
+                                                       confi = g_new0 (ZakConfiConfi, 1);
+                                                       confi->name = gdaex_data_model_get_field_value_stringify_at (dmZakConfigs, row, "name");
+                                                       confi->description = gdaex_data_model_get_field_value_stringify_at (dmZakConfigs, row, "description");
                                                        lst = g_list_append (lst, confi);
                                                }
                                }
@@ -435,36 +435,36 @@ static GList
 }
 
 static gchar
-*confi_db_plugin_path_get_value (ConfiPluggable *pluggable, const gchar *path)
+*zak_confi_db_plugin_path_get_value (ZakConfiPluggable *pluggable, const gchar *path)
 {
        gchar *ret;
        gchar *path_;
 
-       ConfiDBPluginPrivate *priv = CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
+       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
 
        ret = NULL;
 
-       path_ = confi_path_normalize (pluggable, path);
+       path_ = zak_confi_path_normalize (pluggable, path);
        if (path_ == NULL)
                {
                        return NULL;
                }
 
-       ret = confi_db_plugin_path_get_value_from_db (pluggable, path_);
+       ret = zak_confi_db_plugin_path_get_value_from_db (pluggable, path_);
 
        return ret;
 }
 
 static gboolean
-confi_db_plugin_path_set_value (ConfiPluggable *pluggable, const gchar *path, const gchar *value)
+zak_confi_db_plugin_path_set_value (ZakConfiPluggable *pluggable, const gchar *path, const gchar *value)
 {
        GdaDataModel *dm;
        gchar *sql;
        gboolean ret;
 
-       dm = confi_db_plugin_path_get_data_model (pluggable, confi_path_normalize (pluggable, path));
+       dm = zak_confi_db_plugin_path_get_data_model (pluggable, zak_confi_path_normalize (pluggable, path));
 
-       ConfiDBPluginPrivate *priv = CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
+       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
 
        ret = FALSE;
        if (dm != NULL && gda_data_model_get_n_rows (dm) > 0)
@@ -493,16 +493,16 @@ confi_db_plugin_path_set_value (ConfiPluggable *pluggable, const gchar *path, co
 }
 
 GNode
-*confi_db_plugin_get_tree (ConfiPluggable *pluggable)
+*zak_confi_db_plugin_get_tree (ZakConfiPluggable *pluggable)
 {
        gchar *path;
        GNode *node;
 
-       ConfiDBPluginPrivate *priv = CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
+       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
 
        path = g_strdup ("");
 
-       ConfiKey *ck = g_new0 (ConfiKey, 1);
+       ZakConfiKey *ck = g_new0 (ZakConfiKey, 1);
 
        ck->id_config = priv->id_config;
        ck->id = 0;
@@ -514,22 +514,22 @@ GNode
 
        node = g_node_new (ck);
 
-       confi_db_plugin_get_children (pluggable, node, 0, path);
+       zak_confi_db_plugin_get_children (pluggable, node, 0, path);
 
        return node;
 }
 
-static ConfiKey
-*confi_db_plugin_add_key (ConfiPluggable *pluggable, const gchar *parent, const gchar *key, const gchar *value)
+static ZakConfiKey
+*zak_confi_db_plugin_add_key (ZakConfiPluggable *pluggable, const gchar *parent, const gchar *key, const gchar *value)
 {
-       ConfiKey *ck;
+       ZakConfiKey *ck;
        GdaDataModel *dmParent;
 
        gchar *sql;
        gint id;
        GdaDataModel *dm;
 
-       ConfiDBPluginPrivate *priv = CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
+       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
 
        gint id_parent;
        gchar *parent_;
@@ -551,7 +551,7 @@ static ConfiKey
                                }
                        else
                                {
-                                       dmParent = confi_db_plugin_path_get_data_model (pluggable, confi_path_normalize (pluggable, parent_));
+                                       dmParent = zak_confi_db_plugin_path_get_data_model (pluggable, zak_confi_path_normalize (pluggable, parent_));
                                        if (dmParent == NULL)
                                                {
                                                        id_parent = -1;
@@ -642,7 +642,7 @@ static ConfiKey
                                        g_free (sql);
                                }
 
-                       ck = g_new0 (ConfiKey, 1);
+                       ck = g_new0 (ZakConfiKey, 1);
                        ck->id_config = priv->id_config;
                        ck->id = id;
                        ck->id_parent = id_parent;
@@ -673,7 +673,7 @@ static ConfiKey
                                        path = g_strdup (ck->key);
                                }
 
-                       if (!confi_db_plugin_path_set_value (pluggable, path, value))
+                       if (!zak_confi_db_plugin_path_set_value (pluggable, path, value))
                                {
                                        ck = NULL;
                                }
@@ -688,13 +688,13 @@ static ConfiKey
 }
 
 static gboolean
-confi_db_plugin_key_set_key (ConfiPluggable *pluggable,
-                             ConfiKey *ck)
+zak_confi_db_plugin_key_set_key (ZakConfiPluggable *pluggable,
+                             ZakConfiKey *ck)
 {
        gboolean ret;
        gchar *sql;
 
-       ConfiDBPluginPrivate *priv = CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
+       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
 
        sql = g_strdup_printf ("UPDATE %cvalues%c"
                               " SET %ckey%c = '%s',"
@@ -716,22 +716,22 @@ confi_db_plugin_key_set_key (ConfiPluggable *pluggable,
        return ret;
 }
 
-static ConfiKey
-*confi_db_plugin_path_get_confi_key (ConfiPluggable *pluggable, const gchar *path)
+static ZakConfiKey
+*zak_confi_db_plugin_path_get_confi_key (ZakConfiPluggable *pluggable, const gchar *path)
 {
        GdaDataModel *dm;
        gchar *path_;
-       ConfiKey *ck;
+       ZakConfiKey *ck;
 
-       ConfiDBPluginPrivate *priv = CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
+       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
 
-       path_ = confi_path_normalize (pluggable, path);
+       path_ = zak_confi_path_normalize (pluggable, path);
        if (path_ == NULL)
                {
                        return NULL;
                }
 
-       dm = confi_db_plugin_path_get_data_model (pluggable, path_);
+       dm = zak_confi_db_plugin_path_get_data_model (pluggable, path_);
        if (dm == NULL || gda_data_model_get_n_rows (dm) <= 0)
                {
                        if (dm != NULL)
@@ -741,7 +741,7 @@ static ConfiKey
                        return NULL;
                }
 
-       ck = g_new0 (ConfiKey, 1);
+       ck = g_new0 (ZakConfiKey, 1);
        ck->id_config = gdaex_data_model_get_field_value_integer_at (dm, 0, "id_configs");
        ck->id = gdaex_data_model_get_field_value_integer_at (dm, 0, "id");
        ck->id_parent = gdaex_data_model_get_field_value_integer_at (dm, 0, "id_parent");
@@ -759,12 +759,12 @@ static ConfiKey
 }
 
 static gboolean
-confi_db_plugin_delete_id_from_db_values (ConfiPluggable *pluggable, gint id)
+zak_confi_db_plugin_delete_id_from_db_values (ZakConfiPluggable *pluggable, gint id)
 {
        gboolean ret;
        gchar *sql;
 
-       ConfiDBPluginPrivate *priv = CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
+       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
 
        sql = g_strdup_printf ("DELETE FROM %cvalues%c"
                               " WHERE id_configs = %d"
@@ -787,26 +787,26 @@ confi_db_plugin_delete_id_from_db_values (ConfiPluggable *pluggable, gint id)
 }
 
 static gboolean
-confi_db_plugin_remove_path_traverse_func (GNode *node, gpointer data)
+zak_confi_db_plugin_remove_path_traverse_func (GNode *node, gpointer data)
 {
-       ConfiKey *ck = (ConfiKey *)node->data;
+       ZakConfiKey *ck = (ZakConfiKey *)node->data;
        if (ck->id != 0)
                {
-                       confi_db_plugin_delete_id_from_db_values ((ConfiPluggable *)data, ck->id);
+                       zak_confi_db_plugin_delete_id_from_db_values ((ZakConfiPluggable *)data, ck->id);
                }
 
        return FALSE;
 }
 
 static gboolean
-confi_db_plugin_remove_path (ConfiPluggable *pluggable, const gchar *path)
+zak_confi_db_plugin_remove_path (ZakConfiPluggable *pluggable, const gchar *path)
 {
        gboolean ret = FALSE;
        GdaDataModel *dm;
 
-       ConfiDBPluginPrivate *priv = CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
+       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
 
-       dm = confi_db_plugin_path_get_data_model (pluggable, confi_path_normalize (pluggable, path));
+       dm = zak_confi_db_plugin_path_get_data_model (pluggable, zak_confi_path_normalize (pluggable, path));
 
        if (dm != NULL && gda_data_model_get_n_rows (dm) > 0)
                {
@@ -817,17 +817,17 @@ confi_db_plugin_remove_path (ConfiPluggable *pluggable, const gchar *path)
                        gint id = gdaex_data_model_get_field_value_integer_at (dm, 0, "id");
 
                        node = g_node_new (path_);
-                       confi_db_plugin_get_children (pluggable, node, id, path_);
+                       zak_confi_db_plugin_get_children (pluggable, node, id, path_);
 
                        root = g_node_get_root (node);
 
                        if (g_node_n_nodes (root, G_TRAVERSE_ALL) > 1)
                                {
-                                       g_node_traverse (root, G_PRE_ORDER, G_TRAVERSE_ALL, -1, confi_db_plugin_remove_path_traverse_func, (gpointer)pluggable);
+                                       g_node_traverse (root, G_PRE_ORDER, G_TRAVERSE_ALL, -1, zak_confi_db_plugin_remove_path_traverse_func, (gpointer)pluggable);
                                }
 
                        /* removing the path */
-                       ret = confi_db_plugin_delete_id_from_db_values (pluggable, id);
+                       ret = zak_confi_db_plugin_delete_id_from_db_values (pluggable, id);
                }
        else
                {
@@ -842,12 +842,12 @@ confi_db_plugin_remove_path (ConfiPluggable *pluggable, const gchar *path)
 }
 
 static gboolean
-confi_db_plugin_remove (ConfiPluggable *pluggable)
+zak_confi_db_plugin_remove (ZakConfiPluggable *pluggable)
 {
        gboolean ret;
        gchar *sql;
 
-       ConfiDBPluginPrivate *priv = CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
+       ZakConfiDBPluginPrivate *priv = ZAK_CONFI_DB_PLUGIN_GET_PRIVATE (pluggable);
 
        ret = TRUE;
        sql = g_strdup_printf ("DELETE FROM %cvalues%c WHERE id_configs = %d",
@@ -875,15 +875,15 @@ confi_db_plugin_remove (ConfiPluggable *pluggable)
 }
 
 static void
-confi_db_plugin_class_init (ConfiDBPluginClass *klass)
+zak_confi_db_plugin_class_init (ZakConfiDBPluginClass *klass)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-       g_type_class_add_private (object_class, sizeof (ConfiDBPluginPrivate));
+       g_type_class_add_private (object_class, sizeof (ZakConfiDBPluginPrivate));
 
-       object_class->set_property = confi_db_plugin_set_property;
-       object_class->get_property = confi_db_plugin_get_property;
-       object_class->finalize = confi_db_plugin_finalize;
+       object_class->set_property = zak_confi_db_plugin_set_property;
+       object_class->get_property = zak_confi_db_plugin_get_property;
+       object_class->finalize = zak_confi_db_plugin_finalize;
 
        g_object_class_override_property (object_class, PROP_CNC_STRING, "cnc_string");
        g_object_class_override_property (object_class, PROP_NAME, "name");
@@ -892,31 +892,31 @@ confi_db_plugin_class_init (ConfiDBPluginClass *klass)
 }
 
 static void
-confi_pluggable_iface_init (ConfiPluggableInterface *iface)
+zak_confi_pluggable_iface_init (ZakConfiPluggableInterface *iface)
 {
-       iface->initialize = confi_db_plugin_initialize;
-       iface->get_configs_list = confi_db_plugin_get_configs_list;
-       iface->path_get_value = confi_db_plugin_path_get_value;
-       iface->path_set_value = confi_db_plugin_path_set_value;
-       iface->get_tree = confi_db_plugin_get_tree;
-       iface->add_key = confi_db_plugin_add_key;
-       iface->key_set_key = confi_db_plugin_key_set_key;
-       iface->path_get_confi_key = confi_db_plugin_path_get_confi_key;
-       iface->remove_path = confi_db_plugin_remove_path;
-       iface->remove = confi_db_plugin_remove;
+       iface->initialize = zak_confi_db_plugin_initialize;
+       iface->get_configs_list = zak_confi_db_plugin_get_configs_list;
+       iface->path_get_value = zak_confi_db_plugin_path_get_value;
+       iface->path_set_value = zak_confi_db_plugin_path_set_value;
+       iface->get_tree = zak_confi_db_plugin_get_tree;
+       iface->add_key = zak_confi_db_plugin_add_key;
+       iface->key_set_key = zak_confi_db_plugin_key_set_key;
+       iface->path_get_confi_key = zak_confi_db_plugin_path_get_confi_key;
+       iface->remove_path = zak_confi_db_plugin_remove_path;
+       iface->remove = zak_confi_db_plugin_remove;
 }
 
 static void
-confi_db_plugin_class_finalize (ConfiDBPluginClass *klass)
+zak_confi_db_plugin_class_finalize (ZakConfiDBPluginClass *klass)
 {
 }
 
 G_MODULE_EXPORT void
 peas_register_types (PeasObjectModule *module)
 {
-       confi_db_plugin_register_type (G_TYPE_MODULE (module));
+       zak_confi_db_plugin_register_type (G_TYPE_MODULE (module));
 
        peas_object_module_register_extension_type (module,
-                                                   CONFI_TYPE_PLUGGABLE,
-                                                   CONFI_TYPE_DB_PLUGIN);
+                                                   ZAK_CONFI_TYPE_PLUGGABLE,
+                                                   ZAK_CONFI_TYPE_DB_PLUGIN);
 }
index 34b899caefcc68f42a0d98ab4a4990978299314a..066004cebf4f0d63dbee9ea4d7882595cd2d856f 100644 (file)
@@ -2,7 +2,7 @@
  * plgdb.h
  * This file is part of confi
  *
- * Copyright (C) 2014 Andrea Zagli
+ * Copyright (C) 2014-2016 Andrea Zagli <azagli@libero.it>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU Library General Public License as published by
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-#ifndef __CONFI_DB_PLUGIN_H__
-#define __CONFI_DB_PLUGIN_H__
+#ifndef __ZAK_CONFI_DB_PLUGIN_H__
+#define __ZAK_CONFI_DB_PLUGIN_H__
 
 #include <libpeas/peas.h>
 
 G_BEGIN_DECLS
 
-#define CONFI_TYPE_DB_PLUGIN         (confi_db_plugin_get_type ())
-#define CONFI_DB_PLUGIN(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), CONFI_TYPE_DB_PLUGIN, ConfiDBPlugin))
-#define CONFI_DB_PLUGIN_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), CONFI_TYPE_DB_PLUGIN, ConfiDBPlugin))
-#define CONFI_IS_DB_PLUGIN(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), CONFI_TYPE_DB_PLUGIN))
-#define CONFI_IS_DB_PLUGIN_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), CONFI_TYPE_DB_PLUGIN))
-#define CONFI_DB_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CONFI_TYPE_DB_PLUGIN, ConfiDBPluginClass))
+#define ZAK_CONFI_TYPE_DB_PLUGIN         (zak_confi_db_plugin_get_type ())
+#define ZAK_CONFI_DB_PLUGIN(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), ZAK_CONFI_TYPE_DB_PLUGIN, ZakConfiDBPlugin))
+#define ZAK_CONFI_DB_PLUGIN_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), ZAK_CONFI_TYPE_DB_PLUGIN, ZakConfiDBPlugin))
+#define ZAK_CONFI_IS_DB_PLUGIN(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZAK_CONFI_TYPE_DB_PLUGIN))
+#define ZAK_CONFI_IS_DB_PLUGIN_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), ZAK_CONFI_TYPE_DB_PLUGIN))
+#define ZAK_CONFI_DB_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZAK_CONFI_TYPE_DB_PLUGIN, ZakConfiDBPluginClass))
 
-typedef struct _ConfiDBPlugin       ConfiDBPlugin;
-typedef struct _ConfiDBPluginClass  ConfiDBPluginClass;
+typedef struct _ZakConfiDBPlugin       ZakConfiDBPlugin;
+typedef struct _ZakConfiDBPluginClass  ZakConfiDBPluginClass;
 
-struct _ConfiDBPlugin {
+struct _ZakConfiDBPlugin {
        PeasExtensionBase parent_instance;
 };
 
-struct _ConfiDBPluginClass {
+struct _ZakConfiDBPluginClass {
        PeasExtensionBaseClass parent_class;
 };
 
-GType                 confi_db_plugin_get_type        (void) G_GNUC_CONST;
+GType                 zak_confi_db_plugin_get_type        (void) G_GNUC_CONST;
 G_MODULE_EXPORT void  peas_register_types                         (PeasObjectModule *module);
 
 G_END_DECLS
 
-#endif /* __CONFI_DB_PLUGIN_H__ */
+#endif /* __ZAK_CONFI_DB_PLUGIN_H__ */
index bae778ff31378e8de7f54e4bf7ff15c3db0ef1eb..f8df7f94aadcab64eb6dc4c80b9db29b50708ca5 100644 (file)
@@ -1,18 +1,18 @@
 pluginsdir = $(libdir)/$(PACKAGE)/plugins
 
 AM_CPPFLAGS = \
-       -I$(top_srcdir) \
-       $(LIBCONFI_CFLAGS)
+              -I$(top_srcdir) \
+              $(LIBCONFI_CFLAGS)
 
 plugins_LTLIBRARIES = libfile.la
 
 libfile_la_SOURCES = \
-       plgfile.h \
-       plgfile.c
+                     plgfile.h \
+                     plgfile.c
 
 libfile_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS)
 libfile_la_LIBADD = \
-       $(top_builddir)/src/libconfi.la \
-       $(LIBCONFI_LIBS)
+                    $(top_builddir)/src/libzakconfi.la \
+                    $(LIBCONFI_LIBS)
 
 plugins_DATA = file.plugin
index 91f4849325ddd06b96e34f28f8b30ef8abc86433..b31dec38e496420d15f2148c379a3afe56f0e311 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * plgfile.c
- * This file is part of confi
+ * This file is part of libzakconfi
  *
- * Copyright (C) 2014 Andrea Zagli
+ * Copyright (C) 2014-2016 Andrea Zagli <azagli@libero.it>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU Library General Public License as published by
 
 #include <libpeas/peas.h>
 
-#include "../../src/libconfi.h"
+#include "../../src/libzakconfi.h"
 #include "../../src/confipluggable.h"
 
 #include "plgfile.h"
 
-static void confi_pluggable_iface_init (ConfiPluggableInterface *iface);
+static void zak_confi_pluggable_iface_init (ZakConfiPluggableInterface *iface);
 
-static gboolean confi_file_plugin_path_get_group_and_key (ConfiPluggable *pluggable, const gchar *path, gchar **group, gchar **key);
-static gchar *confi_file_plugin_path_get_value_from_file (ConfiPluggable *pluggable, const gchar *path);
-static gchar *confi_file_plugin_path_get_value (ConfiPluggable *pluggable, const gchar *path);
-static gboolean confi_file_plugin_path_set_value (ConfiPluggable *pluggable, const gchar *path, const gchar *value);
-static void confi_file_plugin_get_children (ConfiPluggable *pluggable, GNode *parentNode);
+static gboolean zak_confi_file_plugin_path_get_group_and_key (ZakConfiPluggable *pluggable, const gchar *path, gchar **group, gchar **key);
+static gchar *zak_confi_file_plugin_path_get_value_from_file (ZakConfiPluggable *pluggable, const gchar *path);
+static gchar *zak_confi_file_plugin_path_get_value (ZakConfiPluggable *pluggable, const gchar *path);
+static gboolean zak_confi_file_plugin_path_set_value (ZakConfiPluggable *pluggable, const gchar *path, const gchar *value);
+static void zak_confi_file_plugin_get_children (ZakConfiPluggable *pluggable, GNode *parentNode);
 
-#define CONFI_FILE_PLUGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CONFI_TYPE_FILE_PLUGIN, ConfiFilePluginPrivate))
+#define ZAK_CONFI_FILE_PLUGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_CONFI_TYPE_FILE_PLUGIN, ZakConfiFilePluginPrivate))
 
-typedef struct _ConfiFilePluginPrivate ConfiFilePluginPrivate;
-struct _ConfiFilePluginPrivate
+typedef struct _ZakConfiFilePluginPrivate ZakConfiFilePluginPrivate;
+struct _ZakConfiFilePluginPrivate
        {
                gchar *cnc_string;
 
@@ -58,12 +58,12 @@ struct _ConfiFilePluginPrivate
                gchar *root;
        };
 
-G_DEFINE_DYNAMIC_TYPE_EXTENDED (ConfiFilePlugin,
-                                confi_file_plugin,
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (ZakConfiFilePlugin,
+                                zak_confi_file_plugin,
                                 PEAS_TYPE_EXTENSION_BASE,
                                 0,
-                                G_IMPLEMENT_INTERFACE_DYNAMIC (CONFI_TYPE_PLUGGABLE,
-                                                               confi_pluggable_iface_init))
+                                G_IMPLEMENT_INTERFACE_DYNAMIC (ZAK_CONFI_TYPE_PLUGGABLE,
+                                                               zak_confi_pluggable_iface_init))
 
 enum {
        PROP_0,
@@ -74,32 +74,32 @@ enum {
 };
 
 static void
-confi_file_plugin_set_property (GObject      *object,
+zak_confi_file_plugin_set_property (GObject      *object,
                               guint         prop_id,
                               const GValue *value,
                               GParamSpec   *pspec)
 {
-       ConfiFilePlugin *plugin = CONFI_FILE_PLUGIN (object);
-       ConfiFilePluginPrivate *priv = CONFI_FILE_PLUGIN_GET_PRIVATE (plugin);
+       ZakConfiFilePlugin *plugin = ZAK_CONFI_FILE_PLUGIN (object);
+       ZakConfiFilePluginPrivate *priv = ZAK_CONFI_FILE_PLUGIN_GET_PRIVATE (plugin);
 
        switch (prop_id)
                {
                        case PROP_CNC_STRING:
-                               confi_file_plugin_initialize ((ConfiPluggable *)plugin, g_value_get_string (value));
+                               zak_confi_file_plugin_initialize ((ZakConfiPluggable *)plugin, g_value_get_string (value));
                                break;
 
                        case PROP_NAME:
                                priv->name = g_strdup (g_value_get_string (value));
-                               confi_file_plugin_path_set_value ((ConfiPluggable *)plugin, "/CONFI/name", priv->name);
+                               zak_confi_file_plugin_path_set_value ((ZakConfiPluggable *)plugin, "/CONFI/name", priv->name);
                                break;
 
                        case PROP_DESCRIPTION:
                                priv->description = g_strdup (g_value_get_string (value));
-                               confi_file_plugin_path_set_value ((ConfiPluggable *)plugin, "/CONFI/description", priv->description);
+                               zak_confi_file_plugin_path_set_value ((ZakConfiPluggable *)plugin, "/CONFI/description", priv->description);
                                break;
 
                        case PROP_ROOT:
-                               priv->root = confi_normalize_root (g_value_get_string (value));
+                               priv->root = zak_confi_normalize_root (g_value_get_string (value));
                                break;
 
                        default:
@@ -109,13 +109,13 @@ confi_file_plugin_set_property (GObject      *object,
 }
 
 static void
-confi_file_plugin_get_property (GObject    *object,
+zak_confi_file_plugin_get_property (GObject    *object,
                               guint       prop_id,
                               GValue     *value,
                               GParamSpec *pspec)
 {
-       ConfiFilePlugin *plugin = CONFI_FILE_PLUGIN (object);
-       ConfiFilePluginPrivate *priv = CONFI_FILE_PLUGIN_GET_PRIVATE (plugin);
+       ZakConfiFilePlugin *plugin = ZAK_CONFI_FILE_PLUGIN (object);
+       ZakConfiFilePluginPrivate *priv = ZAK_CONFI_FILE_PLUGIN_GET_PRIVATE (plugin);
 
        switch (prop_id)
                {
@@ -142,9 +142,9 @@ confi_file_plugin_get_property (GObject    *object,
 }
 
 static void
-confi_file_plugin_init (ConfiFilePlugin *plugin)
+zak_confi_file_plugin_init (ZakConfiFilePlugin *plugin)
 {
-       ConfiFilePluginPrivate *priv = CONFI_FILE_PLUGIN_GET_PRIVATE (plugin);
+       ZakConfiFilePluginPrivate *priv = ZAK_CONFI_FILE_PLUGIN_GET_PRIVATE (plugin);
 
        priv->cnc_string = NULL;
        priv->kfile = NULL;
@@ -153,21 +153,21 @@ confi_file_plugin_init (ConfiFilePlugin *plugin)
 }
 
 static void
-confi_file_plugin_finalize (GObject *object)
+zak_confi_file_plugin_finalize (GObject *object)
 {
-       ConfiFilePlugin *plugin = CONFI_FILE_PLUGIN (object);
+       ZakConfiFilePlugin *plugin = ZAK_CONFI_FILE_PLUGIN (object);
 
-       G_OBJECT_CLASS (confi_file_plugin_parent_class)->finalize (object);
+       G_OBJECT_CLASS (zak_confi_file_plugin_parent_class)->finalize (object);
 }
 
 gboolean
-confi_file_plugin_initialize (ConfiPluggable *pluggable, const gchar *cnc_string)
+zak_confi_file_plugin_initialize (ZakConfiPluggable *pluggable, const gchar *cnc_string)
 {
        gboolean ret;
        GError *error;
 
-       ConfiFilePlugin *plugin = CONFI_FILE_PLUGIN (pluggable);
-       ConfiFilePluginPrivate *priv = CONFI_FILE_PLUGIN_GET_PRIVATE (plugin);
+       ZakConfiFilePlugin *plugin = ZAK_CONFI_FILE_PLUGIN (pluggable);
+       ZakConfiFilePluginPrivate *priv = ZAK_CONFI_FILE_PLUGIN_GET_PRIVATE (plugin);
 
        priv->cnc_string = g_strdup (cnc_string);
 
@@ -196,7 +196,7 @@ confi_file_plugin_initialize (ConfiPluggable *pluggable, const gchar *cnc_string
 }
 
 static gboolean
-confi_file_plugin_path_get_group_and_key (ConfiPluggable *pluggable, const gchar *path, gchar **group, gchar **key)
+zak_confi_file_plugin_path_get_group_and_key (ZakConfiPluggable *pluggable, const gchar *path, gchar **group, gchar **key)
 {
        gchar *path_;
        gchar **tokens;
@@ -242,7 +242,7 @@ confi_file_plugin_path_get_group_and_key (ConfiPluggable *pluggable, const gchar
 }
 
 static gchar
-*confi_file_plugin_path_get_value_from_file (ConfiPluggable *pluggable, const gchar *path)
+*zak_confi_file_plugin_path_get_value_from_file (ZakConfiPluggable *pluggable, const gchar *path)
 {
        gchar *ret;
 
@@ -251,13 +251,13 @@ static gchar
 
        GError *error;
 
-       ConfiFilePluginPrivate *priv = CONFI_FILE_PLUGIN_GET_PRIVATE (pluggable);
+       ZakConfiFilePluginPrivate *priv = ZAK_CONFI_FILE_PLUGIN_GET_PRIVATE (pluggable);
 
        if (path == NULL) return NULL;
 
        group = NULL;
        key = NULL;
-       if (!confi_file_plugin_path_get_group_and_key (pluggable, path, &group, &key))
+       if (!zak_confi_file_plugin_path_get_group_and_key (pluggable, path, &group, &key))
                {
                        return NULL;
                }
@@ -279,12 +279,12 @@ static gchar
 }
 
 static void
-confi_file_plugin_get_children (ConfiPluggable *pluggable, GNode *parentNode)
+zak_confi_file_plugin_get_children (ZakConfiPluggable *pluggable, GNode *parentNode)
 {
        gchar **groups;
        gchar **keys;
-       guint lg;
-       guint lk;
+       gsize lg;
+       gsize lk;
        guint g;
        guint k;
 
@@ -295,13 +295,13 @@ confi_file_plugin_get_children (ConfiPluggable *pluggable, GNode *parentNode)
 
        GNode *gNode;
 
-       ConfiFilePluginPrivate *priv = CONFI_FILE_PLUGIN_GET_PRIVATE (pluggable);
+       ZakConfiFilePluginPrivate *priv = ZAK_CONFI_FILE_PLUGIN_GET_PRIVATE (pluggable);
 
        groups = g_key_file_get_groups (priv->kfile, &lg);
 
        for (g = 0; g < lg; g++)
                {
-                       ConfiKey *ck = g_new0 (ConfiKey, 1);
+                       ZakConfiKey *ck = g_new0 (ZakConfiKey, 1);
 
                        ck->key = g_strdup (groups[g]);
                        ck->value = "";
@@ -316,11 +316,11 @@ confi_file_plugin_get_children (ConfiPluggable *pluggable, GNode *parentNode)
                                {
                                        for (k = 0; k < lk; k++)
                                                {
-                                                       ConfiKey *ck = g_new0 (ConfiKey, 1);
+                                                       ZakConfiKey *ck = g_new0 (ZakConfiKey, 1);
 
                                                        ck->key = g_strdup (keys[k]);
                                                        ck->path = g_strdup (groups[g]);
-                                                       ck->value = confi_file_plugin_path_get_value (pluggable, g_strdup_printf ("%s/%s", groups[g], keys[k]));
+                                                       ck->value = zak_confi_file_plugin_path_get_value (pluggable, g_strdup_printf ("%s/%s", groups[g], keys[k]));
                                                        ck->description = g_key_file_get_comment (priv->kfile, groups[g], keys[k], NULL);
 
                                                        g_node_append_data (gNode, ck);
@@ -340,17 +340,17 @@ confi_file_plugin_get_children (ConfiPluggable *pluggable, GNode *parentNode)
 }
 
 static GList
-*confi_file_plugin_get_configs_list (ConfiPluggable *pluggable,
+*zak_confi_file_plugin_get_configs_list (ZakConfiPluggable *pluggable,
                                      const gchar *filter)
 {
        GList *lst;
 
-       ConfiFilePluginPrivate *priv = CONFI_FILE_PLUGIN_GET_PRIVATE (pluggable);
+       ZakConfiFilePluginPrivate *priv = ZAK_CONFI_FILE_PLUGIN_GET_PRIVATE (pluggable);
 
        lst = NULL;
 
-       ConfiConfi *confi;
-       confi = g_new0 (ConfiConfi, 1);
+       ZakConfiConfi *confi;
+       confi = g_new0 (ZakConfiConfi, 1);
        confi->name = g_strdup (priv->name);
        confi->description = g_strdup (priv->description);
        lst = g_list_append (lst, confi);
@@ -359,28 +359,28 @@ static GList
 }
 
 static gchar
-*confi_file_plugin_path_get_value (ConfiPluggable *pluggable, const gchar *path)
+*zak_confi_file_plugin_path_get_value (ZakConfiPluggable *pluggable, const gchar *path)
 {
        gchar *ret;
        gchar *path_;
 
-       ConfiFilePluginPrivate *priv = CONFI_FILE_PLUGIN_GET_PRIVATE (pluggable);
+       ZakConfiFilePluginPrivate *priv = ZAK_CONFI_FILE_PLUGIN_GET_PRIVATE (pluggable);
 
        ret = NULL;
 
-       path_ = confi_path_normalize (pluggable, path);
+       path_ = zak_confi_path_normalize (pluggable, path);
        if (path_ == NULL)
                {
                        return NULL;
                }
 
-       ret = confi_file_plugin_path_get_value_from_file (pluggable, path_);
+       ret = zak_confi_file_plugin_path_get_value_from_file (pluggable, path_);
 
        return ret;
 }
 
 static gboolean
-confi_file_plugin_path_set_value (ConfiPluggable *pluggable, const gchar *path, const gchar *value)
+zak_confi_file_plugin_path_set_value (ZakConfiPluggable *pluggable, const gchar *path, const gchar *value)
 {
        gboolean ret;
 
@@ -389,13 +389,13 @@ confi_file_plugin_path_set_value (ConfiPluggable *pluggable, const gchar *path,
 
        GError *error;
 
-       ConfiFilePluginPrivate *priv = CONFI_FILE_PLUGIN_GET_PRIVATE (pluggable);
+       ZakConfiFilePluginPrivate *priv = ZAK_CONFI_FILE_PLUGIN_GET_PRIVATE (pluggable);
 
        g_return_val_if_fail (value != NULL, FALSE);
 
        group = NULL;
        key = NULL;
-       if (!confi_file_plugin_path_get_group_and_key (pluggable, path, &group, &key))
+       if (!zak_confi_file_plugin_path_get_group_and_key (pluggable, path, &group, &key))
                {
                        return FALSE;
                }
@@ -415,13 +415,13 @@ confi_file_plugin_path_set_value (ConfiPluggable *pluggable, const gchar *path,
 }
 
 GNode
-*confi_file_plugin_get_tree (ConfiPluggable *pluggable)
+*zak_confi_file_plugin_get_tree (ZakConfiPluggable *pluggable)
 {
        GNode *node;
 
-       ConfiFilePluginPrivate *priv = CONFI_FILE_PLUGIN_GET_PRIVATE (pluggable);
+       ZakConfiFilePluginPrivate *priv = ZAK_CONFI_FILE_PLUGIN_GET_PRIVATE (pluggable);
 
-       ConfiKey *ck = g_new0 (ConfiKey, 1);
+       ZakConfiKey *ck = g_new0 (ZakConfiKey, 1);
 
        ck->path = "";
        ck->description = "";
@@ -430,33 +430,33 @@ GNode
 
        node = g_node_new (ck);
 
-       confi_file_plugin_get_children (pluggable, node);
+       zak_confi_file_plugin_get_children (pluggable, node);
 
        return node;
 }
 
-static ConfiKey
-*confi_file_plugin_add_key (ConfiPluggable *pluggable, const gchar *parent, const gchar *key, const gchar *value)
+static ZakConfiKey
+*zak_confi_file_plugin_add_key (ZakConfiPluggable *pluggable, const gchar *parent, const gchar *key, const gchar *value)
 {
-       ConfiKey *ck;
+       ZakConfiKey *ck;
        gchar *path;
 
        gchar *group;
        gchar *key_;
 
-       ConfiFilePluginPrivate *priv = CONFI_FILE_PLUGIN_GET_PRIVATE (pluggable);
+       ZakConfiFilePluginPrivate *priv = ZAK_CONFI_FILE_PLUGIN_GET_PRIVATE (pluggable);
 
        ck = NULL;
        path = g_strdup_printf ("%s/%s", parent, key);
-       if (confi_file_plugin_path_set_value (pluggable, path, value))
+       if (zak_confi_file_plugin_path_set_value (pluggable, path, value))
                {
                        group = NULL;
                        key_ = NULL;
-                       if (confi_file_plugin_path_get_group_and_key (pluggable, path, &group, &key_))
+                       if (zak_confi_file_plugin_path_get_group_and_key (pluggable, path, &group, &key_))
                                {
-                                       ck = g_new0 (ConfiKey, 1);
+                                       ck = g_new0 (ZakConfiKey, 1);
                                        ck->key = g_strdup (key);
-                                       ck->value = confi_file_plugin_path_get_value (pluggable, path);
+                                       ck->value = zak_confi_file_plugin_path_get_value (pluggable, path);
                                        ck->description = g_key_file_get_comment (priv->kfile, group, key, NULL);;
                                        ck->path = g_strdup (path);
 
@@ -470,34 +470,34 @@ static ConfiKey
 }
 
 static gboolean
-confi_file_plugin_key_set_key (ConfiPluggable *pluggable,
-                               ConfiKey *ck)
+zak_confi_file_plugin_key_set_key (ZakConfiPluggable *pluggable,
+                               ZakConfiKey *ck)
 {
        gboolean ret;
 
        gchar *path;
 
-       ConfiFilePluginPrivate *priv = CONFI_FILE_PLUGIN_GET_PRIVATE (pluggable);
+       ZakConfiFilePluginPrivate *priv = ZAK_CONFI_FILE_PLUGIN_GET_PRIVATE (pluggable);
 
        path = g_strdup_printf ("%s/%s", ck->path, ck->key);
-       ret = confi_file_plugin_path_set_value (pluggable, path, ck->value);
+       ret = zak_confi_file_plugin_path_set_value (pluggable, path, ck->value);
        g_free (path);
 
        return ret;
 }
 
-static ConfiKey
-*confi_file_plugin_path_get_confi_key (ConfiPluggable *pluggable, const gchar *path)
+static ZakConfiKey
+*zak_confi_file_plugin_path_get_confi_key (ZakConfiPluggable *pluggable, const gchar *path)
 {
        gchar *path_;
-       ConfiKey *ck;
+       ZakConfiKey *ck;
 
        gchar *group;
        gchar *key;
 
-       ConfiFilePluginPrivate *priv = CONFI_FILE_PLUGIN_GET_PRIVATE (pluggable);
+       ZakConfiFilePluginPrivate *priv = ZAK_CONFI_FILE_PLUGIN_GET_PRIVATE (pluggable);
 
-       path_ = confi_path_normalize (pluggable, path);
+       path_ = zak_confi_path_normalize (pluggable, path);
        if (path_ == NULL)
                {
                        return NULL;
@@ -505,11 +505,11 @@ static ConfiKey
 
        group = NULL;
        key = NULL;
-       if (confi_file_plugin_path_get_group_and_key (pluggable, path_, &group, &key))
+       if (zak_confi_file_plugin_path_get_group_and_key (pluggable, path_, &group, &key))
                {
-                       ck = g_new0 (ConfiKey, 1);
+                       ck = g_new0 (ZakConfiKey, 1);
                        ck->key = g_strdup (key);
-                       ck->value = confi_file_plugin_path_get_value (pluggable, path_);
+                       ck->value = zak_confi_file_plugin_path_get_value (pluggable, path_);
                        ck->description = g_key_file_get_comment (priv->kfile, group, key, NULL);
                        ck->path = g_strdup (group);
 
@@ -526,7 +526,7 @@ static ConfiKey
 }
 
 static gboolean
-confi_file_plugin_remove_path (ConfiPluggable *pluggable, const gchar *path)
+zak_confi_file_plugin_remove_path (ZakConfiPluggable *pluggable, const gchar *path)
 {
        gboolean ret;
 
@@ -535,11 +535,11 @@ confi_file_plugin_remove_path (ConfiPluggable *pluggable, const gchar *path)
 
        GError *error;
 
-       ConfiFilePluginPrivate *priv = CONFI_FILE_PLUGIN_GET_PRIVATE (pluggable);
+       ZakConfiFilePluginPrivate *priv = ZAK_CONFI_FILE_PLUGIN_GET_PRIVATE (pluggable);
 
        group = NULL;
        key = NULL;
-       if (confi_file_plugin_path_get_group_and_key (pluggable, path, &group, &key))
+       if (zak_confi_file_plugin_path_get_group_and_key (pluggable, path, &group, &key))
                {
                        error = NULL;
                        ret = g_key_file_remove_key (priv->kfile, group, key, &error);
@@ -558,12 +558,12 @@ confi_file_plugin_remove_path (ConfiPluggable *pluggable, const gchar *path)
 }
 
 static gboolean
-confi_file_plugin_remove (ConfiPluggable *pluggable)
+zak_confi_file_plugin_remove (ZakConfiPluggable *pluggable)
 {
        gboolean ret;
        GFile *gfile;
 
-       ConfiFilePluginPrivate *priv = CONFI_FILE_PLUGIN_GET_PRIVATE (pluggable);
+       ZakConfiFilePluginPrivate *priv = ZAK_CONFI_FILE_PLUGIN_GET_PRIVATE (pluggable);
 
        ret = TRUE;
 
@@ -578,15 +578,15 @@ confi_file_plugin_remove (ConfiPluggable *pluggable)
 }
 
 static void
-confi_file_plugin_class_init (ConfiFilePluginClass *klass)
+zak_confi_file_plugin_class_init (ZakConfiFilePluginClass *klass)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-       g_type_class_add_private (object_class, sizeof (ConfiFilePluginPrivate));
+       g_type_class_add_private (object_class, sizeof (ZakConfiFilePluginPrivate));
 
-       object_class->set_property = confi_file_plugin_set_property;
-       object_class->get_property = confi_file_plugin_get_property;
-       object_class->finalize = confi_file_plugin_finalize;
+       object_class->set_property = zak_confi_file_plugin_set_property;
+       object_class->get_property = zak_confi_file_plugin_get_property;
+       object_class->finalize = zak_confi_file_plugin_finalize;
 
        g_object_class_override_property (object_class, PROP_CNC_STRING, "cnc_string");
        g_object_class_override_property (object_class, PROP_NAME, "name");
@@ -595,31 +595,31 @@ confi_file_plugin_class_init (ConfiFilePluginClass *klass)
 }
 
 static void
-confi_pluggable_iface_init (ConfiPluggableInterface *iface)
+zak_confi_pluggable_iface_init (ZakConfiPluggableInterface *iface)
 {
-       iface->initialize = confi_file_plugin_initialize;
-       iface->get_configs_list = confi_file_plugin_get_configs_list;
-       iface->path_get_value = confi_file_plugin_path_get_value;
-       iface->path_set_value = confi_file_plugin_path_set_value;
-       iface->get_tree = confi_file_plugin_get_tree;
-       iface->add_key = confi_file_plugin_add_key;
-       iface->key_set_key = confi_file_plugin_key_set_key;
-       iface->path_get_confi_key = confi_file_plugin_path_get_confi_key;
-       iface->remove_path = confi_file_plugin_remove_path;
-       iface->remove = confi_file_plugin_remove;
+       iface->initialize = zak_confi_file_plugin_initialize;
+       iface->get_configs_list = zak_confi_file_plugin_get_configs_list;
+       iface->path_get_value = zak_confi_file_plugin_path_get_value;
+       iface->path_set_value = zak_confi_file_plugin_path_set_value;
+       iface->get_tree = zak_confi_file_plugin_get_tree;
+       iface->add_key = zak_confi_file_plugin_add_key;
+       iface->key_set_key = zak_confi_file_plugin_key_set_key;
+       iface->path_get_confi_key = zak_confi_file_plugin_path_get_confi_key;
+       iface->remove_path = zak_confi_file_plugin_remove_path;
+       iface->remove = zak_confi_file_plugin_remove;
 }
 
 static void
-confi_file_plugin_class_finalize (ConfiFilePluginClass *klass)
+zak_confi_file_plugin_class_finalize (ZakConfiFilePluginClass *klass)
 {
 }
 
 G_MODULE_EXPORT void
 peas_register_types (PeasObjectModule *module)
 {
-       confi_file_plugin_register_type (G_TYPE_MODULE (module));
+       zak_confi_file_plugin_register_type (G_TYPE_MODULE (module));
 
        peas_object_module_register_extension_type (module,
-                                                   CONFI_TYPE_PLUGGABLE,
-                                                   CONFI_TYPE_FILE_PLUGIN);
+                                                   ZAK_CONFI_TYPE_PLUGGABLE,
+                                                   ZAK_CONFI_TYPE_FILE_PLUGIN);
 }
index 9ef071ba372224cc39632789644feef3c9f1a68c..3a3a44034f7f2e09c120b0a2b465ae69dd06fb7f 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * plgfile.h
- * This file is part of confi
+ * This file is part of libzakconfi
  *
- * Copyright (C) 2014 Andrea Zagli
+ * Copyright (C) 2014-2016 Andrea Zagli <azagli@libero.it>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU Library General Public License as published by
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-#ifndef __CONFI_FILE_PLUGIN_H__
-#define __CONFI_FILE_PLUGIN_H__
+#ifndef __ZAK_CONFI_FILE_PLUGIN_H__
+#define __ZAK_CONFI_FILE_PLUGIN_H__
 
 #include <libpeas/peas.h>
 
 G_BEGIN_DECLS
 
-#define CONFI_TYPE_FILE_PLUGIN         (confi_file_plugin_get_type ())
-#define CONFI_FILE_PLUGIN(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), CONFI_TYPE_FILE_PLUGIN, ConfiFilePlugin))
-#define CONFI_FILE_PLUGIN_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), CONFI_TYPE_FILE_PLUGIN, ConfiFilePlugin))
-#define CONFI_IS_FILE_PLUGIN(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), CONFI_TYPE_FILE_PLUGIN))
-#define CONFI_IS_FILE_PLUGIN_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), CONFI_TYPE_FILE_PLUGIN))
-#define CONFI_FILE_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CONFI_TYPE_FILE_PLUGIN, ConfiFilePluginClass))
+#define ZAK_CONFI_TYPE_FILE_PLUGIN         (zak_confi_file_plugin_get_type ())
+#define ZAK_CONFI_FILE_PLUGIN(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), ZAK_CONFI_TYPE_FILE_PLUGIN, ZakConfiFilePlugin))
+#define ZAK_CONFI_FILE_PLUGIN_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), ZAK_CONFI_TYPE_FILE_PLUGIN, ZakConfiFilePlugin))
+#define ZAK_CONFI_IS_FILE_PLUGIN(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), ZAK_CONFI_TYPE_FILE_PLUGIN))
+#define ZAK_CONFI_IS_FILE_PLUGIN_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), ZAK_CONFI_TYPE_FILE_PLUGIN))
+#define ZAK_CONFI_FILE_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ZAK_CONFI_TYPE_FILE_PLUGIN, ZakConfiFilePluginClass))
 
-typedef struct _ConfiFilePlugin       ConfiFilePlugin;
-typedef struct _ConfiFilePluginClass  ConfiFilePluginClass;
+typedef struct _ZakConfiFilePlugin       ZakConfiFilePlugin;
+typedef struct _ZakConfiFilePluginClass  ZakConfiFilePluginClass;
 
-struct _ConfiFilePlugin {
+struct _ZakConfiFilePlugin {
        PeasExtensionBase parent_instance;
 };
 
-struct _ConfiFilePluginClass {
+struct _ZakConfiFilePluginClass {
        PeasExtensionBaseClass parent_class;
 };
 
-GType                 confi_file_plugin_get_type        (void) G_GNUC_CONST;
+GType                 zak_confi_file_plugin_get_type        (void) G_GNUC_CONST;
 G_MODULE_EXPORT void  peas_register_types                         (PeasObjectModule *module);
 
 G_END_DECLS
 
-#endif /* __CONFI_FILE_PLUGIN_H__ */
+#endif /* __ZAK_CONFI_FILE_PLUGIN_H__ */
index 83ff6afbd7a733913a4fc7339bbdbbff122459f6..d9d0262de8985dd98b67989218a0e142f1f9a63e 100644 (file)
@@ -2,23 +2,23 @@ AM_CPPFLAGS = $(WARN_CFLAGS) \
               $(DISABLE_DEPRECATED_CFLAGS) \
               $(LIBCONFI_CFLAGS) \
               -DPLUGINSDIR=\""$(libdir)/$(PACKAGE)/plugins"\" \
-              -DG_LOG_DOMAIN=\"Confi\"
+              -DG_LOG_DOMAIN=\"ZakConfi\"
 
 LIBS = $(LIBCONFI_LIBS)
 
-lib_LTLIBRARIES = libconfi.la
+lib_LTLIBRARIES = libzakconfi.la
 
-libconfi_la_SOURCES = commons.c \
-                      libconfi.c \
-                      confipluggable.c
+libzakconfi_la_SOURCES = commons.c \
+                         confi.c \
+                         confipluggable.c
 
-libconfi_la_LDFLAGS = -no-undefined
+libzakconfi_la_LDFLAGS = -no-undefined
 
-libconfi_include_HEADERS = commons.h \
-                  libconfi.h \
-                  confipluggable.h
+libzakconfi_include_HEADERS = commons.h \
+                              libzakconfi.h \
+                              confipluggable.h
 
-libconfi_includedir = $(includedir)/libconfi
+libzakconfi_includedir = $(includedir)/libzakconfi
 
 install-exec-hook:
        mkdir -p "$(libdir)/$(PACKAGE)/plugins"
@@ -35,14 +35,14 @@ INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir)
 INTROSPECTION_SCANNER_ENV = CC="$(CC)"
 
 if HAVE_INTROSPECTION
-introspection_sources = $(libconfi_la_SOURCES) $(libconfi_include_HEADERS)
+introspection_sources = $(libzakconfi_la_SOURCES) $(libzakconfi_include_HEADERS)
 
-Confi-1.0.gir: libconfi.la
-Confi_1_0_gir_INCLUDES = Gda-5.0 Peas-1.0
-Confi_1_0_gir_CFLAGS = $(AM_CPPFLAGS)
-Confi_1_0_gir_LIBS = libconfi.la
-Confi_1_0_gir_FILES = $(introspection_sources)
-INTROSPECTION_GIRS += Confi-1.0.gir
+ZakConfi-1.0.gir: libzakconfi.la
+ZakConfi_1_0_gir_INCLUDES = Gda-5.0 Peas-1.0
+ZakConfi_1_0_gir_CFLAGS = $(AM_CPPFLAGS)
+ZakConfi_1_0_gir_LIBS = libzakconfi.la
+ZakConfi_1_0_gir_FILES = $(introspection_sources)
+INTROSPECTION_GIRS += ZakConfi-1.0.gir
 
 girdir = $(datadir)/gir-1.0
 gir_DATA = $(INTROSPECTION_GIRS)
@@ -51,4 +51,4 @@ typelibdir = $(libdir)/girepository-1.0
 typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
 
 CLEANFILES += $(gir_DATA) $(typelib_DATA)
-endif
\ No newline at end of file
+endif
index fab690fe20b3bb2dfa77d3620a44086353277cd6..5b01a8dc08ac01659a6e0630ba02ee16deee4882 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * commons.c
- * This file is part of libconfi
+ * This file is part of libzakconfi
  *
- * Copyright (C) 2014 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2014-2016 Andrea Zagli <azagli@libero.it>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU Library General Public License as published by
 
 #include <commons.h>
 
-ConfiConfi
-*confi_confi_copy (ConfiConfi *confi)
+ZakConfiConfi
+*zak_confi_confi_copy (ZakConfiConfi *confi)
 {
-       ConfiConfi *b;
+       ZakConfiConfi *b;
 
-       b = g_slice_new (ConfiConfi);
+       b = g_slice_new (ZakConfiConfi);
        b->name = g_strdup (confi->name);
        b->description = g_strdup (confi->description);
 
@@ -38,21 +38,21 @@ ConfiConfi
 }
 
 void
-confi_confi_free (ConfiConfi *confi)
+zak_confi_confi_free (ZakConfiConfi *confi)
 {
        g_free (confi->name);
        g_free (confi->description);
-       g_slice_free (ConfiConfi, confi);
+       g_slice_free (ZakConfiConfi, confi);
 }
 
-G_DEFINE_BOXED_TYPE (ConfiConfi, confi_confi, confi_confi_copy, confi_confi_free)
+G_DEFINE_BOXED_TYPE (ZakConfiConfi, zak_confi_confi, zak_confi_confi_copy, zak_confi_confi_free)
 
-ConfiKey
-*confi_key_copy (ConfiKey *key)
+ZakConfiKey
+*zak_confi_key_copy (ZakConfiKey *key)
 {
-       ConfiKey *b;
+       ZakConfiKey *b;
 
-       b = g_slice_new (ConfiKey);
+       b = g_slice_new (ZakConfiKey);
        b->id_config = key->id_config;
        b->id = key->id;
        b->id_parent = key->id_parent;
@@ -65,13 +65,13 @@ ConfiKey
 }
 
 void
-confi_key_free (ConfiKey *key)
+zak_confi_key_free (ZakConfiKey *key)
 {
        g_free (key->key);
        g_free (key->value);
        g_free (key->description);
        g_free (key->path);
-       g_slice_free (ConfiKey, key);
+       g_slice_free (ZakConfiKey, key);
 }
 
-G_DEFINE_BOXED_TYPE (ConfiKey, confi_key, confi_key_copy, confi_key_free)
+G_DEFINE_BOXED_TYPE (ZakConfiKey, zak_confi_key, zak_confi_key_copy, zak_confi_key_free)
index 38ebe18033381621119a65f4cb8c8c478a076474..f3a866cf5b40b9ff9727985098257f6bc62afd71 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (C) 2014 Andrea Zagli <azagli@libero.it>
+ *  Copyright (C) 2014-2016 Andrea Zagli <azagli@libero.it>
  *
  *  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
@@ -16,8 +16,8 @@
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-#ifndef __LIBCONFI_COMMONS_H__
-#define __LIBCONFI_COMMONS_H__
+#ifndef __LIBZAKCONFI_COMMONS_H__
+#define __LIBZAKCONFI_COMMONS_H__
 
 #include <glib-object.h>
 
 G_BEGIN_DECLS
 
 
-#define CONFI_TYPE_CONFI (confi_confi_get_type ())
+#define ZAK_CONFI_TYPE_CONFI (zak_confi_confi_get_type ())
 
-GType confi_confi_get_type ();
+GType zak_confi_confi_get_type ();
 
-typedef struct _ConfiConfi ConfiConfi;
-struct _ConfiConfi
+typedef struct _ZakConfiConfi ZakConfiConfi;
+struct _ZakConfiConfi
        {
                gchar *name;
                gchar *description;
        };
 
-ConfiConfi *confi_confi_copy (ConfiConfi *confi);
-void confi_confi_free (ConfiConfi *confi);
+ZakConfiConfi *zak_confi_confi_copy (ZakConfiConfi *confi);
+void zak_confi_confi_free (ZakConfiConfi *confi);
 
-#define CONFI_TYPE_KEY (confi_key_get_type ())
+#define ZAK_CONFI_TYPE_KEY (zak_confi_key_get_type ())
 
-GType confi_key_get_type ();
+GType zak_confi_key_get_type ();
 
-typedef struct _ConfiKey ConfiKey;
-struct _ConfiKey
+typedef struct _ZakConfiKey ZakConfiKey;
+struct _ZakConfiKey
        {
                gint id_config;
                gint id;
@@ -55,10 +55,10 @@ struct _ConfiKey
                gchar *path;
        };
 
-ConfiKey *confi_key_copy (ConfiKey *key);
-void confi_key_free (ConfiKey *key);
+ZakConfiKey *zak_confi_key_copy (ZakConfiKey *key);
+void zak_confi_key_free (ZakConfiKey *key);
 
 
 G_END_DECLS
 
-#endif /* __LIBCONFI_COMMONS_H__ */
+#endif /* __LIBZAKCONFI_COMMONS_H__ */
diff --git a/src/confi.c b/src/confi.c
new file mode 100644 (file)
index 0000000..6c30627
--- /dev/null
@@ -0,0 +1,608 @@
+/*
+ *  Copyright (C) 2005-2016 Andrea Zagli <azagli@libero.it>
+ *
+ *  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.
+ */
+
+#ifdef HAVE_CONFIG_H
+       #include <config.h>
+#endif
+
+#include <string.h>
+
+#include <libgdaex/libgdaex.h>
+
+#include "libzakconfi.h"
+
+
+enum
+{
+       PROP_0,
+       PROP_ID_CONFIG,
+       PROP_NAME,
+       PROP_DESCRIPTION,
+       PROP_ROOT
+};
+
+static void zak_confi_class_init (ZakConfiClass *klass);
+static void zak_confi_init (ZakConfi *confi);
+
+static void zak_confi_set_property (GObject *object,
+                                guint property_id,
+                                const GValue *value,
+                                GParamSpec *pspec);
+static void zak_confi_get_property (GObject *object,
+                                guint property_id,
+                                GValue *value,
+                                GParamSpec *pspec);
+
+static ZakConfiPluggable *zak_confi_get_confi_pluggable_from_cnc_string (const gchar *cnc_string);
+
+#define ZAK_CONFI_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_TYPE_CONFI, ZakConfiPrivate))
+
+typedef struct _ZakConfiPrivate ZakConfiPrivate;
+struct _ZakConfiPrivate
+       {
+               GdaEx *gdaex;
+               gint id_config;
+               gchar *name;
+               gchar *description;
+               gchar *root;
+               GHashTable *values;
+
+               gchar chrquot;
+
+               ZakConfiPluggable *pluggable;
+       };
+
+G_DEFINE_TYPE (ZakConfi, zak_confi, G_TYPE_OBJECT)
+
+static void
+zak_confi_class_init (ZakConfiClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+       g_type_class_add_private (object_class, sizeof (ZakConfiPrivate));
+
+       object_class->set_property = zak_confi_set_property;
+       object_class->get_property = zak_confi_get_property;
+}
+
+static void
+zak_confi_init (ZakConfi *confi)
+{
+       ZakConfiPrivate *priv = ZAK_CONFI_GET_PRIVATE (confi);
+
+       priv->pluggable = NULL;
+}
+
+static ZakConfiPluggable
+*zak_confi_get_confi_pluggable_from_cnc_string (const gchar *cnc_string)
+{
+       ZakConfiPluggable *pluggable;
+
+       const GList *lst_plugins;
+
+       pluggable = NULL;
+
+       PeasEngine *peas_engine;
+
+       peas_engine = peas_engine_get_default ();
+       if (peas_engine == NULL)
+               {
+                       return NULL;
+               }
+
+       peas_engine_add_search_path (peas_engine, PLUGINSDIR, NULL);
+
+       lst_plugins = peas_engine_get_plugin_list (peas_engine);
+       while (lst_plugins)
+               {
+                       PeasPluginInfo *ppinfo;
+                       gchar *uri;
+
+                       ppinfo = (PeasPluginInfo *)lst_plugins->data;
+
+                       uri = g_strdup_printf ("%s://", peas_plugin_info_get_module_name (ppinfo));
+                       if (g_str_has_prefix (cnc_string, uri))
+                               {
+                                       if (peas_engine_load_plugin (peas_engine, ppinfo))
+                                               {
+                                                       PeasExtension *ext;
+                                                       ext = peas_engine_create_extension (peas_engine, ppinfo, ZAK_CONFI_TYPE_PLUGGABLE,
+                                                                                           "cnc_string", cnc_string + strlen (uri),
+                                                                                           NULL);
+                                                       pluggable = (ZakConfiPluggable *)ext;
+                                                       break;
+                                               }
+                               }
+                       g_free (uri);
+
+                       lst_plugins = g_list_next (lst_plugins);
+               }
+
+       if (pluggable == NULL)
+               {
+                       g_warning ("No plugin found for connection string \"%s\".", cnc_string);
+               }
+
+       return pluggable;
+}
+
+/**
+ * zak_confi_new:
+ * @cnc_string: the connection string.
+ *
+ * Returns: (transfer none): the newly created #ZakConfi object, or NULL if it fails.
+ */
+ZakConfi
+*zak_confi_new (const gchar *cnc_string)
+{
+       ZakConfi *confi;
+       ZakConfiPrivate *priv;
+       ZakConfiPluggable *pluggable;
+
+       g_return_val_if_fail (cnc_string != NULL, NULL);
+
+       confi = NULL;
+
+       pluggable = zak_confi_get_confi_pluggable_from_cnc_string (cnc_string);
+       if (pluggable != NULL)
+               {
+                       confi = ZAK_CONFI (g_object_new (zak_confi_get_type (), NULL));
+                       priv = ZAK_CONFI_GET_PRIVATE (confi);
+                       priv->pluggable = pluggable;
+               }
+
+       return confi;
+}
+
+PeasPluginInfo
+*zak_confi_get_plugin_info (ZakConfi *confi)
+{
+       PeasPluginInfo *ppinfo;
+
+       ZakConfiPrivate *priv = ZAK_CONFI_GET_PRIVATE (confi);
+
+       if (priv->pluggable == NULL)
+               {
+                       g_warning ("Not initialized.");
+                       ppinfo = NULL;
+               }
+       else
+               {
+                       ppinfo = peas_extension_base_get_plugin_info ((PeasExtensionBase *)priv->pluggable);
+               }
+
+       return ppinfo;
+}
+
+/**
+ * zak_confi_get_configs_list:
+ * @cnc_string: the connection string to use to connect to database that
+ * contains configuration.
+ * @filter: (nullable):
+ *
+ * Returns: (element-type ZakConfi) (transfer container):  a #GList of #ZakConfiZakConfi. If there's no configurations, returns a valid
+ * #GList but with a unique NULL element.
+ */
+GList
+*zak_confi_get_configs_list (const gchar *cnc_string,
+                         const gchar *filter)
+{
+       ZakConfiPluggable *pluggable;
+       GList *lst;
+
+       lst = NULL;
+
+       pluggable = zak_confi_get_confi_pluggable_from_cnc_string (cnc_string);
+
+       if (pluggable != NULL)
+               {
+                       lst = zak_confi_pluggable_get_configs_list (pluggable, filter);
+               }
+
+       return lst;
+}
+
+/**
+ * zak_confi_get_tree:
+ * @confi: a #ZakConfi object.
+ *
+ * Returns: a #GNode.
+ */
+GNode
+*zak_confi_get_tree (ZakConfi *confi)
+{
+       ZakConfiPrivate *priv = ZAK_CONFI_GET_PRIVATE (confi);
+
+       if (priv->pluggable != NULL)
+               {
+                       return zak_confi_pluggable_get_tree (priv->pluggable);
+               }
+       else
+               {
+                       return NULL;
+               }
+}
+
+/**
+ * zak_confi_normalize_set_root:
+ * @confi: a #ZakConfi object.
+ * @root: the root.
+ *
+ * Returns: a correct value for root property.
+ */
+gchar
+*zak_confi_normalize_root (const gchar *root)
+{
+       GString *root_;
+       gchar *strret;
+
+       if (root == NULL)
+               {
+                       root_ = g_string_new ("/");
+               }
+       else
+               {
+                       root_ = g_string_new (root);
+                       g_strstrip (root_->str);
+                       if (g_strcmp0 (root_->str, "") == 0)
+                               {
+                                       g_string_printf (root_, "/");
+                               }
+                       else
+                               {
+                                       if (root_->str[0] != '/')
+                                               {
+                                                       g_string_prepend (root_, "/");
+                                               }
+                                       if (root_->str[root_->len - 1] != '/')
+                                               {
+                                                       g_string_append (root_, "/");
+                                               }
+                               }
+               }
+
+       strret = g_strdup (root_->str);
+       g_string_free (root_, TRUE);
+
+       return strret;
+}
+
+/**
+ * zak_confi_set_root:
+ * @confi: a #ZakConfi object.
+ * @root: the root.
+ *
+ */
+gboolean
+zak_confi_set_root (ZakConfi *confi, const gchar *root)
+{
+       gboolean ret;
+
+       ZakConfiPrivate *priv = ZAK_CONFI_GET_PRIVATE (confi);
+
+       if (priv->pluggable == NULL)
+               {
+                       g_warning ("Not initialized.");
+                       ret = FALSE;
+               }
+       else
+               {
+                       g_object_set (priv->pluggable, "root", root, NULL);
+                       ret = TRUE;
+               }
+
+       return ret;
+}
+
+/**
+ * zak_confi_add_key:
+ * @confi: a #ZakConfi object.
+ * @parent: the path where add the key.
+ * @key: the key's name.
+ * @value: the key's value.
+ *
+ * Returns: a #ZakConfigKey struct filled with data from the key just added.
+ */
+ZakConfiKey
+*zak_confi_add_key (ZakConfi *confi, const gchar *parent, const gchar *key, const gchar *value)
+{
+       ZakConfiKey *ck;
+
+       ZakConfiPrivate *priv = ZAK_CONFI_GET_PRIVATE (confi);
+
+       if (priv->pluggable == NULL)
+               {
+                       g_warning ("Not initialized.");
+                       ck = NULL;
+               }
+       else
+               {
+                       ck = zak_confi_pluggable_add_key (priv->pluggable, parent, key, value);
+               }
+
+       return ck;
+}
+
+/**
+ * zak_confi_key_set_key:
+ * @confi: a #ZakConfi object.
+ * @ck: a #ZakConfiKey struct.
+ *
+ */
+gboolean
+zak_confi_key_set_key (ZakConfi *confi,
+                   ZakConfiKey *ck)
+{
+       gboolean ret;
+
+       ZakConfiPrivate *priv = ZAK_CONFI_GET_PRIVATE (confi);
+
+       if (priv->pluggable == NULL)
+               {
+                       g_warning ("Not initialized.");
+                       ret = FALSE;
+               }
+       else
+               {
+                       ret = zak_confi_pluggable_key_set_key (priv->pluggable, ck);
+               }
+
+       return ret;
+}
+
+/**
+ * zak_confi_remove_path:
+ * @confi: a #ZakConfi object.
+ * @path: the path to remove.
+ *
+ * Removes @path and every child key.
+ */
+gboolean
+zak_confi_remove_path (ZakConfi *confi, const gchar *path)
+{
+       gboolean ret;
+       ZakConfiPrivate *priv = ZAK_CONFI_GET_PRIVATE (confi);
+
+       if (priv->pluggable == NULL)
+               {
+                       g_warning ("Not initialized.");
+                       ret = FALSE;
+               }
+       else
+               {
+                       ret = zak_confi_pluggable_remove_path (priv->pluggable, path);
+               }
+
+       return ret;
+}
+
+/**
+ * zak_confi_path_get_value:
+ * @confi: a #ZakConfi object.
+ * @path: the path from which retrieving the value.
+ *
+ * Returns: the configuration's value as a string.
+ */
+gchar
+*zak_confi_path_get_value (ZakConfi *confi, const gchar *path)
+{
+       gchar *ret;
+
+       ZakConfiPrivate *priv = ZAK_CONFI_GET_PRIVATE (confi);
+
+       if (priv->pluggable == NULL)
+               {
+                       g_warning ("Not initialized.");
+                       ret = NULL;
+               }
+       else
+               {
+                       ret = zak_confi_pluggable_path_get_value (priv->pluggable, path);
+               }
+
+       return ret;
+}
+
+/**
+ * zak_confi_path_set_value:
+ * @confi: a #ZakConfi object.
+ * @path: the key's path.
+ * @value: the value to set.
+ *
+ */
+gboolean
+zak_confi_path_set_value (ZakConfi *confi, const gchar *path, const gchar *value)
+{
+       gboolean ret;
+
+       ZakConfiPrivate *priv = ZAK_CONFI_GET_PRIVATE (confi);
+
+       if (priv->pluggable == NULL)
+               {
+                       g_warning ("Not initialized.");
+                       ret = FALSE;
+               }
+       else
+               {
+                       ret = zak_confi_pluggable_path_set_value (priv->pluggable, path, value);
+               }
+
+       return ret;
+}
+
+/**
+ * zak_confi_path_get_confi_key:
+ * @confi: a #ZakConfi object.
+ * @path: the key's path to get.
+ *
+ * Returns: (transfer full): a #ZakConfiKey from @path
+ */
+ZakConfiKey
+*zak_confi_path_get_confi_key (ZakConfi *confi, const gchar *path)
+{
+       ZakConfiKey *ck;
+
+       ZakConfiPrivate *priv = ZAK_CONFI_GET_PRIVATE (confi);
+
+       if (priv->pluggable == NULL)
+               {
+                       g_warning ("Not initialized.");
+                       ck = NULL;
+               }
+       else
+               {
+                       ck = zak_confi_pluggable_path_get_confi_key (priv->pluggable, path);
+               }
+
+       return ck;
+}
+
+/**
+ * zak_confi_remove:
+ * @confi: a #ZakConfi object.
+ *
+ * Remove a configuration from databases and destroy the relative object.
+ */
+gboolean
+zak_confi_remove (ZakConfi *confi)
+{
+       gboolean ret;
+
+       ZakConfiPrivate *priv = ZAK_CONFI_GET_PRIVATE (confi);
+
+       if (priv->pluggable == NULL)
+               {
+                       g_warning ("Not initialized.");
+                       ret = FALSE;
+               }
+       else
+               {
+                       ret = zak_confi_pluggable_remove (priv->pluggable);
+               }
+
+       if (ret)
+               {
+                       zak_confi_destroy (confi);
+               }
+
+       return ret;
+}
+
+/**
+ * zak_confi_destroy:
+ * @confi: a #ZakConfi object.
+ *
+ * Destroy the #ZakConfi object, freeing memory.
+ */
+void
+zak_confi_destroy (ZakConfi *confi)
+{
+       ZakConfiPrivate *priv = ZAK_CONFI_GET_PRIVATE (confi);
+
+       g_free (priv->name);
+       g_free (priv->description);
+       g_free (priv->root);
+       g_object_unref (priv->pluggable);
+}
+
+/**
+ * zak_confi_path_normalize:
+ * @pluggable: a #ZakConfiPluggable object.
+ *
+ * Returns: a normalize path (with root).
+ */
+gchar
+*zak_confi_path_normalize (ZakConfiPluggable *pluggable, const gchar *path)
+{
+       GString *ret;
+       gchar *strret;
+
+       guint lead;
+
+       gchar *root;
+
+       if (path == NULL)
+               {
+                       return NULL;
+               }
+
+       ret = g_string_new (path);
+       g_strstrip (ret->str);
+       if (g_strcmp0 (ret->str, "") == 0)
+               {
+                       return NULL;
+               }
+       else if (ret->str[strlen (ret->str) - 1] == '/')
+               {
+                       return NULL;
+               }
+
+       /* removing leading '/' */
+       lead = 0;
+       for (lead = 0; lead < ret->len; lead++)
+               {
+                       if (ret->str[lead] != '/')
+                               {
+                                       break;
+                               }
+               }
+
+       if (lead < ret->len)
+               {
+                       g_string_erase (ret, 0, lead++);
+               }
+
+       g_object_get (pluggable, "root", &root, NULL);
+       g_string_prepend (ret, root);
+
+       strret = g_strdup (ret->str);
+       g_string_free (ret, TRUE);
+
+       return strret;
+}
+
+/* PRIVATE */
+static void
+zak_confi_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
+{
+       gchar *sql;
+
+       ZakConfi *confi = ZAK_CONFI (object);
+       ZakConfiPrivate *priv = ZAK_CONFI_GET_PRIVATE (confi);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+               }
+}
+
+static void
+zak_confi_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
+{
+       ZakConfi *confi = ZAK_CONFI (object);
+       ZakConfiPrivate *priv = ZAK_CONFI_GET_PRIVATE (confi);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+               }
+}
index 5b7b51017b518fa1609afd1b6829c3d36fb58478..beae829ce5232394e0e07e294ea991155c289ac6 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * confipluggable.c
- * This file is part of libconfi
+ * This file is part of libzakconfi
  *
- * Copyright (C) 2014 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2014-2016 Andrea Zagli <azagli@libero.it>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU Library General Public License as published by
  *
  **/
 
-G_DEFINE_INTERFACE(ConfiPluggable, confi_pluggable, G_TYPE_OBJECT)
+G_DEFINE_INTERFACE(ZakConfiPluggable, zak_confi_pluggable, G_TYPE_OBJECT)
 
 void
-confi_pluggable_default_init (ConfiPluggableInterface *iface)
+zak_confi_pluggable_default_init (ZakConfiPluggableInterface *iface)
 {
        static gboolean initialized = FALSE;
 
        if (!initialized)
                {
                        /**
-                       * ConfiPluggable:cnc_string:
+                       * ZakConfiPluggable:cnc_string:
                        *
                        */
                        g_object_interface_install_property (iface,
@@ -53,7 +53,7 @@ confi_pluggable_default_init (ConfiPluggableInterface *iface)
                                                                                  G_PARAM_READWRITE));
 
                        /**
-                       * ConfiPluggable:name:
+                       * ZakConfiPluggable:name:
                        *
                        */
                        g_object_interface_install_property (iface,
@@ -64,7 +64,7 @@ confi_pluggable_default_init (ConfiPluggableInterface *iface)
                                                                                  G_PARAM_READWRITE));
 
                        /**
-                       * ConfiPluggable:description:
+                       * ZakConfiPluggable:description:
                        *
                        */
                        g_object_interface_install_property (iface,
@@ -75,7 +75,7 @@ confi_pluggable_default_init (ConfiPluggableInterface *iface)
                                                                                  G_PARAM_READWRITE));
 
                        /**
-                       * ConfiPluggable:root:
+                       * ZakConfiPluggable:root:
                        *
                        */
                        g_object_interface_install_property (iface,
@@ -90,8 +90,8 @@ confi_pluggable_default_init (ConfiPluggableInterface *iface)
 }
 
 /**
- * confi_pluggable_initialize:
- * @pluggable: A #ConfiPluggable.
+ * zak_confi_pluggable_initialize:
+ * @pluggable: A #ZakConfiPluggable.
  * @cnc_string: The connection string.
  *
  * Initialize the backend.
@@ -99,194 +99,194 @@ confi_pluggable_default_init (ConfiPluggableInterface *iface)
  * Returns: #TRUE if success.
  */
 gboolean
-confi_pluggable_initialize (ConfiPluggable *pluggable, const gchar *cnc_string)
+zak_confi_pluggable_initialize (ZakConfiPluggable *pluggable, const gchar *cnc_string)
 {
-       ConfiPluggableInterface *iface;
+       ZakConfiPluggableInterface *iface;
 
-       g_return_val_if_fail (CONFI_IS_PLUGGABLE (pluggable), FALSE);
+       g_return_val_if_fail (ZAK_CONFI_IS_PLUGGABLE (pluggable), FALSE);
 
-       iface = CONFI_PLUGGABLE_GET_IFACE (pluggable);
+       iface = ZAK_CONFI_PLUGGABLE_GET_IFACE (pluggable);
        g_return_val_if_fail (iface->initialize != NULL, FALSE);
 
        return iface->initialize (pluggable, cnc_string);
 }
 
 /**
- * confi_pluggable_get_configs_list:
- * @pluggable: A #ConfiPluggable.
+ * zak_confi_pluggable_get_configs_list:
+ * @pluggable: A #ZakConfiPluggable.
  * @filter: (nullable):
  *
- * Returns: (element-type ConfiConfi) (transfer container): a #GList of #ConfiConfi. If there's no configurations, returns a valid
+ * Returns: (element-type ZakConfi) (transfer container): a #GList of #ZakConfi. If there's no configurations, returns a valid
  * #GList but with a unique NULL element.
 */
 GList
-*confi_pluggable_get_configs_list (ConfiPluggable *pluggable, const gchar *filter)
+*zak_confi_pluggable_get_configs_list (ZakConfiPluggable *pluggable, const gchar *filter)
 {
-       ConfiPluggableInterface *iface;
+       ZakConfiPluggableInterface *iface;
 
-       g_return_val_if_fail (CONFI_IS_PLUGGABLE (pluggable), FALSE);
+       g_return_val_if_fail (ZAK_CONFI_IS_PLUGGABLE (pluggable), FALSE);
 
-       iface = CONFI_PLUGGABLE_GET_IFACE (pluggable);
+       iface = ZAK_CONFI_PLUGGABLE_GET_IFACE (pluggable);
        g_return_val_if_fail (iface->get_configs_list != NULL, FALSE);
 
        return iface->get_configs_list (pluggable, filter);
 }
 
 /**
- * confi_pluggable_path_get_value:
- * @pluggable: A #ConfiPluggable.
+ * zak_confi_pluggable_path_get_value:
+ * @pluggable: A #ZakConfiPluggable.
  * @path:
  *
  * Returns: the value of the @path.
 */
 gchar
-*confi_pluggable_path_get_value (ConfiPluggable *pluggable, const gchar *path)
+*zak_confi_pluggable_path_get_value (ZakConfiPluggable *pluggable, const gchar *path)
 {
-       ConfiPluggableInterface *iface;
+       ZakConfiPluggableInterface *iface;
 
-       g_return_val_if_fail (CONFI_IS_PLUGGABLE (pluggable), FALSE);
+       g_return_val_if_fail (ZAK_CONFI_IS_PLUGGABLE (pluggable), FALSE);
 
-       iface = CONFI_PLUGGABLE_GET_IFACE (pluggable);
+       iface = ZAK_CONFI_PLUGGABLE_GET_IFACE (pluggable);
        g_return_val_if_fail (iface->path_get_value != NULL, FALSE);
 
        return iface->path_get_value (pluggable, path);
 }
 
 /**
- * confi_pluggable_path_set_value:
- * @pluggable: a #ConfiPluggable object.
+ * zak_confi_pluggable_path_set_value:
+ * @pluggable: a #ZakConfiPluggable object.
  * @path: the key's path.
  * @value: the value to set.
  *
  */
 gboolean
-confi_pluggable_path_set_value (ConfiPluggable *pluggable, const gchar *path, const gchar *value)
+zak_confi_pluggable_path_set_value (ZakConfiPluggable *pluggable, const gchar *path, const gchar *value)
 {
-       ConfiPluggableInterface *iface;
+       ZakConfiPluggableInterface *iface;
 
-       g_return_val_if_fail (CONFI_IS_PLUGGABLE (pluggable), FALSE);
+       g_return_val_if_fail (ZAK_CONFI_IS_PLUGGABLE (pluggable), FALSE);
 
-       iface = CONFI_PLUGGABLE_GET_IFACE (pluggable);
+       iface = ZAK_CONFI_PLUGGABLE_GET_IFACE (pluggable);
        g_return_val_if_fail (iface->path_set_value != NULL, FALSE);
 
        return iface->path_set_value (pluggable, path, value);
 }
 
 /**
- * confi_pluggable_get_tree:
- * @pluggable: a #ConfiPluggable object.
+ * zak_confi_pluggable_get_tree:
+ * @pluggable: a #ZakConfiPluggable object.
  *
  * Returns: a #GNode with the entire tree of configurations.
  */
 GNode
-*confi_pluggable_get_tree (ConfiPluggable *pluggable)
+*zak_confi_pluggable_get_tree (ZakConfiPluggable *pluggable)
 {
-       ConfiPluggableInterface *iface;
+       ZakConfiPluggableInterface *iface;
 
-       g_return_val_if_fail (CONFI_IS_PLUGGABLE (pluggable), FALSE);
+       g_return_val_if_fail (ZAK_CONFI_IS_PLUGGABLE (pluggable), FALSE);
 
-       iface = CONFI_PLUGGABLE_GET_IFACE (pluggable);
+       iface = ZAK_CONFI_PLUGGABLE_GET_IFACE (pluggable);
        g_return_val_if_fail (iface->get_tree != NULL, FALSE);
 
        return iface->get_tree (pluggable);
 }
 
 /**
- * confi_pluggable_add_key:
- * @pluggable: a #ConfiPluggable object.
+ * zak_confi_pluggable_add_key:
+ * @pluggable: a #ZakConfiPluggable object.
  * @parent: the path where add the key.
  * @key: the key's name.
  * @value: the key's value.
  *
- * Returns: a #ConfigKey struct filled with data from the key just added.
+ * Returns: a #ZakConfigKey struct filled with data from the key just added.
  */
-ConfiKey
-*confi_pluggable_add_key (ConfiPluggable *pluggable, const gchar *parent, const gchar *key, const gchar *value)
+ZakConfiKey
+*zak_confi_pluggable_add_key (ZakConfiPluggable *pluggable, const gchar *parent, const gchar *key, const gchar *value)
 {
-       ConfiPluggableInterface *iface;
+       ZakConfiPluggableInterface *iface;
 
-       g_return_val_if_fail (CONFI_IS_PLUGGABLE (pluggable), FALSE);
+       g_return_val_if_fail (ZAK_CONFI_IS_PLUGGABLE (pluggable), FALSE);
 
-       iface = CONFI_PLUGGABLE_GET_IFACE (pluggable);
+       iface = ZAK_CONFI_PLUGGABLE_GET_IFACE (pluggable);
        g_return_val_if_fail (iface->add_key != NULL, FALSE);
 
        return iface->add_key (pluggable, parent, key, value);
 }
 
 /**
- * confi_pluggable_key_set_key:
- * @pluggable: a #ConfiPluggable object.
- * @ck: a #ConfiKey struct.
+ * zak_confi_pluggable_key_set_key:
+ * @pluggable: a #ZakConfiPluggable object.
+ * @ck: a #ZakConfiKey struct.
  *
  */
 gboolean
-confi_pluggable_key_set_key (ConfiPluggable *pluggable,
-                   ConfiKey *ck)
+zak_confi_pluggable_key_set_key (ZakConfiPluggable *pluggable,
+                   ZakConfiKey *ck)
 {
-       ConfiPluggableInterface *iface;
+       ZakConfiPluggableInterface *iface;
 
-       g_return_val_if_fail (CONFI_IS_PLUGGABLE (pluggable), FALSE);
+       g_return_val_if_fail (ZAK_CONFI_IS_PLUGGABLE (pluggable), FALSE);
 
-       iface = CONFI_PLUGGABLE_GET_IFACE (pluggable);
+       iface = ZAK_CONFI_PLUGGABLE_GET_IFACE (pluggable);
        g_return_val_if_fail (iface->key_set_key != NULL, FALSE);
 
        return iface->key_set_key (pluggable, ck);
 }
 
 /**
- * confi_pluggable_path_get_confi_key:
- * @pluggable: a #ConfiPluggable object.
+ * zak_confi_pluggable_path_get_confi_key:
+ * @pluggable: a #ZakConfiPluggable object.
  * @path: the key's path to get.
  *
- * Returns: (transfer full): a #ConfiKey from @path
+ * Returns: (transfer full): a #ZakConfiKey from @path
  */
-ConfiKey
-*confi_pluggable_path_get_confi_key (ConfiPluggable *pluggable, const gchar *path)
+ZakConfiKey
+*zak_confi_pluggable_path_get_confi_key (ZakConfiPluggable *pluggable, const gchar *path)
 {
-       ConfiPluggableInterface *iface;
+       ZakConfiPluggableInterface *iface;
 
-       g_return_val_if_fail (CONFI_IS_PLUGGABLE (pluggable), FALSE);
+       g_return_val_if_fail (ZAK_CONFI_IS_PLUGGABLE (pluggable), FALSE);
 
-       iface = CONFI_PLUGGABLE_GET_IFACE (pluggable);
+       iface = ZAK_CONFI_PLUGGABLE_GET_IFACE (pluggable);
        g_return_val_if_fail (iface->path_get_confi_key != NULL, FALSE);
 
        return iface->path_get_confi_key (pluggable, path);
 }
 
 /**
- * confi_pluggable_remove_path:
- * @pluggable: a #ConfiPluggable object.
+ * zak_confi_pluggable_remove_path:
+ * @pluggable: a #ZakConfiPluggable object.
  * @path: the path to remove.
  *
  * Removes @path and every child key.
  */
 gboolean
-confi_pluggable_remove_path (ConfiPluggable *pluggable, const gchar *path)
+zak_confi_pluggable_remove_path (ZakConfiPluggable *pluggable, const gchar *path)
 {
-       ConfiPluggableInterface *iface;
+       ZakConfiPluggableInterface *iface;
 
-       g_return_val_if_fail (CONFI_IS_PLUGGABLE (pluggable), FALSE);
+       g_return_val_if_fail (ZAK_CONFI_IS_PLUGGABLE (pluggable), FALSE);
 
-       iface = CONFI_PLUGGABLE_GET_IFACE (pluggable);
+       iface = ZAK_CONFI_PLUGGABLE_GET_IFACE (pluggable);
        g_return_val_if_fail (iface->remove_path != NULL, FALSE);
 
        return iface->remove_path (pluggable, path);
 }
 
 /**
- * confi_pluggable_remove:
- * @pluggable: a #ConfiPluggable object.
+ * zak_confi_pluggable_remove:
+ * @pluggable: a #ZakConfiPluggable object.
  *
  * Remove a configuration from databases and destroy the relative object.
  */
 gboolean
-confi_pluggable_remove (ConfiPluggable *pluggable)
+zak_confi_pluggable_remove (ZakConfiPluggable *pluggable)
 {
-       ConfiPluggableInterface *iface;
+       ZakConfiPluggableInterface *iface;
 
-       g_return_val_if_fail (CONFI_IS_PLUGGABLE (pluggable), FALSE);
+       g_return_val_if_fail (ZAK_CONFI_IS_PLUGGABLE (pluggable), FALSE);
 
-       iface = CONFI_PLUGGABLE_GET_IFACE (pluggable);
+       iface = ZAK_CONFI_PLUGGABLE_GET_IFACE (pluggable);
        g_return_val_if_fail (iface->remove != NULL, FALSE);
 
        return iface->remove (pluggable);
index a8c29472165f42bd95e175feeedfdd634b65afad..fbb844944ccee084411e0f18abf1138975c3cf29 100644 (file)
@@ -2,7 +2,7 @@
  * confipluggable.h
  * This file is part of libconfi
  *
- * Copyright (C) 2014 - Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2014-2016 - Andrea Zagli <azagli@libero.it>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU Library General Public License as published by
@@ -19,8 +19,8 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-#ifndef __CONFI_PLUGGABLE_H__
-#define __CONFI_PLUGGABLE_H__
+#ifndef __ZAK_CONFI_PLUGGABLE_H__
+#define __ZAK_CONFI_PLUGGABLE_H__
 
 #include <glib-object.h>
 
@@ -31,78 +31,78 @@ G_BEGIN_DECLS
 /*
  * Type checking and casting macros
  */
-#define CONFI_TYPE_PLUGGABLE             (confi_pluggable_get_type ())
-#define CONFI_PLUGGABLE(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONFI_TYPE_PLUGGABLE, ConfiPluggable))
-#define CONFI_PLUGGABLE_IFACE(obj)       (G_TYPE_CHECK_CLASS_CAST ((obj), CONFI_TYPE_PLUGGABLE, ConfiPluggableInterface))
-#define CONFI_IS_PLUGGABLE(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONFI_TYPE_PLUGGABLE))
-#define CONFI_PLUGGABLE_GET_IFACE(obj)   (G_TYPE_INSTANCE_GET_INTERFACE ((obj), CONFI_TYPE_PLUGGABLE, ConfiPluggableInterface))
+#define ZAK_CONFI_TYPE_PLUGGABLE             (zak_confi_pluggable_get_type ())
+#define ZAK_CONFI_PLUGGABLE(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONFI_TYPE_PLUGGABLE, ZakConfiPluggable))
+#define ZAK_CONFI_PLUGGABLE_IFACE(obj)       (G_TYPE_CHECK_CLASS_CAST ((obj), ZAK_CONFI_TYPE_PLUGGABLE, ZakConfiPluggableInterface))
+#define ZAK_CONFI_IS_PLUGGABLE(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ZAK_CONFI_TYPE_PLUGGABLE))
+#define ZAK_CONFI_PLUGGABLE_GET_IFACE(obj)   (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ZAK_CONFI_TYPE_PLUGGABLE, ZakConfiPluggableInterface))
 
 /**
- * ConfiPluggable:
+ * ZakConfiPluggable:
  *
  * Interface for pluggable plugins.
  */
-typedef struct _ConfiPluggable           ConfiPluggable; /* dummy typedef */
-typedef struct _ConfiPluggableInterface  ConfiPluggableInterface;
+typedef struct _ZakConfiPluggable           ZakConfiPluggable; /* dummy typedef */
+typedef struct _ZakConfiPluggableInterface  ZakConfiPluggableInterface;
 
 /**
- * ConfiPluggableInterface:
+ * ZakConfiPluggableInterface:
  * @g_iface: The parent interface.
  * @initialize: Construct the plugin.
  *
  * Provides an interface for pluggable plugins.
  */
-struct _ConfiPluggableInterface {
+struct _ZakConfiPluggableInterface {
        GTypeInterface g_iface;
 
        /* Virtual public methods */
-       gboolean (*initialize) (ConfiPluggable *pluggable, const gchar *cnc_string);
-       GList *(*get_configs_list) (ConfiPluggable *pluggable,
+       gboolean (*initialize) (ZakConfiPluggable *pluggable, const gchar *cnc_string);
+       GList *(*get_configs_list) (ZakConfiPluggable *pluggable,
                                    const gchar *filter);
-       gchar *(*path_get_value) (ConfiPluggable *pluggable, const gchar *path);
-       gboolean (*path_set_value) (ConfiPluggable *pluggable,
+       gchar *(*path_get_value) (ZakConfiPluggable *pluggable, const gchar *path);
+       gboolean (*path_set_value) (ZakConfiPluggable *pluggable,
                                    const gchar *path,
                                    const gchar *value);
-       GNode *(*get_tree) (ConfiPluggable *pluggable);
-       ConfiKey *(*add_key) (ConfiPluggable *pluggable,
+       GNode *(*get_tree) (ZakConfiPluggable *pluggable);
+       ZakConfiKey *(*add_key) (ZakConfiPluggable *pluggable,
                              const gchar *parent,
                              const gchar *key,
                              const gchar *value);
-       ConfiKey *(*path_get_confi_key) (ConfiPluggable *pluggable, const gchar *path);
-       gboolean (*remove_path) (ConfiPluggable *pluggable,
+       ZakConfiKey *(*path_get_confi_key) (ZakConfiPluggable *pluggable, const gchar *path);
+       gboolean (*remove_path) (ZakConfiPluggable *pluggable,
                                 const gchar *path);
-       gboolean (*remove) (ConfiPluggable *pluggable);
-       gboolean (*key_set_key) (ConfiPluggable *pluggable,
-                                ConfiKey *ck);
+       gboolean (*remove) (ZakConfiPluggable *pluggable);
+       gboolean (*key_set_key) (ZakConfiPluggable *pluggable,
+                                ZakConfiKey *ck);
 };
 
 /*
  * Public methods
  */
-GType confi_pluggable_get_type (void) G_GNUC_CONST;
+GType zak_confi_pluggable_get_type (void) G_GNUC_CONST;
 
-gboolean confi_pluggable_initialize (ConfiPluggable *pluggable,
+gboolean zak_confi_pluggable_initialize (ZakConfiPluggable *pluggable,
                                      const gchar *cnc_string);
 
-GList *confi_pluggable_get_configs_list (ConfiPluggable *pluggable,
+GList *zak_confi_pluggable_get_configs_list (ZakConfiPluggable *pluggable,
                                          const gchar *filter);
-gchar *confi_pluggable_path_get_value (ConfiPluggable *pluggable,
+gchar *zak_confi_pluggable_path_get_value (ZakConfiPluggable *pluggable,
                                        const gchar *path);
-gboolean confi_pluggable_path_set_value (ConfiPluggable *pluggable,
+gboolean zak_confi_pluggable_path_set_value (ZakConfiPluggable *pluggable,
                                const gchar *path,
                                const gchar *value);
-GNode *confi_pluggable_get_tree (ConfiPluggable *pluggable);
-ConfiKey *confi_pluggable_add_key (ConfiPluggable *pluggable,
+GNode *zak_confi_pluggable_get_tree (ZakConfiPluggable *pluggable);
+ZakConfiKey *zak_confi_pluggable_add_key (ZakConfiPluggable *pluggable,
                                    const gchar *parent,
                                    const gchar *key,
                                    const gchar *value);
-gboolean confi_pluggable_key_set_key (ConfiPluggable *pluggable,
-                   ConfiKey *ck);
-ConfiKey *confi_pluggable_path_get_confi_key (ConfiPluggable *pluggable, const gchar *path);
-gboolean confi_pluggable_remove_path (ConfiPluggable *pluggable, const gchar *path);
-gboolean confi_pluggable_remove (ConfiPluggable *pluggable);
+gboolean zak_confi_pluggable_key_set_key (ZakConfiPluggable *pluggable,
+                   ZakConfiKey *ck);
+ZakConfiKey *zak_confi_pluggable_path_get_confi_key (ZakConfiPluggable *pluggable, const gchar *path);
+gboolean zak_confi_pluggable_remove_path (ZakConfiPluggable *pluggable, const gchar *path);
+gboolean zak_confi_pluggable_remove (ZakConfiPluggable *pluggable);
 
 
 G_END_DECLS
 
-#endif /* __CONFI_PLUGGABLE_H__ */
+#endif /* __ZAK_CONFI_PLUGGABLE_H__ */
diff --git a/src/libconfi.c b/src/libconfi.c
deleted file mode 100644 (file)
index 71a7791..0000000
+++ /dev/null
@@ -1,608 +0,0 @@
-/*
- *  Copyright (C) 2005-2014 Andrea Zagli <azagli@libero.it>
- *
- *  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.
- */
-
-#ifdef HAVE_CONFIG_H
-       #include <config.h>
-#endif
-
-#include <string.h>
-
-#include <libgdaex/libgdaex.h>
-
-#include "libconfi.h"
-
-
-enum
-{
-       PROP_0,
-       PROP_ID_CONFIG,
-       PROP_NAME,
-       PROP_DESCRIPTION,
-       PROP_ROOT
-};
-
-static void confi_class_init (ConfiClass *klass);
-static void confi_init (Confi *confi);
-
-static void confi_set_property (GObject *object,
-                                guint property_id,
-                                const GValue *value,
-                                GParamSpec *pspec);
-static void confi_get_property (GObject *object,
-                                guint property_id,
-                                GValue *value,
-                                GParamSpec *pspec);
-
-static ConfiPluggable *confi_get_confi_pluggable_from_cnc_string (const gchar *cnc_string);
-
-#define CONFI_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_CONFI, ConfiPrivate))
-
-typedef struct _ConfiPrivate ConfiPrivate;
-struct _ConfiPrivate
-       {
-               GdaEx *gdaex;
-               gint id_config;
-               gchar *name;
-               gchar *description;
-               gchar *root;
-               GHashTable *values;
-
-               gchar chrquot;
-
-               ConfiPluggable *pluggable;
-       };
-
-G_DEFINE_TYPE (Confi, confi, G_TYPE_OBJECT)
-
-static void
-confi_class_init (ConfiClass *klass)
-{
-       GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-       g_type_class_add_private (object_class, sizeof (ConfiPrivate));
-
-       object_class->set_property = confi_set_property;
-       object_class->get_property = confi_get_property;
-}
-
-static void
-confi_init (Confi *confi)
-{
-       ConfiPrivate *priv = CONFI_GET_PRIVATE (confi);
-
-       priv->pluggable = NULL;
-}
-
-static ConfiPluggable
-*confi_get_confi_pluggable_from_cnc_string (const gchar *cnc_string)
-{
-       ConfiPluggable *pluggable;
-
-       const GList *lst_plugins;
-
-       pluggable = NULL;
-
-       PeasEngine *peas_engine;
-
-       peas_engine = peas_engine_get_default ();
-       if (peas_engine == NULL)
-               {
-                       return NULL;
-               }
-
-       peas_engine_add_search_path (peas_engine, PLUGINSDIR, NULL);
-
-       lst_plugins = peas_engine_get_plugin_list (peas_engine);
-       while (lst_plugins)
-               {
-                       PeasPluginInfo *ppinfo;
-                       gchar *uri;
-
-                       ppinfo = (PeasPluginInfo *)lst_plugins->data;
-
-                       uri = g_strdup_printf ("%s://", peas_plugin_info_get_module_name (ppinfo));
-                       if (g_str_has_prefix (cnc_string, uri))
-                               {
-                                       if (peas_engine_load_plugin (peas_engine, ppinfo))
-                                               {
-                                                       PeasExtension *ext;
-                                                       ext = peas_engine_create_extension (peas_engine, ppinfo, CONFI_TYPE_PLUGGABLE,
-                                                                                           "cnc_string", cnc_string + strlen (uri),
-                                                                                           NULL);
-                                                       pluggable = (ConfiPluggable *)ext;
-                                                       break;
-                                               }
-                               }
-                       g_free (uri);
-
-                       lst_plugins = g_list_next (lst_plugins);
-               }
-
-       if (pluggable == NULL)
-               {
-                       g_warning ("No plugin found for connection string \"%s\".", cnc_string);
-               }
-
-       return pluggable;
-}
-
-/**
- * confi_new:
- * @cnc_string: the connection string.
- *
- * Returns: (transfer none): the newly created #Confi object, or NULL if it fails.
- */
-Confi
-*confi_new (const gchar *cnc_string)
-{
-       Confi *confi;
-       ConfiPrivate *priv;
-       ConfiPluggable *pluggable;
-
-       g_return_val_if_fail (cnc_string != NULL, NULL);
-
-       confi = NULL;
-
-       pluggable = confi_get_confi_pluggable_from_cnc_string (cnc_string);
-       if (pluggable != NULL)
-               {
-                       confi = CONFI (g_object_new (confi_get_type (), NULL));
-                       priv = CONFI_GET_PRIVATE (confi);
-                       priv->pluggable = pluggable;
-               }
-
-       return confi;
-}
-
-PeasPluginInfo
-*confi_get_plugin_info (Confi *confi)
-{
-       PeasPluginInfo *ppinfo;
-
-       ConfiPrivate *priv = CONFI_GET_PRIVATE (confi);
-
-       if (priv->pluggable == NULL)
-               {
-                       g_warning ("Not initialized.");
-                       ppinfo = NULL;
-               }
-       else
-               {
-                       ppinfo = peas_extension_base_get_plugin_info ((PeasExtensionBase *)priv->pluggable);
-               }
-
-       return ppinfo;
-}
-
-/**
- * confi_get_configs_list:
- * @cnc_string: the connection string to use to connect to database that
- * contains configuration.
- * @filter: (nullable):
- *
- * Returns: (element-type Confi) (transfer container):  a #GList of #ConfiConfi. If there's no configurations, returns a valid
- * #GList but with a unique NULL element.
- */
-GList
-*confi_get_configs_list (const gchar *cnc_string,
-                         const gchar *filter)
-{
-       ConfiPluggable *pluggable;
-       GList *lst;
-
-       lst = NULL;
-
-       pluggable = confi_get_confi_pluggable_from_cnc_string (cnc_string);
-
-       if (pluggable != NULL)
-               {
-                       lst = confi_pluggable_get_configs_list (pluggable, filter);
-               }
-
-       return lst;
-}
-
-/**
- * confi_get_tree:
- * @confi: a #Confi object.
- *
- * Returns: a #GNode.
- */
-GNode
-*confi_get_tree (Confi *confi)
-{
-       ConfiPrivate *priv = CONFI_GET_PRIVATE (confi);
-
-       if (priv->pluggable != NULL)
-               {
-                       return confi_pluggable_get_tree (priv->pluggable);
-               }
-       else
-               {
-                       return NULL;
-               }
-}
-
-/**
- * confi_normalize_set_root:
- * @confi: a #Confi object.
- * @root: the root.
- *
- * Returns: a correct value for root property.
- */
-gchar
-*confi_normalize_root (const gchar *root)
-{
-       GString *root_;
-       gchar *strret;
-
-       if (root == NULL)
-               {
-                       root_ = g_string_new ("/");
-               }
-       else
-               {
-                       root_ = g_string_new (root);
-                       g_strstrip (root_->str);
-                       if (g_strcmp0 (root_->str, "") == 0)
-                               {
-                                       g_string_printf (root_, "/");
-                               }
-                       else
-                               {
-                                       if (root_->str[0] != '/')
-                                               {
-                                                       g_string_prepend (root_, "/");
-                                               }
-                                       if (root_->str[root_->len - 1] != '/')
-                                               {
-                                                       g_string_append (root_, "/");
-                                               }
-                               }
-               }
-
-       strret = g_strdup (root_->str);
-       g_string_free (root_, TRUE);
-
-       return strret;
-}
-
-/**
- * confi_set_root:
- * @confi: a #Confi object.
- * @root: the root.
- *
- */
-gboolean
-confi_set_root (Confi *confi, const gchar *root)
-{
-       gboolean ret;
-
-       ConfiPrivate *priv = CONFI_GET_PRIVATE (confi);
-
-       if (priv->pluggable == NULL)
-               {
-                       g_warning ("Not initialized.");
-                       ret = FALSE;
-               }
-       else
-               {
-                       g_object_set (priv->pluggable, "root", root, NULL);
-                       ret = TRUE;
-               }
-
-       return ret;
-}
-
-/**
- * confi_add_key:
- * @confi: a #Confi object.
- * @parent: the path where add the key.
- * @key: the key's name.
- * @value: the key's value.
- *
- * Returns: a #ConfigKey struct filled with data from the key just added.
- */
-ConfiKey
-*confi_add_key (Confi *confi, const gchar *parent, const gchar *key, const gchar *value)
-{
-       ConfiKey *ck;
-
-       ConfiPrivate *priv = CONFI_GET_PRIVATE (confi);
-
-       if (priv->pluggable == NULL)
-               {
-                       g_warning ("Not initialized.");
-                       ck = NULL;
-               }
-       else
-               {
-                       ck = confi_pluggable_add_key (priv->pluggable, parent, key, value);
-               }
-
-       return ck;
-}
-
-/**
- * confi_key_set_key:
- * @confi: a #Confi object.
- * @ck: a #ConfiKey struct.
- *
- */
-gboolean
-confi_key_set_key (Confi *confi,
-                   ConfiKey *ck)
-{
-       gboolean ret;
-
-       ConfiPrivate *priv = CONFI_GET_PRIVATE (confi);
-
-       if (priv->pluggable == NULL)
-               {
-                       g_warning ("Not initialized.");
-                       ret = FALSE;
-               }
-       else
-               {
-                       ret = confi_pluggable_key_set_key (priv->pluggable, ck);
-               }
-
-       return ret;
-}
-
-/**
- * confi_remove_path:
- * @confi: a #Confi object.
- * @path: the path to remove.
- *
- * Removes @path and every child key.
- */
-gboolean
-confi_remove_path (Confi *confi, const gchar *path)
-{
-       gboolean ret;
-       ConfiPrivate *priv = CONFI_GET_PRIVATE (confi);
-
-       if (priv->pluggable == NULL)
-               {
-                       g_warning ("Not initialized.");
-                       ret = FALSE;
-               }
-       else
-               {
-                       ret = confi_pluggable_remove_path (priv->pluggable, path);
-               }
-
-       return ret;
-}
-
-/**
- * confi_path_get_value:
- * @confi: a #Confi object.
- * @path: the path from which retrieving the value.
- *
- * Returns: the configuration's value as a string.
- */
-gchar
-*confi_path_get_value (Confi *confi, const gchar *path)
-{
-       gchar *ret;
-
-       ConfiPrivate *priv = CONFI_GET_PRIVATE (confi);
-
-       if (priv->pluggable == NULL)
-               {
-                       g_warning ("Not initialized.");
-                       ret = NULL;
-               }
-       else
-               {
-                       ret = confi_pluggable_path_get_value (priv->pluggable, path);
-               }
-
-       return ret;
-}
-
-/**
- * confi_path_set_value:
- * @confi: a #Confi object.
- * @path: the key's path.
- * @value: the value to set.
- *
- */
-gboolean
-confi_path_set_value (Confi *confi, const gchar *path, const gchar *value)
-{
-       gboolean ret;
-
-       ConfiPrivate *priv = CONFI_GET_PRIVATE (confi);
-
-       if (priv->pluggable == NULL)
-               {
-                       g_warning ("Not initialized.");
-                       ret = FALSE;
-               }
-       else
-               {
-                       ret = confi_pluggable_path_set_value (priv->pluggable, path, value);
-               }
-
-       return ret;
-}
-
-/**
- * confi_path_get_confi_key:
- * @confi: a #Confi object.
- * @path: the key's path to get.
- *
- * Returns: (transfer full): a #ConfiKey from @path
- */
-ConfiKey
-*confi_path_get_confi_key (Confi *confi, const gchar *path)
-{
-       ConfiKey *ck;
-
-       ConfiPrivate *priv = CONFI_GET_PRIVATE (confi);
-
-       if (priv->pluggable == NULL)
-               {
-                       g_warning ("Not initialized.");
-                       ck = NULL;
-               }
-       else
-               {
-                       ck = confi_pluggable_path_get_confi_key (priv->pluggable, path);
-               }
-
-       return ck;
-}
-
-/**
- * confi_remove:
- * @confi: a #Confi object.
- *
- * Remove a configuration from databases and destroy the relative object.
- */
-gboolean
-confi_remove (Confi *confi)
-{
-       gboolean ret;
-
-       ConfiPrivate *priv = CONFI_GET_PRIVATE (confi);
-
-       if (priv->pluggable == NULL)
-               {
-                       g_warning ("Not initialized.");
-                       ret = FALSE;
-               }
-       else
-               {
-                       ret = confi_pluggable_remove (priv->pluggable);
-               }
-
-       if (ret)
-               {
-                       confi_destroy (confi);
-               }
-
-       return ret;
-}
-
-/**
- * confi_destroy:
- * @confi: a #Confi object.
- *
- * Destroy the #Confi object, freeing memory.
- */
-void
-confi_destroy (Confi *confi)
-{
-       ConfiPrivate *priv = CONFI_GET_PRIVATE (confi);
-
-       g_free (priv->name);
-       g_free (priv->description);
-       g_free (priv->root);
-       g_object_unref (priv->pluggable);
-}
-
-/**
- * confi_path_normalize:
- * @pluggable: a #ConfiPluggable object.
- *
- * Returns: a normalize path (with root).
- */
-gchar
-*confi_path_normalize (ConfiPluggable *pluggable, const gchar *path)
-{
-       GString *ret;
-       gchar *strret;
-
-       guint lead;
-
-       gchar *root;
-
-       if (path == NULL)
-               {
-                       return NULL;
-               }
-
-       ret = g_string_new (path);
-       g_strstrip (ret->str);
-       if (g_strcmp0 (ret->str, "") == 0)
-               {
-                       return NULL;
-               }
-       else if (ret->str[strlen (ret->str) - 1] == '/')
-               {
-                       return NULL;
-               }
-
-       /* removing leading '/' */
-       lead = 0;
-       for (lead = 0; lead < ret->len; lead++)
-               {
-                       if (ret->str[lead] != '/')
-                               {
-                                       break;
-                               }
-               }
-
-       if (lead < ret->len)
-               {
-                       g_string_erase (ret, 0, lead++);
-               }
-
-       g_object_get (pluggable, "root", &root, NULL);
-       g_string_prepend (ret, root);
-
-       strret = g_strdup (ret->str);
-       g_string_free (ret, TRUE);
-
-       return strret;
-}
-
-/* PRIVATE */
-static void
-confi_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
-{
-       gchar *sql;
-
-       Confi *confi = CONFI (object);
-       ConfiPrivate *priv = CONFI_GET_PRIVATE (confi);
-
-       switch (property_id)
-               {
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-               }
-}
-
-static void
-confi_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
-{
-       Confi *confi = CONFI (object);
-       ConfiPrivate *priv = CONFI_GET_PRIVATE (confi);
-
-       switch (property_id)
-               {
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-               }
-}
diff --git a/src/libconfi.h b/src/libconfi.h
deleted file mode 100644 (file)
index 0955a8b..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- *  Copyright (C) 2005-2014 Andrea Zagli <azagli@libero.it>
- *
- *  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.
- */
-
-#ifndef __LIBCONFI_H__
-#define __LIBCONFI_H__
-
-#include <glib-object.h>
-
-#include <libpeas/peas.h>
-
-#include "commons.h"
-#include "confipluggable.h"
-
-
-G_BEGIN_DECLS
-
-
-#define TYPE_CONFI                 (confi_get_type ())
-#define CONFI(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CONFI, Confi))
-#define CONFI_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CONFI, ConfiClass))
-#define IS_CONFI(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CONFI))
-#define IS_CONFI_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CONFI))
-#define CONFI_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CONFI, ConfiClass))
-
-
-typedef struct _Confi Confi;
-typedef struct _ConfiClass ConfiClass;
-
-struct _Confi
-       {
-               GObject parent;
-       };
-
-struct _ConfiClass
-       {
-               GObjectClass parent_class;
-       };
-
-GType confi_get_type (void);
-
-Confi *confi_new (const gchar *cnc_string);
-
-PeasPluginInfo *confi_get_plugin_info (Confi *confi);
-
-GList *confi_get_configs_list (const gchar *cnc_string,
-                               const gchar *filter);
-
-GNode *confi_get_tree (Confi *confi);
-
-gchar *confi_normalize_root (const gchar *root);
-gboolean confi_set_root (Confi *confi, const gchar *root);
-
-ConfiKey *confi_add_key (Confi *confi,
-                         const gchar *parent,
-                         const gchar *key,
-                         const gchar *value);
-
-gboolean confi_key_set_key (Confi *confi,
-                            ConfiKey *ck);
-
-gboolean confi_remove_path (Confi *confi,
-                            const gchar *path);
-
-gchar *confi_path_get_value (Confi *confi,
-                             const gchar *path);
-gboolean confi_path_set_value (Confi *confi,
-                               const gchar *path,
-                               const gchar *value);
-
-ConfiKey *confi_path_get_confi_key (Confi *confi,
-                                    const gchar *path);
-
-gboolean confi_remove (Confi *confi);
-
-void confi_destroy (Confi *confi);
-
-gchar *confi_path_normalize (ConfiPluggable *pluggable, const gchar *path);
-
-
-G_END_DECLS
-
-#endif /* __LIBCONFI_H__ */
diff --git a/src/libzakconfi.h b/src/libzakconfi.h
new file mode 100644 (file)
index 0000000..fb167e9
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ *  Copyright (C) 2005-2016 Andrea Zagli <azagli@libero.it>
+ *
+ *  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.
+ */
+
+#ifndef __LIBZAKCONFI_H__
+#define __LIBZAKCONFI_H__
+
+#include <glib-object.h>
+
+#include <libpeas/peas.h>
+
+#include "commons.h"
+#include "confipluggable.h"
+
+
+G_BEGIN_DECLS
+
+
+#define ZAK_TYPE_CONFI                 (zak_confi_get_type ())
+#define ZAK_CONFI(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), ZAK_TYPE_CONFI, ZakConfi))
+#define ZAK_CONFI_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), ZAK_TYPE_CONFI, ZakConfiClass))
+#define ZAK_IS_CONFI(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ZAK_TYPE_CONFI))
+#define ZAK_IS_CONFI_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), ZAK_TYPE_CONFI))
+#define ZAK_CONFI_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), ZAK_TYPE_CONFI, ZakConfiClass))
+
+
+typedef struct _ZakConfi ZakConfi;
+typedef struct _ZakConfiClass ZakConfiClass;
+
+struct _ZakConfi
+       {
+               GObject parent;
+       };
+
+struct _ZakConfiClass
+       {
+               GObjectClass parent_class;
+       };
+
+GType zak_confi_get_type (void);
+
+ZakConfi *zak_confi_new (const gchar *cnc_string);
+
+PeasPluginInfo *zak_confi_get_plugin_info (ZakConfi *confi);
+
+GList *zak_confi_get_configs_list (const gchar *cnc_string,
+                               const gchar *filter);
+
+GNode *zak_confi_get_tree (ZakConfi *confi);
+
+gchar *zak_confi_normalize_root (const gchar *root);
+gboolean zak_confi_set_root (ZakConfi *confi, const gchar *root);
+
+ZakConfiKey *zak_confi_add_key (ZakConfi *confi,
+                         const gchar *parent,
+                         const gchar *key,
+                         const gchar *value);
+
+gboolean zak_confi_key_set_key (ZakConfi *confi,
+                            ZakConfiKey *ck);
+
+gboolean zak_confi_remove_path (ZakConfi *confi,
+                            const gchar *path);
+
+gchar *zak_confi_path_get_value (ZakConfi *confi,
+                             const gchar *path);
+gboolean zak_confi_path_set_value (ZakConfi *confi,
+                               const gchar *path,
+                               const gchar *value);
+
+ZakConfiKey *zak_confi_path_get_confi_key (ZakConfi *confi,
+                                    const gchar *path);
+
+gboolean zak_confi_remove (ZakConfi *confi);
+
+void zak_confi_destroy (ZakConfi *confi);
+
+gchar *zak_confi_path_normalize (ZakConfiPluggable *pluggable, const gchar *path);
+
+
+G_END_DECLS
+
+#endif /* __LIBZAKCONFI_H__ */
index c76e13ff129a5b394ff9119909b095204ac76e51..70c3c0b04ef05363c18d00d58e6e00363180322a 100644 (file)
@@ -2,7 +2,7 @@ AM_CPPFLAGS = $(LIBCONFI_CFLAGS) \
               -I../src
 
 LIBS = $(LIBCONFI_LIBS) \
-       -L../src -lconfi
+       -L../src -lzakconfi
 
 noinst_PROGRAMS = test
 
index 39f9ead214714499193b0ef7b9199f4a06069189..988d2c6241fd2db0b8bd8c75915066e71bdbec05 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-var_dump(GIRepository\load_ns('Confi'));
+var_dump(GIRepository\load_ns('ZakConfi'));
 
 /*$confi = new Confi\Confi;
 var_dump ($confi);
index cd406726c8f0438ebe5272ccd6944cdc04ff4533..730dea6cdd2e7596e8c2dbd2bd2fcc6576caa13b 100755 (executable)
@@ -1,10 +1,10 @@
 #!/usr/bin/python
 
 from gi.repository import GLib
-from gi.repository import Confi
+from gi.repository import ZakConfi
 
 # Create a new object
-confi = Confi.Confi.new("PostgreSQL://postgres:postgres@HOST=localhost;DB_NAME=confi", "Default", None, False)
+confi = ZakConfi.Confi.new("PostgreSQL://postgres:postgres@HOST=localhost;DB_NAME=confi", "Default", None, False)
 
 print("Properties of a Confi object: ")
 print(dir(confi.props))
index 850b4073a12af602a5665acbbee96b4c2408b052..dcc1f51b9dc9aef6b7dc4415b9068247de8e283b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2014 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2005-2016 Andrea Zagli <azagli@libero.it>
  *
  *  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
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#include <glib/gprintf.h>
 #include <libpeas/peas.h>
-#include <libconfi.h>
+
+#include <libgdaex/libgdaex.h>
+
+#include <libzakconfi.h>
 
 gboolean
 traverse_func (GNode *node,
                gpointer data)
 {
-       ConfiKey *ck = (ConfiKey *)node->data;
+       ZakConfiKey *ck = (ZakConfiKey *)node->data;
        g_printf ("%s%s%s => %s\n", ck->path, g_strcmp0 (ck->path, "") == 0 ? "" : "/", ck->key, ck->value);
 
        return FALSE;
@@ -33,7 +37,7 @@ int
 main (int argc, char **argv)
 {
        PeasEngine *engine;
-       Confi *confi;
+       ZakConfi *confi;
        PeasPluginInfo *ppinfo;
        GList *confis;
        GNode *tree;
@@ -49,10 +53,10 @@ main (int argc, char **argv)
        engine = peas_engine_get_default ();
        peas_engine_add_search_path (engine, "./plugins", NULL);
 
-       confis = confi_get_configs_list (argv[1], NULL);
+       confis = zak_confi_get_configs_list (argv[1], NULL);
        while (confis)
                {
-                       ConfiConfi *confi = (ConfiConfi *)confis->data;
+                       ZakConfiConfi *confi = (ZakConfiConfi *)confis->data;
 
                        if (confi == NULL) break;
 
@@ -62,14 +66,14 @@ main (int argc, char **argv)
                        confis = g_list_next (confis);
                }
 
-       confi = confi_new (argv[1]);
+       confi = zak_confi_new (argv[1]);
        if (confi == NULL)
                {
                        g_error ("Error on configuration initialization.");
                        return 0;
                }
 
-       ppinfo = confi_get_plugin_info (confi);
+       ppinfo = zak_confi_get_plugin_info (confi);
        g_printf ("Plugin info\n");
        g_printf ("Name: %s\n", peas_plugin_info_get_name (ppinfo));
        g_printf ("Module dir: %s\n", peas_plugin_info_get_module_dir (ppinfo));
@@ -77,24 +81,24 @@ main (int argc, char **argv)
        g_printf ("\n");
 
        g_printf ("Traversing the entire tree\n");
-       tree = confi_get_tree (confi);
+       tree = zak_confi_get_tree (confi);
        g_node_traverse (tree, G_PRE_ORDER, G_TRAVERSE_ALL, -1, traverse_func, NULL);
        g_printf ("\n");
 
        if (g_strcmp0 (peas_plugin_info_get_module_name (ppinfo), "file") == 0)
                {
-                       gchar *val = confi_path_get_value (confi, "FOLDER1/key1");
+                       gchar *val = zak_confi_path_get_value (confi, "FOLDER1/key1");
                        g_printf ("Value from key \"FOLDER1/key1\"\n%s\n\n", val);
-                       confi_path_set_value (confi, "FOLDER1/key1", "new value programmatically setted");
-                       g_printf ("Value from key \"FOLDER1/key1\"\n%s\n\n", confi_path_get_value (confi, "FOLDER1/key1"));
-                       confi_path_set_value (confi, "FOLDER1/key1", val);
+                       zak_confi_path_set_value (confi, "FOLDER1/key1", "new value programmatically setted");
+                       g_printf ("Value from key \"FOLDER1/key1\"\n%s\n\n", zak_confi_path_get_value (confi, "FOLDER1/key1"));
+                       zak_confi_path_set_value (confi, "FOLDER1/key1", val);
 
-                       confi_add_key (confi, "FOLDER2", "key999", NULL);
-                       confi_path_set_value (confi, "FOLDER2/key999", "value for key999, programmatically setted");
+                       zak_confi_add_key (confi, "FOLDER2", "key999", NULL);
+                       zak_confi_path_set_value (confi, "FOLDER2/key999", "value for key999, programmatically setted");
 
-                       ConfiKey *ck;
-                       ck = confi_path_get_confi_key (confi, "FOLDER1/key2");
-                       g_printf ("ConfiKey for FOLDER1/key2\n");
+                       ZakConfiKey *ck;
+                       ck = zak_confi_path_get_confi_key (confi, "FOLDER1/key2");
+                       g_printf ("ZakConfiKey for FOLDER1/key2\n");
                        g_printf ("Path: %s\n", ck->path);
                        g_printf ("Key: %s\n", ck->key);
                        g_printf ("Description: %s\n", ck->description);
@@ -102,24 +106,24 @@ main (int argc, char **argv)
                        g_printf ("\n");
 
                        g_printf ("Setting root \"FOLDER2\"\n");
-                       confi_set_root (confi, "FOLDER2");
-                       g_printf ("Value from key \"key2\" %s\n", confi_path_get_value (confi, "key2"));
-                       g_printf ("Value from key \"FOLDER2/key2\" (expected null) %s\n", confi_path_get_value (confi, "FOLDER2/key2"));
+                       zak_confi_set_root (confi, "FOLDER2");
+                       g_printf ("Value from key \"key2\" %s\n", zak_confi_path_get_value (confi, "key2"));
+                       g_printf ("Value from key \"FOLDER2/key2\" (expected null) %s\n", zak_confi_path_get_value (confi, "FOLDER2/key2"));
                }
        else
                {
-                       gchar *val = confi_path_get_value (confi, "folder/key1/key1_2");
+                       gchar *val = zak_confi_path_get_value (confi, "folder/key1/key1_2");
                        g_printf ("Value from key \"folder/key1/key1_2\"\n%s\n\n", val);
-                       confi_path_set_value (confi, "folder/key1/key1_2", "new value programmatically setted");
-                       g_printf ("Value from key \"folder/key1/key1_2\"\n%s\n\n", confi_path_get_value (confi, "folder/key1/key1_2"));
-                       confi_path_set_value (confi, "folder/key1/key1_2", val);
+                       zak_confi_path_set_value (confi, "folder/key1/key1_2", "new value programmatically setted");
+                       g_printf ("Value from key \"folder/key1/key1_2\"\n%s\n\n", zak_confi_path_get_value (confi, "folder/key1/key1_2"));
+                       zak_confi_path_set_value (confi, "folder/key1/key1_2", val);
 
-                       confi_add_key (confi, "folder/key2", "key2-2", NULL);
-                       confi_path_set_value (confi, "folder/key2/key2-2", "value for key2-2, programmatically setted");
+                       zak_confi_add_key (confi, "folder/key2", "key2-2", NULL);
+                       zak_confi_path_set_value (confi, "folder/key2/key2-2", "value for key2-2, programmatically setted");
 
-                       ConfiKey *ck;
-                       ck = confi_path_get_confi_key (confi, "folder/key2/key2-2");
-                       g_printf ("ConfiKey for folder/key2/key2-2\n");
+                       ZakConfiKey *ck;
+                       ck = zak_confi_path_get_confi_key (confi, "folder/key2/key2-2");
+                       g_printf ("ZakConfiKey for folder/key2/key2-2\n");
                        g_printf ("Path: %s\n", ck->path);
                        g_printf ("Key: %s\n", ck->key);
                        g_printf ("Description: %s\n", ck->description);
@@ -127,12 +131,12 @@ main (int argc, char **argv)
                        g_printf ("\n");
 
                        g_printf ("Setting root \"folder/key2\"\n");
-                       confi_set_root (confi, "folder/key2");
-                       g_printf ("Value from key \"key2-1\" %s\n", confi_path_get_value (confi, "key2-1"));
-                       g_printf ("Value from key \"folder/key1/key1_2\" (expected null) %s\n", confi_path_get_value (confi, "folder/key1/key1_2"));
+                       zak_confi_set_root (confi, "folder/key2");
+                       g_printf ("Value from key \"key2-1\" %s\n", zak_confi_path_get_value (confi, "key2-1"));
+                       g_printf ("Value from key \"folder/key1/key1_2\" (expected null) %s\n", zak_confi_path_get_value (confi, "folder/key1/key1_2"));
                }
 
-       confi_destroy (confi);
+       zak_confi_destroy (confi);
 
        return 0;
 }