gnunet

Main GNUnet Logic
Log | Files | Refs | Submodules | README | LICENSE

commit f5961cc463e301090c16577f2f0cb28ca614d734
parent 344f48e48e8d4f1ea631f29d8fb3ae0faf3d7ef0
Author: Omar Tarabai <tarabai@devegypt.com>
Date:   Fri, 25 Apr 2014 18:00:04 +0000

towards PEERSTORE file plugin


Diffstat:
Msrc/include/gnunet_peerstore_plugin.h | 2+-
Msrc/peerstore/Makefile.am | 17+++++++++++++++++
Msrc/peerstore/gnunet-service-peerstore.c | 28++++++++++++++++++++--------
Asrc/peerstore/plugin_peerstore_file.c | 33+++++++++++++++++++++++++++++++++
4 files changed, 71 insertions(+), 9 deletions(-)

diff --git a/src/include/gnunet_peerstore_plugin.h b/src/include/gnunet_peerstore_plugin.h @@ -59,5 +59,5 @@ struct GNUNET_PEERSTORE_PluginFunctions } #endif -/* end of gnunet_namestore_plugin.h */ +/* end of gnunet_peerstore_plugin.h */ #endif diff --git a/src/peerstore/Makefile.am b/src/peerstore/Makefile.am @@ -1,5 +1,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/src/include +plugindir = $(libdir)/gnunet + pkgcfgdir= $(pkgdatadir)/config.d/ libexecdir= $(pkglibdir)/libexec/ @@ -44,6 +46,21 @@ libgnunetpeerstore_la_LIBADD = \ libgnunetpeerstore_la_LDFLAGS = \ $(GNUNET_LDFLAGS) +plugin_LTLIBRARIES = \ + libgnunet_plugin_peerstore_file.la + +libgnunet_plugin_peerstore_file_la_SOURCES = \ + plugin_peerstore_file.c +libgnunet_plugin_peerstore_file_la_LIBADD = \ + $(top_builddir)/src/peerstore/libgnunetpeerstore.la \ + $(top_builddir)/src/util/libgnunetutil.la \ + $(LTLIBINTL) +libgnunet_plugin_peerstore_file_la_LDFLAGS = \ + $(GN_PLUGIN_LDFLAGS) +libgnunet_plugin_peerstore_file_la_DEPENDENCIES = \ + $(top_builddir)/src/util/libgnunetutil.la \ + libgnunetpeerstore.la + check_PROGRAMS = \ test_peerstore_api diff --git a/src/peerstore/gnunet-service-peerstore.c b/src/peerstore/gnunet-service-peerstore.c @@ -33,6 +33,11 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg; /** + * Database handle + */ +static struct GNUNET_PEERSTORE_PluginFunctions *db; + +/** * Task run during shutdown. * * @param cls unused @@ -80,16 +85,23 @@ run (void *cls, if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "peerstore", "DATABASE", &database)) - { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No database backend configured\n"); - return; - } - GNUNET_asprintf (&db_lib_name, "libgnunet_plugin_peerstore_%s", database); - GNUNET_SERVER_add_handlers (server, handlers); - GNUNET_SERVER_disconnect_notify (server, - &handle_client_disconnect, - NULL); + else + { + GNUNET_asprintf (&db_lib_name, "libgnunet_plugin_peerstore_%s", database); + db = GNUNET_PLUGIN_load(db_lib_name, (void *) cfg); + GNUNET_free(database); + } + if(NULL == db) + GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Could not load database backend `%s'\n", db_lib_name); + else + { + GNUNET_SERVER_add_handlers (server, handlers); + GNUNET_SERVER_disconnect_notify (server, + &handle_client_disconnect, + NULL); + } GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); diff --git a/src/peerstore/plugin_peerstore_file.c b/src/peerstore/plugin_peerstore_file.c @@ -0,0 +1,33 @@ +/* + * This file is part of GNUnet + * (C) 2013 Christian Grothoff (and other contributing authors) + * + * GNUnet 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 3, or (at your + * option) any later version. + * + * GNUnet 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 GNUnet; see the file COPYING. If not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/** + * @file peerstore/plugin_peerstore_file.c + * @brief file-based peerstore backend + * @author Omar Tarabai + */ + +#include "platform.h" +#include "gnunet_peerstore_plugin.h" +#include "gnunet_peerstore_service.h" +#include "peerstore.h" + + +/* end of plugin_peerstore_file.c */