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