diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-06-09 09:03:18 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-06-09 09:03:18 +0000 |
commit | e43211d969b27eeb38043b5fd67232c1e593c83d (patch) | |
tree | 9e0d2a0ce077915031b6b1f143cd72fdfcce6105 /src | |
parent | 995ff4c783691df5462353d0ef4f698942de1010 (diff) | |
download | gnunet-e43211d969b27eeb38043b5fd67232c1e593c83d.tar.gz gnunet-e43211d969b27eeb38043b5fd67232c1e593c83d.zip |
-fixing doxygen, indentation
Diffstat (limited to 'src')
-rw-r--r-- | src/peerinfo-tool/gnunet-peerinfo.c | 265 |
1 files changed, 168 insertions, 97 deletions
diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c index 9c5f1953a..9f2370731 100644 --- a/src/peerinfo-tool/gnunet-peerinfo.c +++ b/src/peerinfo-tool/gnunet-peerinfo.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2001-2012 Christian Grothoff (and other contributing authors) | 3 | (C) 2001-2014 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -25,10 +25,7 @@ | |||
25 | * @author Matthias Wachs | 25 | * @author Matthias Wachs |
26 | */ | 26 | */ |
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_crypto_lib.h" | 28 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_configuration_lib.h" | ||
30 | #include "gnunet_getopt_lib.h" | ||
31 | #include "gnunet_program_lib.h" | ||
32 | #include "gnunet_hello_lib.h" | 29 | #include "gnunet_hello_lib.h" |
33 | #include "gnunet_transport_service.h" | 30 | #include "gnunet_transport_service.h" |
34 | #include "gnunet_peerinfo_service.h" | 31 | #include "gnunet_peerinfo_service.h" |
@@ -98,22 +95,22 @@ struct PrintContext | |||
98 | struct AddressRecord *address_list; | 95 | struct AddressRecord *address_list; |
99 | 96 | ||
100 | /** | 97 | /** |
101 | * Number of completed addresses in 'address_list'. | 98 | * Number of completed addresses in @e address_list. |
102 | */ | 99 | */ |
103 | unsigned int num_addresses; | 100 | unsigned int num_addresses; |
104 | 101 | ||
105 | /** | 102 | /** |
106 | * Number of addresses allocated in 'address_list'. | 103 | * Number of addresses allocated in @e address_list. |
107 | */ | 104 | */ |
108 | unsigned int address_list_size; | 105 | unsigned int address_list_size; |
109 | 106 | ||
110 | /** | 107 | /** |
111 | * Current offset in 'address_list' (counted down). | 108 | * Current offset in @e address_list (counted down). |
112 | */ | 109 | */ |
113 | unsigned int off; | 110 | unsigned int off; |
114 | 111 | ||
115 | /** | 112 | /** |
116 | * Hello was friend only, GNUNET_YES or GNUNET_NO | 113 | * Hello was friend only, #GNUNET_YES or #GNUNET_NO |
117 | */ | 114 | */ |
118 | int friend_only; | 115 | int friend_only; |
119 | 116 | ||
@@ -201,7 +198,7 @@ static struct PrintContext *pc_head; | |||
201 | static struct PrintContext *pc_tail; | 198 | static struct PrintContext *pc_tail; |
202 | 199 | ||
203 | /** | 200 | /** |
204 | * Handle to current 'GNUNET_PEERINFO_add_peer' operation. | 201 | * Handle to current #GNUNET_PEERINFO_add_peer() operation. |
205 | */ | 202 | */ |
206 | static struct GNUNET_PEERINFO_AddContext *ac; | 203 | static struct GNUNET_PEERINFO_AddContext *ac; |
207 | 204 | ||
@@ -221,7 +218,7 @@ state_machine (void *cls, | |||
221 | /* ********************* 'get_info' ******************* */ | 218 | /* ********************* 'get_info' ******************* */ |
222 | 219 | ||
223 | /** | 220 | /** |
224 | * Print the collected address information to the console and free 'pc'. | 221 | * Print the collected address information to the console and free @a pc. |
225 | * | 222 | * |
226 | * @param pc printing context | 223 | * @param pc printing context |
227 | */ | 224 | */ |
@@ -237,7 +234,9 @@ dump_pc (struct PrintContext *pc) | |||
237 | { | 234 | { |
238 | if (NULL != pc->address_list[i].result) | 235 | if (NULL != pc->address_list[i].result) |
239 | { | 236 | { |
240 | printf (_("\tExpires: %s \t %s\n"), GNUNET_STRINGS_absolute_time_to_string(pc->address_list[i].expiration), pc->address_list[i].result); | 237 | printf (_("\tExpires: %s \t %s\n"), |
238 | GNUNET_STRINGS_absolute_time_to_string (pc->address_list[i].expiration), | ||
239 | pc->address_list[i].result); | ||
241 | GNUNET_free (pc->address_list[i].result); | 240 | GNUNET_free (pc->address_list[i].result); |
242 | } | 241 | } |
243 | } | 242 | } |
@@ -249,7 +248,8 @@ dump_pc (struct PrintContext *pc) | |||
249 | GNUNET_free (pc); | 248 | GNUNET_free (pc); |
250 | if ( (NULL == pc_head) && | 249 | if ( (NULL == pc_head) && |
251 | (NULL == pic) ) | 250 | (NULL == pic) ) |
252 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); | 251 | tt = GNUNET_SCHEDULER_add_now (&state_machine, |
252 | NULL); | ||
253 | } | 253 | } |
254 | 254 | ||
255 | 255 | ||
@@ -263,7 +263,9 @@ dump_pc (struct PrintContext *pc) | |||
263 | * @param address NULL on error, otherwise 0-terminated printable UTF-8 string | 263 | * @param address NULL on error, otherwise 0-terminated printable UTF-8 string |
264 | */ | 264 | */ |
265 | static void | 265 | static void |
266 | process_resolved_address (void *cls, const char *address, int res) | 266 | process_resolved_address (void *cls, |
267 | const char *address, | ||
268 | int res) | ||
267 | { | 269 | { |
268 | struct AddressRecord * ar = cls; | 270 | struct AddressRecord * ar = cls; |
269 | struct PrintContext *pc = ar->pc; | 271 | struct PrintContext *pc = ar->pc; |
@@ -294,13 +296,14 @@ process_resolved_address (void *cls, const char *address, int res) | |||
294 | /** | 296 | /** |
295 | * Iterator callback to go over all addresses and count them. | 297 | * Iterator callback to go over all addresses and count them. |
296 | * | 298 | * |
297 | * @param cls 'struct PrintContext' with 'off' to increment | 299 | * @param cls `struct PrintContext *` with `off` to increment |
298 | * @param address the address | 300 | * @param address the address |
299 | * @param expiration expiration time | 301 | * @param expiration expiration time |
300 | * @return GNUNET_OK to keep the address and continue | 302 | * @return #GNUNET_OK to keep the address and continue |
301 | */ | 303 | */ |
302 | static int | 304 | static int |
303 | count_address (void *cls, const struct GNUNET_HELLO_Address *address, | 305 | count_address (void *cls, |
306 | const struct GNUNET_HELLO_Address *address, | ||
304 | struct GNUNET_TIME_Absolute expiration) | 307 | struct GNUNET_TIME_Absolute expiration) |
305 | { | 308 | { |
306 | struct PrintContext *pc = cls; | 309 | struct PrintContext *pc = cls; |
@@ -316,10 +319,11 @@ count_address (void *cls, const struct GNUNET_HELLO_Address *address, | |||
316 | * @param cls closure | 319 | * @param cls closure |
317 | * @param address the address | 320 | * @param address the address |
318 | * @param expiration expiration time | 321 | * @param expiration expiration time |
319 | * @return GNUNET_OK to keep the address and continue | 322 | * @return #GNUNET_OK to keep the address and continue |
320 | */ | 323 | */ |
321 | static int | 324 | static int |
322 | print_address (void *cls, const struct GNUNET_HELLO_Address *address, | 325 | print_address (void *cls, |
326 | const struct GNUNET_HELLO_Address *address, | ||
323 | struct GNUNET_TIME_Absolute expiration) | 327 | struct GNUNET_TIME_Absolute expiration) |
324 | { | 328 | { |
325 | struct PrintContext *pc = cls; | 329 | struct PrintContext *pc = cls; |
@@ -328,7 +332,9 @@ print_address (void *cls, const struct GNUNET_HELLO_Address *address, | |||
328 | ar = &pc->address_list[--pc->off]; | 332 | ar = &pc->address_list[--pc->off]; |
329 | ar->pc = pc; | 333 | ar->pc = pc; |
330 | ar->expiration = expiration; | 334 | ar->expiration = expiration; |
331 | ar->atsc = GNUNET_TRANSPORT_address_to_string (cfg, address, no_resolve, | 335 | ar->atsc = GNUNET_TRANSPORT_address_to_string (cfg, |
336 | address, | ||
337 | no_resolve, | ||
332 | GNUNET_TIME_relative_multiply | 338 | GNUNET_TIME_relative_multiply |
333 | (GNUNET_TIME_UNIT_SECONDS, 10), | 339 | (GNUNET_TIME_UNIT_SECONDS, 10), |
334 | &process_resolved_address, ar); | 340 | &process_resolved_address, ar); |
@@ -337,17 +343,19 @@ print_address (void *cls, const struct GNUNET_HELLO_Address *address, | |||
337 | 343 | ||
338 | 344 | ||
339 | /** | 345 | /** |
340 | * Print information about the peer. | 346 | * Print information about the peer. Currently prints the `struct |
341 | * Currently prints the GNUNET_PeerIdentity and the transport address. | 347 | * GNUNET_PeerIdentity` and the transport address. |
342 | * | 348 | * |
343 | * @param cls the 'struct PrintContext' | 349 | * @param cls the `struct PrintContext *` |
344 | * @param peer identity of the peer | 350 | * @param peer identity of the peer |
345 | * @param hello addresses of the peer | 351 | * @param hello addresses of the peer |
346 | * @param err_msg error message | 352 | * @param err_msg error message |
347 | */ | 353 | */ |
348 | static void | 354 | static void |
349 | print_peer_info (void *cls, const struct GNUNET_PeerIdentity *peer, | 355 | print_peer_info (void *cls, |
350 | const struct GNUNET_HELLO_Message *hello, const char *err_msg) | 356 | const struct GNUNET_PeerIdentity *peer, |
357 | const struct GNUNET_HELLO_Message *hello, | ||
358 | const char *err_msg) | ||
351 | { | 359 | { |
352 | struct PrintContext *pc; | 360 | struct PrintContext *pc; |
353 | int friend_only; | 361 | int friend_only; |
@@ -398,82 +406,106 @@ print_peer_info (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
398 | 406 | ||
399 | /* ************************* DUMP Hello ************************** */ | 407 | /* ************************* DUMP Hello ************************** */ |
400 | 408 | ||
401 | static int count_addr(void *cls, | 409 | /** |
402 | const struct GNUNET_HELLO_Address *address, | 410 | * Count the number of addresses in the HELLO. |
403 | struct GNUNET_TIME_Absolute expiration) | 411 | * |
412 | * @param cls pointer to an `int *` used for the counter | ||
413 | * @param address an address to count | ||
414 | * @param expiration (unused) | ||
415 | * @return #GNUNET_OK | ||
416 | */ | ||
417 | static int | ||
418 | count_addr (void *cls, | ||
419 | const struct GNUNET_HELLO_Address *address, | ||
420 | struct GNUNET_TIME_Absolute expiration) | ||
404 | { | 421 | { |
405 | int *c = cls; | 422 | int *c = cls; |
423 | |||
406 | (*c) ++; | 424 | (*c) ++; |
407 | return GNUNET_OK; | 425 | return GNUNET_OK; |
408 | } | 426 | } |
409 | 427 | ||
428 | |||
410 | /** | 429 | /** |
411 | * Write Hello of my peer to a file. | 430 | * Write Hello of my peer to a file. |
412 | * | 431 | * |
413 | * @param cls the 'struct GetUriContext' | 432 | * @param cls the `struct GetUriContext *` |
414 | * @param peer identity of the peer (unused) | 433 | * @param peer identity of the peer (unused) |
415 | * @param hello addresses of the peer | 434 | * @param hello addresses of the peer |
416 | * @param err_msg error message | 435 | * @param err_msg error message |
417 | */ | 436 | */ |
418 | static void | 437 | static void |
419 | dump_my_hello (void *cls, const struct GNUNET_PeerIdentity *peer, | 438 | dump_my_hello (void *cls, |
420 | const struct GNUNET_HELLO_Message *hello, | 439 | const struct GNUNET_PeerIdentity *peer, |
421 | const char *err_msg) | 440 | const struct GNUNET_HELLO_Message *hello, |
441 | const char *err_msg) | ||
422 | { | 442 | { |
423 | unsigned int size; | 443 | unsigned int size; |
424 | unsigned int c_addr; | 444 | unsigned int c_addr; |
425 | if (peer == NULL) | 445 | |
446 | if (NULL == peer) | ||
426 | { | 447 | { |
427 | pic = NULL; | 448 | pic = NULL; |
428 | if (err_msg != NULL) | 449 | if (NULL != err_msg) |
429 | FPRINTF (stderr, | 450 | FPRINTF (stderr, |
430 | _("Error in communication with PEERINFO service: %s\n"), | 451 | _("Error in communication with PEERINFO service: %s\n"), |
431 | err_msg); | 452 | err_msg); |
432 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); | 453 | tt = GNUNET_SCHEDULER_add_now (&state_machine, |
454 | NULL); | ||
433 | return; | 455 | return; |
434 | } | 456 | } |
435 | 457 | ||
436 | if (NULL == hello) | 458 | if (NULL == hello) |
437 | { | 459 | { |
438 | FPRINTF (stderr, | 460 | FPRINTF (stderr, |
439 | _("Failure: Did not receive %s\n"), "HELLO"); | 461 | _("Failure: Did not receive %s\n"), |
462 | "HELLO"); | ||
440 | return; | 463 | return; |
441 | } | 464 | } |
442 | 465 | ||
443 | size = GNUNET_HELLO_size (hello); | 466 | size = GNUNET_HELLO_size (hello); |
444 | if (0 == size) | 467 | if (0 == size) |
445 | { | 468 | { |
446 | FPRINTF (stderr, | 469 | FPRINTF (stderr, |
447 | _("Failure: Received invalid %s\n"), "HELLO"); | 470 | _("Failure: Received invalid %s\n"), |
471 | "HELLO"); | ||
448 | return; | 472 | return; |
449 | } | 473 | } |
450 | if (GNUNET_SYSERR == GNUNET_DISK_fn_write (dump_hello, hello, size, | 474 | if (GNUNET_SYSERR == |
475 | GNUNET_DISK_fn_write (dump_hello, hello, size, | ||
451 | GNUNET_DISK_PERM_USER_READ | | 476 | GNUNET_DISK_PERM_USER_READ | |
452 | GNUNET_DISK_PERM_USER_WRITE | | 477 | GNUNET_DISK_PERM_USER_WRITE | |
453 | GNUNET_DISK_PERM_GROUP_READ | | 478 | GNUNET_DISK_PERM_GROUP_READ | |
454 | GNUNET_DISK_PERM_OTHER_READ)) | 479 | GNUNET_DISK_PERM_OTHER_READ)) |
455 | { | 480 | { |
456 | FPRINTF (stderr, _("Failed to write HELLO with %u bytes to file `%s'\n"), | 481 | FPRINTF (stderr, |
457 | size, dump_hello); | 482 | _("Failed to write HELLO with %u bytes to file `%s'\n"), |
458 | if (0 != UNLINK (dump_hello)) | 483 | size, |
459 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING | | 484 | dump_hello); |
460 | GNUNET_ERROR_TYPE_BULK, "unlink", dump_hello); | 485 | if (0 != UNLINK (dump_hello)) |
486 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING | | ||
487 | GNUNET_ERROR_TYPE_BULK, | ||
488 | "unlink", | ||
489 | dump_hello); | ||
461 | 490 | ||
462 | } | 491 | } |
463 | c_addr = 0; | 492 | c_addr = 0; |
464 | GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, count_addr, &c_addr); | 493 | GNUNET_HELLO_iterate_addresses (hello, |
494 | GNUNET_NO, | ||
495 | count_addr, | ||
496 | &c_addr); | ||
465 | 497 | ||
466 | if (!be_quiet) | 498 | if (! be_quiet) |
467 | { | 499 | { |
468 | FPRINTF (stderr, | 500 | FPRINTF (stderr, |
469 | _("Wrote %s HELLO containing %u addresses with %u bytes to file `%s'\n"), | 501 | _("Wrote %s HELLO containing %u addresses with %u bytes to file `%s'\n"), |
470 | (GNUNET_YES == GNUNET_HELLO_is_friend_only(hello)) ? "friend-only": "public", | 502 | (GNUNET_YES == GNUNET_HELLO_is_friend_only(hello)) ? "friend-only": "public", |
471 | c_addr, size, dump_hello); | 503 | c_addr, |
504 | size, | ||
505 | dump_hello); | ||
472 | } | 506 | } |
473 | |||
474 | GNUNET_free (dump_hello); | 507 | GNUNET_free (dump_hello); |
475 | dump_hello = NULL; | 508 | dump_hello = NULL; |
476 | |||
477 | } | 509 | } |
478 | 510 | ||
479 | 511 | ||
@@ -483,20 +515,21 @@ dump_my_hello (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
483 | /** | 515 | /** |
484 | * Print URI of the peer. | 516 | * Print URI of the peer. |
485 | * | 517 | * |
486 | * @param cls the 'struct GetUriContext' | 518 | * @param cls the `struct GetUriContext *` |
487 | * @param peer identity of the peer (unused) | 519 | * @param peer identity of the peer (unused) |
488 | * @param hello addresses of the peer | 520 | * @param hello addresses of the peer |
489 | * @param err_msg error message | 521 | * @param err_msg error message |
490 | */ | 522 | */ |
491 | static void | 523 | static void |
492 | print_my_uri (void *cls, const struct GNUNET_PeerIdentity *peer, | 524 | print_my_uri (void *cls, |
525 | const struct GNUNET_PeerIdentity *peer, | ||
493 | const struct GNUNET_HELLO_Message *hello, | 526 | const struct GNUNET_HELLO_Message *hello, |
494 | const char *err_msg) | 527 | const char *err_msg) |
495 | { | 528 | { |
496 | if (peer == NULL) | 529 | if (NULL == peer) |
497 | { | 530 | { |
498 | pic = NULL; | 531 | pic = NULL; |
499 | if (err_msg != NULL) | 532 | if (NULL != err_msg) |
500 | FPRINTF (stderr, | 533 | FPRINTF (stderr, |
501 | _("Error in communication with PEERINFO service: %s\n"), | 534 | _("Error in communication with PEERINFO service: %s\n"), |
502 | err_msg); | 535 | err_msg); |
@@ -506,9 +539,12 @@ print_my_uri (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
506 | 539 | ||
507 | if (NULL == hello) | 540 | if (NULL == hello) |
508 | return; | 541 | return; |
509 | char *uri = GNUNET_HELLO_compose_uri(hello, &GPI_plugins_find); | 542 | char *uri = GNUNET_HELLO_compose_uri (hello, |
510 | if (NULL != uri) { | 543 | &GPI_plugins_find); |
511 | printf ("%s\n", (const char *) uri); | 544 | if (NULL != uri) |
545 | { | ||
546 | printf ("%s\n", | ||
547 | (const char *) uri); | ||
512 | GNUNET_free (uri); | 548 | GNUNET_free (uri); |
513 | } | 549 | } |
514 | } | 550 | } |
@@ -518,7 +554,7 @@ print_my_uri (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
518 | 554 | ||
519 | 555 | ||
520 | /** | 556 | /** |
521 | * Continuation called from 'GNUNET_PEERINFO_add_peer' | 557 | * Continuation called from #GNUNET_PEERINFO_add_peer() |
522 | * | 558 | * |
523 | * @param cls closure, NULL | 559 | * @param cls closure, NULL |
524 | * @param emsg error message, NULL on success | 560 | * @param emsg error message, NULL on success |
@@ -541,20 +577,27 @@ add_continuation (void *cls, | |||
541 | * database. | 577 | * database. |
542 | * | 578 | * |
543 | * @param put_uri URI string to parse | 579 | * @param put_uri URI string to parse |
544 | * @return GNUNET_OK on success, GNUNET_SYSERR if the URI was invalid, GNUNET_NO on other errors | 580 | * @return #GNUNET_OK on success, |
581 | * #GNUNET_SYSERR if the URI was invalid, | ||
582 | * #GNUNET_NO on other errors | ||
545 | */ | 583 | */ |
546 | static int | 584 | static int |
547 | parse_hello_uri (const char *put_uri) | 585 | parse_hello_uri (const char *put_uri) |
548 | { | 586 | { |
549 | struct GNUNET_HELLO_Message *hello = NULL; | 587 | struct GNUNET_HELLO_Message *hello = NULL; |
550 | 588 | ||
551 | int ret = GNUNET_HELLO_parse_uri(put_uri, &my_peer_identity.public_key, | 589 | int ret = GNUNET_HELLO_parse_uri(put_uri, |
552 | &hello, &GPI_plugins_find); | 590 | &my_peer_identity.public_key, |
591 | &hello, | ||
592 | &GPI_plugins_find); | ||
553 | 593 | ||
554 | if (NULL != hello) { | 594 | if (NULL != hello) |
595 | { | ||
555 | /* WARNING: this adds the address from URI WITHOUT verification! */ | 596 | /* WARNING: this adds the address from URI WITHOUT verification! */ |
556 | if (GNUNET_OK == ret) | 597 | if (GNUNET_OK == ret) |
557 | ac = GNUNET_PEERINFO_add_peer (peerinfo, hello, &add_continuation, NULL); | 598 | ac = GNUNET_PEERINFO_add_peer (peerinfo, hello, |
599 | &add_continuation, | ||
600 | NULL); | ||
558 | else | 601 | else |
559 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); | 602 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); |
560 | GNUNET_free (hello); | 603 | GNUNET_free (hello); |
@@ -626,43 +669,57 @@ shutdown_task (void *cls, | |||
626 | } | 669 | } |
627 | } | 670 | } |
628 | 671 | ||
672 | |||
629 | /** | 673 | /** |
630 | * Function called with the result of the check if the 'peerinfo' | 674 | * Function called with the result of the check if the PEERINFO |
631 | * service is running. | 675 | * service is running. |
632 | * | 676 | * |
633 | * @param cls closure with our configuration | 677 | * @param cls closure with our configuration |
634 | * @param result #GNUNET_YES if transport is running | 678 | * @param result #GNUNET_YES if PEERINFO is running |
635 | */ | 679 | */ |
636 | static void | 680 | static void |
637 | testservice_task (void *cls, int result) | 681 | testservice_task (void *cls, |
682 | int result) | ||
638 | { | 683 | { |
639 | struct GNUNET_CRYPTO_EddsaPrivateKey *priv; | 684 | struct GNUNET_CRYPTO_EddsaPrivateKey *priv; |
640 | char *fn; | 685 | char *fn; |
641 | 686 | ||
642 | if (GNUNET_YES != result) | 687 | if (GNUNET_YES != result) |
643 | { | 688 | { |
644 | FPRINTF (stderr, _("Service `%s' is not running, please start GNUnet\n"), "peerinfo"); | 689 | FPRINTF (stderr, |
690 | _("Service `%s' is not running, please start GNUnet\n"), | ||
691 | "peerinfo"); | ||
645 | return; | 692 | return; |
646 | } | 693 | } |
647 | 694 | ||
648 | if (NULL == (peerinfo = GNUNET_PEERINFO_connect (cfg))) | 695 | if (NULL == (peerinfo = GNUNET_PEERINFO_connect (cfg))) |
649 | { | 696 | { |
650 | FPRINTF (stderr, "%s", _("Could not access PEERINFO service. Exiting.\n")); | 697 | FPRINTF (stderr, |
698 | "%s", | ||
699 | _("Could not access PEERINFO service. Exiting.\n")); | ||
651 | return; | 700 | return; |
652 | } | 701 | } |
653 | if ( (GNUNET_YES == get_self) || (GNUNET_YES == get_uri) || (NULL != dump_hello) ) | 702 | if ( (GNUNET_YES == get_self) || |
703 | (GNUNET_YES == get_uri) || | ||
704 | (NULL != dump_hello) ) | ||
654 | { | 705 | { |
655 | /* load private key */ | 706 | /* load private key */ |
656 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "PEER", | 707 | if (GNUNET_OK != |
657 | "PRIVATE_KEY", | 708 | GNUNET_CONFIGURATION_get_value_filename (cfg, |
658 | &fn)) | 709 | "PEER", |
710 | "PRIVATE_KEY", | ||
711 | &fn)) | ||
659 | { | 712 | { |
660 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "PEER", "PRIVATE_KEY"); | 713 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, |
714 | "PEER", | ||
715 | "PRIVATE_KEY"); | ||
661 | return; | 716 | return; |
662 | } | 717 | } |
663 | if (NULL == (priv = GNUNET_CRYPTO_eddsa_key_create_from_file (fn))) | 718 | if (NULL == (priv = GNUNET_CRYPTO_eddsa_key_create_from_file (fn))) |
664 | { | 719 | { |
665 | FPRINTF (stderr, _("Loading hostkey from `%s' failed.\n"), fn); | 720 | FPRINTF (stderr, |
721 | _("Loading hostkey from `%s' failed.\n"), | ||
722 | fn); | ||
666 | GNUNET_free (fn); | 723 | GNUNET_free (fn); |
667 | return; | 724 | return; |
668 | } | 725 | } |
@@ -688,7 +745,9 @@ testservice_task (void *cls, int result) | |||
688 | * @param c configuration | 745 | * @param c configuration |
689 | */ | 746 | */ |
690 | static void | 747 | static void |
691 | run (void *cls, char *const *args, const char *cfgfile, | 748 | run (void *cls, |
749 | char *const *args, | ||
750 | const char *cfgfile, | ||
692 | const struct GNUNET_CONFIGURATION_Handle *c) | 751 | const struct GNUNET_CONFIGURATION_Handle *c) |
693 | { | 752 | { |
694 | cfg = c; | 753 | cfg = c; |
@@ -707,8 +766,10 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
707 | return; | 766 | return; |
708 | } | 767 | } |
709 | 768 | ||
710 | GNUNET_CLIENT_service_test ("peerinfo", cfg, GNUNET_TIME_UNIT_SECONDS, | 769 | GNUNET_CLIENT_service_test ("peerinfo", |
711 | &testservice_task, (void *) cfg); | 770 | cfg, |
771 | GNUNET_TIME_UNIT_SECONDS, | ||
772 | &testservice_task, (void *) cfg); | ||
712 | } | 773 | } |
713 | 774 | ||
714 | 775 | ||
@@ -742,7 +803,9 @@ state_machine (void *cls, | |||
742 | { | 803 | { |
743 | get_info = GNUNET_NO; | 804 | get_info = GNUNET_NO; |
744 | GPI_plugins_load (cfg); | 805 | GPI_plugins_load (cfg); |
745 | pic = GNUNET_PEERINFO_iterate (peerinfo, include_friend_only, NULL, | 806 | pic = GNUNET_PEERINFO_iterate (peerinfo, |
807 | include_friend_only, | ||
808 | NULL, | ||
746 | TIMEOUT, | 809 | TIMEOUT, |
747 | &print_peer_info, NULL); | 810 | &print_peer_info, NULL); |
748 | } | 811 | } |
@@ -760,27 +823,33 @@ state_machine (void *cls, | |||
760 | else if (GNUNET_YES == get_uri) | 823 | else if (GNUNET_YES == get_uri) |
761 | { | 824 | { |
762 | GPI_plugins_load (cfg); | 825 | GPI_plugins_load (cfg); |
763 | pic = GNUNET_PEERINFO_iterate (peerinfo, include_friend_only, &my_peer_identity, | 826 | pic = GNUNET_PEERINFO_iterate (peerinfo, |
764 | TIMEOUT, &print_my_uri, NULL); | 827 | include_friend_only, |
828 | &my_peer_identity, | ||
829 | TIMEOUT, | ||
830 | &print_my_uri, NULL); | ||
765 | get_uri = GNUNET_NO; | 831 | get_uri = GNUNET_NO; |
766 | } | 832 | } |
767 | else if (NULL != dump_hello) | 833 | else if (NULL != dump_hello) |
768 | { | 834 | { |
769 | pic = GNUNET_PEERINFO_iterate (peerinfo, include_friend_only, &my_peer_identity, | 835 | pic = GNUNET_PEERINFO_iterate (peerinfo, |
770 | TIMEOUT, &dump_my_hello, NULL); | 836 | include_friend_only, |
837 | &my_peer_identity, | ||
838 | TIMEOUT, | ||
839 | &dump_my_hello, NULL); | ||
771 | } | 840 | } |
772 | else if (GNUNET_YES == default_operation) | 841 | else if (GNUNET_YES == default_operation) |
773 | { | 842 | { |
774 | /* default operation list all */ | 843 | /* default operation list all */ |
775 | default_operation = GNUNET_NO; | 844 | default_operation = GNUNET_NO; |
776 | get_info = GNUNET_YES; | 845 | get_info = GNUNET_YES; |
777 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); | 846 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); |
778 | } | 847 | } |
779 | else | 848 | else |
780 | { | 849 | { |
781 | GNUNET_SCHEDULER_shutdown (); | 850 | GNUNET_SCHEDULER_shutdown (); |
782 | } | 851 | } |
783 | default_operation = GNUNET_NO; | 852 | default_operation = GNUNET_NO; |
784 | } | 853 | } |
785 | 854 | ||
786 | 855 | ||
@@ -794,7 +863,6 @@ state_machine (void *cls, | |||
794 | int | 863 | int |
795 | main (int argc, char *const *argv) | 864 | main (int argc, char *const *argv) |
796 | { | 865 | { |
797 | default_operation = GNUNET_YES; | ||
798 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 866 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { |
799 | {'n', "numeric", NULL, | 867 | {'n', "numeric", NULL, |
800 | gettext_noop ("don't resolve host names"), | 868 | gettext_noop ("don't resolve host names"), |
@@ -824,7 +892,10 @@ main (int argc, char *const *argv) | |||
824 | }; | 892 | }; |
825 | int ret; | 893 | int ret; |
826 | 894 | ||
827 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 895 | default_operation = GNUNET_YES; |
896 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, | ||
897 | argv, | ||
898 | &argc, &argv)) | ||
828 | return 2; | 899 | return 2; |
829 | 900 | ||
830 | ret = (GNUNET_OK == | 901 | ret = (GNUNET_OK == |