diff options
Diffstat (limited to 'src/block')
-rw-r--r-- | src/block/bg_bf.c | 116 | ||||
-rw-r--r-- | src/block/block.c | 250 | ||||
-rw-r--r-- | src/block/plugin_block_template.c | 104 | ||||
-rw-r--r-- | src/block/plugin_block_test.c | 120 |
4 files changed, 297 insertions, 293 deletions
diff --git a/src/block/bg_bf.c b/src/block/bg_bf.c index 9814a28ec..ae8ee0e51 100644 --- a/src/block/bg_bf.c +++ b/src/block/bg_bf.c | |||
@@ -32,7 +32,8 @@ | |||
32 | /** | 32 | /** |
33 | * Internal data structure for a block group. | 33 | * Internal data structure for a block group. |
34 | */ | 34 | */ |
35 | struct BfGroupInternals { | 35 | struct BfGroupInternals |
36 | { | ||
36 | /** | 37 | /** |
37 | * A Bloom filter to weed out duplicate replies probabilistically. | 38 | * A Bloom filter to weed out duplicate replies probabilistically. |
38 | */ | 39 | */ |
@@ -61,24 +62,24 @@ struct BfGroupInternals { | |||
61 | * supported, #GNUNET_SYSERR on error | 62 | * supported, #GNUNET_SYSERR on error |
62 | */ | 63 | */ |
63 | static int | 64 | static int |
64 | bf_group_serialize_cb(struct GNUNET_BLOCK_Group *bg, | 65 | bf_group_serialize_cb (struct GNUNET_BLOCK_Group *bg, |
65 | uint32_t *nonce, | 66 | uint32_t *nonce, |
66 | void **raw_data, | 67 | void **raw_data, |
67 | size_t *raw_data_size) | 68 | size_t *raw_data_size) |
68 | { | 69 | { |
69 | struct BfGroupInternals *gi = bg->internal_cls; | 70 | struct BfGroupInternals *gi = bg->internal_cls; |
70 | char *raw; | 71 | char *raw; |
71 | 72 | ||
72 | raw = GNUNET_malloc(gi->bf_size); | 73 | raw = GNUNET_malloc (gi->bf_size); |
73 | if (GNUNET_OK != | 74 | if (GNUNET_OK != |
74 | GNUNET_CONTAINER_bloomfilter_get_raw_data(gi->bf, | 75 | GNUNET_CONTAINER_bloomfilter_get_raw_data (gi->bf, |
75 | raw, | 76 | raw, |
76 | gi->bf_size)) | 77 | gi->bf_size)) |
77 | { | 78 | { |
78 | GNUNET_free(raw); | 79 | GNUNET_free (raw); |
79 | GNUNET_break(0); | 80 | GNUNET_break (0); |
80 | return GNUNET_SYSERR; | 81 | return GNUNET_SYSERR; |
81 | } | 82 | } |
82 | *nonce = gi->bf_mutator; | 83 | *nonce = gi->bf_mutator; |
83 | *raw_data = raw; | 84 | *raw_data = raw; |
84 | *raw_data_size = gi->bf_size; | 85 | *raw_data_size = gi->bf_size; |
@@ -95,22 +96,22 @@ bf_group_serialize_cb(struct GNUNET_BLOCK_Group *bg, | |||
95 | * @param seen_results_count number of entries in @a seen_results | 96 | * @param seen_results_count number of entries in @a seen_results |
96 | */ | 97 | */ |
97 | static void | 98 | static void |
98 | bf_group_mark_seen_cb(struct GNUNET_BLOCK_Group *bg, | 99 | bf_group_mark_seen_cb (struct GNUNET_BLOCK_Group *bg, |
99 | const struct GNUNET_HashCode *seen_results, | 100 | const struct GNUNET_HashCode *seen_results, |
100 | unsigned int seen_results_count) | 101 | unsigned int seen_results_count) |
101 | { | 102 | { |
102 | struct BfGroupInternals *gi = bg->internal_cls; | 103 | struct BfGroupInternals *gi = bg->internal_cls; |
103 | 104 | ||
104 | for (unsigned int i = 0; i < seen_results_count; i++) | 105 | for (unsigned int i = 0; i < seen_results_count; i++) |
105 | { | 106 | { |
106 | struct GNUNET_HashCode mhash; | 107 | struct GNUNET_HashCode mhash; |
107 | 108 | ||
108 | GNUNET_BLOCK_mingle_hash(&seen_results[i], | 109 | GNUNET_BLOCK_mingle_hash (&seen_results[i], |
109 | gi->bf_mutator, | 110 | gi->bf_mutator, |
110 | &mhash); | 111 | &mhash); |
111 | GNUNET_CONTAINER_bloomfilter_add(gi->bf, | 112 | GNUNET_CONTAINER_bloomfilter_add (gi->bf, |
112 | &mhash); | 113 | &mhash); |
113 | } | 114 | } |
114 | } | 115 | } |
115 | 116 | ||
116 | 117 | ||
@@ -124,8 +125,8 @@ bf_group_mark_seen_cb(struct GNUNET_BLOCK_Group *bg, | |||
124 | * we failed. | 125 | * we failed. |
125 | */ | 126 | */ |
126 | static int | 127 | static int |
127 | bf_group_merge_cb(struct GNUNET_BLOCK_Group *bg1, | 128 | bf_group_merge_cb (struct GNUNET_BLOCK_Group *bg1, |
128 | const struct GNUNET_BLOCK_Group *bg2) | 129 | const struct GNUNET_BLOCK_Group *bg2) |
129 | { | 130 | { |
130 | struct BfGroupInternals *gi1 = bg1->internal_cls; | 131 | struct BfGroupInternals *gi1 = bg1->internal_cls; |
131 | struct BfGroupInternals *gi2 = bg2->internal_cls; | 132 | struct BfGroupInternals *gi2 = bg2->internal_cls; |
@@ -134,8 +135,8 @@ bf_group_merge_cb(struct GNUNET_BLOCK_Group *bg1, | |||
134 | return GNUNET_NO; | 135 | return GNUNET_NO; |
135 | if (gi1->bf_size != gi2->bf_size) | 136 | if (gi1->bf_size != gi2->bf_size) |
136 | return GNUNET_NO; | 137 | return GNUNET_NO; |
137 | GNUNET_CONTAINER_bloomfilter_or2(gi1->bf, | 138 | GNUNET_CONTAINER_bloomfilter_or2 (gi1->bf, |
138 | gi2->bf); | 139 | gi2->bf); |
139 | return GNUNET_OK; | 140 | return GNUNET_OK; |
140 | } | 141 | } |
141 | 142 | ||
@@ -146,13 +147,13 @@ bf_group_merge_cb(struct GNUNET_BLOCK_Group *bg1, | |||
146 | * @param bg group to destroy, NULL is allowed | 147 | * @param bg group to destroy, NULL is allowed |
147 | */ | 148 | */ |
148 | static void | 149 | static void |
149 | bf_group_destroy_cb(struct GNUNET_BLOCK_Group *bg) | 150 | bf_group_destroy_cb (struct GNUNET_BLOCK_Group *bg) |
150 | { | 151 | { |
151 | struct BfGroupInternals *gi = bg->internal_cls; | 152 | struct BfGroupInternals *gi = bg->internal_cls; |
152 | 153 | ||
153 | GNUNET_CONTAINER_bloomfilter_free(gi->bf); | 154 | GNUNET_CONTAINER_bloomfilter_free (gi->bf); |
154 | GNUNET_free(gi); | 155 | GNUNET_free (gi); |
155 | GNUNET_free(bg); | 156 | GNUNET_free (bg); |
156 | } | 157 | } |
157 | 158 | ||
158 | 159 | ||
@@ -170,24 +171,25 @@ bf_group_destroy_cb(struct GNUNET_BLOCK_Group *bg) | |||
170 | * by this @a type of block (this is not an error) | 171 | * by this @a type of block (this is not an error) |
171 | */ | 172 | */ |
172 | struct GNUNET_BLOCK_Group * | 173 | struct GNUNET_BLOCK_Group * |
173 | GNUNET_BLOCK_GROUP_bf_create(void *cls, | 174 | GNUNET_BLOCK_GROUP_bf_create (void *cls, |
174 | size_t bf_size, | 175 | size_t bf_size, |
175 | unsigned int bf_k, | 176 | unsigned int bf_k, |
176 | enum GNUNET_BLOCK_Type type, | 177 | enum GNUNET_BLOCK_Type type, |
177 | uint32_t nonce, | 178 | uint32_t nonce, |
178 | const void *raw_data, | 179 | const void *raw_data, |
179 | size_t raw_data_size) | 180 | size_t raw_data_size) |
180 | { | 181 | { |
181 | struct BfGroupInternals *gi; | 182 | struct BfGroupInternals *gi; |
182 | struct GNUNET_BLOCK_Group *bg; | 183 | struct GNUNET_BLOCK_Group *bg; |
183 | 184 | ||
184 | gi = GNUNET_new(struct BfGroupInternals); | 185 | gi = GNUNET_new (struct BfGroupInternals); |
185 | gi->bf = GNUNET_CONTAINER_bloomfilter_init((bf_size != raw_data_size) ? NULL : raw_data, | 186 | gi->bf = GNUNET_CONTAINER_bloomfilter_init ((bf_size != raw_data_size) ? |
186 | bf_size, | 187 | NULL : raw_data, |
187 | bf_k); | 188 | bf_size, |
189 | bf_k); | ||
188 | gi->bf_mutator = nonce; | 190 | gi->bf_mutator = nonce; |
189 | gi->bf_size = bf_size; | 191 | gi->bf_size = bf_size; |
190 | bg = GNUNET_new(struct GNUNET_BLOCK_Group); | 192 | bg = GNUNET_new (struct GNUNET_BLOCK_Group); |
191 | bg->type = type; | 193 | bg->type = type; |
192 | bg->serialize_cb = &bf_group_serialize_cb; | 194 | bg->serialize_cb = &bf_group_serialize_cb; |
193 | bg->mark_seen_cb = &bf_group_mark_seen_cb; | 195 | bg->mark_seen_cb = &bf_group_mark_seen_cb; |
@@ -209,8 +211,8 @@ GNUNET_BLOCK_GROUP_bf_create(void *cls, | |||
209 | * #GNUNET_NO if @a hc was definitively not in @bg (but now is) | 211 | * #GNUNET_NO if @a hc was definitively not in @bg (but now is) |
210 | */ | 212 | */ |
211 | int | 213 | int |
212 | GNUNET_BLOCK_GROUP_bf_test_and_set(struct GNUNET_BLOCK_Group *bg, | 214 | GNUNET_BLOCK_GROUP_bf_test_and_set (struct GNUNET_BLOCK_Group *bg, |
213 | const struct GNUNET_HashCode *hc) | 215 | const struct GNUNET_HashCode *hc) |
214 | { | 216 | { |
215 | struct BfGroupInternals *gi; | 217 | struct BfGroupInternals *gi; |
216 | struct GNUNET_HashCode mhash; | 218 | struct GNUNET_HashCode mhash; |
@@ -218,15 +220,15 @@ GNUNET_BLOCK_GROUP_bf_test_and_set(struct GNUNET_BLOCK_Group *bg, | |||
218 | if (NULL == bg) | 220 | if (NULL == bg) |
219 | return GNUNET_NO; | 221 | return GNUNET_NO; |
220 | gi = bg->internal_cls; | 222 | gi = bg->internal_cls; |
221 | GNUNET_BLOCK_mingle_hash(hc, | 223 | GNUNET_BLOCK_mingle_hash (hc, |
222 | gi->bf_mutator, | 224 | gi->bf_mutator, |
223 | &mhash); | 225 | &mhash); |
224 | if (GNUNET_YES == | 226 | if (GNUNET_YES == |
225 | GNUNET_CONTAINER_bloomfilter_test(gi->bf, | 227 | GNUNET_CONTAINER_bloomfilter_test (gi->bf, |
226 | &mhash)) | 228 | &mhash)) |
227 | return GNUNET_YES; | 229 | return GNUNET_YES; |
228 | GNUNET_CONTAINER_bloomfilter_add(gi->bf, | 230 | GNUNET_CONTAINER_bloomfilter_add (gi->bf, |
229 | &mhash); | 231 | &mhash); |
230 | return GNUNET_NO; | 232 | return GNUNET_NO; |
231 | } | 233 | } |
232 | 234 | ||
@@ -245,8 +247,8 @@ GNUNET_BLOCK_GROUP_bf_test_and_set(struct GNUNET_BLOCK_Group *bg, | |||
245 | * @return must be a power of two and smaller or equal to 2^15. | 247 | * @return must be a power of two and smaller or equal to 2^15. |
246 | */ | 248 | */ |
247 | size_t | 249 | size_t |
248 | GNUNET_BLOCK_GROUP_compute_bloomfilter_size(unsigned int entry_count, | 250 | GNUNET_BLOCK_GROUP_compute_bloomfilter_size (unsigned int entry_count, |
249 | unsigned int k) | 251 | unsigned int k) |
250 | { | 252 | { |
251 | size_t size; | 253 | size_t size; |
252 | unsigned int ideal = (entry_count * k) / 4; | 254 | unsigned int ideal = (entry_count * k) / 4; |
diff --git a/src/block/block.c b/src/block/block.c index 78e9bc2dd..dafba9d8c 100644 --- a/src/block/block.c +++ b/src/block/block.c | |||
@@ -34,7 +34,8 @@ | |||
34 | /** | 34 | /** |
35 | * Handle for a plugin. | 35 | * Handle for a plugin. |
36 | */ | 36 | */ |
37 | struct Plugin { | 37 | struct Plugin |
38 | { | ||
38 | /** | 39 | /** |
39 | * Name of the shared library. | 40 | * Name of the shared library. |
40 | */ | 41 | */ |
@@ -50,7 +51,8 @@ struct Plugin { | |||
50 | /** | 51 | /** |
51 | * Handle to an initialized block library. | 52 | * Handle to an initialized block library. |
52 | */ | 53 | */ |
53 | struct GNUNET_BLOCK_Context { | 54 | struct GNUNET_BLOCK_Context |
55 | { | ||
54 | /** | 56 | /** |
55 | * Array of our plugins. | 57 | * Array of our plugins. |
56 | */ | 58 | */ |
@@ -76,18 +78,18 @@ struct GNUNET_BLOCK_Context { | |||
76 | * @param hc where to store the result. | 78 | * @param hc where to store the result. |
77 | */ | 79 | */ |
78 | void | 80 | void |
79 | GNUNET_BLOCK_mingle_hash(const struct GNUNET_HashCode *in, | 81 | GNUNET_BLOCK_mingle_hash (const struct GNUNET_HashCode *in, |
80 | uint32_t mingle_number, | 82 | uint32_t mingle_number, |
81 | struct GNUNET_HashCode *hc) | 83 | struct GNUNET_HashCode *hc) |
82 | { | 84 | { |
83 | struct GNUNET_HashCode m; | 85 | struct GNUNET_HashCode m; |
84 | 86 | ||
85 | GNUNET_CRYPTO_hash(&mingle_number, | 87 | GNUNET_CRYPTO_hash (&mingle_number, |
86 | sizeof(uint32_t), | 88 | sizeof(uint32_t), |
87 | &m); | 89 | &m); |
88 | GNUNET_CRYPTO_hash_xor(&m, | 90 | GNUNET_CRYPTO_hash_xor (&m, |
89 | in, | 91 | in, |
90 | hc); | 92 | hc); |
91 | } | 93 | } |
92 | 94 | ||
93 | 95 | ||
@@ -99,23 +101,23 @@ GNUNET_BLOCK_mingle_hash(const struct GNUNET_HashCode *in, | |||
99 | * @param lib_ret the plugin API | 101 | * @param lib_ret the plugin API |
100 | */ | 102 | */ |
101 | static void | 103 | static void |
102 | add_plugin(void *cls, | 104 | add_plugin (void *cls, |
103 | const char *library_name, | 105 | const char *library_name, |
104 | void *lib_ret) | 106 | void *lib_ret) |
105 | { | 107 | { |
106 | struct GNUNET_BLOCK_Context *ctx = cls; | 108 | struct GNUNET_BLOCK_Context *ctx = cls; |
107 | struct GNUNET_BLOCK_PluginFunctions *api = lib_ret; | 109 | struct GNUNET_BLOCK_PluginFunctions *api = lib_ret; |
108 | struct Plugin *plugin; | 110 | struct Plugin *plugin; |
109 | 111 | ||
110 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 112 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
111 | "Loading block plugin `%s'\n", | 113 | "Loading block plugin `%s'\n", |
112 | library_name); | 114 | library_name); |
113 | plugin = GNUNET_new(struct Plugin); | 115 | plugin = GNUNET_new (struct Plugin); |
114 | plugin->api = api; | 116 | plugin->api = api; |
115 | plugin->library_name = GNUNET_strdup(library_name); | 117 | plugin->library_name = GNUNET_strdup (library_name); |
116 | GNUNET_array_append(ctx->plugins, | 118 | GNUNET_array_append (ctx->plugins, |
117 | ctx->num_plugins, | 119 | ctx->num_plugins, |
118 | plugin); | 120 | plugin); |
119 | } | 121 | } |
120 | 122 | ||
121 | 123 | ||
@@ -127,16 +129,16 @@ add_plugin(void *cls, | |||
127 | * @return NULL on error | 129 | * @return NULL on error |
128 | */ | 130 | */ |
129 | struct GNUNET_BLOCK_Context * | 131 | struct GNUNET_BLOCK_Context * |
130 | GNUNET_BLOCK_context_create(const struct GNUNET_CONFIGURATION_Handle *cfg) | 132 | GNUNET_BLOCK_context_create (const struct GNUNET_CONFIGURATION_Handle *cfg) |
131 | { | 133 | { |
132 | struct GNUNET_BLOCK_Context *ctx; | 134 | struct GNUNET_BLOCK_Context *ctx; |
133 | 135 | ||
134 | ctx = GNUNET_new(struct GNUNET_BLOCK_Context); | 136 | ctx = GNUNET_new (struct GNUNET_BLOCK_Context); |
135 | ctx->cfg = cfg; | 137 | ctx->cfg = cfg; |
136 | GNUNET_PLUGIN_load_all("libgnunet_plugin_block_", | 138 | GNUNET_PLUGIN_load_all ("libgnunet_plugin_block_", |
137 | (void *)cfg, | 139 | (void *) cfg, |
138 | &add_plugin, | 140 | &add_plugin, |
139 | ctx); | 141 | ctx); |
140 | return ctx; | 142 | return ctx; |
141 | } | 143 | } |
142 | 144 | ||
@@ -147,21 +149,21 @@ GNUNET_BLOCK_context_create(const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
147 | * @param ctx context to destroy | 149 | * @param ctx context to destroy |
148 | */ | 150 | */ |
149 | void | 151 | void |
150 | GNUNET_BLOCK_context_destroy(struct GNUNET_BLOCK_Context *ctx) | 152 | GNUNET_BLOCK_context_destroy (struct GNUNET_BLOCK_Context *ctx) |
151 | { | 153 | { |
152 | struct Plugin *plugin; | 154 | struct Plugin *plugin; |
153 | 155 | ||
154 | for (unsigned int i = 0; i < ctx->num_plugins; i++) | 156 | for (unsigned int i = 0; i < ctx->num_plugins; i++) |
155 | { | 157 | { |
156 | plugin = ctx->plugins[i]; | 158 | plugin = ctx->plugins[i]; |
157 | GNUNET_break(NULL == | 159 | GNUNET_break (NULL == |
158 | GNUNET_PLUGIN_unload(plugin->library_name, | 160 | GNUNET_PLUGIN_unload (plugin->library_name, |
159 | plugin->api)); | 161 | plugin->api)); |
160 | GNUNET_free(plugin->library_name); | 162 | GNUNET_free (plugin->library_name); |
161 | GNUNET_free(plugin); | 163 | GNUNET_free (plugin); |
162 | } | 164 | } |
163 | GNUNET_free(ctx->plugins); | 165 | GNUNET_free (ctx->plugins); |
164 | GNUNET_free(ctx); | 166 | GNUNET_free (ctx); |
165 | } | 167 | } |
166 | 168 | ||
167 | 169 | ||
@@ -176,10 +178,10 @@ GNUNET_BLOCK_context_destroy(struct GNUNET_BLOCK_Context *ctx) | |||
176 | * supported, #GNUNET_SYSERR on error | 178 | * supported, #GNUNET_SYSERR on error |
177 | */ | 179 | */ |
178 | int | 180 | int |
179 | GNUNET_BLOCK_group_serialize(struct GNUNET_BLOCK_Group *bg, | 181 | GNUNET_BLOCK_group_serialize (struct GNUNET_BLOCK_Group *bg, |
180 | uint32_t *nonce, | 182 | uint32_t *nonce, |
181 | void **raw_data, | 183 | void **raw_data, |
182 | size_t *raw_data_size) | 184 | size_t *raw_data_size) |
183 | { | 185 | { |
184 | *nonce = 0; | 186 | *nonce = 0; |
185 | *raw_data = NULL; | 187 | *raw_data = NULL; |
@@ -188,10 +190,10 @@ GNUNET_BLOCK_group_serialize(struct GNUNET_BLOCK_Group *bg, | |||
188 | return GNUNET_NO; | 190 | return GNUNET_NO; |
189 | if (NULL == bg->serialize_cb) | 191 | if (NULL == bg->serialize_cb) |
190 | return GNUNET_NO; | 192 | return GNUNET_NO; |
191 | return bg->serialize_cb(bg, | 193 | return bg->serialize_cb (bg, |
192 | nonce, | 194 | nonce, |
193 | raw_data, | 195 | raw_data, |
194 | raw_data_size); | 196 | raw_data_size); |
195 | } | 197 | } |
196 | 198 | ||
197 | 199 | ||
@@ -201,11 +203,11 @@ GNUNET_BLOCK_group_serialize(struct GNUNET_BLOCK_Group *bg, | |||
201 | * @param bg group to destroy, NULL is allowed | 203 | * @param bg group to destroy, NULL is allowed |
202 | */ | 204 | */ |
203 | void | 205 | void |
204 | GNUNET_BLOCK_group_destroy(struct GNUNET_BLOCK_Group *bg) | 206 | GNUNET_BLOCK_group_destroy (struct GNUNET_BLOCK_Group *bg) |
205 | { | 207 | { |
206 | if (NULL == bg) | 208 | if (NULL == bg) |
207 | return; | 209 | return; |
208 | bg->destroy_cb(bg); | 210 | bg->destroy_cb (bg); |
209 | } | 211 | } |
210 | 212 | ||
211 | 213 | ||
@@ -222,24 +224,24 @@ GNUNET_BLOCK_group_destroy(struct GNUNET_BLOCK_Group *bg) | |||
222 | * #GNUNET_SYSERR if merging is not supported | 224 | * #GNUNET_SYSERR if merging is not supported |
223 | */ | 225 | */ |
224 | int | 226 | int |
225 | GNUNET_BLOCK_group_merge(struct GNUNET_BLOCK_Group *bg1, | 227 | GNUNET_BLOCK_group_merge (struct GNUNET_BLOCK_Group *bg1, |
226 | struct GNUNET_BLOCK_Group *bg2) | 228 | struct GNUNET_BLOCK_Group *bg2) |
227 | { | 229 | { |
228 | int ret; | 230 | int ret; |
229 | 231 | ||
230 | if (NULL == bg2) | 232 | if (NULL == bg2) |
231 | return GNUNET_OK; | 233 | return GNUNET_OK; |
232 | if (NULL == bg1) | 234 | if (NULL == bg1) |
233 | { | 235 | { |
234 | bg2->destroy_cb(bg2); | 236 | bg2->destroy_cb (bg2); |
235 | return GNUNET_OK; | 237 | return GNUNET_OK; |
236 | } | 238 | } |
237 | if (NULL == bg1->merge_cb) | 239 | if (NULL == bg1->merge_cb) |
238 | return GNUNET_SYSERR; | 240 | return GNUNET_SYSERR; |
239 | GNUNET_assert(bg1->merge_cb == bg1->merge_cb); | 241 | GNUNET_assert (bg1->merge_cb == bg1->merge_cb); |
240 | ret = bg1->merge_cb(bg1, | 242 | ret = bg1->merge_cb (bg1, |
241 | bg2); | 243 | bg2); |
242 | bg2->destroy_cb(bg2); | 244 | bg2->destroy_cb (bg2); |
243 | return ret; | 245 | return ret; |
244 | } | 246 | } |
245 | 247 | ||
@@ -252,23 +254,23 @@ GNUNET_BLOCK_group_merge(struct GNUNET_BLOCK_Group *bg1, | |||
252 | * @return NULL if no matching plugin exists | 254 | * @return NULL if no matching plugin exists |
253 | */ | 255 | */ |
254 | static struct GNUNET_BLOCK_PluginFunctions * | 256 | static struct GNUNET_BLOCK_PluginFunctions * |
255 | find_plugin(struct GNUNET_BLOCK_Context *ctx, | 257 | find_plugin (struct GNUNET_BLOCK_Context *ctx, |
256 | enum GNUNET_BLOCK_Type type) | 258 | enum GNUNET_BLOCK_Type type) |
257 | { | 259 | { |
258 | struct Plugin *plugin; | 260 | struct Plugin *plugin; |
259 | unsigned int j; | 261 | unsigned int j; |
260 | 262 | ||
261 | for (unsigned i = 0; i < ctx->num_plugins; i++) | 263 | for (unsigned i = 0; i < ctx->num_plugins; i++) |
264 | { | ||
265 | plugin = ctx->plugins[i]; | ||
266 | j = 0; | ||
267 | while (0 != (plugin->api->types[j])) | ||
262 | { | 268 | { |
263 | plugin = ctx->plugins[i]; | 269 | if (type == plugin->api->types[j]) |
264 | j = 0; | 270 | return plugin->api; |
265 | while (0 != (plugin->api->types[j])) | 271 | j++; |
266 | { | ||
267 | if (type == plugin->api->types[j]) | ||
268 | return plugin->api; | ||
269 | j++; | ||
270 | } | ||
271 | } | 272 | } |
273 | } | ||
272 | return NULL; | 274 | return NULL; |
273 | } | 275 | } |
274 | 276 | ||
@@ -285,32 +287,32 @@ find_plugin(struct GNUNET_BLOCK_Context *ctx, | |||
285 | * by this @a type of block (this is not an error) | 287 | * by this @a type of block (this is not an error) |
286 | */ | 288 | */ |
287 | struct GNUNET_BLOCK_Group * | 289 | struct GNUNET_BLOCK_Group * |
288 | GNUNET_BLOCK_group_create(struct GNUNET_BLOCK_Context *ctx, | 290 | GNUNET_BLOCK_group_create (struct GNUNET_BLOCK_Context *ctx, |
289 | enum GNUNET_BLOCK_Type type, | 291 | enum GNUNET_BLOCK_Type type, |
290 | uint32_t nonce, | 292 | uint32_t nonce, |
291 | const void *raw_data, | 293 | const void *raw_data, |
292 | size_t raw_data_size, | 294 | size_t raw_data_size, |
293 | ...) | 295 | ...) |
294 | { | 296 | { |
295 | struct GNUNET_BLOCK_PluginFunctions *plugin; | 297 | struct GNUNET_BLOCK_PluginFunctions *plugin; |
296 | struct GNUNET_BLOCK_Group *bg; | 298 | struct GNUNET_BLOCK_Group *bg; |
297 | va_list ap; | 299 | va_list ap; |
298 | 300 | ||
299 | plugin = find_plugin(ctx, | 301 | plugin = find_plugin (ctx, |
300 | type); | 302 | type); |
301 | if (NULL == plugin) | 303 | if (NULL == plugin) |
302 | return NULL; | 304 | return NULL; |
303 | if (NULL == plugin->create_group) | 305 | if (NULL == plugin->create_group) |
304 | return NULL; | 306 | return NULL; |
305 | va_start(ap, | 307 | va_start (ap, |
306 | raw_data_size); | 308 | raw_data_size); |
307 | bg = plugin->create_group(plugin->cls, | 309 | bg = plugin->create_group (plugin->cls, |
308 | type, | 310 | type, |
309 | nonce, | 311 | nonce, |
310 | raw_data, | 312 | raw_data, |
311 | raw_data_size, | 313 | raw_data_size, |
312 | ap); | 314 | ap); |
313 | va_end(ap); | 315 | va_end (ap); |
314 | return bg; | 316 | return bg; |
315 | } | 317 | } |
316 | 318 | ||
@@ -334,31 +336,31 @@ GNUNET_BLOCK_group_create(struct GNUNET_BLOCK_Context *ctx, | |||
334 | * @return characterization of result | 336 | * @return characterization of result |
335 | */ | 337 | */ |
336 | enum GNUNET_BLOCK_EvaluationResult | 338 | enum GNUNET_BLOCK_EvaluationResult |
337 | GNUNET_BLOCK_evaluate(struct GNUNET_BLOCK_Context *ctx, | 339 | GNUNET_BLOCK_evaluate (struct GNUNET_BLOCK_Context *ctx, |
338 | enum GNUNET_BLOCK_Type type, | 340 | enum GNUNET_BLOCK_Type type, |
339 | struct GNUNET_BLOCK_Group *group, | 341 | struct GNUNET_BLOCK_Group *group, |
340 | enum GNUNET_BLOCK_EvaluationOptions eo, | 342 | enum GNUNET_BLOCK_EvaluationOptions eo, |
341 | const struct GNUNET_HashCode *query, | 343 | const struct GNUNET_HashCode *query, |
342 | const void *xquery, | 344 | const void *xquery, |
343 | size_t xquery_size, | 345 | size_t xquery_size, |
344 | const void *reply_block, | 346 | const void *reply_block, |
345 | size_t reply_block_size) | 347 | size_t reply_block_size) |
346 | { | 348 | { |
347 | struct GNUNET_BLOCK_PluginFunctions *plugin = find_plugin(ctx, | 349 | struct GNUNET_BLOCK_PluginFunctions *plugin = find_plugin (ctx, |
348 | type); | 350 | type); |
349 | 351 | ||
350 | if (NULL == plugin) | 352 | if (NULL == plugin) |
351 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; | 353 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; |
352 | return plugin->evaluate(plugin->cls, | 354 | return plugin->evaluate (plugin->cls, |
353 | ctx, | 355 | ctx, |
354 | type, | 356 | type, |
355 | group, | 357 | group, |
356 | eo, | 358 | eo, |
357 | query, | 359 | query, |
358 | xquery, | 360 | xquery, |
359 | xquery_size, | 361 | xquery_size, |
360 | reply_block, | 362 | reply_block, |
361 | reply_block_size); | 363 | reply_block_size); |
362 | } | 364 | } |
363 | 365 | ||
364 | 366 | ||
@@ -374,22 +376,22 @@ GNUNET_BLOCK_evaluate(struct GNUNET_BLOCK_Context *ctx, | |||
374 | * (or if extracting a key from a block of this type does not work) | 376 | * (or if extracting a key from a block of this type does not work) |
375 | */ | 377 | */ |
376 | int | 378 | int |
377 | GNUNET_BLOCK_get_key(struct GNUNET_BLOCK_Context *ctx, | 379 | GNUNET_BLOCK_get_key (struct GNUNET_BLOCK_Context *ctx, |
378 | enum GNUNET_BLOCK_Type type, | 380 | enum GNUNET_BLOCK_Type type, |
379 | const void *block, | 381 | const void *block, |
380 | size_t block_size, | 382 | size_t block_size, |
381 | struct GNUNET_HashCode *key) | 383 | struct GNUNET_HashCode *key) |
382 | { | 384 | { |
383 | struct GNUNET_BLOCK_PluginFunctions *plugin = find_plugin(ctx, | 385 | struct GNUNET_BLOCK_PluginFunctions *plugin = find_plugin (ctx, |
384 | type); | 386 | type); |
385 | 387 | ||
386 | if (plugin == NULL) | 388 | if (plugin == NULL) |
387 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; | 389 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; |
388 | return plugin->get_key(plugin->cls, | 390 | return plugin->get_key (plugin->cls, |
389 | type, | 391 | type, |
390 | block, | 392 | block, |
391 | block_size, | 393 | block_size, |
392 | key); | 394 | key); |
393 | } | 395 | } |
394 | 396 | ||
395 | 397 | ||
@@ -405,17 +407,17 @@ GNUNET_BLOCK_get_key(struct GNUNET_BLOCK_Context *ctx, | |||
405 | * @return #GNUNET_SYSERR if not supported, #GNUNET_OK on success | 407 | * @return #GNUNET_SYSERR if not supported, #GNUNET_OK on success |
406 | */ | 408 | */ |
407 | int | 409 | int |
408 | GNUNET_BLOCK_group_set_seen(struct GNUNET_BLOCK_Group *bg, | 410 | GNUNET_BLOCK_group_set_seen (struct GNUNET_BLOCK_Group *bg, |
409 | const struct GNUNET_HashCode *seen_results, | 411 | const struct GNUNET_HashCode *seen_results, |
410 | unsigned int seen_results_count) | 412 | unsigned int seen_results_count) |
411 | { | 413 | { |
412 | if (NULL == bg) | 414 | if (NULL == bg) |
413 | return GNUNET_OK; | 415 | return GNUNET_OK; |
414 | if (NULL == bg->mark_seen_cb) | 416 | if (NULL == bg->mark_seen_cb) |
415 | return GNUNET_SYSERR; | 417 | return GNUNET_SYSERR; |
416 | bg->mark_seen_cb(bg, | 418 | bg->mark_seen_cb (bg, |
417 | seen_results, | 419 | seen_results, |
418 | seen_results_count); | 420 | seen_results_count); |
419 | return GNUNET_OK; | 421 | return GNUNET_OK; |
420 | } | 422 | } |
421 | 423 | ||
diff --git a/src/block/plugin_block_template.c b/src/block/plugin_block_template.c index 5bfacb660..21b8a9be6 100644 --- a/src/block/plugin_block_template.c +++ b/src/block/plugin_block_template.c | |||
@@ -56,37 +56,38 @@ | |||
56 | * by this @a type of block (this is not an error) | 56 | * by this @a type of block (this is not an error) |
57 | */ | 57 | */ |
58 | static struct GNUNET_BLOCK_Group * | 58 | static struct GNUNET_BLOCK_Group * |
59 | block_plugin_template_create_group(void *cls, | 59 | block_plugin_template_create_group (void *cls, |
60 | enum GNUNET_BLOCK_Type type, | 60 | enum GNUNET_BLOCK_Type type, |
61 | uint32_t nonce, | 61 | uint32_t nonce, |
62 | const void *raw_data, | 62 | const void *raw_data, |
63 | size_t raw_data_size, | 63 | size_t raw_data_size, |
64 | va_list va) | 64 | va_list va) |
65 | { | 65 | { |
66 | unsigned int bf_size; | 66 | unsigned int bf_size; |
67 | const char *guard; | 67 | const char *guard; |
68 | 68 | ||
69 | guard = va_arg(va, const char *); | 69 | guard = va_arg (va, const char *); |
70 | if (0 == strcmp(guard, | 70 | if (0 == strcmp (guard, |
71 | "seen-set-size")) | 71 | "seen-set-size")) |
72 | bf_size = GNUNET_BLOCK_GROUP_compute_bloomfilter_size(va_arg(va, unsigned int), | 72 | bf_size = GNUNET_BLOCK_GROUP_compute_bloomfilter_size (va_arg (va, unsigned |
73 | BLOOMFILTER_K); | 73 | int), |
74 | else if (0 == strcmp(guard, | 74 | BLOOMFILTER_K); |
75 | "filter-size")) | 75 | else if (0 == strcmp (guard, |
76 | bf_size = va_arg(va, unsigned int); | 76 | "filter-size")) |
77 | bf_size = va_arg (va, unsigned int); | ||
77 | else | 78 | else |
78 | { | 79 | { |
79 | GNUNET_break(0); | 80 | GNUNET_break (0); |
80 | bf_size = TEMPLATE_BF_SIZE; | 81 | bf_size = TEMPLATE_BF_SIZE; |
81 | } | 82 | } |
82 | GNUNET_break(NULL == va_arg(va, const char *)); | 83 | GNUNET_break (NULL == va_arg (va, const char *)); |
83 | return GNUNET_BLOCK_GROUP_bf_create(cls, | 84 | return GNUNET_BLOCK_GROUP_bf_create (cls, |
84 | bf_size, | 85 | bf_size, |
85 | BLOOMFILTER_K, | 86 | BLOOMFILTER_K, |
86 | type, | 87 | type, |
87 | nonce, | 88 | nonce, |
88 | raw_data, | 89 | raw_data, |
89 | raw_data_size); | 90 | raw_data_size); |
90 | } | 91 | } |
91 | 92 | ||
92 | 93 | ||
@@ -107,27 +108,27 @@ block_plugin_template_create_group(void *cls, | |||
107 | * @return characterization of result | 108 | * @return characterization of result |
108 | */ | 109 | */ |
109 | static enum GNUNET_BLOCK_EvaluationResult | 110 | static enum GNUNET_BLOCK_EvaluationResult |
110 | block_plugin_template_evaluate(void *cls, | 111 | block_plugin_template_evaluate (void *cls, |
111 | struct GNUNET_BLOCK_Context *ctx, | 112 | struct GNUNET_BLOCK_Context *ctx, |
112 | enum GNUNET_BLOCK_Type type, | 113 | enum GNUNET_BLOCK_Type type, |
113 | struct GNUNET_BLOCK_Group *group, | 114 | struct GNUNET_BLOCK_Group *group, |
114 | enum GNUNET_BLOCK_EvaluationOptions eo, | 115 | enum GNUNET_BLOCK_EvaluationOptions eo, |
115 | const struct GNUNET_HashCode *query, | 116 | const struct GNUNET_HashCode *query, |
116 | const void *xquery, | 117 | const void *xquery, |
117 | size_t xquery_size, | 118 | size_t xquery_size, |
118 | const void *reply_block, | 119 | const void *reply_block, |
119 | size_t reply_block_size) | 120 | size_t reply_block_size) |
120 | { | 121 | { |
121 | struct GNUNET_HashCode chash; | 122 | struct GNUNET_HashCode chash; |
122 | 123 | ||
123 | if (NULL == reply_block) | 124 | if (NULL == reply_block) |
124 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; | 125 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; |
125 | GNUNET_CRYPTO_hash(reply_block, | 126 | GNUNET_CRYPTO_hash (reply_block, |
126 | reply_block_size, | 127 | reply_block_size, |
127 | &chash); | 128 | &chash); |
128 | if (GNUNET_YES == | 129 | if (GNUNET_YES == |
129 | GNUNET_BLOCK_GROUP_bf_test_and_set(group, | 130 | GNUNET_BLOCK_GROUP_bf_test_and_set (group, |
130 | &chash)) | 131 | &chash)) |
131 | return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; | 132 | return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; |
132 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; | 133 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; |
133 | } | 134 | } |
@@ -145,11 +146,11 @@ block_plugin_template_evaluate(void *cls, | |||
145 | * (or if extracting a key from a block of this type does not work) | 146 | * (or if extracting a key from a block of this type does not work) |
146 | */ | 147 | */ |
147 | static int | 148 | static int |
148 | block_plugin_template_get_key(void *cls, | 149 | block_plugin_template_get_key (void *cls, |
149 | enum GNUNET_BLOCK_Type type, | 150 | enum GNUNET_BLOCK_Type type, |
150 | const void *block, | 151 | const void *block, |
151 | size_t block_size, | 152 | size_t block_size, |
152 | struct GNUNET_HashCode *key) | 153 | struct GNUNET_HashCode *key) |
153 | { | 154 | { |
154 | return GNUNET_SYSERR; | 155 | return GNUNET_SYSERR; |
155 | } | 156 | } |
@@ -161,16 +162,15 @@ block_plugin_template_get_key(void *cls, | |||
161 | * @param cls a `const struct GNUNET_CONFIGURATION_Handle` | 162 | * @param cls a `const struct GNUNET_CONFIGURATION_Handle` |
162 | */ | 163 | */ |
163 | void * | 164 | void * |
164 | libgnunet_plugin_block_template_init(void *cls) | 165 | libgnunet_plugin_block_template_init (void *cls) |
165 | { | 166 | { |
166 | static enum GNUNET_BLOCK_Type types[] = | 167 | static enum GNUNET_BLOCK_Type types[] = { |
167 | { | ||
168 | /* FIXME: insert supported block types here */ | 168 | /* FIXME: insert supported block types here */ |
169 | GNUNET_BLOCK_TYPE_ANY /* end of list */ | 169 | GNUNET_BLOCK_TYPE_ANY /* end of list */ |
170 | }; | 170 | }; |
171 | struct GNUNET_BLOCK_PluginFunctions *api; | 171 | struct GNUNET_BLOCK_PluginFunctions *api; |
172 | 172 | ||
173 | api = GNUNET_new(struct GNUNET_BLOCK_PluginFunctions); | 173 | api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); |
174 | api->evaluate = &block_plugin_template_evaluate; | 174 | api->evaluate = &block_plugin_template_evaluate; |
175 | api->get_key = &block_plugin_template_get_key; | 175 | api->get_key = &block_plugin_template_get_key; |
176 | api->create_group = &block_plugin_template_create_group; | 176 | api->create_group = &block_plugin_template_create_group; |
@@ -183,11 +183,11 @@ libgnunet_plugin_block_template_init(void *cls) | |||
183 | * Exit point from the plugin. | 183 | * Exit point from the plugin. |
184 | */ | 184 | */ |
185 | void * | 185 | void * |
186 | libgnunet_plugin_block_template_done(void *cls) | 186 | libgnunet_plugin_block_template_done (void *cls) |
187 | { | 187 | { |
188 | struct GNUNET_BLOCK_PluginFunctions *api = cls; | 188 | struct GNUNET_BLOCK_PluginFunctions *api = cls; |
189 | 189 | ||
190 | GNUNET_free(api); | 190 | GNUNET_free (api); |
191 | return NULL; | 191 | return NULL; |
192 | } | 192 | } |
193 | 193 | ||
diff --git a/src/block/plugin_block_test.c b/src/block/plugin_block_test.c index 815fc15cc..b73e58cab 100644 --- a/src/block/plugin_block_test.c +++ b/src/block/plugin_block_test.c | |||
@@ -54,37 +54,38 @@ | |||
54 | * by this @a type of block (this is not an error) | 54 | * by this @a type of block (this is not an error) |
55 | */ | 55 | */ |
56 | static struct GNUNET_BLOCK_Group * | 56 | static struct GNUNET_BLOCK_Group * |
57 | block_plugin_test_create_group(void *cls, | 57 | block_plugin_test_create_group (void *cls, |
58 | enum GNUNET_BLOCK_Type type, | 58 | enum GNUNET_BLOCK_Type type, |
59 | uint32_t nonce, | 59 | uint32_t nonce, |
60 | const void *raw_data, | 60 | const void *raw_data, |
61 | size_t raw_data_size, | 61 | size_t raw_data_size, |
62 | va_list va) | 62 | va_list va) |
63 | { | 63 | { |
64 | unsigned int bf_size; | 64 | unsigned int bf_size; |
65 | const char *guard; | 65 | const char *guard; |
66 | 66 | ||
67 | guard = va_arg(va, const char *); | 67 | guard = va_arg (va, const char *); |
68 | if (0 == strcmp(guard, | 68 | if (0 == strcmp (guard, |
69 | "seen-set-size")) | 69 | "seen-set-size")) |
70 | bf_size = GNUNET_BLOCK_GROUP_compute_bloomfilter_size(va_arg(va, unsigned int), | 70 | bf_size = GNUNET_BLOCK_GROUP_compute_bloomfilter_size (va_arg (va, unsigned |
71 | BLOOMFILTER_K); | 71 | int), |
72 | else if (0 == strcmp(guard, | 72 | BLOOMFILTER_K); |
73 | "filter-size")) | 73 | else if (0 == strcmp (guard, |
74 | bf_size = va_arg(va, unsigned int); | 74 | "filter-size")) |
75 | bf_size = va_arg (va, unsigned int); | ||
75 | else | 76 | else |
76 | { | 77 | { |
77 | GNUNET_break(0); | 78 | GNUNET_break (0); |
78 | bf_size = TEST_BF_SIZE; | 79 | bf_size = TEST_BF_SIZE; |
79 | } | 80 | } |
80 | GNUNET_break(NULL == va_arg(va, const char *)); | 81 | GNUNET_break (NULL == va_arg (va, const char *)); |
81 | return GNUNET_BLOCK_GROUP_bf_create(cls, | 82 | return GNUNET_BLOCK_GROUP_bf_create (cls, |
82 | bf_size, | 83 | bf_size, |
83 | BLOOMFILTER_K, | 84 | BLOOMFILTER_K, |
84 | type, | 85 | type, |
85 | nonce, | 86 | nonce, |
86 | raw_data, | 87 | raw_data, |
87 | raw_data_size); | 88 | raw_data_size); |
88 | } | 89 | } |
89 | 90 | ||
90 | 91 | ||
@@ -105,37 +106,37 @@ block_plugin_test_create_group(void *cls, | |||
105 | * @return characterization of result | 106 | * @return characterization of result |
106 | */ | 107 | */ |
107 | static enum GNUNET_BLOCK_EvaluationResult | 108 | static enum GNUNET_BLOCK_EvaluationResult |
108 | block_plugin_test_evaluate(void *cls, | 109 | block_plugin_test_evaluate (void *cls, |
109 | struct GNUNET_BLOCK_Context *ctx, | 110 | struct GNUNET_BLOCK_Context *ctx, |
110 | enum GNUNET_BLOCK_Type type, | 111 | enum GNUNET_BLOCK_Type type, |
111 | struct GNUNET_BLOCK_Group *group, | 112 | struct GNUNET_BLOCK_Group *group, |
112 | enum GNUNET_BLOCK_EvaluationOptions eo, | 113 | enum GNUNET_BLOCK_EvaluationOptions eo, |
113 | const struct GNUNET_HashCode *query, | 114 | const struct GNUNET_HashCode *query, |
114 | const void *xquery, | 115 | const void *xquery, |
115 | size_t xquery_size, | 116 | size_t xquery_size, |
116 | const void *reply_block, | 117 | const void *reply_block, |
117 | size_t reply_block_size) | 118 | size_t reply_block_size) |
118 | { | 119 | { |
119 | struct GNUNET_HashCode chash; | 120 | struct GNUNET_HashCode chash; |
120 | 121 | ||
121 | if (GNUNET_BLOCK_TYPE_TEST != type) | 122 | if (GNUNET_BLOCK_TYPE_TEST != type) |
122 | { | 123 | { |
123 | GNUNET_break(0); | 124 | GNUNET_break (0); |
124 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; | 125 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; |
125 | } | 126 | } |
126 | if (0 != xquery_size) | 127 | if (0 != xquery_size) |
127 | { | 128 | { |
128 | GNUNET_break_op(0); | 129 | GNUNET_break_op (0); |
129 | return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; | 130 | return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; |
130 | } | 131 | } |
131 | if (NULL == reply_block) | 132 | if (NULL == reply_block) |
132 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; | 133 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; |
133 | GNUNET_CRYPTO_hash(reply_block, | 134 | GNUNET_CRYPTO_hash (reply_block, |
134 | reply_block_size, | 135 | reply_block_size, |
135 | &chash); | 136 | &chash); |
136 | if (GNUNET_YES == | 137 | if (GNUNET_YES == |
137 | GNUNET_BLOCK_GROUP_bf_test_and_set(group, | 138 | GNUNET_BLOCK_GROUP_bf_test_and_set (group, |
138 | &chash)) | 139 | &chash)) |
139 | return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; | 140 | return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; |
140 | return GNUNET_BLOCK_EVALUATION_OK_MORE; | 141 | return GNUNET_BLOCK_EVALUATION_OK_MORE; |
141 | } | 142 | } |
@@ -153,11 +154,11 @@ block_plugin_test_evaluate(void *cls, | |||
153 | * (or if extracting a key from a block of this type does not work) | 154 | * (or if extracting a key from a block of this type does not work) |
154 | */ | 155 | */ |
155 | static int | 156 | static int |
156 | block_plugin_test_get_key(void *cls, | 157 | block_plugin_test_get_key (void *cls, |
157 | enum GNUNET_BLOCK_Type type, | 158 | enum GNUNET_BLOCK_Type type, |
158 | const void *block, | 159 | const void *block, |
159 | size_t block_size, | 160 | size_t block_size, |
160 | struct GNUNET_HashCode *key) | 161 | struct GNUNET_HashCode *key) |
161 | { | 162 | { |
162 | /* always fails since there is no fixed relationship between | 163 | /* always fails since there is no fixed relationship between |
163 | * keys and values for test values */ | 164 | * keys and values for test values */ |
@@ -172,16 +173,15 @@ block_plugin_test_get_key(void *cls, | |||
172 | * @return the exported block API | 173 | * @return the exported block API |
173 | */ | 174 | */ |
174 | void * | 175 | void * |
175 | libgnunet_plugin_block_test_init(void *cls) | 176 | libgnunet_plugin_block_test_init (void *cls) |
176 | { | 177 | { |
177 | static enum GNUNET_BLOCK_Type types[] = | 178 | static enum GNUNET_BLOCK_Type types[] = { |
178 | { | ||
179 | GNUNET_BLOCK_TYPE_TEST, | 179 | GNUNET_BLOCK_TYPE_TEST, |
180 | GNUNET_BLOCK_TYPE_ANY /* end of list */ | 180 | GNUNET_BLOCK_TYPE_ANY /* end of list */ |
181 | }; | 181 | }; |
182 | struct GNUNET_BLOCK_PluginFunctions *api; | 182 | struct GNUNET_BLOCK_PluginFunctions *api; |
183 | 183 | ||
184 | api = GNUNET_new(struct GNUNET_BLOCK_PluginFunctions); | 184 | api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); |
185 | api->evaluate = &block_plugin_test_evaluate; | 185 | api->evaluate = &block_plugin_test_evaluate; |
186 | api->get_key = &block_plugin_test_get_key; | 186 | api->get_key = &block_plugin_test_get_key; |
187 | api->create_group = &block_plugin_test_create_group; | 187 | api->create_group = &block_plugin_test_create_group; |
@@ -197,11 +197,11 @@ libgnunet_plugin_block_test_init(void *cls) | |||
197 | * @return NULL | 197 | * @return NULL |
198 | */ | 198 | */ |
199 | void * | 199 | void * |
200 | libgnunet_plugin_block_test_done(void *cls) | 200 | libgnunet_plugin_block_test_done (void *cls) |
201 | { | 201 | { |
202 | struct GNUNET_BLOCK_PluginFunctions *api = cls; | 202 | struct GNUNET_BLOCK_PluginFunctions *api = cls; |
203 | 203 | ||
204 | GNUNET_free(api); | 204 | GNUNET_free (api); |
205 | return NULL; | 205 | return NULL; |
206 | } | 206 | } |
207 | 207 | ||