aboutsummaryrefslogtreecommitdiff
path: root/src/datacache/plugin_datacache_template.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/datacache/plugin_datacache_template.c')
-rw-r--r--src/datacache/plugin_datacache_template.c77
1 files changed, 39 insertions, 38 deletions
diff --git a/src/datacache/plugin_datacache_template.c b/src/datacache/plugin_datacache_template.c
index 4c322d3ab..edb3b6757 100644
--- a/src/datacache/plugin_datacache_template.c
+++ b/src/datacache/plugin_datacache_template.c
@@ -31,7 +31,8 @@
31/** 31/**
32 * Context for all functions in this plugin. 32 * Context for all functions in this plugin.
33 */ 33 */
34struct Plugin { 34struct Plugin
35{
35 /** 36 /**
36 * Our execution environment. 37 * Our execution environment.
37 */ 38 */
@@ -54,17 +55,17 @@ struct Plugin {
54 * @return 0 if duplicate, -1 on error, number of bytes used otherwise 55 * @return 0 if duplicate, -1 on error, number of bytes used otherwise
55 */ 56 */
56static ssize_t 57static ssize_t
57template_plugin_put(void *cls, 58template_plugin_put (void *cls,
58 const struct GNUNET_HashCode *key, 59 const struct GNUNET_HashCode *key,
59 uint32_t xor_distance, 60 uint32_t xor_distance,
60 size_t size, 61 size_t size,
61 const char *data, 62 const char *data,
62 enum GNUNET_BLOCK_Type type, 63 enum GNUNET_BLOCK_Type type,
63 struct GNUNET_TIME_Absolute discard_time, 64 struct GNUNET_TIME_Absolute discard_time,
64 unsigned int path_info_len, 65 unsigned int path_info_len,
65 const struct GNUNET_PeerIdentity *path_info) 66 const struct GNUNET_PeerIdentity *path_info)
66{ 67{
67 GNUNET_break(0); 68 GNUNET_break (0);
68 return -1; 69 return -1;
69} 70}
70 71
@@ -81,13 +82,13 @@ template_plugin_put(void *cls,
81 * @return the number of results found 82 * @return the number of results found
82 */ 83 */
83static unsigned int 84static unsigned int
84template_plugin_get(void *cls, 85template_plugin_get (void *cls,
85 const struct GNUNET_HashCode *key, 86 const struct GNUNET_HashCode *key,
86 enum GNUNET_BLOCK_Type type, 87 enum GNUNET_BLOCK_Type type,
87 GNUNET_DATACACHE_Iterator iter, 88 GNUNET_DATACACHE_Iterator iter,
88 void *iter_cls) 89 void *iter_cls)
89{ 90{
90 GNUNET_break(0); 91 GNUNET_break (0);
91 return 0; 92 return 0;
92} 93}
93 94
@@ -100,9 +101,9 @@ template_plugin_get(void *cls,
100 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 101 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
101 */ 102 */
102static int 103static int
103template_plugin_del(void *cls) 104template_plugin_del (void *cls)
104{ 105{
105 GNUNET_break(0); 106 GNUNET_break (0);
106 return GNUNET_SYSERR; 107 return GNUNET_SYSERR;
107} 108}
108 109
@@ -116,11 +117,11 @@ template_plugin_del(void *cls)
116 * @return the number of results found (zero or one) 117 * @return the number of results found (zero or one)
117 */ 118 */
118static unsigned int 119static unsigned int
119template_plugin_get_random(void *cls, 120template_plugin_get_random (void *cls,
120 GNUNET_DATACACHE_Iterator iter, 121 GNUNET_DATACACHE_Iterator iter,
121 void *iter_cls) 122 void *iter_cls)
122{ 123{
123 GNUNET_break(0); 124 GNUNET_break (0);
124 return 0; 125 return 0;
125} 126}
126 127
@@ -140,13 +141,13 @@ template_plugin_get_random(void *cls,
140 * @return the number of results found 141 * @return the number of results found
141 */ 142 */
142static unsigned int 143static unsigned int
143template_plugin_get_closest(void *cls, 144template_plugin_get_closest (void *cls,
144 const struct GNUNET_HashCode *key, 145 const struct GNUNET_HashCode *key,
145 unsigned int num_results, 146 unsigned int num_results,
146 GNUNET_DATACACHE_Iterator iter, 147 GNUNET_DATACACHE_Iterator iter,
147 void *iter_cls) 148 void *iter_cls)
148{ 149{
149 GNUNET_break(0); 150 GNUNET_break (0);
150 return 0; 151 return 0;
151} 152}
152 153
@@ -158,24 +159,24 @@ template_plugin_get_closest(void *cls,
158 * @return the plugin's closure (our `struct Plugin`) 159 * @return the plugin's closure (our `struct Plugin`)
159 */ 160 */
160void * 161void *
161libgnunet_plugin_datacache_template_init(void *cls) 162libgnunet_plugin_datacache_template_init (void *cls)
162{ 163{
163 struct GNUNET_DATACACHE_PluginEnvironment *env = cls; 164 struct GNUNET_DATACACHE_PluginEnvironment *env = cls;
164 struct GNUNET_DATACACHE_PluginFunctions *api; 165 struct GNUNET_DATACACHE_PluginFunctions *api;
165 struct Plugin *plugin; 166 struct Plugin *plugin;
166 167
167 plugin = GNUNET_new(struct Plugin); 168 plugin = GNUNET_new (struct Plugin);
168 plugin->env = env; 169 plugin->env = env;
169 api = GNUNET_new(struct GNUNET_DATACACHE_PluginFunctions); 170 api = GNUNET_new (struct GNUNET_DATACACHE_PluginFunctions);
170 api->cls = plugin; 171 api->cls = plugin;
171 api->get = &template_plugin_get; 172 api->get = &template_plugin_get;
172 api->put = &template_plugin_put; 173 api->put = &template_plugin_put;
173 api->del = &template_plugin_del; 174 api->del = &template_plugin_del;
174 api->get_random = &template_plugin_get_random; 175 api->get_random = &template_plugin_get_random;
175 api->get_closest = &template_plugin_get_closest; 176 api->get_closest = &template_plugin_get_closest;
176 GNUNET_log_from(GNUNET_ERROR_TYPE_INFO, 177 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO,
177 "template", 178 "template",
178 "Template datacache running\n"); 179 "Template datacache running\n");
179 return api; 180 return api;
180} 181}
181 182
@@ -187,13 +188,13 @@ libgnunet_plugin_datacache_template_init(void *cls)
187 * @return NULL 188 * @return NULL
188 */ 189 */
189void * 190void *
190libgnunet_plugin_datacache_template_done(void *cls) 191libgnunet_plugin_datacache_template_done (void *cls)
191{ 192{
192 struct GNUNET_DATACACHE_PluginFunctions *api = cls; 193 struct GNUNET_DATACACHE_PluginFunctions *api = cls;
193 struct Plugin *plugin = api->cls; 194 struct Plugin *plugin = api->cls;
194 195
195 GNUNET_free(plugin); 196 GNUNET_free (plugin);
196 GNUNET_free(api); 197 GNUNET_free (api);
197 return NULL; 198 return NULL;
198} 199}
199 200