diff options
author | Omar Tarabai <tarabai@devegypt.com> | 2014-04-25 18:00:04 +0000 |
---|---|---|
committer | Omar Tarabai <tarabai@devegypt.com> | 2014-04-25 18:00:04 +0000 |
commit | f5961cc463e301090c16577f2f0cb28ca614d734 (patch) | |
tree | d864d47295159e892c5b2a824cdc380e7513a919 | |
parent | 344f48e48e8d4f1ea631f29d8fb3ae0faf3d7ef0 (diff) | |
download | gnunet-f5961cc463e301090c16577f2f0cb28ca614d734.tar.gz gnunet-f5961cc463e301090c16577f2f0cb28ca614d734.zip |
towards PEERSTORE file plugin
-rw-r--r-- | src/include/gnunet_peerstore_plugin.h | 2 | ||||
-rw-r--r-- | src/peerstore/Makefile.am | 17 | ||||
-rw-r--r-- | src/peerstore/gnunet-service-peerstore.c | 28 | ||||
-rw-r--r-- | src/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 index 9618f2b9f..dc2322459 100644 --- a/src/include/gnunet_peerstore_plugin.h +++ b/src/include/gnunet_peerstore_plugin.h | |||
@@ -59,5 +59,5 @@ struct GNUNET_PEERSTORE_PluginFunctions | |||
59 | } | 59 | } |
60 | #endif | 60 | #endif |
61 | 61 | ||
62 | /* end of gnunet_namestore_plugin.h */ | 62 | /* end of gnunet_peerstore_plugin.h */ |
63 | #endif | 63 | #endif |
diff --git a/src/peerstore/Makefile.am b/src/peerstore/Makefile.am index 0b111cc50..821700b5a 100644 --- a/src/peerstore/Makefile.am +++ b/src/peerstore/Makefile.am | |||
@@ -1,5 +1,7 @@ | |||
1 | AM_CPPFLAGS = -I$(top_srcdir)/src/include | 1 | AM_CPPFLAGS = -I$(top_srcdir)/src/include |
2 | 2 | ||
3 | plugindir = $(libdir)/gnunet | ||
4 | |||
3 | pkgcfgdir= $(pkgdatadir)/config.d/ | 5 | pkgcfgdir= $(pkgdatadir)/config.d/ |
4 | 6 | ||
5 | libexecdir= $(pkglibdir)/libexec/ | 7 | libexecdir= $(pkglibdir)/libexec/ |
@@ -44,6 +46,21 @@ libgnunetpeerstore_la_LIBADD = \ | |||
44 | libgnunetpeerstore_la_LDFLAGS = \ | 46 | libgnunetpeerstore_la_LDFLAGS = \ |
45 | $(GNUNET_LDFLAGS) | 47 | $(GNUNET_LDFLAGS) |
46 | 48 | ||
49 | plugin_LTLIBRARIES = \ | ||
50 | libgnunet_plugin_peerstore_file.la | ||
51 | |||
52 | libgnunet_plugin_peerstore_file_la_SOURCES = \ | ||
53 | plugin_peerstore_file.c | ||
54 | libgnunet_plugin_peerstore_file_la_LIBADD = \ | ||
55 | $(top_builddir)/src/peerstore/libgnunetpeerstore.la \ | ||
56 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
57 | $(LTLIBINTL) | ||
58 | libgnunet_plugin_peerstore_file_la_LDFLAGS = \ | ||
59 | $(GN_PLUGIN_LDFLAGS) | ||
60 | libgnunet_plugin_peerstore_file_la_DEPENDENCIES = \ | ||
61 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
62 | libgnunetpeerstore.la | ||
63 | |||
47 | check_PROGRAMS = \ | 64 | check_PROGRAMS = \ |
48 | test_peerstore_api | 65 | test_peerstore_api |
49 | 66 | ||
diff --git a/src/peerstore/gnunet-service-peerstore.c b/src/peerstore/gnunet-service-peerstore.c index 2c54b6d0c..418e33703 100644 --- a/src/peerstore/gnunet-service-peerstore.c +++ b/src/peerstore/gnunet-service-peerstore.c | |||
@@ -33,6 +33,11 @@ | |||
33 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 33 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
34 | 34 | ||
35 | /** | 35 | /** |
36 | * Database handle | ||
37 | */ | ||
38 | static struct GNUNET_PEERSTORE_PluginFunctions *db; | ||
39 | |||
40 | /** | ||
36 | * Task run during shutdown. | 41 | * Task run during shutdown. |
37 | * | 42 | * |
38 | * @param cls unused | 43 | * @param cls unused |
@@ -80,16 +85,23 @@ run (void *cls, | |||
80 | if (GNUNET_OK != | 85 | if (GNUNET_OK != |
81 | GNUNET_CONFIGURATION_get_value_string (cfg, "peerstore", "DATABASE", | 86 | GNUNET_CONFIGURATION_get_value_string (cfg, "peerstore", "DATABASE", |
82 | &database)) | 87 | &database)) |
83 | { | ||
84 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No database backend configured\n"); | 88 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No database backend configured\n"); |
85 | return; | ||
86 | } | ||
87 | GNUNET_asprintf (&db_lib_name, "libgnunet_plugin_peerstore_%s", database); | ||
88 | 89 | ||
89 | GNUNET_SERVER_add_handlers (server, handlers); | 90 | else |
90 | GNUNET_SERVER_disconnect_notify (server, | 91 | { |
91 | &handle_client_disconnect, | 92 | GNUNET_asprintf (&db_lib_name, "libgnunet_plugin_peerstore_%s", database); |
92 | NULL); | 93 | db = GNUNET_PLUGIN_load(db_lib_name, (void *) cfg); |
94 | GNUNET_free(database); | ||
95 | } | ||
96 | if(NULL == db) | ||
97 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Could not load database backend `%s'\n", db_lib_name); | ||
98 | else | ||
99 | { | ||
100 | GNUNET_SERVER_add_handlers (server, handlers); | ||
101 | GNUNET_SERVER_disconnect_notify (server, | ||
102 | &handle_client_disconnect, | ||
103 | NULL); | ||
104 | } | ||
93 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 105 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
94 | &shutdown_task, | 106 | &shutdown_task, |
95 | NULL); | 107 | NULL); |
diff --git a/src/peerstore/plugin_peerstore_file.c b/src/peerstore/plugin_peerstore_file.c new file mode 100644 index 000000000..b23088bc2 --- /dev/null +++ b/src/peerstore/plugin_peerstore_file.c | |||
@@ -0,0 +1,33 @@ | |||
1 | /* | ||
2 | * This file is part of GNUnet | ||
3 | * (C) 2013 Christian Grothoff (and other contributing authors) | ||
4 | * | ||
5 | * GNUnet is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published | ||
7 | * by the Free Software Foundation; either version 3, or (at your | ||
8 | * option) any later version. | ||
9 | * | ||
10 | * GNUnet is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with GNUnet; see the file COPYING. If not, write to the | ||
17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | * Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file peerstore/plugin_peerstore_file.c | ||
23 | * @brief file-based peerstore backend | ||
24 | * @author Omar Tarabai | ||
25 | */ | ||
26 | |||
27 | #include "platform.h" | ||
28 | #include "gnunet_peerstore_plugin.h" | ||
29 | #include "gnunet_peerstore_service.h" | ||
30 | #include "peerstore.h" | ||
31 | |||
32 | |||
33 | /* end of plugin_peerstore_file.c */ | ||