GNUnet  0.10.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 
121 
133 static void
135  void *proc_cls)
136 {
137  GNUNET_break (0);
138 }
139 
140 
149 static void
151  void *proc_cls)
152 {
153  GNUNET_break (0);
154 }
155 
156 
168 static void
169 template_plugin_get_zero_anonymity (void *cls, uint64_t next_uid,
170  enum GNUNET_BLOCK_Type type,
171  PluginDatumProcessor proc, void *proc_cls)
172 {
173  GNUNET_break (0);
174 }
175 
176 
180 static void
182 {
183  GNUNET_break (0);
184 }
185 
186 
194 static void
196  PluginKeyProcessor proc,
197  void *proc_cls)
198 {
199  proc (proc_cls, NULL, 0);
200 }
201 
202 
213 static void
215  const struct GNUNET_HashCode *key,
216  uint32_t size,
217  const void *data,
218  PluginRemoveCont cont,
219  void *cont_cls)
220 {
221  GNUNET_break (0);
222  cont (cont_cls, key, size, GNUNET_SYSERR, "not implemented");
223 }
224 
225 
232 void *
234 {
237  struct Plugin *plugin;
238 
239  plugin = GNUNET_new (struct Plugin);
240  plugin->env = env;
242  api->cls = plugin;
244  api->put = &template_plugin_put;
249  api->drop = &template_plugin_drop;
250  api->get_keys = &template_get_keys;
253  _("Template database running\n"));
254  return api;
255 }
256 
257 
263 void *
265 {
267  struct Plugin *plugin = api->cls;
268 
269  GNUNET_free (plugin);
270  GNUNET_free (api);
271  return NULL;
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 char * expiration
Credential TTL.
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:208
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.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
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 void template_plugin_drop(void *cls)
Drop database.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
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.