GNUnet  0.11.x
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;
243  api->put = &template_plugin_put;
248  api->drop = &template_plugin_drop;
249  api->get_keys = &template_get_keys;
252  _ ("Template database running\n"));
253  return api;
254 }
255 
256 
262 void *
264 {
266  struct Plugin *plugin = api->cls;
267 
268  GNUNET_free (plugin);
269  GNUNET_free (api);
270  return NULL;
271 }
272 
273 
274 /* end of plugin_datastore_template.c */
static void template_plugin_get_expiration(void *cls, PluginDatumProcessor proc, void *proc_cls)
Get a random item for expiration.
PluginGetKeys get_keys
Iterate over all keys in the database.
PluginPut put
Function to store an item in the datastore.
int(* 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.
PluginGetType get_zero_anonymity
Get datum (of the specified type) with anonymity level zero.
static void template_get_keys(void *cls, PluginKeyProcessor proc, void *proc_cls)
Get all of the keys in the datastore.
GNUNET_BLOCK_Type
Blocks in the datastore and the datacache must have a unique type.
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.
PluginRemoveKey remove_key
Function to remove an item from the database.
char * key
TLS key.
static unsigned int replication
PluginEstimateSize estimate_size
Calculate the current on-disk size of the SQ store.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
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_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.
void(* PluginPutCont)(void *cls, const struct GNUNET_HashCode *key, uint32_t size, int status, const char *msg)
Put continuation.
void * libgnunet_plugin_datastore_template_done(void *cls)
Exit point from 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:47
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
PluginGetRandom get_replication
Function to get a random item with high replication score from the database, lowering the item&#39;s repl...
static void template_plugin_get_replication(void *cls, PluginDatumProcessor proc, void *proc_cls)
Get a random item for replication.
PluginDrop drop
Delete the database.
void * libgnunet_plugin_datastore_template_init(void *cls)
Entry point for 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.
void(* PluginKeyProcessor)(void *cls, const struct GNUNET_HashCode *key, unsigned int count)
An processor over a set of keys stored in the datastore.
PluginGetRandom get_expiration
Function to get a random expired item or, if none are expired, either the oldest entry or one with a ...
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
The datastore service will pass a pointer to a struct of this type as the first and only argument to ...
A 512-bit hashcode.
static char * expiration
Credential TTL.
Definition: gnunet-abd.c:96
static void template_plugin_drop(void *cls)
Drop database.
static char * plugin
Solver plugin name as string.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
void(* PluginRemoveCont)(void *cls, const struct GNUNET_HashCode *key, uint32_t size, int status, const char *msg)
Remove continuation.
void * cls
Closure to use for all of the following callbacks (except "next_request").
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.
unsigned long long size
Size of all values we&#39;re storing.
Handle for a plugin.
Definition: block.c:37
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Time for absolute times used by GNUnet, in microseconds.
static unsigned int anonymity
#define GNUNET_log_from(kind, comp,...)
PluginGetKey get_key
Get a particular datum matching a given hash from the datastore.
uint32_t data
The data value.
#define GNUNET_free(ptr)
Wrapper around free.