From: Thadeu Lima de Souza Cascardo Date: Tue, 6 Jan 2009 23:47:19 +0000 (-0200) Subject: Moved config current only implementation to subdirectory X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fatompub.git;a=commitdiff_plain;h=203d1d66ad0e4e614ab5e61dc82da2c5da4c58d5 Moved config current only implementation to subdirectory To allow multiple config backend implementations, move the gkeyfile implementation to its own subdirectory. --- diff --git a/atom/Makefile.am b/atom/Makefile.am index 166e8fc..c929f60 100644 --- a/atom/Makefile.am +++ b/atom/Makefile.am @@ -9,5 +9,5 @@ libatom_la_LIBADD += -L$(top_builddir)/backend/files -lgiochannel libatom_la_LIBADD += -L$(top_builddir)/backend/gio -lgio libatom_la_LIBADD += -L$(top_builddir)/backend/soup -lsoup libatom_la_LIBADD += -L$(top_builddir)/frontend/cgi -lcgi -libatom_la_LIBADD += -L$(top_builddir)/config -lgkeyfile +libatom_la_LIBADD += -L$(top_builddir)/config/gkeyfile -lgkeyfile libatom_la_LIBADD += -L$(top_builddir)/iri -liri diff --git a/config/Makefile.am b/config/Makefile.am index f778d19..b92f8f5 100644 --- a/config/Makefile.am +++ b/config/Makefile.am @@ -1,3 +1 @@ -noinst_LTLIBRARIES = libgkeyfile.la -libgkeyfile_la_SOURCES = gkeyfile.c -libgkeyfile_la_CFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS) +SUBDIRS = gkeyfile diff --git a/config/gkeyfile.c b/config/gkeyfile.c deleted file mode 100644 index 358354d..0000000 --- a/config/gkeyfile.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2007-2008 Thadeu Lima de Souza Cascardo - * - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - - -#include -#include - -static gchar * -gkeyfile_atom_config_get_str (AtomCtx *ctx, gchar *group, gchar * key) -{ - GKeyFile *keyfile; - gchar *value; - GError *error = NULL; - keyfile = atom_config_data (atom_config (ctx)); - value = g_key_file_get_string (keyfile, group, key, &error); - if (value == NULL) - { - AtomError *aerr = atom_error_new (); - atom_error_code_set (aerr, 500); - atom_error_message_set (aerr, error->message); - atom_error_set (ctx, aerr); - g_error_free (error); - } - return value; -} - -AtomConfig * -gkeyfile_atom_config_init (AtomCtx *ctx, char *name) -{ - AtomConfig *config; - GKeyFile *keyfile; - GError *error = NULL; - keyfile = g_key_file_new (); - if (!g_key_file_load_from_file (keyfile, name, - G_KEY_FILE_NONE, &error)) - { - AtomError *aerr = atom_error_new (); - atom_error_code_set (aerr, 500); - atom_error_message_set (aerr, error->message); - atom_error_set (ctx, aerr); - g_error_free (error); - return; - } - config = atom_config_new (); - atom_config_get_str_set (config, gkeyfile_atom_config_get_str); - atom_config_data_set (config, keyfile); -} diff --git a/config/gkeyfile/Makefile.am b/config/gkeyfile/Makefile.am new file mode 100644 index 0000000..f778d19 --- /dev/null +++ b/config/gkeyfile/Makefile.am @@ -0,0 +1,3 @@ +noinst_LTLIBRARIES = libgkeyfile.la +libgkeyfile_la_SOURCES = gkeyfile.c +libgkeyfile_la_CFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS) diff --git a/config/gkeyfile/gkeyfile.c b/config/gkeyfile/gkeyfile.c new file mode 100644 index 0000000..358354d --- /dev/null +++ b/config/gkeyfile/gkeyfile.c @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2007-2008 Thadeu Lima de Souza Cascardo + * + * + * 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + + +#include +#include + +static gchar * +gkeyfile_atom_config_get_str (AtomCtx *ctx, gchar *group, gchar * key) +{ + GKeyFile *keyfile; + gchar *value; + GError *error = NULL; + keyfile = atom_config_data (atom_config (ctx)); + value = g_key_file_get_string (keyfile, group, key, &error); + if (value == NULL) + { + AtomError *aerr = atom_error_new (); + atom_error_code_set (aerr, 500); + atom_error_message_set (aerr, error->message); + atom_error_set (ctx, aerr); + g_error_free (error); + } + return value; +} + +AtomConfig * +gkeyfile_atom_config_init (AtomCtx *ctx, char *name) +{ + AtomConfig *config; + GKeyFile *keyfile; + GError *error = NULL; + keyfile = g_key_file_new (); + if (!g_key_file_load_from_file (keyfile, name, + G_KEY_FILE_NONE, &error)) + { + AtomError *aerr = atom_error_new (); + atom_error_code_set (aerr, 500); + atom_error_message_set (aerr, error->message); + atom_error_set (ctx, aerr); + g_error_free (error); + return; + } + config = atom_config_new (); + atom_config_get_str_set (config, gkeyfile_atom_config_get_str); + atom_config_data_set (config, keyfile); +}