GNUnet  0.11.x
plugin_datacache_template.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2006, 2009, 2015 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your 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  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
26 #include "platform.h"
27 #include "gnunet_util_lib.h"
29 
30 
34 struct Plugin
35 {
40 };
41 
42 
57 static ssize_t
59  const struct GNUNET_HashCode *key,
60  uint32_t xor_distance,
61  size_t size,
62  const char *data,
64  struct GNUNET_TIME_Absolute discard_time,
65  unsigned int path_info_len,
66  const struct GNUNET_DHT_PathElement *path_info)
67 {
68  GNUNET_break (0);
69  return -1;
70 }
71 
72 
84 static unsigned int
86  const struct GNUNET_HashCode *key,
89  void *iter_cls)
90 {
91  GNUNET_break (0);
92  return 0;
93 }
94 
95 
103 static int
105 {
106  GNUNET_break (0);
107  return GNUNET_SYSERR;
108 }
109 
110 
124 static unsigned int
126  const struct GNUNET_HashCode *key,
127  unsigned int num_results,
129  void *iter_cls)
130 {
131  GNUNET_break (0);
132  return 0;
133 }
134 
135 
142 void *
144 {
147  struct Plugin *plugin;
148 
149  plugin = GNUNET_new (struct Plugin);
150  plugin->env = env;
152  api->cls = plugin;
153  api->get = &template_plugin_get;
154  api->put = &template_plugin_put;
155  api->del = &template_plugin_del;
156  api->get_closest = &template_plugin_get_closest;
158  "template",
159  "Template datacache running\n");
160  return api;
161 }
162 
163 
170 void *
172 {
174  struct Plugin *plugin = api->cls;
175 
177  GNUNET_free (api);
178  return NULL;
179 }
180 
181 
182 /* end of plugin_datacache_template.c */
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct Plugin * plugin
The process handle to the testbed service.
struct GNUNET_HashCode key
The key used in the DHT.
uint32_t data
The data value.
#define GNUNET_log_from(kind, comp,...)
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
GNUNET_BLOCK_Type
Blocks in the datastore and the datacache must have a unique type.
enum GNUNET_GenericReturnValue(* GNUNET_DATACACHE_Iterator)(void *cls, const struct GNUNET_HashCode *key, size_t data_size, const char *data, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute exp, unsigned int path_info_len, const struct GNUNET_DHT_PathElement *path_info)
An iterator over a set of items stored in the datacache.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_INFO
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
static unsigned int size
Size of the "table".
Definition: peer.c:67
void * libgnunet_plugin_datacache_template_init(void *cls)
Entry point for the plugin.
static ssize_t template_plugin_put(void *cls, const struct GNUNET_HashCode *key, uint32_t xor_distance, size_t size, const char *data, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute discard_time, unsigned int path_info_len, const struct GNUNET_DHT_PathElement *path_info)
Store an item in the datastore.
static unsigned int template_plugin_get(void *cls, const struct GNUNET_HashCode *key, enum GNUNET_BLOCK_Type type, GNUNET_DATACACHE_Iterator iter, void *iter_cls)
Iterate over the results for a particular key in the datastore.
void * libgnunet_plugin_datacache_template_done(void *cls)
Exit point from the plugin.
static unsigned int template_plugin_get_closest(void *cls, const struct GNUNET_HashCode *key, unsigned int num_results, GNUNET_DATACACHE_Iterator iter, void *iter_cls)
Iterate over the results that are "close" to a particular key in the datacache.
static int template_plugin_del(void *cls)
Delete the entry with the lowest expiration value from the datacache right now.
void * cls
Closure for all of the callbacks.
The datastore service will pass a pointer to a struct of this type as the first and only argument to ...
void * cls
Closure to use for callbacks.
struct returned by the initialization function of the plugin
void * cls
Closure to pass to all plugin functions.
A (signed) path tracking a block's flow through the DHT is represented by an array of path elements,...
A 512-bit hashcode.
Time for absolute times used by GNUnet, in microseconds.
Handle for a plugin.
Definition: block.c:38
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model