GNUnet  0.20.0
plugin_datastore_template.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2009, 2011 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 
27 #include "platform.h"
29 
30 
34 struct Plugin
35 {
40 };
41 
42 
50 static void
51 template_plugin_estimate_size (void *cls, unsigned long long *estimate)
52 {
53  if (NULL == estimate)
54  return;
55  GNUNET_break (0);
56  *estimate = 0;
57 }
58 
59 
76 static void
78  const struct GNUNET_HashCode *key,
79  bool absent,
80  uint32_t size,
81  const void *data,
83  uint32_t priority,
84  uint32_t anonymity,
85  uint32_t replication,
87  PluginPutCont cont,
88  void *cont_cls)
89 {
90  GNUNET_break (0);
91  cont (cont_cls, key, size, GNUNET_SYSERR, "not implemented");
92 }
93 
94 
108 static void
110  uint64_t next_uid,
111  bool random,
112  const struct GNUNET_HashCode *key,
113  enum GNUNET_BLOCK_Type type,
115  void *proc_cls)
116 {
117  GNUNET_break (0);
118 }
119 
120 
132 static void
134  void *proc_cls)
135 {
136  GNUNET_break (0);
137 }
138 
139 
148 static void
150  void *proc_cls)
151 {
152  GNUNET_break (0);
153 }
154 
155 
167 static void
168 template_plugin_get_zero_anonymity (void *cls, uint64_t next_uid,
169  enum GNUNET_BLOCK_Type type,
170  PluginDatumProcessor proc, void *proc_cls)
171 {
172  GNUNET_break (0);
173 }
174 
175 
179 static void
181 {
182  GNUNET_break (0);
183 }
184 
185 
193 static void
195  PluginKeyProcessor proc,
196  void *proc_cls)
197 {
198  proc (proc_cls, NULL, 0);
199 }
200 
201 
212 static void
214  const struct GNUNET_HashCode *key,
215  uint32_t size,
216  const void *data,
217  PluginRemoveCont cont,
218  void *cont_cls)
219 {
220  GNUNET_break (0);
221  cont (cont_cls, key, size, GNUNET_SYSERR, "not implemented");
222 }
223 
224 
231 void *
233 {
236  struct Plugin *plugin;
237 
238  plugin = GNUNET_new (struct Plugin);
239  plugin->env = env;
241  api->cls = plugin;
242  api->estimate_size = &template_plugin_estimate_size;
243  api->put = &template_plugin_put;
245  api->get_replication = &template_plugin_get_replication;
246  api->get_expiration = &template_plugin_get_expiration;
247  api->get_zero_anonymity = &template_plugin_get_zero_anonymity;
248  api->drop = &template_plugin_drop;
249  api->get_keys = &template_get_keys;
250  api->remove_key = &template_plugin_remove_key;
252  _ ("Template database running\n"));
253  return api;
254 }
255 
256 
262 void *
264 {
266  struct Plugin *plugin = api->cls;
267 
269  GNUNET_free (api);
270  return NULL;
271 }
272 
273 
274 /* end of plugin_datastore_template.c */
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
GNUNET_BLOCK_Type
WARNING: This header is generated! In order to add DHT block types, you must register them in GANA,...
static char * expiration
Credential TTL.
Definition: gnunet-abd.c:96
struct TestcasePlugin * plugin
The process handle to the testbed service.
static unsigned int replication
struct GNUNET_HashCode key
The key used in the DHT.
static unsigned int anonymity
uint32_t data
The data value.
API for the database backend plugins.
enum GNUNET_GenericReturnValue(* PluginDatumProcessor)(void *cls, const struct GNUNET_HashCode *key, uint32_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, uint64_t uid)
An processor over a set of items stored in the datastore.
void(* PluginPutCont)(void *cls, const struct GNUNET_HashCode *key, uint32_t size, int status, const char *msg)
Put continuation.
void(* PluginKeyProcessor)(void *cls, const struct GNUNET_HashCode *key, unsigned int count)
An processor over a set of keys stored in the datastore.
void(* PluginRemoveCont)(void *cls, const struct GNUNET_HashCode *key, uint32_t size, int status, const char *msg)
Remove continuation.
#define GNUNET_log_from(kind, comp,...)
@ GNUNET_SYSERR
#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:68
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
void * libgnunet_plugin_datastore_template_init(void *cls)
Entry point for the plugin.
static void template_plugin_get_zero_anonymity(void *cls, uint64_t next_uid, enum GNUNET_BLOCK_Type type, PluginDatumProcessor proc, void *proc_cls)
Call the given processor on an item with zero anonymity.
static void template_plugin_estimate_size(void *cls, unsigned long long *estimate)
Get an estimate of how much space the database is currently using.
static void template_plugin_remove_key(void *cls, const struct GNUNET_HashCode *key, uint32_t size, const void *data, PluginRemoveCont cont, void *cont_cls)
Remove a particular key in the datastore.
static void template_get_keys(void *cls, PluginKeyProcessor proc, void *proc_cls)
Get all of the keys in the datastore.
static void template_plugin_get_expiration(void *cls, PluginDatumProcessor proc, void *proc_cls)
Get a random item for expiration.
static void template_plugin_drop(void *cls)
Drop database.
void * libgnunet_plugin_datastore_template_done(void *cls)
Exit point from the plugin.
static void template_plugin_get_key(void *cls, uint64_t next_uid, bool random, const struct GNUNET_HashCode *key, enum GNUNET_BLOCK_Type type, PluginDatumProcessor proc, void *proc_cls)
Get one of the results for a particular key in the datastore.
static void template_plugin_get_replication(void *cls, PluginDatumProcessor proc, void *proc_cls)
Get a random item for replication.
static void template_plugin_put(void *cls, const struct GNUNET_HashCode *key, bool absent, uint32_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, PluginPutCont cont, void *cont_cls)
Store an item in the datastore.
GNUNET_BLOCK_GetKeyFunction get_key
Obtain the key for a given block (if possible).
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 ...
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
void * cls
Closure to use for all of the following callbacks (except "next_request").
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