diff options
Diffstat (limited to 'src/block/plugin_block_template.c')
-rw-r--r-- | src/block/plugin_block_template.c | 104 |
1 files changed, 52 insertions, 52 deletions
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 | ||