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/peerinfo-tool | |
parent | a0fce305c565c0937d917a92712f15e9c5736260 (diff) | |
download | gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.tar.gz gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.zip |
uncrustify as demanded.
Diffstat (limited to 'src/peerinfo-tool')
-rw-r--r-- | src/peerinfo-tool/gnunet-peerinfo.c | 677 | ||||
-rw-r--r-- | src/peerinfo-tool/gnunet-peerinfo_plugins.c | 117 | ||||
-rw-r--r-- | src/peerinfo-tool/gnunet-peerinfo_plugins.h | 10 | ||||
-rw-r--r-- | src/peerinfo-tool/plugin_rest_peerinfo.c | 520 |
4 files changed, 657 insertions, 667 deletions
diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c index fdcaaba58..bd029b2d1 100644 --- a/src/peerinfo-tool/gnunet-peerinfo.c +++ b/src/peerinfo-tool/gnunet-peerinfo.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 peerinfo-tool/gnunet-peerinfo.c | 22 | * @file peerinfo-tool/gnunet-peerinfo.c |
@@ -35,7 +35,7 @@ | |||
35 | /** | 35 | /** |
36 | * How long until we time out during address lookup? | 36 | * How long until we time out during address lookup? |
37 | */ | 37 | */ |
38 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | 38 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5) |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * Structure we use to collect printable address information. | 41 | * Structure we use to collect printable address information. |
@@ -45,8 +45,7 @@ struct PrintContext; | |||
45 | /** | 45 | /** |
46 | * Record we keep for each printable address. | 46 | * Record we keep for each printable address. |
47 | */ | 47 | */ |
48 | struct AddressRecord | 48 | struct AddressRecord { |
49 | { | ||
50 | /** | 49 | /** |
51 | * Current address-to-string context (if active, otherwise NULL). | 50 | * Current address-to-string context (if active, otherwise NULL). |
52 | */ | 51 | */ |
@@ -72,9 +71,7 @@ struct AddressRecord | |||
72 | /** | 71 | /** |
73 | * Structure we use to collect printable address information. | 72 | * Structure we use to collect printable address information. |
74 | */ | 73 | */ |
75 | struct PrintContext | 74 | struct PrintContext { |
76 | { | ||
77 | |||
78 | /** | 75 | /** |
79 | * Kept in DLL. | 76 | * Kept in DLL. |
80 | */ | 77 | */ |
@@ -220,7 +217,7 @@ static struct GNUNET_HELLO_Message *my_hello; | |||
220 | * @param cls unused | 217 | * @param cls unused |
221 | */ | 218 | */ |
222 | static void | 219 | static void |
223 | state_machine (void *cls); | 220 | state_machine(void *cls); |
224 | 221 | ||
225 | 222 | ||
226 | /* ********************* 'get_info' ******************* */ | 223 | /* ********************* 'get_info' ******************* */ |
@@ -231,30 +228,30 @@ state_machine (void *cls); | |||
231 | * @param pc printing context | 228 | * @param pc printing context |
232 | */ | 229 | */ |
233 | static void | 230 | static void |
234 | dump_pc (struct PrintContext *pc) | 231 | dump_pc(struct PrintContext *pc) |
235 | { | 232 | { |
236 | unsigned int i; | 233 | unsigned int i; |
237 | 234 | ||
238 | printf (_ ("%sPeer `%s'\n"), | 235 | printf(_("%sPeer `%s'\n"), |
239 | (GNUNET_YES == pc->friend_only) ? "F2F: " : "", | 236 | (GNUNET_YES == pc->friend_only) ? "F2F: " : "", |
240 | GNUNET_i2s_full (&pc->peer)); | 237 | GNUNET_i2s_full(&pc->peer)); |
241 | for (i = 0; i < pc->num_addresses; i++) | 238 | for (i = 0; i < pc->num_addresses; i++) |
242 | { | ||
243 | if (NULL != pc->address_list[i].result) | ||
244 | { | 239 | { |
245 | printf (_ ("\tExpires: %s \t %s\n"), | 240 | if (NULL != pc->address_list[i].result) |
246 | GNUNET_STRINGS_absolute_time_to_string ( | 241 | { |
247 | pc->address_list[i].expiration), | 242 | printf(_("\tExpires: %s \t %s\n"), |
248 | pc->address_list[i].result); | 243 | GNUNET_STRINGS_absolute_time_to_string( |
249 | GNUNET_free (pc->address_list[i].result); | 244 | pc->address_list[i].expiration), |
245 | pc->address_list[i].result); | ||
246 | GNUNET_free(pc->address_list[i].result); | ||
247 | } | ||
250 | } | 248 | } |
251 | } | 249 | printf("\n"); |
252 | printf ("\n"); | 250 | GNUNET_free_non_null(pc->address_list); |
253 | GNUNET_free_non_null (pc->address_list); | 251 | GNUNET_CONTAINER_DLL_remove(pc_head, pc_tail, pc); |
254 | GNUNET_CONTAINER_DLL_remove (pc_head, pc_tail, pc); | 252 | GNUNET_free(pc); |
255 | GNUNET_free (pc); | ||
256 | if ((NULL == pc_head) && (NULL == pic)) | 253 | if ((NULL == pc_head) && (NULL == pic)) |
257 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); | 254 | tt = GNUNET_SCHEDULER_add_now(&state_machine, NULL); |
258 | } | 255 | } |
259 | 256 | ||
260 | 257 | ||
@@ -272,29 +269,29 @@ dump_pc (struct PrintContext *pc) | |||
272 | * if #GNUNET_SYSERR: address is invalid | 269 | * if #GNUNET_SYSERR: address is invalid |
273 | */ | 270 | */ |
274 | static void | 271 | static void |
275 | process_resolved_address (void *cls, const char *address, int res) | 272 | process_resolved_address(void *cls, const char *address, int res) |
276 | { | 273 | { |
277 | struct AddressRecord *ar = cls; | 274 | struct AddressRecord *ar = cls; |
278 | struct PrintContext *pc = ar->pc; | 275 | struct PrintContext *pc = ar->pc; |
279 | 276 | ||
280 | if (NULL != address) | 277 | if (NULL != address) |
281 | { | ||
282 | if (0 != strlen (address)) | ||
283 | { | 278 | { |
284 | if (NULL != ar->result) | 279 | if (0 != strlen(address)) |
285 | GNUNET_free (ar->result); | 280 | { |
286 | ar->result = GNUNET_strdup (address); | 281 | if (NULL != ar->result) |
282 | GNUNET_free(ar->result); | ||
283 | ar->result = GNUNET_strdup(address); | ||
284 | } | ||
285 | return; | ||
287 | } | 286 | } |
288 | return; | ||
289 | } | ||
290 | ar->atsc = NULL; | 287 | ar->atsc = NULL; |
291 | if (GNUNET_SYSERR == res) | 288 | if (GNUNET_SYSERR == res) |
292 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 289 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
293 | _ ("Failure: Cannot convert address to string for peer `%s'\n"), | 290 | _("Failure: Cannot convert address to string for peer `%s'\n"), |
294 | GNUNET_i2s (&ar->pc->peer)); | 291 | GNUNET_i2s(&ar->pc->peer)); |
295 | pc->num_addresses++; | 292 | pc->num_addresses++; |
296 | if (pc->num_addresses == pc->address_list_size) | 293 | if (pc->num_addresses == pc->address_list_size) |
297 | dump_pc (pc); | 294 | dump_pc(pc); |
298 | } | 295 | } |
299 | 296 | ||
300 | 297 | ||
@@ -307,9 +304,9 @@ process_resolved_address (void *cls, const char *address, int res) | |||
307 | * @return #GNUNET_OK to keep the address and continue | 304 | * @return #GNUNET_OK to keep the address and continue |
308 | */ | 305 | */ |
309 | static int | 306 | static int |
310 | count_address (void *cls, | 307 | count_address(void *cls, |
311 | const struct GNUNET_HELLO_Address *address, | 308 | const struct GNUNET_HELLO_Address *address, |
312 | struct GNUNET_TIME_Absolute expiration) | 309 | struct GNUNET_TIME_Absolute expiration) |
313 | { | 310 | { |
314 | struct PrintContext *pc = cls; | 311 | struct PrintContext *pc = cls; |
315 | 312 | ||
@@ -327,28 +324,28 @@ count_address (void *cls, | |||
327 | * @return #GNUNET_OK to keep the address and continue | 324 | * @return #GNUNET_OK to keep the address and continue |
328 | */ | 325 | */ |
329 | static int | 326 | static int |
330 | print_address (void *cls, | 327 | print_address(void *cls, |
331 | const struct GNUNET_HELLO_Address *address, | 328 | const struct GNUNET_HELLO_Address *address, |
332 | struct GNUNET_TIME_Absolute expiration) | 329 | struct GNUNET_TIME_Absolute expiration) |
333 | { | 330 | { |
334 | struct PrintContext *pc = cls; | 331 | struct PrintContext *pc = cls; |
335 | struct AddressRecord *ar; | 332 | struct AddressRecord *ar; |
336 | 333 | ||
337 | GNUNET_assert (0 < pc->off); | 334 | GNUNET_assert(0 < pc->off); |
338 | ar = &pc->address_list[--pc->off]; | 335 | ar = &pc->address_list[--pc->off]; |
339 | ar->pc = pc; | 336 | ar->pc = pc; |
340 | ar->expiration = expiration; | 337 | ar->expiration = expiration; |
341 | GNUNET_asprintf (&ar->result, | 338 | GNUNET_asprintf(&ar->result, |
342 | "%s:%u:%u", | 339 | "%s:%u:%u", |
343 | address->transport_name, | 340 | address->transport_name, |
344 | address->address_length, | 341 | address->address_length, |
345 | address->local_info); | 342 | address->local_info); |
346 | ar->atsc = GNUNET_TRANSPORT_address_to_string (cfg, | 343 | ar->atsc = GNUNET_TRANSPORT_address_to_string(cfg, |
347 | address, | 344 | address, |
348 | no_resolve, | 345 | no_resolve, |
349 | TIMEOUT, | 346 | TIMEOUT, |
350 | &process_resolved_address, | 347 | &process_resolved_address, |
351 | ar); | 348 | ar); |
352 | return GNUNET_OK; | 349 | return GNUNET_OK; |
353 | } | 350 | } |
354 | 351 | ||
@@ -363,50 +360,50 @@ print_address (void *cls, | |||
363 | * @param err_msg error message | 360 | * @param err_msg error message |
364 | */ | 361 | */ |
365 | static void | 362 | static void |
366 | print_peer_info (void *cls, | 363 | print_peer_info(void *cls, |
367 | const struct GNUNET_PeerIdentity *peer, | 364 | const struct GNUNET_PeerIdentity *peer, |
368 | const struct GNUNET_HELLO_Message *hello, | 365 | const struct GNUNET_HELLO_Message *hello, |
369 | const char *err_msg) | 366 | const char *err_msg) |
370 | { | 367 | { |
371 | struct PrintContext *pc; | 368 | struct PrintContext *pc; |
372 | int friend_only; | 369 | int friend_only; |
373 | 370 | ||
374 | if (NULL == peer) | 371 | if (NULL == peer) |
375 | { | ||
376 | pic = NULL; /* end of iteration */ | ||
377 | if (NULL != err_msg) | ||
378 | { | 372 | { |
379 | fprintf (stderr, | 373 | pic = NULL; /* end of iteration */ |
380 | _ ("Error in communication with PEERINFO service: %s\n"), | 374 | if (NULL != err_msg) |
381 | err_msg); | 375 | { |
376 | fprintf(stderr, | ||
377 | _("Error in communication with PEERINFO service: %s\n"), | ||
378 | err_msg); | ||
379 | } | ||
380 | if (NULL == pc_head) | ||
381 | tt = GNUNET_SCHEDULER_add_now(&state_machine, NULL); | ||
382 | return; | ||
382 | } | 383 | } |
383 | if (NULL == pc_head) | ||
384 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); | ||
385 | return; | ||
386 | } | ||
387 | friend_only = GNUNET_NO; | 384 | friend_only = GNUNET_NO; |
388 | if (NULL != hello) | 385 | if (NULL != hello) |
389 | friend_only = GNUNET_HELLO_is_friend_only (hello); | 386 | friend_only = GNUNET_HELLO_is_friend_only(hello); |
390 | if ((GNUNET_YES == be_quiet) || (NULL == hello)) | 387 | if ((GNUNET_YES == be_quiet) || (NULL == hello)) |
391 | { | 388 | { |
392 | printf ("%s%s\n", | 389 | printf("%s%s\n", |
393 | (GNUNET_YES == friend_only) ? "F2F: " : "", | 390 | (GNUNET_YES == friend_only) ? "F2F: " : "", |
394 | GNUNET_i2s_full (peer)); | 391 | GNUNET_i2s_full(peer)); |
395 | return; | 392 | return; |
396 | } | 393 | } |
397 | pc = GNUNET_new (struct PrintContext); | 394 | pc = GNUNET_new(struct PrintContext); |
398 | GNUNET_CONTAINER_DLL_insert (pc_head, pc_tail, pc); | 395 | GNUNET_CONTAINER_DLL_insert(pc_head, pc_tail, pc); |
399 | pc->peer = *peer; | 396 | pc->peer = *peer; |
400 | pc->friend_only = friend_only; | 397 | pc->friend_only = friend_only; |
401 | GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &count_address, pc); | 398 | GNUNET_HELLO_iterate_addresses(hello, GNUNET_NO, &count_address, pc); |
402 | if (0 == pc->off) | 399 | if (0 == pc->off) |
403 | { | 400 | { |
404 | dump_pc (pc); | 401 | dump_pc(pc); |
405 | return; | 402 | return; |
406 | } | 403 | } |
407 | pc->address_list_size = pc->off; | 404 | pc->address_list_size = pc->off; |
408 | pc->address_list = GNUNET_malloc (sizeof (struct AddressRecord) * pc->off); | 405 | pc->address_list = GNUNET_malloc(sizeof(struct AddressRecord) * pc->off); |
409 | GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &print_address, pc); | 406 | GNUNET_HELLO_iterate_addresses(hello, GNUNET_NO, &print_address, pc); |
410 | } | 407 | } |
411 | 408 | ||
412 | /* ************************* DUMP Hello ************************** */ | 409 | /* ************************* DUMP Hello ************************** */ |
@@ -420,9 +417,9 @@ print_peer_info (void *cls, | |||
420 | * @return #GNUNET_OK | 417 | * @return #GNUNET_OK |
421 | */ | 418 | */ |
422 | static int | 419 | static int |
423 | count_addr (void *cls, | 420 | count_addr(void *cls, |
424 | const struct GNUNET_HELLO_Address *address, | 421 | const struct GNUNET_HELLO_Address *address, |
425 | struct GNUNET_TIME_Absolute expiration) | 422 | struct GNUNET_TIME_Absolute expiration) |
426 | { | 423 | { |
427 | int *c = cls; | 424 | int *c = cls; |
428 | 425 | ||
@@ -440,50 +437,50 @@ count_addr (void *cls, | |||
440 | * @param err_msg error message | 437 | * @param err_msg error message |
441 | */ | 438 | */ |
442 | static void | 439 | static void |
443 | dump_my_hello () | 440 | dump_my_hello() |
444 | { | 441 | { |
445 | unsigned int size; | 442 | unsigned int size; |
446 | unsigned int c_addr; | 443 | unsigned int c_addr; |
447 | 444 | ||
448 | size = GNUNET_HELLO_size (my_hello); | 445 | size = GNUNET_HELLO_size(my_hello); |
449 | if (0 == size) | 446 | if (0 == size) |
450 | { | 447 | { |
451 | fprintf (stderr, _ ("Failure: Received invalid %s\n"), "HELLO"); | 448 | fprintf(stderr, _("Failure: Received invalid %s\n"), "HELLO"); |
452 | return; | 449 | return; |
453 | } | 450 | } |
454 | if (GNUNET_SYSERR == GNUNET_DISK_fn_write (dump_hello, | 451 | if (GNUNET_SYSERR == GNUNET_DISK_fn_write(dump_hello, |
455 | my_hello, | 452 | my_hello, |
456 | size, | 453 | size, |
457 | GNUNET_DISK_PERM_USER_READ | | 454 | GNUNET_DISK_PERM_USER_READ | |
458 | GNUNET_DISK_PERM_USER_WRITE | | 455 | GNUNET_DISK_PERM_USER_WRITE | |
459 | GNUNET_DISK_PERM_GROUP_READ | | 456 | GNUNET_DISK_PERM_GROUP_READ | |
460 | GNUNET_DISK_PERM_OTHER_READ)) | 457 | GNUNET_DISK_PERM_OTHER_READ)) |
461 | { | 458 | { |
462 | fprintf (stderr, | 459 | fprintf(stderr, |
463 | _ ("Failed to write HELLO with %u bytes to file `%s'\n"), | 460 | _("Failed to write HELLO with %u bytes to file `%s'\n"), |
464 | size, | 461 | size, |
465 | dump_hello); | 462 | dump_hello); |
466 | if (0 != unlink (dump_hello)) | 463 | if (0 != unlink(dump_hello)) |
467 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING | | 464 | GNUNET_log_strerror_file(GNUNET_ERROR_TYPE_WARNING | |
468 | GNUNET_ERROR_TYPE_BULK, | 465 | GNUNET_ERROR_TYPE_BULK, |
469 | "unlink", | 466 | "unlink", |
470 | dump_hello); | 467 | dump_hello); |
471 | } | 468 | } |
472 | c_addr = 0; | 469 | c_addr = 0; |
473 | GNUNET_HELLO_iterate_addresses (my_hello, GNUNET_NO, count_addr, &c_addr); | 470 | GNUNET_HELLO_iterate_addresses(my_hello, GNUNET_NO, count_addr, &c_addr); |
474 | 471 | ||
475 | if (! be_quiet) | 472 | if (!be_quiet) |
476 | { | 473 | { |
477 | fprintf ( | 474 | fprintf( |
478 | stderr, | 475 | stderr, |
479 | _ ("Wrote %s HELLO containing %u addresses with %u bytes to file `%s'\n"), | 476 | _("Wrote %s HELLO containing %u addresses with %u bytes to file `%s'\n"), |
480 | (GNUNET_YES == GNUNET_HELLO_is_friend_only (my_hello)) ? "friend-only" | 477 | (GNUNET_YES == GNUNET_HELLO_is_friend_only(my_hello)) ? "friend-only" |
481 | : "public", | 478 | : "public", |
482 | c_addr, | 479 | c_addr, |
483 | size, | 480 | size, |
484 | dump_hello); | 481 | dump_hello); |
485 | } | 482 | } |
486 | GNUNET_free (dump_hello); | 483 | GNUNET_free(dump_hello); |
487 | dump_hello = NULL; | 484 | dump_hello = NULL; |
488 | } | 485 | } |
489 | 486 | ||
@@ -500,32 +497,32 @@ dump_my_hello () | |||
500 | * @param err_msg error message | 497 | * @param err_msg error message |
501 | */ | 498 | */ |
502 | static void | 499 | static void |
503 | print_my_uri (void *cls, | 500 | print_my_uri(void *cls, |
504 | const struct GNUNET_PeerIdentity *peer, | 501 | const struct GNUNET_PeerIdentity *peer, |
505 | const struct GNUNET_HELLO_Message *hello, | 502 | const struct GNUNET_HELLO_Message *hello, |
506 | const char *err_msg) | 503 | const char *err_msg) |
507 | { | 504 | { |
508 | char *uri; | 505 | char *uri; |
509 | 506 | ||
510 | if (NULL == peer) | 507 | if (NULL == peer) |
511 | { | 508 | { |
512 | pic = NULL; | 509 | pic = NULL; |
513 | if (NULL != err_msg) | 510 | if (NULL != err_msg) |
514 | fprintf (stderr, | 511 | fprintf(stderr, |
515 | _ ("Error in communication with PEERINFO service: %s\n"), | 512 | _("Error in communication with PEERINFO service: %s\n"), |
516 | err_msg); | 513 | err_msg); |
517 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); | 514 | tt = GNUNET_SCHEDULER_add_now(&state_machine, NULL); |
518 | return; | 515 | return; |
519 | } | 516 | } |
520 | 517 | ||
521 | if (NULL == hello) | 518 | if (NULL == hello) |
522 | return; | 519 | return; |
523 | uri = GNUNET_HELLO_compose_uri (hello, &GPI_plugins_find); | 520 | uri = GNUNET_HELLO_compose_uri(hello, &GPI_plugins_find); |
524 | if (NULL != uri) | 521 | if (NULL != uri) |
525 | { | 522 | { |
526 | printf ("%s\n", (const char *) uri); | 523 | printf("%s\n", (const char *)uri); |
527 | GNUNET_free (uri); | 524 | GNUNET_free(uri); |
528 | } | 525 | } |
529 | } | 526 | } |
530 | 527 | ||
531 | 528 | ||
@@ -538,10 +535,10 @@ print_my_uri (void *cls, | |||
538 | * @param cls closure, NULL | 535 | * @param cls closure, NULL |
539 | */ | 536 | */ |
540 | static void | 537 | static void |
541 | add_continuation (void *cls) | 538 | add_continuation(void *cls) |
542 | { | 539 | { |
543 | ac = NULL; | 540 | ac = NULL; |
544 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); | 541 | tt = GNUNET_SCHEDULER_add_now(&state_machine, NULL); |
545 | } | 542 | } |
546 | 543 | ||
547 | 544 | ||
@@ -555,24 +552,24 @@ add_continuation (void *cls) | |||
555 | * #GNUNET_NO on other errors | 552 | * #GNUNET_NO on other errors |
556 | */ | 553 | */ |
557 | static int | 554 | static int |
558 | parse_hello_uri (const char *put_uri) | 555 | parse_hello_uri(const char *put_uri) |
559 | { | 556 | { |
560 | struct GNUNET_HELLO_Message *hello = NULL; | 557 | struct GNUNET_HELLO_Message *hello = NULL; |
561 | 558 | ||
562 | int ret = GNUNET_HELLO_parse_uri (put_uri, | 559 | int ret = GNUNET_HELLO_parse_uri(put_uri, |
563 | &my_peer_identity.public_key, | 560 | &my_peer_identity.public_key, |
564 | &hello, | 561 | &hello, |
565 | &GPI_plugins_find); | 562 | &GPI_plugins_find); |
566 | 563 | ||
567 | if (NULL != hello) | 564 | if (NULL != hello) |
568 | { | 565 | { |
569 | /* WARNING: this adds the address from URI WITHOUT verification! */ | 566 | /* WARNING: this adds the address from URI WITHOUT verification! */ |
570 | if (GNUNET_OK == ret) | 567 | if (GNUNET_OK == ret) |
571 | ac = GNUNET_PEERINFO_add_peer (peerinfo, hello, &add_continuation, NULL); | 568 | ac = GNUNET_PEERINFO_add_peer(peerinfo, hello, &add_continuation, NULL); |
572 | else | 569 | else |
573 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); | 570 | tt = GNUNET_SCHEDULER_add_now(&state_machine, NULL); |
574 | GNUNET_free (hello); | 571 | GNUNET_free(hello); |
575 | } | 572 | } |
576 | return ret; | 573 | return ret; |
577 | } | 574 | } |
578 | 575 | ||
@@ -587,59 +584,59 @@ parse_hello_uri (const char *put_uri) | |||
587 | * @param cls unused | 584 | * @param cls unused |
588 | */ | 585 | */ |
589 | static void | 586 | static void |
590 | shutdown_task (void *cls) | 587 | shutdown_task(void *cls) |
591 | { | 588 | { |
592 | struct PrintContext *pc; | 589 | struct PrintContext *pc; |
593 | struct AddressRecord *ar; | 590 | struct AddressRecord *ar; |
594 | unsigned int i; | 591 | unsigned int i; |
595 | 592 | ||
596 | if (NULL != ac) | 593 | if (NULL != ac) |
597 | { | 594 | { |
598 | GNUNET_MQ_send_cancel (ac); | 595 | GNUNET_MQ_send_cancel(ac); |
599 | ac = NULL; | 596 | ac = NULL; |
600 | } | 597 | } |
601 | if (NULL != tt) | 598 | if (NULL != tt) |
602 | { | 599 | { |
603 | GNUNET_SCHEDULER_cancel (tt); | 600 | GNUNET_SCHEDULER_cancel(tt); |
604 | tt = NULL; | 601 | tt = NULL; |
605 | } | 602 | } |
606 | if (NULL != pic) | 603 | if (NULL != pic) |
607 | { | 604 | { |
608 | GNUNET_PEERINFO_iterate_cancel (pic); | 605 | GNUNET_PEERINFO_iterate_cancel(pic); |
609 | pic = NULL; | 606 | pic = NULL; |
610 | } | 607 | } |
611 | if (NULL != gh) | 608 | if (NULL != gh) |
612 | { | 609 | { |
613 | GNUNET_TRANSPORT_hello_get_cancel (gh); | 610 | GNUNET_TRANSPORT_hello_get_cancel(gh); |
614 | gh = NULL; | 611 | gh = NULL; |
615 | } | 612 | } |
616 | while (NULL != (pc = pc_head)) | 613 | while (NULL != (pc = pc_head)) |
617 | { | ||
618 | GNUNET_CONTAINER_DLL_remove (pc_head, pc_tail, pc); | ||
619 | for (i = 0; i < pc->address_list_size; i++) | ||
620 | { | 614 | { |
621 | ar = &pc->address_list[i]; | 615 | GNUNET_CONTAINER_DLL_remove(pc_head, pc_tail, pc); |
622 | GNUNET_free_non_null (ar->result); | 616 | for (i = 0; i < pc->address_list_size; i++) |
623 | if (NULL != ar->atsc) | 617 | { |
624 | { | 618 | ar = &pc->address_list[i]; |
625 | GNUNET_TRANSPORT_address_to_string_cancel (ar->atsc); | 619 | GNUNET_free_non_null(ar->result); |
626 | ar->atsc = NULL; | 620 | if (NULL != ar->atsc) |
627 | } | 621 | { |
622 | GNUNET_TRANSPORT_address_to_string_cancel(ar->atsc); | ||
623 | ar->atsc = NULL; | ||
624 | } | ||
625 | } | ||
626 | GNUNET_free_non_null(pc->address_list); | ||
627 | GNUNET_free(pc); | ||
628 | } | 628 | } |
629 | GNUNET_free_non_null (pc->address_list); | 629 | GPI_plugins_unload(); |
630 | GNUNET_free (pc); | ||
631 | } | ||
632 | GPI_plugins_unload (); | ||
633 | if (NULL != peerinfo) | 630 | if (NULL != peerinfo) |
634 | { | 631 | { |
635 | GNUNET_PEERINFO_disconnect (peerinfo); | 632 | GNUNET_PEERINFO_disconnect(peerinfo); |
636 | peerinfo = NULL; | 633 | peerinfo = NULL; |
637 | } | 634 | } |
638 | if (NULL != my_hello) | 635 | if (NULL != my_hello) |
639 | { | 636 | { |
640 | GNUNET_free (my_hello); | 637 | GNUNET_free(my_hello); |
641 | my_hello = NULL; | 638 | my_hello = NULL; |
642 | } | 639 | } |
643 | } | 640 | } |
644 | 641 | ||
645 | 642 | ||
@@ -651,22 +648,22 @@ shutdown_task (void *cls) | |||
651 | * @param hello the HELLO message | 648 | * @param hello the HELLO message |
652 | */ | 649 | */ |
653 | static void | 650 | static void |
654 | hello_callback (void *cls, const struct GNUNET_MessageHeader *hello) | 651 | hello_callback(void *cls, const struct GNUNET_MessageHeader *hello) |
655 | { | 652 | { |
656 | if (NULL == hello) | 653 | if (NULL == hello) |
657 | { | 654 | { |
658 | fprintf (stderr, "Failed to get my own HELLO from this peer!\n"); | 655 | fprintf(stderr, "Failed to get my own HELLO from this peer!\n"); |
659 | GNUNET_SCHEDULER_shutdown (); | 656 | GNUNET_SCHEDULER_shutdown(); |
660 | return; | 657 | return; |
661 | } | 658 | } |
662 | my_hello = (struct GNUNET_HELLO_Message *) GNUNET_copy_message (hello); | 659 | my_hello = (struct GNUNET_HELLO_Message *)GNUNET_copy_message(hello); |
663 | GNUNET_assert (GNUNET_OK == | 660 | GNUNET_assert(GNUNET_OK == |
664 | GNUNET_HELLO_get_id (my_hello, &my_peer_identity)); | 661 | GNUNET_HELLO_get_id(my_hello, &my_peer_identity)); |
665 | GNUNET_TRANSPORT_hello_get_cancel (gh); | 662 | GNUNET_TRANSPORT_hello_get_cancel(gh); |
666 | gh = NULL; | 663 | gh = NULL; |
667 | if (NULL != dump_hello) | 664 | if (NULL != dump_hello) |
668 | dump_my_hello (); | 665 | dump_my_hello(); |
669 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); | 666 | tt = GNUNET_SCHEDULER_add_now(&state_machine, NULL); |
670 | } | 667 | } |
671 | 668 | ||
672 | 669 | ||
@@ -679,41 +676,41 @@ hello_callback (void *cls, const struct GNUNET_MessageHeader *hello) | |||
679 | * @param c configuration | 676 | * @param c configuration |
680 | */ | 677 | */ |
681 | static void | 678 | static void |
682 | run (void *cls, | 679 | run(void *cls, |
683 | char *const *args, | 680 | char *const *args, |
684 | const char *cfgfile, | 681 | const char *cfgfile, |
685 | const struct GNUNET_CONFIGURATION_Handle *c) | 682 | const struct GNUNET_CONFIGURATION_Handle *c) |
686 | { | 683 | { |
687 | cfg = c; | 684 | cfg = c; |
688 | if ((NULL != args[0]) && (NULL == put_uri) && | 685 | if ((NULL != args[0]) && (NULL == put_uri) && |
689 | (args[0] == strcasestr (args[0], "gnunet://hello/"))) | 686 | (args[0] == strcasestr(args[0], "gnunet://hello/"))) |
690 | { | 687 | { |
691 | put_uri = GNUNET_strdup (args[0]); | 688 | put_uri = GNUNET_strdup(args[0]); |
692 | args++; | 689 | args++; |
693 | } | 690 | } |
694 | if (NULL != args[0]) | 691 | if (NULL != args[0]) |
695 | { | 692 | { |
696 | fprintf (stderr, _ ("Invalid command line argument `%s'\n"), args[0]); | 693 | fprintf(stderr, _("Invalid command line argument `%s'\n"), args[0]); |
697 | return; | 694 | return; |
698 | } | 695 | } |
699 | if (NULL == (peerinfo = GNUNET_PEERINFO_connect (cfg))) | 696 | if (NULL == (peerinfo = GNUNET_PEERINFO_connect(cfg))) |
700 | { | 697 | { |
701 | fprintf (stderr, "%s", "Could not access PEERINFO service. Exiting.\n"); | 698 | fprintf(stderr, "%s", "Could not access PEERINFO service. Exiting.\n"); |
702 | return; | 699 | return; |
703 | } | 700 | } |
704 | if ((GNUNET_YES == get_self) || (GNUNET_YES == get_uri) || | 701 | if ((GNUNET_YES == get_self) || (GNUNET_YES == get_uri) || |
705 | (NULL != dump_hello)) | 702 | (NULL != dump_hello)) |
706 | { | 703 | { |
707 | gh = GNUNET_TRANSPORT_hello_get (cfg, | 704 | gh = GNUNET_TRANSPORT_hello_get(cfg, |
708 | GNUNET_TRANSPORT_AC_ANY, | 705 | GNUNET_TRANSPORT_AC_ANY, |
709 | &hello_callback, | 706 | &hello_callback, |
710 | NULL); | 707 | NULL); |
711 | } | 708 | } |
712 | else | 709 | else |
713 | { | 710 | { |
714 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); | 711 | tt = GNUNET_SCHEDULER_add_now(&state_machine, NULL); |
715 | } | 712 | } |
716 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); | 713 | GNUNET_SCHEDULER_add_shutdown(&shutdown_task, NULL); |
717 | } | 714 | } |
718 | 715 | ||
719 | 716 | ||
@@ -724,61 +721,61 @@ run (void *cls, | |||
724 | * @param cls unused | 721 | * @param cls unused |
725 | */ | 722 | */ |
726 | static void | 723 | static void |
727 | state_machine (void *cls) | 724 | state_machine(void *cls) |
728 | { | 725 | { |
729 | tt = NULL; | 726 | tt = NULL; |
730 | 727 | ||
731 | if (NULL != put_uri) | 728 | if (NULL != put_uri) |
732 | { | ||
733 | GPI_plugins_load (cfg); | ||
734 | if (GNUNET_SYSERR == parse_hello_uri (put_uri)) | ||
735 | { | 729 | { |
736 | fprintf (stderr, _ ("Invalid URI `%s'\n"), put_uri); | 730 | GPI_plugins_load(cfg); |
737 | GNUNET_SCHEDULER_shutdown (); | 731 | if (GNUNET_SYSERR == parse_hello_uri(put_uri)) |
732 | { | ||
733 | fprintf(stderr, _("Invalid URI `%s'\n"), put_uri); | ||
734 | GNUNET_SCHEDULER_shutdown(); | ||
735 | } | ||
736 | GNUNET_free(put_uri); | ||
737 | put_uri = NULL; | ||
738 | } | 738 | } |
739 | GNUNET_free (put_uri); | ||
740 | put_uri = NULL; | ||
741 | } | ||
742 | else if (GNUNET_YES == get_info) | 739 | else if (GNUNET_YES == get_info) |
743 | { | 740 | { |
744 | get_info = GNUNET_NO; | 741 | get_info = GNUNET_NO; |
745 | GPI_plugins_load (cfg); | 742 | GPI_plugins_load(cfg); |
746 | pic = GNUNET_PEERINFO_iterate (peerinfo, | 743 | pic = GNUNET_PEERINFO_iterate(peerinfo, |
747 | include_friend_only, | 744 | include_friend_only, |
748 | NULL, | 745 | NULL, |
749 | &print_peer_info, | 746 | &print_peer_info, |
750 | NULL); | 747 | NULL); |
751 | } | 748 | } |
752 | else if (GNUNET_YES == get_self) | 749 | else if (GNUNET_YES == get_self) |
753 | { | 750 | { |
754 | get_self = GNUNET_NO; | 751 | get_self = GNUNET_NO; |
755 | if (be_quiet) | 752 | if (be_quiet) |
756 | printf ("%s\n", GNUNET_i2s_full (&my_peer_identity)); | 753 | printf("%s\n", GNUNET_i2s_full(&my_peer_identity)); |
757 | else | 754 | else |
758 | printf (_ ("I am peer `%s'.\n"), GNUNET_i2s_full (&my_peer_identity)); | 755 | printf(_("I am peer `%s'.\n"), GNUNET_i2s_full(&my_peer_identity)); |
759 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); | 756 | tt = GNUNET_SCHEDULER_add_now(&state_machine, NULL); |
760 | } | 757 | } |
761 | else if (GNUNET_YES == get_uri) | 758 | else if (GNUNET_YES == get_uri) |
762 | { | 759 | { |
763 | GPI_plugins_load (cfg); | 760 | GPI_plugins_load(cfg); |
764 | pic = GNUNET_PEERINFO_iterate (peerinfo, | 761 | pic = GNUNET_PEERINFO_iterate(peerinfo, |
765 | include_friend_only, | 762 | include_friend_only, |
766 | &my_peer_identity, | 763 | &my_peer_identity, |
767 | &print_my_uri, | 764 | &print_my_uri, |
768 | NULL); | 765 | NULL); |
769 | get_uri = GNUNET_NO; | 766 | get_uri = GNUNET_NO; |
770 | } | 767 | } |
771 | else if (GNUNET_YES == default_operation) | 768 | else if (GNUNET_YES == default_operation) |
772 | { | 769 | { |
773 | /* default operation list all */ | 770 | /* default operation list all */ |
774 | default_operation = GNUNET_NO; | 771 | default_operation = GNUNET_NO; |
775 | get_info = GNUNET_YES; | 772 | get_info = GNUNET_YES; |
776 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); | 773 | tt = GNUNET_SCHEDULER_add_now(&state_machine, NULL); |
777 | } | 774 | } |
778 | else | 775 | else |
779 | { | 776 | { |
780 | GNUNET_SCHEDULER_shutdown (); | 777 | GNUNET_SCHEDULER_shutdown(); |
781 | } | 778 | } |
782 | default_operation = GNUNET_NO; | 779 | default_operation = GNUNET_NO; |
783 | } | 780 | } |
784 | 781 | ||
@@ -791,71 +788,71 @@ state_machine (void *cls) | |||
791 | * @return 0 ok, 1 on error | 788 | * @return 0 ok, 1 on error |
792 | */ | 789 | */ |
793 | int | 790 | int |
794 | main (int argc, char *const *argv) | 791 | main(int argc, char *const *argv) |
795 | { | 792 | { |
796 | struct GNUNET_GETOPT_CommandLineOption options[] = | 793 | struct GNUNET_GETOPT_CommandLineOption options[] = |
797 | {GNUNET_GETOPT_option_flag ('n', | 794 | { GNUNET_GETOPT_option_flag('n', |
798 | "numeric", | 795 | "numeric", |
799 | gettext_noop ("don't resolve host names"), | 796 | gettext_noop("don't resolve host names"), |
800 | &no_resolve), | 797 | &no_resolve), |
801 | 798 | ||
802 | GNUNET_GETOPT_option_flag ('q', | 799 | GNUNET_GETOPT_option_flag('q', |
803 | "quiet", | 800 | "quiet", |
804 | gettext_noop ( | 801 | gettext_noop( |
805 | "output only the identity strings"), | 802 | "output only the identity strings"), |
806 | &be_quiet), | 803 | &be_quiet), |
807 | GNUNET_GETOPT_option_flag ('f', | 804 | GNUNET_GETOPT_option_flag('f', |
808 | "friends", | 805 | "friends", |
809 | gettext_noop ( | 806 | gettext_noop( |
810 | "include friend-only information"), | 807 | "include friend-only information"), |
811 | &include_friend_only), | 808 | &include_friend_only), |
812 | 809 | ||
813 | GNUNET_GETOPT_option_flag ('s', | 810 | GNUNET_GETOPT_option_flag('s', |
814 | "self", | 811 | "self", |
815 | gettext_noop ("output our own identity only"), | 812 | gettext_noop("output our own identity only"), |
816 | &get_self), | 813 | &get_self), |
817 | 814 | ||
818 | GNUNET_GETOPT_option_flag ('i', | 815 | GNUNET_GETOPT_option_flag('i', |
819 | "info", | 816 | "info", |
820 | gettext_noop ("list all known peers"), | 817 | gettext_noop("list all known peers"), |
821 | &get_info), | 818 | &get_info), |
822 | 819 | ||
823 | GNUNET_GETOPT_option_string ('d', | 820 | GNUNET_GETOPT_option_string('d', |
824 | "dump-hello", | 821 | "dump-hello", |
825 | NULL, | 822 | NULL, |
826 | gettext_noop ("dump hello to file"), | 823 | gettext_noop("dump hello to file"), |
827 | &dump_hello), | 824 | &dump_hello), |
828 | 825 | ||
829 | GNUNET_GETOPT_option_flag ('g', | 826 | GNUNET_GETOPT_option_flag('g', |
830 | "get-hello", | 827 | "get-hello", |
831 | gettext_noop ("also output HELLO uri(s)"), | 828 | gettext_noop("also output HELLO uri(s)"), |
832 | &get_uri), | 829 | &get_uri), |
833 | 830 | ||
834 | GNUNET_GETOPT_option_string ('p', | 831 | GNUNET_GETOPT_option_string('p', |
835 | "put-hello", | 832 | "put-hello", |
836 | "HELLO", | 833 | "HELLO", |
837 | gettext_noop ( | 834 | gettext_noop( |
838 | "add given HELLO uri to the database"), | 835 | "add given HELLO uri to the database"), |
839 | &put_uri), | 836 | &put_uri), |
840 | 837 | ||
841 | GNUNET_GETOPT_OPTION_END}; | 838 | GNUNET_GETOPT_OPTION_END }; |
842 | int ret; | 839 | int ret; |
843 | 840 | ||
844 | default_operation = GNUNET_YES; | 841 | default_operation = GNUNET_YES; |
845 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 842 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv)) |
846 | return 2; | 843 | return 2; |
847 | 844 | ||
848 | ret = (GNUNET_OK == | 845 | ret = (GNUNET_OK == |
849 | GNUNET_PROGRAM_run (argc, | 846 | GNUNET_PROGRAM_run(argc, |
850 | argv, | 847 | argv, |
851 | "gnunet-peerinfo", | 848 | "gnunet-peerinfo", |
852 | gettext_noop ("Print information about peers."), | 849 | gettext_noop("Print information about peers."), |
853 | options, | 850 | options, |
854 | &run, | 851 | &run, |
855 | NULL)) | 852 | NULL)) |
856 | ? 0 | 853 | ? 0 |
857 | : 1; | 854 | : 1; |
858 | GNUNET_free ((void *) argv); | 855 | GNUNET_free((void *)argv); |
859 | return ret; | 856 | return ret; |
860 | } | 857 | } |
861 | 858 | ||
diff --git a/src/peerinfo-tool/gnunet-peerinfo_plugins.c b/src/peerinfo-tool/gnunet-peerinfo_plugins.c index a8f43a1f1..13730629e 100644 --- a/src/peerinfo-tool/gnunet-peerinfo_plugins.c +++ b/src/peerinfo-tool/gnunet-peerinfo_plugins.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 peerinfo-tool/gnunet-peerinfo_plugins.c | 22 | * @file peerinfo-tool/gnunet-peerinfo_plugins.c |
@@ -31,8 +31,7 @@ | |||
31 | /** | 31 | /** |
32 | * Entry in doubly-linked list of all of our plugins. | 32 | * Entry in doubly-linked list of all of our plugins. |
33 | */ | 33 | */ |
34 | struct TransportPlugin | 34 | struct TransportPlugin { |
35 | { | ||
36 | /** | 35 | /** |
37 | * This is a doubly-linked list. | 36 | * This is a doubly-linked list. |
38 | */ | 37 | */ |
@@ -64,7 +63,6 @@ struct TransportPlugin | |||
64 | * for this plugin. | 63 | * for this plugin. |
65 | */ | 64 | */ |
66 | struct GNUNET_TRANSPORT_PluginEnvironment env; | 65 | struct GNUNET_TRANSPORT_PluginEnvironment env; |
67 | |||
68 | }; | 66 | }; |
69 | 67 | ||
70 | /** | 68 | /** |
@@ -88,7 +86,7 @@ static struct TransportPlugin *plugins_tail; | |||
88 | * @param cfg configuration to use | 86 | * @param cfg configuration to use |
89 | */ | 87 | */ |
90 | void | 88 | void |
91 | GPI_plugins_load (const struct GNUNET_CONFIGURATION_Handle *cfg) | 89 | GPI_plugins_load(const struct GNUNET_CONFIGURATION_Handle *cfg) |
92 | { | 90 | { |
93 | struct TransportPlugin *plug; | 91 | struct TransportPlugin *plug; |
94 | struct TransportPlugin *next; | 92 | struct TransportPlugin *next; |
@@ -99,41 +97,41 @@ GPI_plugins_load (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
99 | if (NULL != plugins_head) | 97 | if (NULL != plugins_head) |
100 | return; /* already loaded */ | 98 | return; /* already loaded */ |
101 | if (GNUNET_OK != | 99 | if (GNUNET_OK != |
102 | GNUNET_CONFIGURATION_get_value_string (cfg, "TRANSPORT", "PLUGINS", | 100 | GNUNET_CONFIGURATION_get_value_string(cfg, "TRANSPORT", "PLUGINS", |
103 | &plugs)) | 101 | &plugs)) |
104 | return; | 102 | return; |
105 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Starting transport plugins `%s'\n"), | 103 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Starting transport plugins `%s'\n"), |
106 | plugs); | 104 | plugs); |
107 | for (pos = strtok (plugs, " "); pos != NULL; pos = strtok (NULL, " ")) | 105 | for (pos = strtok(plugs, " "); pos != NULL; pos = strtok(NULL, " ")) |
108 | { | 106 | { |
109 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading `%s' transport plugin\n"), | 107 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Loading `%s' transport plugin\n"), |
110 | pos); | 108 | pos); |
111 | GNUNET_asprintf (&libname, "libgnunet_plugin_transport_%s", pos); | 109 | GNUNET_asprintf(&libname, "libgnunet_plugin_transport_%s", pos); |
112 | plug = GNUNET_new (struct TransportPlugin); | 110 | plug = GNUNET_new(struct TransportPlugin); |
113 | plug->short_name = GNUNET_strdup (pos); | 111 | plug->short_name = GNUNET_strdup(pos); |
114 | plug->lib_name = libname; | 112 | plug->lib_name = libname; |
115 | plug->env.cfg = cfg; | 113 | plug->env.cfg = cfg; |
116 | plug->env.cls = plug->short_name; | 114 | plug->env.cls = plug->short_name; |
117 | GNUNET_CONTAINER_DLL_insert (plugins_head, plugins_tail, plug); | 115 | GNUNET_CONTAINER_DLL_insert(plugins_head, plugins_tail, plug); |
118 | } | 116 | } |
119 | GNUNET_free (plugs); | 117 | GNUNET_free(plugs); |
120 | next = plugins_head; | 118 | next = plugins_head; |
121 | while (next != NULL) | 119 | while (next != NULL) |
122 | { | ||
123 | plug = next; | ||
124 | next = plug->next; | ||
125 | plug->api = GNUNET_PLUGIN_load (plug->lib_name, &plug->env); | ||
126 | if (plug->api == NULL) | ||
127 | { | 120 | { |
128 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 121 | plug = next; |
129 | _("Failed to load transport plugin for `%s'\n"), | 122 | next = plug->next; |
130 | plug->lib_name); | 123 | plug->api = GNUNET_PLUGIN_load(plug->lib_name, &plug->env); |
131 | GNUNET_CONTAINER_DLL_remove (plugins_head, plugins_tail, plug); | 124 | if (plug->api == NULL) |
132 | GNUNET_free (plug->short_name); | 125 | { |
133 | GNUNET_free (plug->lib_name); | 126 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
134 | GNUNET_free (plug); | 127 | _("Failed to load transport plugin for `%s'\n"), |
128 | plug->lib_name); | ||
129 | GNUNET_CONTAINER_DLL_remove(plugins_head, plugins_tail, plug); | ||
130 | GNUNET_free(plug->short_name); | ||
131 | GNUNET_free(plug->lib_name); | ||
132 | GNUNET_free(plug); | ||
133 | } | ||
135 | } | 134 | } |
136 | } | ||
137 | } | 135 | } |
138 | 136 | ||
139 | 137 | ||
@@ -141,18 +139,18 @@ GPI_plugins_load (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
141 | * Unload all plugins | 139 | * Unload all plugins |
142 | */ | 140 | */ |
143 | void | 141 | void |
144 | GPI_plugins_unload () | 142 | GPI_plugins_unload() |
145 | { | 143 | { |
146 | struct TransportPlugin *plug; | 144 | struct TransportPlugin *plug; |
147 | 145 | ||
148 | while (NULL != (plug = plugins_head)) | 146 | while (NULL != (plug = plugins_head)) |
149 | { | 147 | { |
150 | GNUNET_break (NULL == GNUNET_PLUGIN_unload (plug->lib_name, plug->api)); | 148 | GNUNET_break(NULL == GNUNET_PLUGIN_unload(plug->lib_name, plug->api)); |
151 | GNUNET_free (plug->lib_name); | 149 | GNUNET_free(plug->lib_name); |
152 | GNUNET_free (plug->short_name); | 150 | GNUNET_free(plug->short_name); |
153 | GNUNET_CONTAINER_DLL_remove (plugins_head, plugins_tail, plug); | 151 | GNUNET_CONTAINER_DLL_remove(plugins_head, plugins_tail, plug); |
154 | GNUNET_free (plug); | 152 | GNUNET_free(plug); |
155 | } | 153 | } |
156 | } | 154 | } |
157 | 155 | ||
158 | 156 | ||
@@ -163,31 +161,32 @@ GPI_plugins_unload () | |||
163 | * @return the plugin's API, NULL if the plugin is not loaded | 161 | * @return the plugin's API, NULL if the plugin is not loaded |
164 | */ | 162 | */ |
165 | struct GNUNET_TRANSPORT_PluginFunctions * | 163 | struct GNUNET_TRANSPORT_PluginFunctions * |
166 | GPI_plugins_find (const char *name) | 164 | GPI_plugins_find(const char *name) |
167 | { | 165 | { |
168 | struct TransportPlugin *head = plugins_head; | 166 | struct TransportPlugin *head = plugins_head; |
169 | 167 | ||
170 | char *stripped = GNUNET_strdup (name); | 168 | char *stripped = GNUNET_strdup(name); |
171 | char *head_stripped; | 169 | char *head_stripped; |
172 | char *sep = strchr (stripped, '_'); | 170 | char *sep = strchr(stripped, '_'); |
171 | |||
173 | if (NULL != sep) | 172 | if (NULL != sep) |
174 | sep[0] = '\0'; | 173 | sep[0] = '\0'; |
175 | 174 | ||
176 | while (head != NULL) | 175 | while (head != NULL) |
177 | { | ||
178 | head_stripped = GNUNET_strdup(head->short_name); | ||
179 | char *head_sep = strchr (head_stripped, '_'); | ||
180 | if (NULL != head_sep) | ||
181 | head_sep[0] = '\0'; | ||
182 | if (0 == strcmp (head_stripped, stripped)) | ||
183 | { | 176 | { |
184 | GNUNET_free (head_stripped); | 177 | head_stripped = GNUNET_strdup(head->short_name); |
185 | break; | 178 | char *head_sep = strchr(head_stripped, '_'); |
179 | if (NULL != head_sep) | ||
180 | head_sep[0] = '\0'; | ||
181 | if (0 == strcmp(head_stripped, stripped)) | ||
182 | { | ||
183 | GNUNET_free(head_stripped); | ||
184 | break; | ||
185 | } | ||
186 | GNUNET_free(head_stripped); | ||
187 | head = head->next; | ||
186 | } | 188 | } |
187 | GNUNET_free (head_stripped); | 189 | GNUNET_free(stripped); |
188 | head = head->next; | ||
189 | } | ||
190 | GNUNET_free (stripped); | ||
191 | if (NULL == head) | 190 | if (NULL == head) |
192 | return NULL; | 191 | return NULL; |
193 | return head->api; | 192 | return head->api; |
diff --git a/src/peerinfo-tool/gnunet-peerinfo_plugins.h b/src/peerinfo-tool/gnunet-peerinfo_plugins.h index 53196677a..b278cfa21 100644 --- a/src/peerinfo-tool/gnunet-peerinfo_plugins.h +++ b/src/peerinfo-tool/gnunet-peerinfo_plugins.h | |||
@@ -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 peerinfo-tool/gnunet-peerinfo_plugins.h | 22 | * @file peerinfo-tool/gnunet-peerinfo_plugins.h |
@@ -34,14 +34,14 @@ | |||
34 | * @param cfg configuration to use | 34 | * @param cfg configuration to use |
35 | */ | 35 | */ |
36 | void | 36 | void |
37 | GPI_plugins_load (const struct GNUNET_CONFIGURATION_Handle *cfg); | 37 | GPI_plugins_load(const struct GNUNET_CONFIGURATION_Handle *cfg); |
38 | 38 | ||
39 | 39 | ||
40 | /** | 40 | /** |
41 | * Unload all plugins | 41 | * Unload all plugins |
42 | */ | 42 | */ |
43 | void | 43 | void |
44 | GPI_plugins_unload (void); | 44 | GPI_plugins_unload(void); |
45 | 45 | ||
46 | 46 | ||
47 | /** | 47 | /** |
@@ -51,7 +51,7 @@ GPI_plugins_unload (void); | |||
51 | * @return the plugin's API, NULL if the plugin is not loaded | 51 | * @return the plugin's API, NULL if the plugin is not loaded |
52 | */ | 52 | */ |
53 | struct GNUNET_TRANSPORT_PluginFunctions * | 53 | struct GNUNET_TRANSPORT_PluginFunctions * |
54 | GPI_plugins_find (const char *name); | 54 | GPI_plugins_find(const char *name); |
55 | 55 | ||
56 | 56 | ||
57 | #endif | 57 | #endif |
diff --git a/src/peerinfo-tool/plugin_rest_peerinfo.c b/src/peerinfo-tool/plugin_rest_peerinfo.c index 24af2c193..238946d54 100644 --- a/src/peerinfo-tool/plugin_rest_peerinfo.c +++ b/src/peerinfo-tool/plugin_rest_peerinfo.c | |||
@@ -16,7 +16,7 @@ | |||
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 | * @author Martin Schanzenbach | 21 | * @author Martin Schanzenbach |
22 | * @author Philippe Buschmann | 22 | * @author Philippe Buschmann |
@@ -61,7 +61,7 @@ | |||
61 | /** | 61 | /** |
62 | * How long until we time out during address lookup? | 62 | * How long until we time out during address lookup? |
63 | */ | 63 | */ |
64 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | 64 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5) |
65 | /** | 65 | /** |
66 | * The configuration handle | 66 | * The configuration handle |
67 | */ | 67 | */ |
@@ -75,8 +75,7 @@ static char* allow_methods; | |||
75 | /** | 75 | /** |
76 | * @brief struct returned by the initialization function of the plugin | 76 | * @brief struct returned by the initialization function of the plugin |
77 | */ | 77 | */ |
78 | struct Plugin | 78 | struct Plugin { |
79 | { | ||
80 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 79 | const struct GNUNET_CONFIGURATION_Handle *cfg; |
81 | }; | 80 | }; |
82 | 81 | ||
@@ -84,8 +83,7 @@ struct Plugin | |||
84 | /** | 83 | /** |
85 | * Record we keep for each printable address. | 84 | * Record we keep for each printable address. |
86 | */ | 85 | */ |
87 | struct AddressRecord | 86 | struct AddressRecord { |
88 | { | ||
89 | /** | 87 | /** |
90 | * Current address-to-string context (if active, otherwise NULL). | 88 | * Current address-to-string context (if active, otherwise NULL). |
91 | */ | 89 | */ |
@@ -111,8 +109,7 @@ struct AddressRecord | |||
111 | /** | 109 | /** |
112 | * Structure we use to collect printable address information. | 110 | * Structure we use to collect printable address information. |
113 | */ | 111 | */ |
114 | struct PrintContext | 112 | struct PrintContext { |
115 | { | ||
116 | /** | 113 | /** |
117 | * Kept in DLL. | 114 | * Kept in DLL. |
118 | */ | 115 | */ |
@@ -157,7 +154,6 @@ struct PrintContext | |||
157 | * RequestHandle | 154 | * RequestHandle |
158 | */ | 155 | */ |
159 | struct RequestHandle *handle; | 156 | struct RequestHandle *handle; |
160 | |||
161 | }; | 157 | }; |
162 | 158 | ||
163 | /** | 159 | /** |
@@ -173,8 +169,7 @@ static struct PrintContext *pc_tail; | |||
173 | /** | 169 | /** |
174 | * The request handle | 170 | * The request handle |
175 | */ | 171 | */ |
176 | struct RequestHandle | 172 | struct RequestHandle { |
177 | { | ||
178 | /** | 173 | /** |
179 | * JSON temporary array | 174 | * JSON temporary array |
180 | */ | 175 | */ |
@@ -214,7 +209,7 @@ struct RequestHandle | |||
214 | * Rest connection | 209 | * Rest connection |
215 | */ | 210 | */ |
216 | struct GNUNET_REST_RequestHandle *rest_handle; | 211 | struct GNUNET_REST_RequestHandle *rest_handle; |
217 | 212 | ||
218 | /** | 213 | /** |
219 | * Desired timeout for the lookup (default is no timeout). | 214 | * Desired timeout for the lookup (default is no timeout). |
220 | */ | 215 | */ |
@@ -249,7 +244,6 @@ struct RequestHandle | |||
249 | * Reponse code | 244 | * Reponse code |
250 | */ | 245 | */ |
251 | int response_code; | 246 | int response_code; |
252 | |||
253 | }; | 247 | }; |
254 | 248 | ||
255 | 249 | ||
@@ -258,51 +252,51 @@ struct RequestHandle | |||
258 | * @param handle Handle to clean up | 252 | * @param handle Handle to clean up |
259 | */ | 253 | */ |
260 | static void | 254 | static void |
261 | cleanup_handle (void *cls) | 255 | cleanup_handle(void *cls) |
262 | { | 256 | { |
263 | struct RequestHandle *handle = cls; | 257 | struct RequestHandle *handle = cls; |
264 | 258 | ||
265 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 259 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
266 | "Cleaning up\n"); | 260 | "Cleaning up\n"); |
267 | if (NULL != handle->timeout_task) | 261 | if (NULL != handle->timeout_task) |
268 | { | 262 | { |
269 | GNUNET_SCHEDULER_cancel (handle->timeout_task); | 263 | GNUNET_SCHEDULER_cancel(handle->timeout_task); |
270 | handle->timeout_task = NULL; | 264 | handle->timeout_task = NULL; |
271 | } | 265 | } |
272 | if (NULL != handle->url) | 266 | if (NULL != handle->url) |
273 | GNUNET_free (handle->url); | 267 | GNUNET_free(handle->url); |
274 | if (NULL != handle->emsg) | 268 | if (NULL != handle->emsg) |
275 | GNUNET_free (handle->emsg); | 269 | GNUNET_free(handle->emsg); |
276 | if (NULL != handle->address) | 270 | if (NULL != handle->address) |
277 | GNUNET_free ((char*)handle->address); | 271 | GNUNET_free((char*)handle->address); |
278 | if (NULL != handle->expiration_str) | 272 | if (NULL != handle->expiration_str) |
279 | GNUNET_free (handle->expiration_str); | 273 | GNUNET_free(handle->expiration_str); |
280 | if (NULL != handle->pubkey) | 274 | if (NULL != handle->pubkey) |
281 | GNUNET_free (handle->pubkey); | 275 | GNUNET_free(handle->pubkey); |
282 | 276 | ||
283 | if (NULL != handle->temp_array) | 277 | if (NULL != handle->temp_array) |
284 | { | 278 | { |
285 | json_decref(handle->temp_array); | 279 | json_decref(handle->temp_array); |
286 | handle->temp_array = NULL; | 280 | handle->temp_array = NULL; |
287 | } | 281 | } |
288 | if (NULL != handle->response) | 282 | if (NULL != handle->response) |
289 | { | 283 | { |
290 | json_decref(handle->response); | 284 | json_decref(handle->response); |
291 | handle->response = NULL; | 285 | handle->response = NULL; |
292 | } | 286 | } |
293 | 287 | ||
294 | if (NULL != handle->list_it) | 288 | if (NULL != handle->list_it) |
295 | { | 289 | { |
296 | GNUNET_PEERINFO_iterate_cancel(handle->list_it); | 290 | GNUNET_PEERINFO_iterate_cancel(handle->list_it); |
297 | handle->list_it = NULL; | 291 | handle->list_it = NULL; |
298 | } | 292 | } |
299 | if (NULL != handle->peerinfo_handle) | 293 | if (NULL != handle->peerinfo_handle) |
300 | { | 294 | { |
301 | GNUNET_PEERINFO_disconnect(handle->peerinfo_handle); | 295 | GNUNET_PEERINFO_disconnect(handle->peerinfo_handle); |
302 | handle->peerinfo_handle = NULL; | 296 | handle->peerinfo_handle = NULL; |
303 | } | 297 | } |
304 | 298 | ||
305 | GNUNET_free (handle); | 299 | GNUNET_free(handle); |
306 | } | 300 | } |
307 | 301 | ||
308 | 302 | ||
@@ -312,7 +306,7 @@ cleanup_handle (void *cls) | |||
312 | * @param cls the `struct RequestHandle` | 306 | * @param cls the `struct RequestHandle` |
313 | */ | 307 | */ |
314 | static void | 308 | static void |
315 | do_error (void *cls) | 309 | do_error(void *cls) |
316 | { | 310 | { |
317 | struct RequestHandle *handle = cls; | 311 | struct RequestHandle *handle = cls; |
318 | struct MHD_Response *resp; | 312 | struct MHD_Response *resp; |
@@ -322,16 +316,16 @@ do_error (void *cls) | |||
322 | if (NULL == handle->emsg) | 316 | if (NULL == handle->emsg) |
323 | handle->emsg = GNUNET_strdup(GNUNET_REST_PEERINFO_ERROR_UNKNOWN); | 317 | handle->emsg = GNUNET_strdup(GNUNET_REST_PEERINFO_ERROR_UNKNOWN); |
324 | 318 | ||
325 | json_object_set_new(json_error,"error", json_string(handle->emsg)); | 319 | json_object_set_new(json_error, "error", json_string(handle->emsg)); |
326 | 320 | ||
327 | if (0 == handle->response_code) | 321 | if (0 == handle->response_code) |
328 | handle->response_code = MHD_HTTP_OK; | 322 | handle->response_code = MHD_HTTP_OK; |
329 | response = json_dumps (json_error, 0); | 323 | response = json_dumps(json_error, 0); |
330 | resp = GNUNET_REST_create_response (response); | 324 | resp = GNUNET_REST_create_response(response); |
331 | handle->proc (handle->proc_cls, resp, handle->response_code); | 325 | handle->proc(handle->proc_cls, resp, handle->response_code); |
332 | json_decref(json_error); | 326 | json_decref(json_error); |
333 | GNUNET_free(response); | 327 | GNUNET_free(response); |
334 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); | 328 | GNUNET_SCHEDULER_add_now(&cleanup_handle, handle); |
335 | } | 329 | } |
336 | 330 | ||
337 | 331 | ||
@@ -341,26 +335,26 @@ do_error (void *cls) | |||
341 | * @param cls the `struct RequestHandle` | 335 | * @param cls the `struct RequestHandle` |
342 | */ | 336 | */ |
343 | static void | 337 | static void |
344 | peerinfo_list_finished (void *cls) | 338 | peerinfo_list_finished(void *cls) |
345 | { | 339 | { |
346 | struct RequestHandle *handle = cls; | 340 | struct RequestHandle *handle = cls; |
347 | char *result_str; | 341 | char *result_str; |
348 | struct MHD_Response *resp; | 342 | struct MHD_Response *resp; |
349 | 343 | ||
350 | if (NULL == handle->response) | 344 | if (NULL == handle->response) |
351 | { | 345 | { |
352 | handle->response_code = MHD_HTTP_NOT_FOUND; | 346 | handle->response_code = MHD_HTTP_NOT_FOUND; |
353 | handle->emsg = GNUNET_strdup ("No peers found"); | 347 | handle->emsg = GNUNET_strdup("No peers found"); |
354 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 348 | GNUNET_SCHEDULER_add_now(&do_error, handle); |
355 | return; | 349 | return; |
356 | } | 350 | } |
357 | 351 | ||
358 | result_str = json_dumps (handle->response, 0); | 352 | result_str = json_dumps(handle->response, 0); |
359 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); | 353 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); |
360 | resp = GNUNET_REST_create_response (result_str); | 354 | resp = GNUNET_REST_create_response(result_str); |
361 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 355 | handle->proc(handle->proc_cls, resp, MHD_HTTP_OK); |
362 | GNUNET_free_non_null (result_str); | 356 | GNUNET_free_non_null(result_str); |
363 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); | 357 | GNUNET_SCHEDULER_add_now(&cleanup_handle, handle); |
364 | } | 358 | } |
365 | 359 | ||
366 | 360 | ||
@@ -373,16 +367,16 @@ peerinfo_list_finished (void *cls) | |||
373 | * @return #GNUNET_OK to keep the address and continue | 367 | * @return #GNUNET_OK to keep the address and continue |
374 | */ | 368 | */ |
375 | static int | 369 | static int |
376 | count_address (void *cls, | 370 | count_address(void *cls, |
377 | const struct GNUNET_HELLO_Address *address, | 371 | const struct GNUNET_HELLO_Address *address, |
378 | struct GNUNET_TIME_Absolute expiration) | 372 | struct GNUNET_TIME_Absolute expiration) |
379 | { | 373 | { |
380 | struct PrintContext *pc = cls; | 374 | struct PrintContext *pc = cls; |
381 | 375 | ||
382 | if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us) | 376 | if (0 == GNUNET_TIME_absolute_get_remaining(expiration).rel_value_us) |
383 | { | 377 | { |
384 | return GNUNET_OK; /* ignore expired address */ | 378 | return GNUNET_OK; /* ignore expired address */ |
385 | } | 379 | } |
386 | 380 | ||
387 | pc->off++; | 381 | pc->off++; |
388 | return GNUNET_OK; | 382 | return GNUNET_OK; |
@@ -395,7 +389,7 @@ count_address (void *cls, | |||
395 | * @param pc printing context | 389 | * @param pc printing context |
396 | */ | 390 | */ |
397 | static void | 391 | static void |
398 | dump_pc (struct PrintContext *pc) | 392 | dump_pc(struct PrintContext *pc) |
399 | { | 393 | { |
400 | struct RequestHandle *handle; | 394 | struct RequestHandle *handle; |
401 | unsigned int i; | 395 | unsigned int i; |
@@ -411,59 +405,58 @@ dump_pc (struct PrintContext *pc) | |||
411 | response_entry = json_object(); | 405 | response_entry = json_object(); |
412 | 406 | ||
413 | for (i = 0; i < pc->num_addresses; i++) | 407 | for (i = 0; i < pc->num_addresses; i++) |
414 | { | ||
415 | if (NULL != pc->address_list[i].result) | ||
416 | { | 408 | { |
417 | object = json_object (); | 409 | if (NULL != pc->address_list[i].result) |
418 | address = json_string(pc->address_list[i].result); | 410 | { |
419 | expires = json_string( | 411 | object = json_object(); |
420 | GNUNET_STRINGS_absolute_time_to_string (pc->address_list[i].expiration)); | 412 | address = json_string(pc->address_list[i].result); |
421 | json_object_set (object, "address", address); | 413 | expires = json_string( |
422 | json_object_set (object, "expires", expires); | 414 | GNUNET_STRINGS_absolute_time_to_string(pc->address_list[i].expiration)); |
423 | 415 | json_object_set(object, "address", address); | |
424 | json_decref(address); | 416 | json_object_set(object, "expires", expires); |
425 | json_decref(expires); | 417 | |
426 | 418 | json_decref(address); | |
427 | json_array_append(temp_array, object); | 419 | json_decref(expires); |
428 | json_decref(object); | 420 | |
429 | GNUNET_free (pc->address_list[i].result); | 421 | json_array_append(temp_array, object); |
422 | json_decref(object); | ||
423 | GNUNET_free(pc->address_list[i].result); | ||
424 | } | ||
430 | } | 425 | } |
431 | } | ||
432 | 426 | ||
433 | if (0 < json_array_size(temp_array)) | 427 | if (0 < json_array_size(temp_array)) |
434 | { | 428 | { |
435 | GNUNET_asprintf(&friend_and_peer, | 429 | GNUNET_asprintf(&friend_and_peer, |
436 | "%s%s", | 430 | "%s%s", |
437 | (GNUNET_YES == pc->friend_only) ? "F2F:" : "", | 431 | (GNUNET_YES == pc->friend_only) ? "F2F:" : "", |
438 | GNUNET_i2s_full (&pc->peer)); | 432 | GNUNET_i2s_full(&pc->peer)); |
439 | friend_and_peer_json = json_string(friend_and_peer); | 433 | friend_and_peer_json = json_string(friend_and_peer); |
440 | json_object_set(response_entry, | 434 | json_object_set(response_entry, |
441 | GNUNET_REST_PEERINFO_PEER, | 435 | GNUNET_REST_PEERINFO_PEER, |
442 | friend_and_peer_json); | 436 | friend_and_peer_json); |
443 | json_object_set(response_entry, | 437 | json_object_set(response_entry, |
444 | GNUNET_REST_PEERINFO_ARRAY, | 438 | GNUNET_REST_PEERINFO_ARRAY, |
445 | temp_array); | 439 | temp_array); |
446 | json_array_append(pc->handle->response, response_entry); | 440 | json_array_append(pc->handle->response, response_entry); |
447 | json_decref(friend_and_peer_json); | 441 | json_decref(friend_and_peer_json); |
448 | GNUNET_free(friend_and_peer); | 442 | GNUNET_free(friend_and_peer); |
449 | } | 443 | } |
450 | 444 | ||
451 | json_decref (temp_array); | 445 | json_decref(temp_array); |
452 | json_decref(response_entry); | 446 | json_decref(response_entry); |
453 | 447 | ||
454 | GNUNET_free_non_null (pc->address_list); | 448 | GNUNET_free_non_null(pc->address_list); |
455 | GNUNET_CONTAINER_DLL_remove (pc_head, | 449 | GNUNET_CONTAINER_DLL_remove(pc_head, |
456 | pc_tail, | 450 | pc_tail, |
457 | pc); | 451 | pc); |
458 | handle = pc->handle; | 452 | handle = pc->handle; |
459 | GNUNET_free (pc); | 453 | GNUNET_free(pc); |
460 | |||
461 | if ( (NULL == pc_head) && | ||
462 | (NULL == handle->list_it) ) | ||
463 | { | ||
464 | GNUNET_SCHEDULER_add_now (&peerinfo_list_finished, handle); | ||
465 | } | ||
466 | 454 | ||
455 | if ((NULL == pc_head) && | ||
456 | (NULL == handle->list_it)) | ||
457 | { | ||
458 | GNUNET_SCHEDULER_add_now(&peerinfo_list_finished, handle); | ||
459 | } | ||
467 | } | 460 | } |
468 | 461 | ||
469 | 462 | ||
@@ -478,31 +471,31 @@ dump_pc (struct PrintContext *pc) | |||
478 | * if #GNUNET_SYSERR: address is invalid | 471 | * if #GNUNET_SYSERR: address is invalid |
479 | */ | 472 | */ |
480 | static void | 473 | static void |
481 | process_resolved_address (void *cls, | 474 | process_resolved_address(void *cls, |
482 | const char *address, | 475 | const char *address, |
483 | int res) | 476 | int res) |
484 | { | 477 | { |
485 | struct AddressRecord *ar = cls; | 478 | struct AddressRecord *ar = cls; |
486 | struct PrintContext *pc = ar->pc; | 479 | struct PrintContext *pc = ar->pc; |
487 | 480 | ||
488 | if (NULL != address) | 481 | if (NULL != address) |
489 | { | ||
490 | if (0 != strlen (address)) | ||
491 | { | 482 | { |
492 | if (NULL != ar->result) | 483 | if (0 != strlen(address)) |
493 | GNUNET_free (ar->result); | 484 | { |
494 | ar->result = GNUNET_strdup (address); | 485 | if (NULL != ar->result) |
486 | GNUNET_free(ar->result); | ||
487 | ar->result = GNUNET_strdup(address); | ||
488 | } | ||
489 | return; | ||
495 | } | 490 | } |
496 | return; | ||
497 | } | ||
498 | ar->atsc = NULL; | 491 | ar->atsc = NULL; |
499 | if (GNUNET_SYSERR == res) | 492 | if (GNUNET_SYSERR == res) |
500 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 493 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
501 | _("Failure: Cannot convert address to string for peer `%s'\n"), | 494 | _("Failure: Cannot convert address to string for peer `%s'\n"), |
502 | GNUNET_i2s (&ar->pc->peer)); | 495 | GNUNET_i2s(&ar->pc->peer)); |
503 | pc->num_addresses++; | 496 | pc->num_addresses++; |
504 | if (pc->num_addresses == pc->address_list_size) | 497 | if (pc->num_addresses == pc->address_list_size) |
505 | dump_pc (ar->pc); | 498 | dump_pc(ar->pc); |
506 | } | 499 | } |
507 | 500 | ||
508 | 501 | ||
@@ -515,33 +508,33 @@ process_resolved_address (void *cls, | |||
515 | * @return #GNUNET_OK to keep the address and continue | 508 | * @return #GNUNET_OK to keep the address and continue |
516 | */ | 509 | */ |
517 | static int | 510 | static int |
518 | print_address (void *cls, | 511 | print_address(void *cls, |
519 | const struct GNUNET_HELLO_Address *address, | 512 | const struct GNUNET_HELLO_Address *address, |
520 | struct GNUNET_TIME_Absolute expiration) | 513 | struct GNUNET_TIME_Absolute expiration) |
521 | { | 514 | { |
522 | struct PrintContext *pc = cls; | 515 | struct PrintContext *pc = cls; |
523 | struct AddressRecord *ar; | 516 | struct AddressRecord *ar; |
524 | 517 | ||
525 | if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us) | 518 | if (0 == GNUNET_TIME_absolute_get_remaining(expiration).rel_value_us) |
526 | { | 519 | { |
527 | return GNUNET_OK; /* ignore expired address */ | 520 | return GNUNET_OK; /* ignore expired address */ |
528 | } | 521 | } |
529 | 522 | ||
530 | GNUNET_assert (0 < pc->off); | 523 | GNUNET_assert(0 < pc->off); |
531 | ar = &pc->address_list[--pc->off]; | 524 | ar = &pc->address_list[--pc->off]; |
532 | ar->pc = pc; | 525 | ar->pc = pc; |
533 | ar->expiration = expiration; | 526 | ar->expiration = expiration; |
534 | GNUNET_asprintf (&ar->result, | 527 | GNUNET_asprintf(&ar->result, |
535 | "%s:%u:%u", | 528 | "%s:%u:%u", |
536 | address->transport_name, | 529 | address->transport_name, |
537 | address->address_length, | 530 | address->address_length, |
538 | address->local_info); | 531 | address->local_info); |
539 | ar->atsc = GNUNET_TRANSPORT_address_to_string (cfg, | 532 | ar->atsc = GNUNET_TRANSPORT_address_to_string(cfg, |
540 | address, | 533 | address, |
541 | GNUNET_NO, | 534 | GNUNET_NO, |
542 | TIMEOUT, | 535 | TIMEOUT, |
543 | &process_resolved_address, | 536 | &process_resolved_address, |
544 | ar); | 537 | ar); |
545 | return GNUNET_OK; | 538 | return GNUNET_OK; |
546 | } | 539 | } |
547 | 540 | ||
@@ -557,63 +550,63 @@ print_address (void *cls, | |||
557 | */ | 550 | */ |
558 | void | 551 | void |
559 | peerinfo_list_iteration(void *cls, | 552 | peerinfo_list_iteration(void *cls, |
560 | const struct GNUNET_PeerIdentity *peer, | 553 | const struct GNUNET_PeerIdentity *peer, |
561 | const struct GNUNET_HELLO_Message *hello, | 554 | const struct GNUNET_HELLO_Message *hello, |
562 | const char *err_msg) | 555 | const char *err_msg) |
563 | { | 556 | { |
564 | struct RequestHandle *handle = cls; | 557 | struct RequestHandle *handle = cls; |
565 | struct PrintContext *pc; | 558 | struct PrintContext *pc; |
566 | int friend_only; | 559 | int friend_only; |
567 | 560 | ||
568 | if (NULL == handle->response) | 561 | if (NULL == handle->response) |
569 | { | 562 | { |
570 | handle->response = json_array(); | 563 | handle->response = json_array(); |
571 | } | 564 | } |
572 | 565 | ||
573 | if (NULL == peer) | 566 | if (NULL == peer) |
574 | { | ||
575 | handle->list_it = NULL; | ||
576 | handle->emsg = GNUNET_strdup ("Error in communication with peerinfo"); | ||
577 | if (NULL != err_msg) | ||
578 | { | 567 | { |
579 | GNUNET_free(handle->emsg); | 568 | handle->list_it = NULL; |
580 | handle->emsg = GNUNET_strdup (err_msg); | 569 | handle->emsg = GNUNET_strdup("Error in communication with peerinfo"); |
581 | handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; | 570 | if (NULL != err_msg) |
571 | { | ||
572 | GNUNET_free(handle->emsg); | ||
573 | handle->emsg = GNUNET_strdup(err_msg); | ||
574 | handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; | ||
575 | } | ||
576 | if (NULL == pc_head) | ||
577 | GNUNET_SCHEDULER_add_now(&do_error, handle); | ||
578 | return; | ||
582 | } | 579 | } |
583 | if (NULL == pc_head) | ||
584 | GNUNET_SCHEDULER_add_now (&do_error, handle); | ||
585 | return; | ||
586 | } | ||
587 | if (NULL == hello) | 580 | if (NULL == hello) |
588 | return; | 581 | return; |
589 | 582 | ||
590 | friend_only = GNUNET_NO; | 583 | friend_only = GNUNET_NO; |
591 | if (NULL != hello) | 584 | if (NULL != hello) |
592 | friend_only = GNUNET_HELLO_is_friend_only (hello); | 585 | friend_only = GNUNET_HELLO_is_friend_only(hello); |
593 | 586 | ||
594 | pc = GNUNET_new(struct PrintContext); | 587 | pc = GNUNET_new(struct PrintContext); |
595 | GNUNET_CONTAINER_DLL_insert (pc_head, | 588 | GNUNET_CONTAINER_DLL_insert(pc_head, |
596 | pc_tail, | 589 | pc_tail, |
597 | pc); | 590 | pc); |
598 | pc->peer = *peer; | 591 | pc->peer = *peer; |
599 | pc->friend_only = friend_only; | 592 | pc->friend_only = friend_only; |
600 | pc->handle = handle; | 593 | pc->handle = handle; |
601 | GNUNET_HELLO_iterate_addresses (hello, | 594 | GNUNET_HELLO_iterate_addresses(hello, |
602 | GNUNET_NO, | 595 | GNUNET_NO, |
603 | &count_address, | 596 | &count_address, |
604 | pc); | 597 | pc); |
605 | if (0 == pc->off) | 598 | if (0 == pc->off) |
606 | { | 599 | { |
607 | dump_pc (pc); | 600 | dump_pc(pc); |
608 | return; | 601 | return; |
609 | } | 602 | } |
610 | pc->address_list_size = pc->off; | 603 | pc->address_list_size = pc->off; |
611 | pc->address_list = GNUNET_malloc( | 604 | pc->address_list = GNUNET_malloc( |
612 | sizeof(struct AddressRecord) * pc->off); | 605 | sizeof(struct AddressRecord) * pc->off); |
613 | GNUNET_HELLO_iterate_addresses (hello, | 606 | GNUNET_HELLO_iterate_addresses(hello, |
614 | GNUNET_NO, | 607 | GNUNET_NO, |
615 | &print_address, | 608 | &print_address, |
616 | pc); | 609 | pc); |
617 | } | 610 | } |
618 | 611 | ||
619 | /** | 612 | /** |
@@ -624,9 +617,9 @@ peerinfo_list_iteration(void *cls, | |||
624 | * @param cls the RequestHandle | 617 | * @param cls the RequestHandle |
625 | */ | 618 | */ |
626 | void | 619 | void |
627 | peerinfo_get (struct GNUNET_REST_RequestHandle *con_handle, | 620 | peerinfo_get(struct GNUNET_REST_RequestHandle *con_handle, |
628 | const char* url, | 621 | const char* url, |
629 | void *cls) | 622 | void *cls) |
630 | { | 623 | { |
631 | struct RequestHandle *handle = cls; | 624 | struct RequestHandle *handle = cls; |
632 | struct GNUNET_HashCode key; | 625 | struct GNUNET_HashCode key; |
@@ -636,38 +629,38 @@ peerinfo_get (struct GNUNET_REST_RequestHandle *con_handle, | |||
636 | char* include_friend_only_str; | 629 | char* include_friend_only_str; |
637 | 630 | ||
638 | include_friend_only = GNUNET_NO; | 631 | include_friend_only = GNUNET_NO; |
639 | GNUNET_CRYPTO_hash (GNUNET_REST_PEERINFO_FRIEND, | 632 | GNUNET_CRYPTO_hash(GNUNET_REST_PEERINFO_FRIEND, |
640 | strlen (GNUNET_REST_PEERINFO_FRIEND), | 633 | strlen(GNUNET_REST_PEERINFO_FRIEND), |
641 | &key); | 634 | &key); |
642 | if ( GNUNET_YES | 635 | if (GNUNET_YES |
643 | == GNUNET_CONTAINER_multihashmap_contains (con_handle->url_param_map, | 636 | == GNUNET_CONTAINER_multihashmap_contains(con_handle->url_param_map, |
644 | &key)) | 637 | &key)) |
645 | { | ||
646 | include_friend_only_str = GNUNET_CONTAINER_multihashmap_get ( | ||
647 | con_handle->url_param_map, &key); | ||
648 | if (0 == strcmp(include_friend_only_str, "yes")) | ||
649 | { | 638 | { |
650 | include_friend_only = GNUNET_YES; | 639 | include_friend_only_str = GNUNET_CONTAINER_multihashmap_get( |
640 | con_handle->url_param_map, &key); | ||
641 | if (0 == strcmp(include_friend_only_str, "yes")) | ||
642 | { | ||
643 | include_friend_only = GNUNET_YES; | ||
644 | } | ||
651 | } | 645 | } |
652 | } | ||
653 | 646 | ||
654 | specific_peer = NULL; | 647 | specific_peer = NULL; |
655 | GNUNET_CRYPTO_hash (GNUNET_REST_PEERINFO_PEER, | 648 | GNUNET_CRYPTO_hash(GNUNET_REST_PEERINFO_PEER, |
656 | strlen (GNUNET_REST_PEERINFO_PEER), | 649 | strlen(GNUNET_REST_PEERINFO_PEER), |
657 | &key); | 650 | &key); |
658 | if ( GNUNET_YES | 651 | if (GNUNET_YES |
659 | == GNUNET_CONTAINER_multihashmap_contains (con_handle->url_param_map, | 652 | == GNUNET_CONTAINER_multihashmap_contains(con_handle->url_param_map, |
660 | &key)) | 653 | &key)) |
661 | { | 654 | { |
662 | //peer_id = *(unsigned int*)GNUNET_CONTAINER_multihashmap_get (con_handle->url_param_map, &key); | 655 | //peer_id = *(unsigned int*)GNUNET_CONTAINER_multihashmap_get (con_handle->url_param_map, &key); |
663 | //specific_peer = GNUNET_PEER_resolve2(peer_id); | 656 | //specific_peer = GNUNET_PEER_resolve2(peer_id); |
664 | } | 657 | } |
665 | 658 | ||
666 | handle->list_it = GNUNET_PEERINFO_iterate(handle->peerinfo_handle, | 659 | handle->list_it = GNUNET_PEERINFO_iterate(handle->peerinfo_handle, |
667 | include_friend_only, | 660 | include_friend_only, |
668 | specific_peer, | 661 | specific_peer, |
669 | &peerinfo_list_iteration, | 662 | &peerinfo_list_iteration, |
670 | handle); | 663 | handle); |
671 | } | 664 | } |
672 | 665 | ||
673 | 666 | ||
@@ -680,20 +673,20 @@ peerinfo_get (struct GNUNET_REST_RequestHandle *con_handle, | |||
680 | * @param cls the RequestHandle | 673 | * @param cls the RequestHandle |
681 | */ | 674 | */ |
682 | static void | 675 | static void |
683 | options_cont (struct GNUNET_REST_RequestHandle *con_handle, | 676 | options_cont(struct GNUNET_REST_RequestHandle *con_handle, |
684 | const char* url, | 677 | const char* url, |
685 | void *cls) | 678 | void *cls) |
686 | { | 679 | { |
687 | struct MHD_Response *resp; | 680 | struct MHD_Response *resp; |
688 | struct RequestHandle *handle = cls; | 681 | struct RequestHandle *handle = cls; |
689 | 682 | ||
690 | //independent of path return all options | 683 | //independent of path return all options |
691 | resp = GNUNET_REST_create_response (NULL); | 684 | resp = GNUNET_REST_create_response(NULL); |
692 | MHD_add_response_header (resp, | 685 | MHD_add_response_header(resp, |
693 | "Access-Control-Allow-Methods", | 686 | "Access-Control-Allow-Methods", |
694 | allow_methods); | 687 | allow_methods); |
695 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 688 | handle->proc(handle->proc_cls, resp, MHD_HTTP_OK); |
696 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); | 689 | GNUNET_SCHEDULER_add_now(&cleanup_handle, handle); |
697 | return; | 690 | return; |
698 | } | 691 | } |
699 | 692 | ||
@@ -704,23 +697,23 @@ options_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
704 | * @param handle the request handle | 697 | * @param handle the request handle |
705 | */ | 698 | */ |
706 | static void | 699 | static void |
707 | init_cont (struct RequestHandle *handle) | 700 | init_cont(struct RequestHandle *handle) |
708 | { | 701 | { |
709 | struct GNUNET_REST_RequestHandlerError err; | 702 | struct GNUNET_REST_RequestHandlerError err; |
710 | static const struct GNUNET_REST_RequestHandler handlers[] = { | 703 | static const struct GNUNET_REST_RequestHandler handlers[] = { |
711 | {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_PEERINFO, &peerinfo_get}, | 704 | { MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_PEERINFO, &peerinfo_get }, |
712 | {MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_PEERINFO, &options_cont}, | 705 | { MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_PEERINFO, &options_cont }, |
713 | GNUNET_REST_HANDLER_END | 706 | GNUNET_REST_HANDLER_END |
714 | }; | 707 | }; |
715 | 708 | ||
716 | if (GNUNET_NO == GNUNET_REST_handle_request (handle->rest_handle, | 709 | if (GNUNET_NO == GNUNET_REST_handle_request(handle->rest_handle, |
717 | handlers, | 710 | handlers, |
718 | &err, | 711 | &err, |
719 | handle)) | 712 | handle)) |
720 | { | 713 | { |
721 | handle->response_code = err.error_code; | 714 | handle->response_code = err.error_code; |
722 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 715 | GNUNET_SCHEDULER_add_now(&do_error, handle); |
723 | } | 716 | } |
724 | } | 717 | } |
725 | 718 | ||
726 | 719 | ||
@@ -737,29 +730,29 @@ init_cont (struct RequestHandle *handle) | |||
737 | */ | 730 | */ |
738 | static void | 731 | static void |
739 | rest_process_request(struct GNUNET_REST_RequestHandle *rest_handle, | 732 | rest_process_request(struct GNUNET_REST_RequestHandle *rest_handle, |
740 | GNUNET_REST_ResultProcessor proc, | 733 | GNUNET_REST_ResultProcessor proc, |
741 | void *proc_cls) | 734 | void *proc_cls) |
742 | { | 735 | { |
743 | struct RequestHandle *handle = GNUNET_new (struct RequestHandle); | 736 | struct RequestHandle *handle = GNUNET_new(struct RequestHandle); |
744 | 737 | ||
745 | handle->response_code = 0; | 738 | handle->response_code = 0; |
746 | handle->timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60); | 739 | handle->timeout = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60); |
747 | handle->proc_cls = proc_cls; | 740 | handle->proc_cls = proc_cls; |
748 | handle->proc = proc; | 741 | handle->proc = proc; |
749 | handle->rest_handle = rest_handle; | 742 | handle->rest_handle = rest_handle; |
750 | 743 | ||
751 | handle->url = GNUNET_strdup (rest_handle->url); | 744 | handle->url = GNUNET_strdup(rest_handle->url); |
752 | if (handle->url[strlen (handle->url)-1] == '/') | 745 | if (handle->url[strlen(handle->url) - 1] == '/') |
753 | handle->url[strlen (handle->url)-1] = '\0'; | 746 | handle->url[strlen(handle->url) - 1] = '\0'; |
754 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n"); | 747 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n"); |
755 | handle->peerinfo_handle = GNUNET_PEERINFO_connect(cfg); | 748 | handle->peerinfo_handle = GNUNET_PEERINFO_connect(cfg); |
756 | init_cont(handle); | 749 | init_cont(handle); |
757 | handle->timeout_task = | 750 | handle->timeout_task = |
758 | GNUNET_SCHEDULER_add_delayed (handle->timeout, | 751 | GNUNET_SCHEDULER_add_delayed(handle->timeout, |
759 | &do_error, | 752 | &do_error, |
760 | handle); | 753 | handle); |
761 | 754 | ||
762 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected\n"); | 755 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connected\n"); |
763 | } | 756 | } |
764 | 757 | ||
765 | 758 | ||
@@ -770,7 +763,7 @@ rest_process_request(struct GNUNET_REST_RequestHandle *rest_handle, | |||
770 | * @return NULL on error, otherwise the plugin context | 763 | * @return NULL on error, otherwise the plugin context |
771 | */ | 764 | */ |
772 | void * | 765 | void * |
773 | libgnunet_plugin_rest_peerinfo_init (void *cls) | 766 | libgnunet_plugin_rest_peerinfo_init(void *cls) |
774 | { | 767 | { |
775 | static struct Plugin plugin; | 768 | static struct Plugin plugin; |
776 | struct GNUNET_REST_Plugin *api; | 769 | struct GNUNET_REST_Plugin *api; |
@@ -778,22 +771,22 @@ libgnunet_plugin_rest_peerinfo_init (void *cls) | |||
778 | cfg = cls; | 771 | cfg = cls; |
779 | if (NULL != plugin.cfg) | 772 | if (NULL != plugin.cfg) |
780 | return NULL; /* can only initialize once! */ | 773 | return NULL; /* can only initialize once! */ |
781 | memset (&plugin, 0, sizeof (struct Plugin)); | 774 | memset(&plugin, 0, sizeof(struct Plugin)); |
782 | plugin.cfg = cfg; | 775 | plugin.cfg = cfg; |
783 | api = GNUNET_new (struct GNUNET_REST_Plugin); | 776 | api = GNUNET_new(struct GNUNET_REST_Plugin); |
784 | api->cls = &plugin; | 777 | api->cls = &plugin; |
785 | api->name = GNUNET_REST_API_NS_PEERINFO; | 778 | api->name = GNUNET_REST_API_NS_PEERINFO; |
786 | api->process_request = &rest_process_request; | 779 | api->process_request = &rest_process_request; |
787 | GNUNET_asprintf (&allow_methods, | 780 | GNUNET_asprintf(&allow_methods, |
788 | "%s, %s, %s, %s, %s", | 781 | "%s, %s, %s, %s, %s", |
789 | MHD_HTTP_METHOD_GET, | 782 | MHD_HTTP_METHOD_GET, |
790 | MHD_HTTP_METHOD_POST, | 783 | MHD_HTTP_METHOD_POST, |
791 | MHD_HTTP_METHOD_PUT, | 784 | MHD_HTTP_METHOD_PUT, |
792 | MHD_HTTP_METHOD_DELETE, | 785 | MHD_HTTP_METHOD_DELETE, |
793 | MHD_HTTP_METHOD_OPTIONS); | 786 | MHD_HTTP_METHOD_OPTIONS); |
794 | 787 | ||
795 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 788 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
796 | _("Peerinfo REST API initialized\n")); | 789 | _("Peerinfo REST API initialized\n")); |
797 | return api; | 790 | return api; |
798 | } | 791 | } |
799 | 792 | ||
@@ -805,16 +798,17 @@ libgnunet_plugin_rest_peerinfo_init (void *cls) | |||
805 | * @return always NULL | 798 | * @return always NULL |
806 | */ | 799 | */ |
807 | void * | 800 | void * |
808 | libgnunet_plugin_rest_peerinfo_done (void *cls) | 801 | libgnunet_plugin_rest_peerinfo_done(void *cls) |
809 | { | 802 | { |
810 | struct GNUNET_REST_Plugin *api = cls; | 803 | struct GNUNET_REST_Plugin *api = cls; |
811 | struct Plugin *plugin = api->cls; | 804 | struct Plugin *plugin = api->cls; |
805 | |||
812 | plugin->cfg = NULL; | 806 | plugin->cfg = NULL; |
813 | 807 | ||
814 | GNUNET_free_non_null (allow_methods); | 808 | GNUNET_free_non_null(allow_methods); |
815 | GNUNET_free (api); | 809 | GNUNET_free(api); |
816 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 810 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
817 | "Peerinfo REST plugin is finished\n"); | 811 | "Peerinfo REST plugin is finished\n"); |
818 | return NULL; | 812 | return NULL; |
819 | } | 813 | } |
820 | 814 | ||