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.c81
1 files changed, 40 insertions, 41 deletions
diff --git a/src/datacache/plugin_datacache_template.c b/src/datacache/plugin_datacache_template.c
index 4775968c3..4c322d3ab 100644
--- a/src/datacache/plugin_datacache_template.c
+++ b/src/datacache/plugin_datacache_template.c
@@ -11,12 +11,12 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 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/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19 */
20 20
21/** 21/**
22 * @file datacache/plugin_datacache_template.c 22 * @file datacache/plugin_datacache_template.c
@@ -31,8 +31,7 @@
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{
36 /** 35 /**
37 * Our execution environment. 36 * Our execution environment.
38 */ 37 */
@@ -55,17 +54,17 @@ struct Plugin
55 * @return 0 if duplicate, -1 on error, number of bytes used otherwise 54 * @return 0 if duplicate, -1 on error, number of bytes used otherwise
56 */ 55 */
57static ssize_t 56static ssize_t
58template_plugin_put (void *cls, 57template_plugin_put(void *cls,
59 const struct GNUNET_HashCode *key, 58 const struct GNUNET_HashCode *key,
60 uint32_t xor_distance, 59 uint32_t xor_distance,
61 size_t size, 60 size_t size,
62 const char *data, 61 const char *data,
63 enum GNUNET_BLOCK_Type type, 62 enum GNUNET_BLOCK_Type type,
64 struct GNUNET_TIME_Absolute discard_time, 63 struct GNUNET_TIME_Absolute discard_time,
65 unsigned int path_info_len, 64 unsigned int path_info_len,
66 const struct GNUNET_PeerIdentity *path_info) 65 const struct GNUNET_PeerIdentity *path_info)
67{ 66{
68 GNUNET_break (0); 67 GNUNET_break(0);
69 return -1; 68 return -1;
70} 69}
71 70
@@ -82,13 +81,13 @@ template_plugin_put (void *cls,
82 * @return the number of results found 81 * @return the number of results found
83 */ 82 */
84static unsigned int 83static unsigned int
85template_plugin_get (void *cls, 84template_plugin_get(void *cls,
86 const struct GNUNET_HashCode *key, 85 const struct GNUNET_HashCode *key,
87 enum GNUNET_BLOCK_Type type, 86 enum GNUNET_BLOCK_Type type,
88 GNUNET_DATACACHE_Iterator iter, 87 GNUNET_DATACACHE_Iterator iter,
89 void *iter_cls) 88 void *iter_cls)
90{ 89{
91 GNUNET_break (0); 90 GNUNET_break(0);
92 return 0; 91 return 0;
93} 92}
94 93
@@ -101,9 +100,9 @@ template_plugin_get (void *cls,
101 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 100 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
102 */ 101 */
103static int 102static int
104template_plugin_del (void *cls) 103template_plugin_del(void *cls)
105{ 104{
106 GNUNET_break (0); 105 GNUNET_break(0);
107 return GNUNET_SYSERR; 106 return GNUNET_SYSERR;
108} 107}
109 108
@@ -117,11 +116,11 @@ template_plugin_del (void *cls)
117 * @return the number of results found (zero or one) 116 * @return the number of results found (zero or one)
118 */ 117 */
119static unsigned int 118static unsigned int
120template_plugin_get_random (void *cls, 119template_plugin_get_random(void *cls,
121 GNUNET_DATACACHE_Iterator iter, 120 GNUNET_DATACACHE_Iterator iter,
122 void *iter_cls) 121 void *iter_cls)
123{ 122{
124 GNUNET_break (0); 123 GNUNET_break(0);
125 return 0; 124 return 0;
126} 125}
127 126
@@ -141,13 +140,13 @@ template_plugin_get_random (void *cls,
141 * @return the number of results found 140 * @return the number of results found
142 */ 141 */
143static unsigned int 142static unsigned int
144template_plugin_get_closest (void *cls, 143template_plugin_get_closest(void *cls,
145 const struct GNUNET_HashCode *key, 144 const struct GNUNET_HashCode *key,
146 unsigned int num_results, 145 unsigned int num_results,
147 GNUNET_DATACACHE_Iterator iter, 146 GNUNET_DATACACHE_Iterator iter,
148 void *iter_cls) 147 void *iter_cls)
149{ 148{
150 GNUNET_break (0); 149 GNUNET_break(0);
151 return 0; 150 return 0;
152} 151}
153 152
@@ -159,24 +158,24 @@ template_plugin_get_closest (void *cls,
159 * @return the plugin's closure (our `struct Plugin`) 158 * @return the plugin's closure (our `struct Plugin`)
160 */ 159 */
161void * 160void *
162libgnunet_plugin_datacache_template_init (void *cls) 161libgnunet_plugin_datacache_template_init(void *cls)
163{ 162{
164 struct GNUNET_DATACACHE_PluginEnvironment *env = cls; 163 struct GNUNET_DATACACHE_PluginEnvironment *env = cls;
165 struct GNUNET_DATACACHE_PluginFunctions *api; 164 struct GNUNET_DATACACHE_PluginFunctions *api;
166 struct Plugin *plugin; 165 struct Plugin *plugin;
167 166
168 plugin = GNUNET_new (struct Plugin); 167 plugin = GNUNET_new(struct Plugin);
169 plugin->env = env; 168 plugin->env = env;
170 api = GNUNET_new (struct GNUNET_DATACACHE_PluginFunctions); 169 api = GNUNET_new(struct GNUNET_DATACACHE_PluginFunctions);
171 api->cls = plugin; 170 api->cls = plugin;
172 api->get = &template_plugin_get; 171 api->get = &template_plugin_get;
173 api->put = &template_plugin_put; 172 api->put = &template_plugin_put;
174 api->del = &template_plugin_del; 173 api->del = &template_plugin_del;
175 api->get_random = &template_plugin_get_random; 174 api->get_random = &template_plugin_get_random;
176 api->get_closest = &template_plugin_get_closest; 175 api->get_closest = &template_plugin_get_closest;
177 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, 176 GNUNET_log_from(GNUNET_ERROR_TYPE_INFO,
178 "template", 177 "template",
179 "Template datacache running\n"); 178 "Template datacache running\n");
180 return api; 179 return api;
181} 180}
182 181
@@ -188,13 +187,13 @@ libgnunet_plugin_datacache_template_init (void *cls)
188 * @return NULL 187 * @return NULL
189 */ 188 */
190void * 189void *
191libgnunet_plugin_datacache_template_done (void *cls) 190libgnunet_plugin_datacache_template_done(void *cls)
192{ 191{
193 struct GNUNET_DATACACHE_PluginFunctions *api = cls; 192 struct GNUNET_DATACACHE_PluginFunctions *api = cls;
194 struct Plugin *plugin = api->cls; 193 struct Plugin *plugin = api->cls;
195 194
196 GNUNET_free (plugin); 195 GNUNET_free(plugin);
197 GNUNET_free (api); 196 GNUNET_free(api);
198 return NULL; 197 return NULL;
199} 198}
200 199