GNUnet  0.10.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 {
39 };
40 
41 
56 static ssize_t
58  const struct GNUNET_HashCode *key,
59  uint32_t xor_distance,
60  size_t size,
61  const char *data,
63  struct GNUNET_TIME_Absolute discard_time,
64  unsigned int path_info_len,
65  const struct GNUNET_PeerIdentity *path_info)
66 {
67  GNUNET_break(0);
68  return -1;
69 }
70 
71 
83 static unsigned int
85  const struct GNUNET_HashCode *key,
88  void *iter_cls)
89 {
90  GNUNET_break(0);
91  return 0;
92 }
93 
94 
102 static int
104 {
105  GNUNET_break(0);
106  return GNUNET_SYSERR;
107 }
108 
109 
118 static unsigned int
121  void *iter_cls)
122 {
123  GNUNET_break(0);
124  return 0;
125 }
126 
127 
128 
142 static unsigned int
144  const struct GNUNET_HashCode *key,
145  unsigned int num_results,
147  void *iter_cls)
148 {
149  GNUNET_break(0);
150  return 0;
151 }
152 
153 
160 void *
162 {
165  struct Plugin *plugin;
166 
167  plugin = GNUNET_new(struct Plugin);
168  plugin->env = env;
170  api->cls = plugin;
171  api->get = &template_plugin_get;
172  api->put = &template_plugin_put;
173  api->del = &template_plugin_del;
177  "template",
178  "Template datacache running\n");
179  return api;
180 }
181 
182 
189 void *
191 {
193  struct Plugin *plugin = api->cls;
194 
195  GNUNET_free(plugin);
196  GNUNET_free(api);
197  return NULL;
198 }
199 
200 
201 /* end of plugin_datacache_template.c */
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.
void * cls
Closure to pass to all plugin functions.
ssize_t(* 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_PeerIdentity *path_info)
Store an item in the datastore.
int(* del)(void *cls)
Delete the entry with the lowest expiration value from the datacache right now.
GNUNET_BLOCK_Type
Blocks in the datastore and the datacache must have a unique type.
char * key
TLS key.
void * libgnunet_plugin_datacache_template_done(void *cls)
Exit point from the plugin.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void * libgnunet_plugin_datacache_template_init(void *cls)
Entry point for the plugin.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:46
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_PeerIdentity *path_info)
Store an item in the datastore.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
unsigned int(* 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.
struct returned by the initialization function of the plugin
A 512-bit hashcode.
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.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
void * iter_cls
Iterator cls.
The identity of the host (wraps the signing key of the peer).
static int template_plugin_del(void *cls)
Delete the entry with the lowest expiration value from the datacache right now.
unsigned long long size
Size of all values we&#39;re storing.
Handle for a plugin.
Definition: block.c:37
int(* 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_PeerIdentity *path_info)
An iterator over a set of items stored in the datacache.
void * cls
Closure to use for callbacks.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Time for absolute times used by GNUnet, in microseconds.
unsigned int(* get_random)(void *cls, GNUNET_DATACACHE_Iterator iter, void *iter_cls)
Return a random value from the datastore.
#define GNUNET_log_from(kind, comp,...)
uint32_t data
The data value.
The datastore service will pass a pointer to a struct of this type as the first and only argument to ...
GNUNET_PEERSTORE_Processor iter
Iterator.
unsigned int(* 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.
#define GNUNET_free(ptr)
Wrapper around free.
static unsigned int template_plugin_get_random(void *cls, GNUNET_DATACACHE_Iterator iter, void *iter_cls)
Return a random value from the datastore.