diff options
Diffstat (limited to 'src/regex/regex_block_lib.c')
-rw-r--r-- | src/regex/regex_block_lib.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/regex/regex_block_lib.c b/src/regex/regex_block_lib.c index af74e89e6..8a1f08290 100644 --- a/src/regex/regex_block_lib.c +++ b/src/regex/regex_block_lib.c | |||
@@ -98,7 +98,7 @@ GNUNET_NETWORK_STRUCT_END | |||
98 | * @param block block to test | 98 | * @param block block to test |
99 | * @param size number of bytes in block | 99 | * @param size number of bytes in block |
100 | * @return GNUNET_YES if the block is accepting, GNUNET_NO if not | 100 | * @return GNUNET_YES if the block is accepting, GNUNET_NO if not |
101 | */ | 101 | */ |
102 | int | 102 | int |
103 | GNUNET_BLOCK_is_accepting (const struct RegexBlock *block, | 103 | GNUNET_BLOCK_is_accepting (const struct RegexBlock *block, |
104 | size_t size) | 104 | size_t size) |
@@ -164,7 +164,7 @@ struct CheckEdgeContext | |||
164 | * @param token Token that follows to next state. | 164 | * @param token Token that follows to next state. |
165 | * @param len Lenght of token. | 165 | * @param len Lenght of token. |
166 | * @param key Hash of next state. | 166 | * @param key Hash of next state. |
167 | * | 167 | * |
168 | * @return GNUNET_YES, to keep iterating | 168 | * @return GNUNET_YES, to keep iterating |
169 | */ | 169 | */ |
170 | static int | 170 | static int |
@@ -175,7 +175,7 @@ check_edge (void *cls, | |||
175 | { | 175 | { |
176 | struct CheckEdgeContext *ctx = cls; | 176 | struct CheckEdgeContext *ctx = cls; |
177 | 177 | ||
178 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 178 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
179 | "edge %.*s [%u]: %s->%s\n", | 179 | "edge %.*s [%u]: %s->%s\n", |
180 | (int) len, token, len, GNUNET_h2s(key)); | 180 | (int) len, token, len, GNUNET_h2s(key)); |
181 | if (NULL == ctx->xquery) | 181 | if (NULL == ctx->xquery) |
@@ -212,7 +212,7 @@ REGEX_BLOCK_check (const struct RegexBlock *block, | |||
212 | int res; | 212 | int res; |
213 | 213 | ||
214 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Block check\n"); | 214 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Block check\n"); |
215 | if (GNUNET_OK != | 215 | if (GNUNET_OK != |
216 | REGEX_BLOCK_get_key (block, size, | 216 | REGEX_BLOCK_get_key (block, size, |
217 | &key)) | 217 | &key)) |
218 | { | 218 | { |
@@ -267,17 +267,17 @@ REGEX_BLOCK_get_key (const struct RegexBlock *block, | |||
267 | uint16_t num_edges; | 267 | uint16_t num_edges; |
268 | size_t total; | 268 | size_t total; |
269 | 269 | ||
270 | if (block_len < sizeof (struct RegexBlock)) | 270 | if (block_len < sizeof (struct RegexBlock)) |
271 | { | 271 | { |
272 | GNUNET_break_op (0); | 272 | GNUNET_break_op (0); |
273 | return GNUNET_SYSERR; | 273 | return GNUNET_SYSERR; |
274 | } | 274 | } |
275 | num_destinations = ntohs (block->num_destinations); | 275 | num_destinations = ntohs (block->num_destinations); |
276 | num_edges = ntohs (block->num_edges); | 276 | num_edges = ntohs (block->num_edges); |
277 | len = ntohs (block->proof_len); | 277 | len = ntohs (block->proof_len); |
278 | destinations = (const struct GNUNET_HashCode *) &block[1]; | 278 | destinations = (const struct GNUNET_HashCode *) &block[1]; |
279 | edges = (const struct EdgeInfo *) &destinations[num_destinations]; | 279 | edges = (const struct EdgeInfo *) &destinations[num_destinations]; |
280 | total = sizeof (struct RegexBlock) + num_destinations * sizeof (struct GNUNET_HashCode) + num_edges + sizeof (struct EdgeInfo) + len; | 280 | total = sizeof (struct RegexBlock) + num_destinations * sizeof (struct GNUNET_HashCode) + num_edges + sizeof (struct EdgeInfo) + len; |
281 | if (block_len < total) | 281 | if (block_len < total) |
282 | { | 282 | { |
283 | GNUNET_break_op (0); | 283 | GNUNET_break_op (0); |
@@ -321,7 +321,7 @@ REGEX_BLOCK_iterate (const struct RegexBlock *block, | |||
321 | size_t off; | 321 | size_t off; |
322 | 322 | ||
323 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Block iterate\n"); | 323 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Block iterate\n"); |
324 | if (size < sizeof (struct RegexBlock)) | 324 | if (size < sizeof (struct RegexBlock)) |
325 | { | 325 | { |
326 | GNUNET_break_op (0); | 326 | GNUNET_break_op (0); |
327 | return GNUNET_SYSERR; | 327 | return GNUNET_SYSERR; |
@@ -333,14 +333,14 @@ REGEX_BLOCK_iterate (const struct RegexBlock *block, | |||
333 | edges = (const struct EdgeInfo *) &destinations[num_destinations]; | 333 | edges = (const struct EdgeInfo *) &destinations[num_destinations]; |
334 | aux = (const char *) &edges[num_edges]; | 334 | aux = (const char *) &edges[num_edges]; |
335 | total = sizeof (struct RegexBlock) + num_destinations * sizeof (struct GNUNET_HashCode) + num_edges * sizeof (struct EdgeInfo) + len; | 335 | total = sizeof (struct RegexBlock) + num_destinations * sizeof (struct GNUNET_HashCode) + num_edges * sizeof (struct EdgeInfo) + len; |
336 | if (size < total) | 336 | if (size < total) |
337 | { | 337 | { |
338 | GNUNET_break_op (0); | 338 | GNUNET_break_op (0); |
339 | return GNUNET_SYSERR; | 339 | return GNUNET_SYSERR; |
340 | } | 340 | } |
341 | for (n=0;n<num_edges;n++) | 341 | for (n=0;n<num_edges;n++) |
342 | total += ntohs (edges[n].token_length); | 342 | total += ntohs (edges[n].token_length); |
343 | if (size != total) | 343 | if (size != total) |
344 | { | 344 | { |
345 | fprintf (stderr, "Expected %u, got %u\n", | 345 | fprintf (stderr, "Expected %u, got %u\n", |
346 | (unsigned int) size, | 346 | (unsigned int) size, |
@@ -360,8 +360,8 @@ REGEX_BLOCK_iterate (const struct RegexBlock *block, | |||
360 | ntohs (edges[n].token_length), ntohs (edges[n].token_length), | 360 | ntohs (edges[n].token_length), ntohs (edges[n].token_length), |
361 | &aux[off]); | 361 | &aux[off]); |
362 | if (NULL != iterator) | 362 | if (NULL != iterator) |
363 | if (GNUNET_NO == iterator (iter_cls, | 363 | if (GNUNET_NO == iterator (iter_cls, |
364 | &aux[off], | 364 | &aux[off], |
365 | ntohs (edges[n].token_length), | 365 | ntohs (edges[n].token_length), |
366 | &destinations[ntohs (edges[n].destination_index)])) | 366 | &destinations[ntohs (edges[n].destination_index)])) |
367 | return GNUNET_OK; | 367 | return GNUNET_OK; |
@@ -403,7 +403,7 @@ REGEX_BLOCK_create (const char *proof, | |||
403 | char *aux; | 403 | char *aux; |
404 | 404 | ||
405 | len = strlen (proof); | 405 | len = strlen (proof); |
406 | if (len > UINT16_MAX) | 406 | if (len > UINT16_MAX) |
407 | { | 407 | { |
408 | GNUNET_break (0); | 408 | GNUNET_break (0); |
409 | return NULL; | 409 | return NULL; |
@@ -413,7 +413,7 @@ REGEX_BLOCK_create (const char *proof, | |||
413 | for (i=0;i<num_edges;i++) | 413 | for (i=0;i<num_edges;i++) |
414 | { | 414 | { |
415 | slen = strlen (edges[i].label); | 415 | slen = strlen (edges[i].label); |
416 | if (slen > UINT16_MAX) | 416 | if (slen > UINT16_MAX) |
417 | { | 417 | { |
418 | GNUNET_break (0); | 418 | GNUNET_break (0); |
419 | return NULL; | 419 | return NULL; |
@@ -449,7 +449,7 @@ REGEX_BLOCK_create (const char *proof, | |||
449 | edgeinfos = (struct EdgeInfo *) &dests[unique_destinations]; | 449 | edgeinfos = (struct EdgeInfo *) &dests[unique_destinations]; |
450 | aux = (char *) &edgeinfos[num_edges]; | 450 | aux = (char *) &edgeinfos[num_edges]; |
451 | off = len; | 451 | off = len; |
452 | memcpy (aux, proof, len); | 452 | memcpy (aux, proof, len); |
453 | for (i=0;i<num_edges;i++) | 453 | for (i=0;i<num_edges;i++) |
454 | { | 454 | { |
455 | slen = strlen (edges[i].label); | 455 | slen = strlen (edges[i].label); |