diff options
Diffstat (limited to 'src/peerinfo-tool/gnunet-peerinfo.c')
-rw-r--r-- | src/peerinfo-tool/gnunet-peerinfo.c | 309 |
1 files changed, 133 insertions, 176 deletions
diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c index 109416600..fdcaaba58 100644 --- a/src/peerinfo-tool/gnunet-peerinfo.c +++ b/src/peerinfo-tool/gnunet-peerinfo.c | |||
@@ -114,7 +114,6 @@ struct PrintContext | |||
114 | * Hello was friend only, #GNUNET_YES or #GNUNET_NO | 114 | * Hello was friend only, #GNUNET_YES or #GNUNET_NO |
115 | */ | 115 | */ |
116 | int friend_only; | 116 | int friend_only; |
117 | |||
118 | }; | 117 | }; |
119 | 118 | ||
120 | 119 | ||
@@ -236,29 +235,26 @@ dump_pc (struct PrintContext *pc) | |||
236 | { | 235 | { |
237 | unsigned int i; | 236 | unsigned int i; |
238 | 237 | ||
239 | printf (_("%sPeer `%s'\n"), | 238 | printf (_ ("%sPeer `%s'\n"), |
240 | (GNUNET_YES == pc->friend_only) ? "F2F: " : "", | 239 | (GNUNET_YES == pc->friend_only) ? "F2F: " : "", |
241 | GNUNET_i2s_full (&pc->peer)); | 240 | GNUNET_i2s_full (&pc->peer)); |
242 | for (i = 0; i < pc->num_addresses; i++) | 241 | for (i = 0; i < pc->num_addresses; i++) |
243 | { | 242 | { |
244 | if (NULL != pc->address_list[i].result) | 243 | if (NULL != pc->address_list[i].result) |
245 | { | 244 | { |
246 | printf (_("\tExpires: %s \t %s\n"), | 245 | printf (_ ("\tExpires: %s \t %s\n"), |
247 | GNUNET_STRINGS_absolute_time_to_string (pc->address_list[i].expiration), | 246 | GNUNET_STRINGS_absolute_time_to_string ( |
247 | pc->address_list[i].expiration), | ||
248 | pc->address_list[i].result); | 248 | pc->address_list[i].result); |
249 | GNUNET_free (pc->address_list[i].result); | 249 | GNUNET_free (pc->address_list[i].result); |
250 | } | 250 | } |
251 | } | 251 | } |
252 | printf ("\n"); | 252 | printf ("\n"); |
253 | GNUNET_free_non_null (pc->address_list); | 253 | GNUNET_free_non_null (pc->address_list); |
254 | GNUNET_CONTAINER_DLL_remove (pc_head, | 254 | GNUNET_CONTAINER_DLL_remove (pc_head, pc_tail, pc); |
255 | pc_tail, | ||
256 | pc); | ||
257 | GNUNET_free (pc); | 255 | GNUNET_free (pc); |
258 | if ( (NULL == pc_head) && | 256 | if ((NULL == pc_head) && (NULL == pic)) |
259 | (NULL == pic) ) | 257 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); |
260 | tt = GNUNET_SCHEDULER_add_now (&state_machine, | ||
261 | NULL); | ||
262 | } | 258 | } |
263 | 259 | ||
264 | 260 | ||
@@ -276,9 +272,7 @@ dump_pc (struct PrintContext *pc) | |||
276 | * if #GNUNET_SYSERR: address is invalid | 272 | * if #GNUNET_SYSERR: address is invalid |
277 | */ | 273 | */ |
278 | static void | 274 | static void |
279 | process_resolved_address (void *cls, | 275 | process_resolved_address (void *cls, const char *address, int res) |
280 | const char *address, | ||
281 | int res) | ||
282 | { | 276 | { |
283 | struct AddressRecord *ar = cls; | 277 | struct AddressRecord *ar = cls; |
284 | struct PrintContext *pc = ar->pc; | 278 | struct PrintContext *pc = ar->pc; |
@@ -296,7 +290,7 @@ process_resolved_address (void *cls, | |||
296 | ar->atsc = NULL; | 290 | ar->atsc = NULL; |
297 | if (GNUNET_SYSERR == res) | 291 | if (GNUNET_SYSERR == res) |
298 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 292 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
299 | _("Failure: Cannot convert address to string for peer `%s'\n"), | 293 | _ ("Failure: Cannot convert address to string for peer `%s'\n"), |
300 | GNUNET_i2s (&ar->pc->peer)); | 294 | GNUNET_i2s (&ar->pc->peer)); |
301 | pc->num_addresses++; | 295 | pc->num_addresses++; |
302 | if (pc->num_addresses == pc->address_list_size) | 296 | if (pc->num_addresses == pc->address_list_size) |
@@ -352,8 +346,9 @@ print_address (void *cls, | |||
352 | ar->atsc = GNUNET_TRANSPORT_address_to_string (cfg, | 346 | ar->atsc = GNUNET_TRANSPORT_address_to_string (cfg, |
353 | address, | 347 | address, |
354 | no_resolve, | 348 | no_resolve, |
355 | TIMEOUT, | 349 | TIMEOUT, |
356 | &process_resolved_address, ar); | 350 | &process_resolved_address, |
351 | ar); | ||
357 | return GNUNET_OK; | 352 | return GNUNET_OK; |
358 | } | 353 | } |
359 | 354 | ||
@@ -381,9 +376,9 @@ print_peer_info (void *cls, | |||
381 | pic = NULL; /* end of iteration */ | 376 | pic = NULL; /* end of iteration */ |
382 | if (NULL != err_msg) | 377 | if (NULL != err_msg) |
383 | { | 378 | { |
384 | FPRINTF (stderr, | 379 | fprintf (stderr, |
385 | _("Error in communication with PEERINFO service: %s\n"), | 380 | _ ("Error in communication with PEERINFO service: %s\n"), |
386 | err_msg); | 381 | err_msg); |
387 | } | 382 | } |
388 | if (NULL == pc_head) | 383 | if (NULL == pc_head) |
389 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); | 384 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); |
@@ -391,25 +386,19 @@ print_peer_info (void *cls, | |||
391 | } | 386 | } |
392 | friend_only = GNUNET_NO; | 387 | friend_only = GNUNET_NO; |
393 | if (NULL != hello) | 388 | if (NULL != hello) |
394 | friend_only = GNUNET_HELLO_is_friend_only (hello); | 389 | friend_only = GNUNET_HELLO_is_friend_only (hello); |
395 | if ( (GNUNET_YES == be_quiet) || | 390 | if ((GNUNET_YES == be_quiet) || (NULL == hello)) |
396 | (NULL == hello) ) | ||
397 | { | 391 | { |
398 | printf ("%s%s\n", | 392 | printf ("%s%s\n", |
399 | (GNUNET_YES == friend_only) ? "F2F: " : "", | 393 | (GNUNET_YES == friend_only) ? "F2F: " : "", |
400 | GNUNET_i2s_full (peer)); | 394 | GNUNET_i2s_full (peer)); |
401 | return; | 395 | return; |
402 | } | 396 | } |
403 | pc = GNUNET_new (struct PrintContext); | 397 | pc = GNUNET_new (struct PrintContext); |
404 | GNUNET_CONTAINER_DLL_insert (pc_head, | 398 | GNUNET_CONTAINER_DLL_insert (pc_head, pc_tail, pc); |
405 | pc_tail, | ||
406 | pc); | ||
407 | pc->peer = *peer; | 399 | pc->peer = *peer; |
408 | pc->friend_only = friend_only; | 400 | pc->friend_only = friend_only; |
409 | GNUNET_HELLO_iterate_addresses (hello, | 401 | GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &count_address, pc); |
410 | GNUNET_NO, | ||
411 | &count_address, | ||
412 | pc); | ||
413 | if (0 == pc->off) | 402 | if (0 == pc->off) |
414 | { | 403 | { |
415 | dump_pc (pc); | 404 | dump_pc (pc); |
@@ -417,10 +406,7 @@ print_peer_info (void *cls, | |||
417 | } | 406 | } |
418 | pc->address_list_size = pc->off; | 407 | pc->address_list_size = pc->off; |
419 | pc->address_list = GNUNET_malloc (sizeof (struct AddressRecord) * pc->off); | 408 | pc->address_list = GNUNET_malloc (sizeof (struct AddressRecord) * pc->off); |
420 | GNUNET_HELLO_iterate_addresses (hello, | 409 | GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &print_address, pc); |
421 | GNUNET_NO, | ||
422 | &print_address, | ||
423 | pc); | ||
424 | } | 410 | } |
425 | 411 | ||
426 | /* ************************* DUMP Hello ************************** */ | 412 | /* ************************* DUMP Hello ************************** */ |
@@ -462,45 +448,40 @@ dump_my_hello () | |||
462 | size = GNUNET_HELLO_size (my_hello); | 448 | size = GNUNET_HELLO_size (my_hello); |
463 | if (0 == size) | 449 | if (0 == size) |
464 | { | 450 | { |
465 | FPRINTF (stderr, | 451 | fprintf (stderr, _ ("Failure: Received invalid %s\n"), "HELLO"); |
466 | _("Failure: Received invalid %s\n"), | ||
467 | "HELLO"); | ||
468 | return; | 452 | return; |
469 | } | 453 | } |
470 | if (GNUNET_SYSERR == | 454 | if (GNUNET_SYSERR == GNUNET_DISK_fn_write (dump_hello, |
471 | GNUNET_DISK_fn_write (dump_hello, | 455 | my_hello, |
472 | my_hello, | 456 | size, |
473 | size, | 457 | GNUNET_DISK_PERM_USER_READ | |
474 | GNUNET_DISK_PERM_USER_READ | | 458 | GNUNET_DISK_PERM_USER_WRITE | |
475 | GNUNET_DISK_PERM_USER_WRITE | | 459 | GNUNET_DISK_PERM_GROUP_READ | |
476 | GNUNET_DISK_PERM_GROUP_READ | | 460 | GNUNET_DISK_PERM_OTHER_READ)) |
477 | GNUNET_DISK_PERM_OTHER_READ)) | ||
478 | { | 461 | { |
479 | FPRINTF (stderr, | 462 | fprintf (stderr, |
480 | _("Failed to write HELLO with %u bytes to file `%s'\n"), | 463 | _ ("Failed to write HELLO with %u bytes to file `%s'\n"), |
481 | size, | 464 | size, |
482 | dump_hello); | 465 | dump_hello); |
483 | if (0 != UNLINK (dump_hello)) | 466 | if (0 != unlink (dump_hello)) |
484 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING | | 467 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING | |
485 | GNUNET_ERROR_TYPE_BULK, | 468 | GNUNET_ERROR_TYPE_BULK, |
486 | "unlink", | 469 | "unlink", |
487 | dump_hello); | 470 | dump_hello); |
488 | |||
489 | } | 471 | } |
490 | c_addr = 0; | 472 | c_addr = 0; |
491 | GNUNET_HELLO_iterate_addresses (my_hello, | 473 | GNUNET_HELLO_iterate_addresses (my_hello, GNUNET_NO, count_addr, &c_addr); |
492 | GNUNET_NO, | ||
493 | count_addr, | ||
494 | &c_addr); | ||
495 | 474 | ||
496 | if (! be_quiet) | 475 | if (! be_quiet) |
497 | { | 476 | { |
498 | FPRINTF (stderr, | 477 | fprintf ( |
499 | _("Wrote %s HELLO containing %u addresses with %u bytes to file `%s'\n"), | 478 | stderr, |
500 | (GNUNET_YES == GNUNET_HELLO_is_friend_only (my_hello)) ? "friend-only": "public", | 479 | _ ("Wrote %s HELLO containing %u addresses with %u bytes to file `%s'\n"), |
501 | c_addr, | 480 | (GNUNET_YES == GNUNET_HELLO_is_friend_only (my_hello)) ? "friend-only" |
502 | size, | 481 | : "public", |
503 | dump_hello); | 482 | c_addr, |
483 | size, | ||
484 | dump_hello); | ||
504 | } | 485 | } |
505 | GNUNET_free (dump_hello); | 486 | GNUNET_free (dump_hello); |
506 | dump_hello = NULL; | 487 | dump_hello = NULL; |
@@ -522,7 +503,7 @@ static void | |||
522 | print_my_uri (void *cls, | 503 | print_my_uri (void *cls, |
523 | const struct GNUNET_PeerIdentity *peer, | 504 | const struct GNUNET_PeerIdentity *peer, |
524 | const struct GNUNET_HELLO_Message *hello, | 505 | const struct GNUNET_HELLO_Message *hello, |
525 | const char *err_msg) | 506 | const char *err_msg) |
526 | { | 507 | { |
527 | char *uri; | 508 | char *uri; |
528 | 509 | ||
@@ -530,21 +511,19 @@ print_my_uri (void *cls, | |||
530 | { | 511 | { |
531 | pic = NULL; | 512 | pic = NULL; |
532 | if (NULL != err_msg) | 513 | if (NULL != err_msg) |
533 | FPRINTF (stderr, | 514 | fprintf (stderr, |
534 | _("Error in communication with PEERINFO service: %s\n"), | 515 | _ ("Error in communication with PEERINFO service: %s\n"), |
535 | err_msg); | 516 | err_msg); |
536 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); | 517 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); |
537 | return; | 518 | return; |
538 | } | 519 | } |
539 | 520 | ||
540 | if (NULL == hello) | 521 | if (NULL == hello) |
541 | return; | 522 | return; |
542 | uri = GNUNET_HELLO_compose_uri (hello, | 523 | uri = GNUNET_HELLO_compose_uri (hello, &GPI_plugins_find); |
543 | &GPI_plugins_find); | ||
544 | if (NULL != uri) | 524 | if (NULL != uri) |
545 | { | 525 | { |
546 | printf ("%s\n", | 526 | printf ("%s\n", (const char *) uri); |
547 | (const char *) uri); | ||
548 | GNUNET_free (uri); | 527 | GNUNET_free (uri); |
549 | } | 528 | } |
550 | } | 529 | } |
@@ -589,10 +568,7 @@ parse_hello_uri (const char *put_uri) | |||
589 | { | 568 | { |
590 | /* WARNING: this adds the address from URI WITHOUT verification! */ | 569 | /* WARNING: this adds the address from URI WITHOUT verification! */ |
591 | if (GNUNET_OK == ret) | 570 | if (GNUNET_OK == ret) |
592 | ac = GNUNET_PEERINFO_add_peer (peerinfo, | 571 | ac = GNUNET_PEERINFO_add_peer (peerinfo, hello, &add_continuation, NULL); |
593 | hello, | ||
594 | &add_continuation, | ||
595 | NULL); | ||
596 | else | 572 | else |
597 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); | 573 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); |
598 | GNUNET_free (hello); | 574 | GNUNET_free (hello); |
@@ -639,17 +615,15 @@ shutdown_task (void *cls) | |||
639 | } | 615 | } |
640 | while (NULL != (pc = pc_head)) | 616 | while (NULL != (pc = pc_head)) |
641 | { | 617 | { |
642 | GNUNET_CONTAINER_DLL_remove (pc_head, | 618 | GNUNET_CONTAINER_DLL_remove (pc_head, pc_tail, pc); |
643 | pc_tail, | 619 | for (i = 0; i < pc->address_list_size; i++) |
644 | pc); | ||
645 | for (i=0;i<pc->address_list_size;i++) | ||
646 | { | 620 | { |
647 | ar = &pc->address_list[i]; | 621 | ar = &pc->address_list[i]; |
648 | GNUNET_free_non_null (ar->result); | 622 | GNUNET_free_non_null (ar->result); |
649 | if (NULL != ar->atsc) | 623 | if (NULL != ar->atsc) |
650 | { | 624 | { |
651 | GNUNET_TRANSPORT_address_to_string_cancel (ar->atsc); | 625 | GNUNET_TRANSPORT_address_to_string_cancel (ar->atsc); |
652 | ar->atsc = NULL; | 626 | ar->atsc = NULL; |
653 | } | 627 | } |
654 | } | 628 | } |
655 | GNUNET_free_non_null (pc->address_list); | 629 | GNUNET_free_non_null (pc->address_list); |
@@ -677,20 +651,17 @@ shutdown_task (void *cls) | |||
677 | * @param hello the HELLO message | 651 | * @param hello the HELLO message |
678 | */ | 652 | */ |
679 | static void | 653 | static void |
680 | hello_callback (void *cls, | 654 | hello_callback (void *cls, const struct GNUNET_MessageHeader *hello) |
681 | const struct GNUNET_MessageHeader *hello) | ||
682 | { | 655 | { |
683 | if (NULL == hello) | 656 | if (NULL == hello) |
684 | { | 657 | { |
685 | fprintf (stderr, | 658 | fprintf (stderr, "Failed to get my own HELLO from this peer!\n"); |
686 | "Failed to get my own HELLO from this peer!\n"); | ||
687 | GNUNET_SCHEDULER_shutdown (); | 659 | GNUNET_SCHEDULER_shutdown (); |
688 | return; | 660 | return; |
689 | } | 661 | } |
690 | my_hello = (struct GNUNET_HELLO_Message *) GNUNET_copy_message (hello); | 662 | my_hello = (struct GNUNET_HELLO_Message *) GNUNET_copy_message (hello); |
691 | GNUNET_assert (GNUNET_OK == | 663 | GNUNET_assert (GNUNET_OK == |
692 | GNUNET_HELLO_get_id (my_hello, | 664 | GNUNET_HELLO_get_id (my_hello, &my_peer_identity)); |
693 | &my_peer_identity)); | ||
694 | GNUNET_TRANSPORT_hello_get_cancel (gh); | 665 | GNUNET_TRANSPORT_hello_get_cancel (gh); |
695 | gh = NULL; | 666 | gh = NULL; |
696 | if (NULL != dump_hello) | 667 | if (NULL != dump_hello) |
@@ -714,44 +685,35 @@ run (void *cls, | |||
714 | const struct GNUNET_CONFIGURATION_Handle *c) | 685 | const struct GNUNET_CONFIGURATION_Handle *c) |
715 | { | 686 | { |
716 | cfg = c; | 687 | cfg = c; |
717 | if ( (NULL != args[0]) && | 688 | if ((NULL != args[0]) && (NULL == put_uri) && |
718 | (NULL == put_uri) && | 689 | (args[0] == strcasestr (args[0], "gnunet://hello/"))) |
719 | (args[0] == strcasestr (args[0], | ||
720 | "gnunet://hello/")) ) | ||
721 | { | 690 | { |
722 | put_uri = GNUNET_strdup (args[0]); | 691 | put_uri = GNUNET_strdup (args[0]); |
723 | args++; | 692 | args++; |
724 | } | 693 | } |
725 | if (NULL != args[0]) | 694 | if (NULL != args[0]) |
726 | { | 695 | { |
727 | FPRINTF (stderr, | 696 | fprintf (stderr, _ ("Invalid command line argument `%s'\n"), args[0]); |
728 | _("Invalid command line argument `%s'\n"), | ||
729 | args[0]); | ||
730 | return; | 697 | return; |
731 | } | 698 | } |
732 | if (NULL == (peerinfo = GNUNET_PEERINFO_connect (cfg))) | 699 | if (NULL == (peerinfo = GNUNET_PEERINFO_connect (cfg))) |
733 | { | 700 | { |
734 | FPRINTF (stderr, | 701 | fprintf (stderr, "%s", "Could not access PEERINFO service. Exiting.\n"); |
735 | "%s", | ||
736 | "Could not access PEERINFO service. Exiting.\n"); | ||
737 | return; | 702 | return; |
738 | } | 703 | } |
739 | if ( (GNUNET_YES == get_self) || | 704 | if ((GNUNET_YES == get_self) || (GNUNET_YES == get_uri) || |
740 | (GNUNET_YES == get_uri) || | 705 | (NULL != dump_hello)) |
741 | (NULL != dump_hello) ) | ||
742 | { | 706 | { |
743 | gh = GNUNET_TRANSPORT_hello_get (cfg, | 707 | gh = GNUNET_TRANSPORT_hello_get (cfg, |
744 | GNUNET_TRANSPORT_AC_ANY, | 708 | GNUNET_TRANSPORT_AC_ANY, |
745 | &hello_callback, | 709 | &hello_callback, |
746 | NULL); | 710 | NULL); |
747 | } | 711 | } |
748 | else | 712 | else |
749 | { | 713 | { |
750 | tt = GNUNET_SCHEDULER_add_now (&state_machine, | 714 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); |
751 | NULL); | ||
752 | } | 715 | } |
753 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | 716 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
754 | NULL); | ||
755 | } | 717 | } |
756 | 718 | ||
757 | 719 | ||
@@ -771,9 +733,7 @@ state_machine (void *cls) | |||
771 | GPI_plugins_load (cfg); | 733 | GPI_plugins_load (cfg); |
772 | if (GNUNET_SYSERR == parse_hello_uri (put_uri)) | 734 | if (GNUNET_SYSERR == parse_hello_uri (put_uri)) |
773 | { | 735 | { |
774 | fprintf (stderr, | 736 | fprintf (stderr, _ ("Invalid URI `%s'\n"), put_uri); |
775 | _("Invalid URI `%s'\n"), | ||
776 | put_uri); | ||
777 | GNUNET_SCHEDULER_shutdown (); | 737 | GNUNET_SCHEDULER_shutdown (); |
778 | } | 738 | } |
779 | GNUNET_free (put_uri); | 739 | GNUNET_free (put_uri); |
@@ -786,20 +746,17 @@ state_machine (void *cls) | |||
786 | pic = GNUNET_PEERINFO_iterate (peerinfo, | 746 | pic = GNUNET_PEERINFO_iterate (peerinfo, |
787 | include_friend_only, | 747 | include_friend_only, |
788 | NULL, | 748 | NULL, |
789 | &print_peer_info, | 749 | &print_peer_info, |
790 | NULL); | 750 | NULL); |
791 | } | 751 | } |
792 | else if (GNUNET_YES == get_self) | 752 | else if (GNUNET_YES == get_self) |
793 | { | 753 | { |
794 | get_self = GNUNET_NO; | 754 | get_self = GNUNET_NO; |
795 | if (be_quiet) | 755 | if (be_quiet) |
796 | printf ("%s\n", | 756 | printf ("%s\n", GNUNET_i2s_full (&my_peer_identity)); |
797 | GNUNET_i2s_full (&my_peer_identity)); | ||
798 | else | 757 | else |
799 | printf (_("I am peer `%s'.\n"), | 758 | printf (_ ("I am peer `%s'.\n"), GNUNET_i2s_full (&my_peer_identity)); |
800 | GNUNET_i2s_full (&my_peer_identity)); | 759 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); |
801 | tt = GNUNET_SCHEDULER_add_now (&state_machine, | ||
802 | NULL); | ||
803 | } | 760 | } |
804 | else if (GNUNET_YES == get_uri) | 761 | else if (GNUNET_YES == get_uri) |
805 | { | 762 | { |
@@ -808,7 +765,7 @@ state_machine (void *cls) | |||
808 | include_friend_only, | 765 | include_friend_only, |
809 | &my_peer_identity, | 766 | &my_peer_identity, |
810 | &print_my_uri, | 767 | &print_my_uri, |
811 | NULL); | 768 | NULL); |
812 | get_uri = GNUNET_NO; | 769 | get_uri = GNUNET_NO; |
813 | } | 770 | } |
814 | else if (GNUNET_YES == default_operation) | 771 | else if (GNUNET_YES == default_operation) |
@@ -816,8 +773,7 @@ state_machine (void *cls) | |||
816 | /* default operation list all */ | 773 | /* default operation list all */ |
817 | default_operation = GNUNET_NO; | 774 | default_operation = GNUNET_NO; |
818 | get_info = GNUNET_YES; | 775 | get_info = GNUNET_YES; |
819 | tt = GNUNET_SCHEDULER_add_now (&state_machine, | 776 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); |
820 | NULL); | ||
821 | } | 777 | } |
822 | else | 778 | else |
823 | { | 779 | { |
@@ -837,68 +793,69 @@ state_machine (void *cls) | |||
837 | int | 793 | int |
838 | main (int argc, char *const *argv) | 794 | main (int argc, char *const *argv) |
839 | { | 795 | { |
840 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 796 | struct GNUNET_GETOPT_CommandLineOption options[] = |
841 | GNUNET_GETOPT_option_flag ('n', | 797 | {GNUNET_GETOPT_option_flag ('n', |
842 | "numeric", | 798 | "numeric", |
843 | gettext_noop ("don't resolve host names"), | 799 | gettext_noop ("don't resolve host names"), |
844 | &no_resolve), | 800 | &no_resolve), |
845 | 801 | ||
846 | GNUNET_GETOPT_option_flag ('q', | 802 | GNUNET_GETOPT_option_flag ('q', |
847 | "quiet", | 803 | "quiet", |
848 | gettext_noop ("output only the identity strings"), | 804 | gettext_noop ( |
849 | &be_quiet), | 805 | "output only the identity strings"), |
850 | GNUNET_GETOPT_option_flag ('f', | 806 | &be_quiet), |
851 | "friends", | 807 | GNUNET_GETOPT_option_flag ('f', |
852 | gettext_noop ("include friend-only information"), | 808 | "friends", |
853 | &include_friend_only), | 809 | gettext_noop ( |
854 | 810 | "include friend-only information"), | |
855 | GNUNET_GETOPT_option_flag ('s', | 811 | &include_friend_only), |
856 | "self", | 812 | |
857 | gettext_noop ("output our own identity only"), | 813 | GNUNET_GETOPT_option_flag ('s', |
858 | &get_self), | 814 | "self", |
859 | 815 | gettext_noop ("output our own identity only"), | |
860 | GNUNET_GETOPT_option_flag ('i', | 816 | &get_self), |
861 | "info", | 817 | |
862 | gettext_noop ("list all known peers"), | 818 | GNUNET_GETOPT_option_flag ('i', |
863 | &get_info), | 819 | "info", |
864 | 820 | gettext_noop ("list all known peers"), | |
865 | GNUNET_GETOPT_option_string ('d', | 821 | &get_info), |
866 | "dump-hello", | 822 | |
867 | NULL, | 823 | GNUNET_GETOPT_option_string ('d', |
868 | gettext_noop ("dump hello to file"), | 824 | "dump-hello", |
869 | &dump_hello), | 825 | NULL, |
870 | 826 | gettext_noop ("dump hello to file"), | |
871 | GNUNET_GETOPT_option_flag ('g', | 827 | &dump_hello), |
872 | "get-hello", | 828 | |
873 | gettext_noop ("also output HELLO uri(s)"), | 829 | GNUNET_GETOPT_option_flag ('g', |
874 | &get_uri), | 830 | "get-hello", |
875 | 831 | gettext_noop ("also output HELLO uri(s)"), | |
876 | GNUNET_GETOPT_option_string ('p', | 832 | &get_uri), |
877 | "put-hello", | 833 | |
878 | "HELLO", | 834 | GNUNET_GETOPT_option_string ('p', |
879 | gettext_noop ("add given HELLO uri to the database"), | 835 | "put-hello", |
880 | &put_uri), | 836 | "HELLO", |
881 | 837 | gettext_noop ( | |
882 | GNUNET_GETOPT_OPTION_END | 838 | "add given HELLO uri to the database"), |
883 | }; | 839 | &put_uri), |
840 | |||
841 | GNUNET_GETOPT_OPTION_END}; | ||
884 | int ret; | 842 | int ret; |
885 | 843 | ||
886 | default_operation = GNUNET_YES; | 844 | default_operation = GNUNET_YES; |
887 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, | 845 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
888 | argv, | ||
889 | &argc, | ||
890 | &argv)) | ||
891 | return 2; | 846 | return 2; |
892 | 847 | ||
893 | ret = (GNUNET_OK == | 848 | ret = (GNUNET_OK == |
894 | GNUNET_PROGRAM_run (argc, | 849 | GNUNET_PROGRAM_run (argc, |
895 | argv, | 850 | argv, |
896 | "gnunet-peerinfo", | 851 | "gnunet-peerinfo", |
897 | gettext_noop ("Print information about peers."), | 852 | gettext_noop ("Print information about peers."), |
898 | options, | 853 | options, |
899 | &run, | 854 | &run, |
900 | NULL)) ? 0 : 1; | 855 | NULL)) |
901 | GNUNET_free ((void*) argv); | 856 | ? 0 |
857 | : 1; | ||
858 | GNUNET_free ((void *) argv); | ||
902 | return ret; | 859 | return ret; |
903 | } | 860 | } |
904 | 861 | ||