summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HACKING2
-rw-r--r--configure.ac11
-rw-r--r--src/Makefile.am1
-rw-r--r--src/datastore/Makefile.am69
-rw-r--r--src/datastore/datastore.h34
-rw-r--r--src/datastore/datastore_api.c160
-rw-r--r--src/datastore/gnunet-service-datastore.c205
-rw-r--r--src/datastore/plugin_datastore.h6
-rw-r--r--src/datastore/plugin_datastore_sqlite.c286
-rw-r--r--src/datastore/plugin_datastore_template.c286
-rw-r--r--src/include/gnunet_datastore_service.h9
-rw-r--r--src/include/gnunet_util_lib.h1
-rw-r--r--src/resolver/gnunet-service-resolver.c2
-rw-r--r--src/transport/Makefile.am2
14 files changed, 1061 insertions, 13 deletions
diff --git a/HACKING b/HACKING
index 73eda98e6..aa4428578 100644
--- a/HACKING
+++ b/HACKING
@@ -26,7 +26,7 @@ testcases:
performance tests:
- must be called "perf_module-under-test_case-description.c"
-- "case-description" maybe omitted if there is only one test
+- "case-description" maybe omitted if there is only one performance test
diff --git a/configure.ac b/configure.ac
index 1fc3e2eb7..634ef34a1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -750,17 +750,19 @@ AM_CONDITIONAL([USE_COVERAGE], [test "x$use_gcov" = "xyes"])
-AC_CONFIG_FILES([ po/Makefile.in m4/Makefile
+AC_CONFIG_FILES([
Makefile
contrib/Makefile
+m4/Makefile
+po/Makefile.in
src/Makefile
src/arm/Makefile
src/core/Makefile
-src/include/Makefile
-src/include/gnunet_directories.h
-src/util/Makefile
+src/datastore/Makefile
src/fragmentation/Makefile
src/hello/Makefile
+src/include/Makefile
+src/include/gnunet_directories.h
src/hostlist/Makefile
src/peerinfo/Makefile
src/resolver/Makefile
@@ -768,6 +770,7 @@ src/statistics/Makefile
src/template/Makefile
src/topology/Makefile
src/transport/Makefile
+src/util/Makefile
])
AC_OUTPUT
diff --git a/src/Makefile.am b/src/Makefile.am
index 4f3d7995a..c366ce20c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -11,6 +11,7 @@ SUBDIRS = \
include $(INTLEMU_SUBDIRS) \
util \
arm \
+ datastore \
fragmentation \
hello \
peerinfo \
diff --git a/src/datastore/Makefile.am b/src/datastore/Makefile.am
new file mode 100644
index 000000000..839df983d
--- /dev/null
+++ b/src/datastore/Makefile.am
@@ -0,0 +1,69 @@
+INCLUDES = -I$(top_srcdir)/src/include
+
+plugindir = $(libdir)/gnunet
+
+if MINGW
+ WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols
+endif
+
+if USE_COVERAGE
+ AM_CFLAGS = --coverage -O0
+ XLIBS = -lgcov
+endif
+
+
+lib_LTLIBRARIES = \
+ libgnunetdatastore.la
+
+libgnunetdatastore_la_SOURCES = \
+ datastore_api.c datastore.h
+libgnunetdatastore_la_LIBADD = \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(GN_LIBINTL)
+libgnunetdatastore_la_LDFLAGS = \
+ $(GN_LIB_LDFLAGS) $(WINFLAGS) \
+ -version-info 0:0:0
+
+
+bin_PROGRAMS = \
+ gnunet-service-datastore
+
+gnunet_service_datastore_SOURCES = \
+ gnunet-service-datastore.c plugin_datastore.h
+gnunet_service_datastore_LDADD = \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(GN_LIBINTL)
+
+
+plugin_LTLIBRARIES = \
+ libgnunet_plugin_datastore_sqlite.la \
+ libgnunet_plugin_datastore_template.la
+
+
+libgnunet_plugin_datastore_sqlite_la_SOURCES = \
+ plugin_datastore_sqlite.c
+libgnunet_plugin_datastore_sqlite_la_LIBADD = \
+ $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) -lsqlite3
+libgnunet_plugin_datastore_sqlite_la_LDFLAGS = \
+ $(GN_PLUGIN_LDFLAGS)
+
+libgnunet_plugin_datastore_template_la_SOURCES = \
+ plugin_datastore_template.c
+libgnunet_plugin_datastore_template_la_LIBADD = \
+ $(top_builddir)/src/util/libgnunetutil.la $(XLIBS)
+libgnunet_plugin_datastore_template_la_LDFLAGS = \
+ $(GN_PLUGIN_LDFLAGS)
+
+
+#check_PROGRAMS = \
+# test_datastore_api
+#
+#TESTS = $(check_PROGRAMS)
+#
+#test_datastore_api_SOURCES = \
+# test_datastore_api.c
+#test_datastore_api_LDADD = \
+# $(top_builddir)/src/datastore/libgnunetdatastore.la \
+# $(top_builddir)/src/util/libgnunetutil.la
+
+
diff --git a/src/datastore/datastore.h b/src/datastore/datastore.h
new file mode 100644
index 000000000..e6860efbb
--- /dev/null
+++ b/src/datastore/datastore.h
@@ -0,0 +1,34 @@
+/*
+ This file is part of GNUnet
+ (C) 2004, 2005, 2006, 2007, 2009 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 2, 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 datastore/datastore.hc
+ * @brief structs for communication between datastore service and API
+ * @author Christian Grothoff
+ */
+
+#ifndef DATASTORE_H
+#define DATASTORE_H
+
+#include "gnunet_util_lib.h"
+
+
+
+#endif
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c
new file mode 100644
index 000000000..cc563ba79
--- /dev/null
+++ b/src/datastore/datastore_api.c
@@ -0,0 +1,160 @@
+/*
+ This file is part of GNUnet
+ (C) 2004, 2005, 2006, 2007, 2009 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 2, 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 datastore/datastore_api.c
+ * @brief Management for the datastore for files stored on a GNUnet node
+ * @author Christian Grothoff
+ */
+
+#include "platform.h"
+#include "gnunet_datastore_service.h"
+#include "datastore.h"
+
+/**
+ * Handle to the datastore service.
+ */
+struct GNUNET_DATASTORE_Handle
+{
+};
+
+
+/**
+ * Connect to the datastore service.
+ *
+ * @param cfg configuration to use
+ * @param sched scheduler to use
+ * @return handle to use to access the service
+ */
+struct GNUNET_DATASTORE_Handle *GNUNET_DATASTORE_connect (struct
+ GNUNET_CONFIGURATION_Handle
+ *cfg,
+ struct
+ GNUNET_SCHEDULER_Handle
+ *sched)
+{
+ return NULL;
+}
+
+
+/**
+ * Disconnect from the datastore service (and free
+ * associated resources).
+ *
+ * @param h handle to the datastore
+ * @param drop set to GNUNET_YES to delete all data in datastore (!)
+ */
+void GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h,
+ int drop)
+{
+}
+
+
+/**
+ * Get the current on-disk size of the datastore.
+ * @param h handle to the datastore
+ * @return size estimate, -1 if datastore is not available (yet)
+ */
+unsigned long long GNUNET_DATASTORE_size (struct GNUNET_DATASTORE_Handle *h)
+{
+ return 0;
+}
+
+
+/**
+ * Store an item in the datastore. If the item is already present,
+ * the priorities are summed up and the higher expiration time and
+ * lower anonymity level is used.
+ *
+ * @param h handle to the datastore
+ * @param key key for the value
+ * @param size number of bytes in data
+ * @param data content stored
+ * @param type type of the content
+ * @param priority priority of the content
+ * @param anonymity anonymity-level for the content
+ * @param expiration expiration time for the content
+ */
+void
+GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h,
+ const GNUNET_HashCode * key,
+ uint32_t size,
+ const void *data,
+ uint32_t type,
+ uint32_t priority,
+ uint32_t anonymity,
+ struct GNUNET_TIME_Absolute expiration)
+{
+}
+
+
+/**
+ * Iterate over the results for a particular key
+ * in the datastore.
+ *
+ * @param h handle to the datastore
+ * @param key maybe NULL (to match all entries)
+ * @param type desired type, 0 for any
+ * @param iter function to call on each matching value;
+ * will be called once with a NULL value at the end
+ * @param iter_cls closure for iter
+ */
+void
+GNUNET_DATASTORE_get (struct GNUNET_DATASTORE_Handle *h,
+ const GNUNET_HashCode * key,
+ uint32_t type,
+ GNUNET_DATASTORE_Iterator iter, void *iter_cls)
+{
+}
+
+
+/**
+ * Get a random value from the datastore.
+ *
+ * @param h handle to the datastore
+ * @param iter function to call on each matching value;
+ * will be called exactly once; if no values
+ * are available, the value will be NULL.
+ * @param iter_cls closure for iter
+ */
+void
+GNUNET_DATASTORE_get_random (struct GNUNET_DATASTORE_Handle *h,
+ GNUNET_DATASTORE_Iterator iter, void *iter_cls)
+{
+}
+
+
+/**
+ * Explicitly remove some content from the database.
+ *
+ * @param h handle to the datastore
+ * @param key key for the value
+ * @param size number of bytes in data
+ * @param data content stored
+ */
+void
+GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h,
+ const GNUNET_HashCode * key,
+ uint32_t size, const void *data)
+{
+}
+
+
+/* end of datastore_api.c */
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c
new file mode 100644
index 000000000..8ee153db0
--- /dev/null
+++ b/src/datastore/gnunet-service-datastore.c
@@ -0,0 +1,205 @@
+/*
+ This file is part of GNUnet
+ (C) 2004, 2005, 2006, 2007, 2009 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 2, 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 datastore/gnunet-service-datastore.c
+ * @brief Management for the datastore for files stored on a GNUnet node
+ * @author Christian Grothoff
+ */
+
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_protocols.h"
+#include "plugin_datastore.h"
+#include "datastore.h"
+
+
+/**
+ * Our datastore plugin.
+ */
+struct DatastorePlugin
+{
+
+ /**
+ * API of the transport as returned by the plugin's
+ * initialization function.
+ */
+ struct GNUNET_DATSTORE_PluginFunctions *api;
+
+ /**
+ * Short name for the plugin (i.e. "sqlite").
+ */
+ char *short_name;
+
+ /**
+ * Name of the library (i.e. "gnunet_plugin_datastore_sqlite").
+ */
+ char *lib_name;
+
+ /**
+ * Environment this transport service is using
+ * for this plugin.
+ */
+ struct GNUNET_DATASTORE_PluginEnvironment env;
+
+};
+
+
+/**
+ * Our datastore plugin (NULL if not available).
+ */
+static struct DatastorePlugin *plugin;
+
+
+/**
+ * List of handlers for the messages understood by this
+ * service.
+ */
+static struct GNUNET_SERVER_MessageHandler handlers[] = {
+ /* {&handle_xxx, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_XXX, 0}, */
+ {NULL, NULL, 0, 0}
+};
+
+
+
+/**
+ * Load the datastore plugin.
+ */
+static struct DatastorePlugin *
+load_plugin (struct GNUNET_CONFIGURATION_Handle *cfg,
+ struct GNUNET_SCHEDULER_Handle *sched)
+{
+ struct DatastorePlugin *ret;
+ char *libname;
+ char *name;
+
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ "DATASTORE", "DATABASE", &name))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("No `%s' specified for `%s' in configuration!\n"),
+ "DATABASE",
+ "DATASTORE");
+ return NULL;
+ }
+ ret = GNUNET_malloc (sizeof(struct DatastorePlugin));
+ ret->env.cfg = cfg;
+ ret->env.sched = sched;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ _("Loading `%s' datastore plugin\n"), name);
+ GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name);
+ ret->short_name = GNUNET_strdup (name);
+ ret->lib_name = libname;
+ ret->api = GNUNET_PLUGIN_load (libname, &ret->env);
+ if (ret->api == NULL)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Failed to load datastore plugin for `%s'\n"), name);
+ GNUNET_free (ret->short_name);
+ GNUNET_free (libname);
+ GNUNET_free (ret);
+ return NULL;
+ }
+ return ret;
+}
+
+
+/**
+ * Function called when the service shuts
+ * down. Unloads our datastore plugin.
+ *
+ * @param cls closure
+ * @param cfg configuration to use
+ */
+static void
+unload_plugin (struct DatastorePlugin *plug)
+{
+#if DEBUG_DATASTORE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Datastore service is unloading plugin...\n");
+#endif
+ GNUNET_break (NULL == GNUNET_PLUGIN_unload (plug->lib_name, plug->api));
+ GNUNET_free (plug->lib_name);
+ GNUNET_free (plug->short_name);
+ GNUNET_free (plug);
+}
+
+
+/**
+ * Last task run during shutdown. Disconnects us from
+ * the transport and core.
+ */
+static void
+cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ unload_plugin (plugin);
+ plugin = NULL;
+}
+
+
+/**
+ * Process datastore requests.
+ *
+ * @param cls closure
+ * @param sched scheduler to use
+ * @param server the initialized server
+ * @param cfg configuration to use
+ */
+static void
+run (void *cls,
+ struct GNUNET_SCHEDULER_Handle *sched,
+ struct GNUNET_SERVER_Handle *server,
+ struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ plugin = load_plugin (cfg, sched);
+ if (NULL == plugin)
+ return;
+ GNUNET_SERVER_add_handlers (server, handlers);
+ GNUNET_SCHEDULER_add_delayed (sched,
+ GNUNET_YES,
+ GNUNET_SCHEDULER_PRIORITY_IDLE,
+ GNUNET_SCHEDULER_NO_PREREQUISITE_TASK,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &cleaning_task, NULL);
+}
+
+
+/**
+ * The main function for the datastore service.
+ *
+ * @param argc number of arguments from the command line
+ * @param argv command line arguments
+ * @return 0 ok, 1 on error
+ */
+int
+main (int argc, char *const *argv)
+{
+ int ret;
+
+ ret = (GNUNET_OK ==
+ GNUNET_SERVICE_run (argc,
+ argv,
+ "datastore", &run, NULL, NULL, NULL)) ? 0 : 1;
+ return ret;
+}
+
+
+/* end of gnunet-service-datastore.c */
diff --git a/src/datastore/plugin_datastore.h b/src/datastore/plugin_datastore.h
index b4dc87f9d..0f3284b07 100644
--- a/src/datastore/plugin_datastore.h
+++ b/src/datastore/plugin_datastore.h
@@ -79,7 +79,7 @@ typedef void
const GNUNET_HashCode * key,
uint32_t size,
const void *data,
- unit32_t type,
+ uint32_t type,
uint32_t priority,
uint32_t anonymity,
struct GNUNET_TIME_Absolute expiration);
@@ -175,7 +175,7 @@ struct GNUNET_DATASTORE_PluginFunctions
* Get the current on-disk size of the SQ store. Estimates are
* fine, if that's the only thing available.
*/
- GNUNET_DATASTORE_GetSize size;
+ GNUNET_DATASTORE_GetSize get_size;
/**
* Function to store an item in the datastore.
@@ -213,7 +213,7 @@ struct GNUNET_DATASTORE_PluginFunctions
* Iterate over the items in the datastore in ascending
* order of expiration time.
*/
- GNUNET_DATSTORE_Selector iter_ascending_expiration;
+ GNUNET_DATASTORE_Selector iter_ascending_expiration;
/**
* Iterate over the items in the datastore in migration
diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c
new file mode 100644
index 000000000..486b9b96e
--- /dev/null
+++ b/src/datastore/plugin_datastore_sqlite.c
@@ -0,0 +1,286 @@
+/*
+ This file is part of GNUnet
+ (C) 2009 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 2, 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 datastore/plugin_datastore_sqlite.c
+ * @brief sqlite-based datastore backend
+ * @author Christian Grothoff
+ */
+
+#include "platform.h"
+#include "plugin_datastore.h"
+
+
+/**
+ * Context for all functions in this plugin.
+ */
+struct Plugin
+{
+ /**
+ * Our execution environment.
+ */
+ struct GNUNET_DATASTORE_PluginEnvironment *env;
+};
+
+
+/**
+ * Get an estimate of how much space the database is
+ * currently using.
+ * @return number of bytes used on disk
+ */
+static unsigned long long sqlite_plugin_get_size (void *cls)
+{
+ return 0;
+}
+
+
+/**
+ * Store an item in the datastore.
+ *
+ * @param cls closure
+ * @param key key for the item
+ * @param size number of bytes in data
+ * @param data content stored
+ * @param type type of the content
+ * @param priority priority of the content
+ * @param anonymity anonymity-level for the content
+ * @param expiration expiration time for the content
+ */
+static void
+sqlite_plugin_put (void *cls,
+ const GNUNET_HashCode * key,
+ uint32_t size,
+ const void *data,
+ uint32_t type,
+ uint32_t priority,
+ uint32_t anonymity,
+ struct GNUNET_TIME_Absolute expiration)
+{
+}
+
+
+/**
+ * Iterate over the results for a particular key
+ * in the datastore.
+ *
+ * @param cls closure
+ * @param key maybe NULL (to match all entries)
+ * @param vhash hash of the value, maybe NULL (to
+ * match all values that have the right key).
+ * Note that for DBlocks there is no difference
+ * betwen key and vhash, but for other blocks
+ * there may be!
+ * @param type entries of which type are relevant?
+ * Use 0 for any type.
+ * @param iter function to call on each matching value;
+ * will be called once with a NULL value at the end
+ * @param iter_cls closure for iter
+ */
+static void
+sqlite_plugin_get (void *cls,
+ const GNUNET_HashCode * key,
+ const GNUNET_HashCode * vhash,
+ uint32_t type,
+ GNUNET_DATASTORE_Iterator iter, void *iter_cls)
+{
+}
+
+
+/**
+ * Update the priority for a particular key in the datastore. If
+ * the expiration time in value is different than the time found in
+ * the datastore, the higher value should be kept. For the
+ * anonymity level, the lower value is to be used. The specified
+ * priority should be added to the existing priority, ignoring the
+ * priority in value.
+ *
+ * Note that it is possible for multiple values to match this put.
+ * In that case, all of the respective values are updated.
+ *
+ * @param uid unique identifier of the datum
+ * @param delta by how much should the priority
+ * change? If priority + delta < 0 the
+ * priority should be set to 0 (never go
+ * negative).
+ * @param expire new expiration time should be the
+ * MAX of any existing expiration time and
+ * this value
+ */
+static void
+sqlite_plugin_update (void *cls,
+ unsigned long long uid,
+ int delta, struct GNUNET_TIME_Absolute expire)
+{
+}
+
+
+/**
+ * Select a subset of the items in the datastore and call
+ * the given iterator for each of them.
+ *
+ * @param type entries of which type should be considered?
+ * Use 0 for any type.
+ * @param iter function to call on each matching value;
+ * will be called once with a NULL value at the end
+ * @param iter_cls closure for iter
+ */
+static void
+sqlite_plugin_iter_low_priority (void *cls,
+ uint32_t type,
+ GNUNET_DATASTORE_Iterator iter,
+ void *iter_cls)
+{
+}
+
+
+
+/**
+ * Select a subset of the items in the datastore and call
+ * the given iterator for each of them.
+ *
+ * @param type entries of which type should be considered?
+ * Use 0 for any type.
+ * @param iter function to call on each matching value;
+ * will be called once with a NULL value at the end
+ * @param iter_cls closure for iter
+ */
+static void
+sqlite_plugin_iter_zero_anonymity (void *cls,
+ uint32_t type,
+ GNUNET_DATASTORE_Iterator iter,
+ void *iter_cls)
+{
+}
+
+
+
+/**
+ * Select a subset of the items in the datastore and call
+ * the given iterator for each of them.
+ *
+ * @param type entries of which type should be considered?
+ * Use 0 for any type.
+ * @param iter function to call on each matching value;
+ * will be called once with a NULL value at the end
+ * @param iter_cls closure for iter
+ */
+static void
+sqlite_plugin_iter_ascending_expiration (void *cls,
+ uint32_t type,
+ GNUNET_DATASTORE_Iterator iter,
+ void *iter_cls)
+{
+}
+
+
+
+/**
+ * Select a subset of the items in the datastore and call
+ * the given iterator for each of them.
+ *
+ * @param type entries of which type should be considered?
+ * Use 0 for any type.
+ * @param iter function to call on each matching value;
+ * will be called once with a NULL value at the end
+ * @param iter_cls closure for iter
+ */
+static void
+sqlite_plugin_iter_migration_order (void *cls,
+ uint32_t type,
+ GNUNET_DATASTORE_Iterator iter,
+ void *iter_cls)
+{
+}
+
+
+
+/**
+ * Select a subset of the items in the datastore and call
+ * the given iterator for each of them.
+ *
+ * @param type entries of which type should be considered?
+ * Use 0 for any type.
+ * @param iter function to call on each matching value;
+ * will be called once with a NULL value at the end
+ * @param iter_cls closure for iter
+ */
+static void
+sqlite_plugin_iter_all_now (void *cls,
+ uint32_t type,
+ GNUNET_DATASTORE_Iterator iter,
+ void *iter_cls)
+{
+}
+
+
+/**
+ * Drop database.
+ */
+static void
+sqlite_plugin_drop (void *cls)
+{
+}
+
+
+/**
+ * Entry point for the plugin.
+ */
+void *
+libgnunet_plugin_datastore_sqlite_init (void *cls)
+{
+ struct GNUNET_DATASTORE_PluginEnvironment *env = cls;
+ struct GNUNET_DATASTORE_PluginFunctions *api;
+ struct Plugin *plugin;
+
+ plugin = GNUNET_malloc (sizeof (struct Plugin));
+ plugin->env = env;
+ api = GNUNET_malloc (sizeof (struct GNUNET_DATASTORE_PluginFunctions));
+ api->cls = plugin;
+ api->get_size = &sqlite_plugin_get_size;
+ api->put = &sqlite_plugin_put;
+ api->get = &sqlite_plugin_get;
+ api->update = &sqlite_plugin_update;
+ api->iter_low_priority = &sqlite_plugin_iter_low_priority;
+ api->iter_zero_anonymity = &sqlite_plugin_iter_zero_anonymity;
+ api->iter_ascending_expiration = &sqlite_plugin_iter_ascending_expiration;
+ api->iter_migration_order = &sqlite_plugin_iter_migration_order;
+ api->iter_all_now = &sqlite_plugin_iter_all_now;
+ api->drop = &sqlite_plugin_drop;
+ GNUNET_log_from (GNUNET_ERROR_TYPE_INFO,
+ "sqlite", _("Sqlite database running\n"));
+ return api;
+}
+
+
+/**
+ * Exit point from the plugin.
+ */
+void *
+libgnunet_plugin_datastore_sqlite_done (void *cls)
+{
+ struct GNUNET_DATASTORE_PluginFunctions *api = cls;
+ struct Plugin *plugin = api->cls;
+
+ GNUNET_free (plugin);
+ GNUNET_free (api);
+ return NULL;
+}
+
+/* end of plugin_datastore_sqlite.c */
diff --git a/src/datastore/plugin_datastore_template.c b/src/datastore/plugin_datastore_template.c
new file mode 100644
index 000000000..70b8c635e
--- /dev/null
+++ b/src/datastore/plugin_datastore_template.c
@@ -0,0 +1,286 @@
+/*
+ This file is part of GNUnet
+ (C) 2009 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 2, 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 datastore/plugin_datastore_template.c
+ * @brief template-based datastore backend
+ * @author Christian Grothoff
+ */
+
+#include "platform.h"
+#include "plugin_datastore.h"
+
+
+/**
+ * Context for all functions in this plugin.
+ */
+struct Plugin
+{
+ /**
+ * Our execution environment.
+ */
+ struct GNUNET_DATASTORE_PluginEnvironment *env;
+};
+
+
+/**
+ * Get an estimate of how much space the database is
+ * currently using.
+ * @return number of bytes used on disk
+ */
+static unsigned long long template_plugin_get_size (void *cls)
+{
+ return 0;
+}
+
+
+/**
+ * Store an item in the datastore.
+ *
+ * @param cls closure
+ * @param key key for the item
+ * @param size number of bytes in data
+ * @param data content stored
+ * @param type type of the content
+ * @param priority priority of the content
+ * @param anonymity anonymity-level for the content
+ * @param expiration expiration time for the content
+ */
+static void
+template_plugin_put (void *cls,
+ const GNUNET_HashCode * key,
+ uint32_t size,
+ const void *data,
+ uint32_t type,
+ uint32_t priority,
+ uint32_t anonymity,
+ struct GNUNET_TIME_Absolute expiration)
+{
+}
+
+
+/**
+ * Iterate over the results for a particular key
+ * in the datastore.
+ *
+ * @param cls closure
+ * @param key maybe NULL (to match all entries)
+ * @param vhash hash of the value, maybe NULL (to
+ * match all values that have the right key).
+ * Note that for DBlocks there is no difference
+ * betwen key and vhash, but for other blocks
+ * there may be!
+ * @param type entries of which type are relevant?
+ * Use 0 for any type.
+ * @param iter function to call on each matching value;
+ * will be called once with a NULL value at the end
+ * @param iter_cls closure for iter
+ */
+static void
+template_plugin_get (void *cls,
+ const GNUNET_HashCode * key,
+ const GNUNET_HashCode * vhash,
+ uint32_t type,
+ GNUNET_DATASTORE_Iterator iter, void *iter_cls)
+{
+}
+
+
+/**
+ * Update the priority for a particular key in the datastore. If
+ * the expiration time in value is different than the time found in
+ * the datastore, the higher value should be kept. For the
+ * anonymity level, the lower value is to be used. The specified
+ * priority should be added to the existing priority, ignoring the
+ * priority in value.
+ *
+ * Note that it is possible for multiple values to match this put.
+ * In that case, all of the respective values are updated.
+ *
+ * @param uid unique identifier of the datum
+ * @param delta by how much should the priority
+ * change? If priority + delta < 0 the
+ * priority should be set to 0 (never go
+ * negative).
+ * @param expire new expiration time should be the
+ * MAX of any existing expiration time and
+ * this value
+ */
+static void
+template_plugin_update (void *cls,
+ unsigned long long uid,
+ int delta, struct GNUNET_TIME_Absolute expire)
+{
+}
+
+
+/**
+ * Select a subset of the items in the datastore and call
+ * the given iterator for each of them.
+ *
+ * @param type entries of which type should be considered?
+ * Use 0 for any type.
+ * @param iter function to call on each matching value;
+ * will be called once with a NULL value at the end
+ * @param iter_cls closure for iter
+ */
+static void
+template_plugin_iter_low_priority (void *cls,
+ uint32_t type,
+ GNUNET_DATASTORE_Iterator iter,
+ void *iter_cls)
+{
+}
+
+
+
+/**
+ * Select a subset of the items in the datastore and call
+ * the given iterator for each of them.
+ *
+ * @param type entries of which type should be considered?
+ * Use 0 for any type.
+ * @param iter function to call on each matching value;
+ * will be called once with a NULL value at the end
+ * @param iter_cls closure for iter
+ */
+static void
+template_plugin_iter_zero_anonymity (void *cls,
+ uint32_t type,
+ GNUNET_DATASTORE_Iterator iter,
+ void *iter_cls)
+{
+}
+
+
+
+/**
+ * Select a subset of the items in the datastore and call
+ * the given iterator for each of them.
+ *
+ * @param type entries of which type should be considered?
+ * Use 0 for any type.
+ * @param iter function to call on each matching value;
+ * will be called once with a NULL value at the end
+ * @param iter_cls closure for iter
+ */
+static void
+template_plugin_iter_ascending_expiration (void *cls,
+ uint32_t type,
+ GNUNET_DATASTORE_Iterator iter,
+ void *iter_cls)
+{
+}
+
+
+
+/**
+ * Select a subset of the items in the datastore and call
+ * the given iterator for each of them.
+ *
+ * @param type entries of which type should be considered?
+ * Use 0 for any type.
+ * @param iter function to call on each matching value;
+ * will be called once with a NULL value at the end
+ * @param iter_cls closure for iter
+ */
+static void
+template_plugin_iter_migration_order (void *cls,
+ uint32_t type,
+ GNUNET_DATASTORE_Iterator iter,
+ void *iter_cls)
+{
+}
+
+
+
+/**
+ * Select a subset of the items in the datastore and call
+ * the given iterator for each of them.
+ *
+ * @param type entries of which type should be considered?
+ * Use 0 for any type.
+ * @param iter function to call on each matching value;
+ * will be called once with a NULL value at the end
+ * @param iter_cls closure for iter
+ */
+static void
+template_plugin_iter_all_now (void *cls,
+ uint32_t type,
+ GNUNET_DATASTORE_Iterator iter,
+ void *iter_cls)
+{
+}
+
+
+/**
+ * Drop database.
+ */
+static void
+template_plugin_drop (void *cls)
+{
+}
+
+
+/**
+ * Entry point for the plugin.
+ */
+void *
+libgnunet_plugin_datastore_template_init (void *cls)
+{
+ struct GNUNET_DATASTORE_PluginEnvironment *env = cls;
+ struct GNUNET_DATASTORE_PluginFunctions *api;
+ struct Plugin *plugin;
+
+ plugin = GNUNET_malloc (sizeof (struct Plugin));
+ plugin->env = env;
+ api = GNUNET_malloc (sizeof (struct GNUNET_DATASTORE_PluginFunctions));
+ api->cls = plugin;
+ api->get_size = &template_plugin_get_size;
+ api->put = &template_plugin_put;
+ api->get = &template_plugin_get;
+ api->update = &template_plugin_update;
+ api->iter_low_priority = &template_plugin_iter_low_priority;
+ api->iter_zero_anonymity = &template_plugin_iter_zero_anonymity;
+ api->iter_ascending_expiration = &template_plugin_iter_ascending_expiration;
+ api->iter_migration_order = &template_plugin_iter_migration_order;
+ api->iter_all_now = &template_plugin_iter_all_now;
+ api->drop = &template_plugin_drop;
+ GNUNET_log_from (GNUNET_ERROR_TYPE_INFO,
+ "template", _("Template database running\n"));
+ return api;
+}
+
+
+/**
+ * Exit point from the plugin.
+ */
+void *
+libgnunet_plugin_datastore_template_done (void *cls)
+{
+ struct GNUNET_DATASTORE_PluginFunctions *api = cls;
+ struct Plugin *plugin = api->cls;
+
+ GNUNET_free (plugin);
+ GNUNET_free (api);
+ return NULL;
+}
+
+/* end of plugin_datastore_template.c */
diff --git a/src/include/gnunet_datastore_service.h b/src/include/gnunet_datastore_service.h
index b20c6b100..ed0fd0856 100644
--- a/src/include/gnunet_datastore_service.h
+++ b/src/include/gnunet_datastore_service.h
@@ -31,7 +31,7 @@
#ifndef GNUNET_DATASTORE_SERVICE_H
#define GNUNET_DATASTORE_SERVICE_H
-#include "gnunet_core.h"
+#include "gnunet_util_lib.h"
#ifdef __cplusplus
extern "C"
@@ -93,9 +93,12 @@ struct GNUNET_DATASTORE_Handle *GNUNET_DATASTORE_connect (struct
/**
* Disconnect from the datastore service (and free
* associated resources).
+ *
* @param h handle to the datastore
+ * @param drop set to GNUNET_YES to delete all data in datastore (!)
*/
-void GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h);
+void GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h,
+ int drop);
/**
@@ -125,7 +128,7 @@ GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h,
const GNUNET_HashCode * key,
uint32_t size,
const void *data,
- unit32_t type,
+ uint32_t type,
uint32_t priority,
uint32_t anonymity,
struct GNUNET_TIME_Absolute expiration);
diff --git a/src/include/gnunet_util_lib.h b/src/include/gnunet_util_lib.h
index c152377c3..6354e28fa 100644
--- a/src/include/gnunet_util_lib.h
+++ b/src/include/gnunet_util_lib.h
@@ -44,6 +44,7 @@ extern "C"
#include "gnunet_disk_lib.h"
#include "gnunet_getopt_lib.h"
#include "gnunet_network_lib.h"
+#include "gnunet_plugin_lib.h"
#include "gnunet_program_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_pseudonym_lib.h"
diff --git a/src/resolver/gnunet-service-resolver.c b/src/resolver/gnunet-service-resolver.c
index c65adacd3..ad62424a5 100644
--- a/src/resolver/gnunet-service-resolver.c
+++ b/src/resolver/gnunet-service-resolver.c
@@ -439,7 +439,7 @@ static struct GNUNET_SERVER_MessageHandler handlers[] = {
/**
- * Process statistics requests.
+ * Process resolver requests.
*
* @param cls closure
* @param sched scheduler to use
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index 88d43e279..fb38f40c8 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -38,7 +38,7 @@ gnunet_transport_LDADD = \
$(GN_LIBINTL)
gnunet_service_transport_SOURCES = \
- gnunet-service-transport.c
+ gnunet-service-transport.c plugin_transport.h
gnunet_service_transport_LDADD = \
$(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \
$(top_builddir)/src/util/libgnunetutil.la \