[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r8574 - in gnunet: . src src/datastore src/include src/reso
From: |
gnunet |
Subject: |
[GNUnet-SVN] r8574 - in gnunet: . src src/datastore src/include src/resolver src/transport |
Date: |
Sun, 14 Jun 2009 21:25:56 -0600 |
Author: grothoff
Date: 2009-06-14 21:25:55 -0600 (Sun, 14 Jun 2009)
New Revision: 8574
Added:
gnunet/src/datastore/Makefile.am
gnunet/src/datastore/datastore.h
gnunet/src/datastore/datastore_api.c
gnunet/src/datastore/gnunet-service-datastore.c
gnunet/src/datastore/plugin_datastore_sqlite.c
gnunet/src/datastore/plugin_datastore_template.c
Modified:
gnunet/HACKING
gnunet/configure.ac
gnunet/src/Makefile.am
gnunet/src/datastore/plugin_datastore.h
gnunet/src/include/gnunet_datastore_service.h
gnunet/src/include/gnunet_util_lib.h
gnunet/src/resolver/gnunet-service-resolver.c
gnunet/src/transport/Makefile.am
Log:
adding basic declarations for datastore implementation
Modified: gnunet/HACKING
===================================================================
--- gnunet/HACKING 2009-06-15 02:44:19 UTC (rev 8573)
+++ gnunet/HACKING 2009-06-15 03:25:55 UTC (rev 8574)
@@ -26,7 +26,7 @@
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
Modified: gnunet/configure.ac
===================================================================
--- gnunet/configure.ac 2009-06-15 02:44:19 UTC (rev 8573)
+++ gnunet/configure.ac 2009-06-15 03:25:55 UTC (rev 8574)
@@ -750,17 +750,19 @@
-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/datastore/Makefile
+src/fragmentation/Makefile
+src/hello/Makefile
src/include/Makefile
src/include/gnunet_directories.h
-src/util/Makefile
-src/fragmentation/Makefile
-src/hello/Makefile
src/hostlist/Makefile
src/peerinfo/Makefile
src/resolver/Makefile
@@ -768,6 +770,7 @@
src/template/Makefile
src/topology/Makefile
src/transport/Makefile
+src/util/Makefile
])
AC_OUTPUT
Modified: gnunet/src/Makefile.am
===================================================================
--- gnunet/src/Makefile.am 2009-06-15 02:44:19 UTC (rev 8573)
+++ gnunet/src/Makefile.am 2009-06-15 03:25:55 UTC (rev 8574)
@@ -11,6 +11,7 @@
include $(INTLEMU_SUBDIRS) \
util \
arm \
+ datastore \
fragmentation \
hello \
peerinfo \
Added: gnunet/src/datastore/Makefile.am
===================================================================
--- gnunet/src/datastore/Makefile.am (rev 0)
+++ gnunet/src/datastore/Makefile.am 2009-06-15 03:25:55 UTC (rev 8574)
@@ -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
+
+
Added: gnunet/src/datastore/datastore.h
===================================================================
--- gnunet/src/datastore/datastore.h (rev 0)
+++ gnunet/src/datastore/datastore.h 2009-06-15 03:25:55 UTC (rev 8574)
@@ -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
Added: gnunet/src/datastore/datastore_api.c
===================================================================
--- gnunet/src/datastore/datastore_api.c (rev 0)
+++ gnunet/src/datastore/datastore_api.c 2009-06-15 03:25:55 UTC (rev
8574)
@@ -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 */
Added: gnunet/src/datastore/gnunet-service-datastore.c
===================================================================
--- gnunet/src/datastore/gnunet-service-datastore.c
(rev 0)
+++ gnunet/src/datastore/gnunet-service-datastore.c 2009-06-15 03:25:55 UTC
(rev 8574)
@@ -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 */
Modified: gnunet/src/datastore/plugin_datastore.h
===================================================================
--- gnunet/src/datastore/plugin_datastore.h 2009-06-15 02:44:19 UTC (rev
8573)
+++ gnunet/src/datastore/plugin_datastore.h 2009-06-15 03:25:55 UTC (rev
8574)
@@ -79,7 +79,7 @@
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 @@
* 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 @@
* 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
Added: gnunet/src/datastore/plugin_datastore_sqlite.c
===================================================================
--- gnunet/src/datastore/plugin_datastore_sqlite.c
(rev 0)
+++ gnunet/src/datastore/plugin_datastore_sqlite.c 2009-06-15 03:25:55 UTC
(rev 8574)
@@ -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 */
Added: gnunet/src/datastore/plugin_datastore_template.c
===================================================================
--- gnunet/src/datastore/plugin_datastore_template.c
(rev 0)
+++ gnunet/src/datastore/plugin_datastore_template.c 2009-06-15 03:25:55 UTC
(rev 8574)
@@ -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 */
Modified: gnunet/src/include/gnunet_datastore_service.h
===================================================================
--- gnunet/src/include/gnunet_datastore_service.h 2009-06-15 02:44:19 UTC
(rev 8573)
+++ gnunet/src/include/gnunet_datastore_service.h 2009-06-15 03:25:55 UTC
(rev 8574)
@@ -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 @@
/**
* 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 @@
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);
Modified: gnunet/src/include/gnunet_util_lib.h
===================================================================
--- gnunet/src/include/gnunet_util_lib.h 2009-06-15 02:44:19 UTC (rev
8573)
+++ gnunet/src/include/gnunet_util_lib.h 2009-06-15 03:25:55 UTC (rev
8574)
@@ -44,6 +44,7 @@
#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"
Modified: gnunet/src/resolver/gnunet-service-resolver.c
===================================================================
--- gnunet/src/resolver/gnunet-service-resolver.c 2009-06-15 02:44:19 UTC
(rev 8573)
+++ gnunet/src/resolver/gnunet-service-resolver.c 2009-06-15 03:25:55 UTC
(rev 8574)
@@ -439,7 +439,7 @@
/**
- * Process statistics requests.
+ * Process resolver requests.
*
* @param cls closure
* @param sched scheduler to use
Modified: gnunet/src/transport/Makefile.am
===================================================================
--- gnunet/src/transport/Makefile.am 2009-06-15 02:44:19 UTC (rev 8573)
+++ gnunet/src/transport/Makefile.am 2009-06-15 03:25:55 UTC (rev 8574)
@@ -38,7 +38,7 @@
$(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 \
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r8574 - in gnunet: . src src/datastore src/include src/resolver src/transport,
gnunet <=