diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-07-30 17:19:11 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-07-30 17:19:11 +0000 |
commit | fc0a7982cd82e6f1915589a89c61dbe9d58aedb3 (patch) | |
tree | cf06b2a01142e5a0beff68291f0702004fa56265 /src/peerinfo-tool | |
parent | 48aec5c799d171609d8ae4918d0b8acbdfbb2bbc (diff) | |
download | gnunet-fc0a7982cd82e6f1915589a89c61dbe9d58aedb3.tar.gz gnunet-fc0a7982cd82e6f1915589a89c61dbe9d58aedb3.zip |
conver to new hello_get API
Diffstat (limited to 'src/peerinfo-tool')
-rw-r--r-- | src/peerinfo-tool/gnunet-peerinfo.c | 56 |
1 files changed, 35 insertions, 21 deletions
diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c index 14f1e4604..67590d2a8 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 | Copyright (C) 2001-2014 GNUnet e.V. | 3 | Copyright (C) 2001-2014, 2016 GNUnet e.V. |
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 |
@@ -28,6 +28,7 @@ | |||
28 | #include "gnunet_util_lib.h" | 28 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_hello_lib.h" | 29 | #include "gnunet_hello_lib.h" |
30 | #include "gnunet_transport_service.h" | 30 | #include "gnunet_transport_service.h" |
31 | #include "gnunet_transport_hello_service.h" | ||
31 | #include "gnunet_peerinfo_service.h" | 32 | #include "gnunet_peerinfo_service.h" |
32 | #include "gnunet-peerinfo_plugins.h" | 33 | #include "gnunet-peerinfo_plugins.h" |
33 | 34 | ||
@@ -175,12 +176,12 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg; | |||
175 | /** | 176 | /** |
176 | * Main state machine task (if active). | 177 | * Main state machine task (if active). |
177 | */ | 178 | */ |
178 | static struct GNUNET_SCHEDULER_Task * tt; | 179 | static struct GNUNET_SCHEDULER_Task *tt; |
179 | 180 | ||
180 | /** | 181 | /** |
181 | * Pending #GNUNET_TRANSPORT_get_hello() operation. | 182 | * Pending #GNUNET_TRANSPORT_hello_get() operation. |
182 | */ | 183 | */ |
183 | static struct GNUNET_TRANSPORT_GetHelloHandle *gh; | 184 | static struct GNUNET_TRANSPORT_HelloGetHandle *gh; |
184 | 185 | ||
185 | /** | 186 | /** |
186 | * Current iterator context (if active, otherwise NULL). | 187 | * Current iterator context (if active, otherwise NULL). |
@@ -439,7 +440,7 @@ count_addr (void *cls, | |||
439 | { | 440 | { |
440 | int *c = cls; | 441 | int *c = cls; |
441 | 442 | ||
442 | (*c) ++; | 443 | (*c)++; |
443 | return GNUNET_OK; | 444 | return GNUNET_OK; |
444 | } | 445 | } |
445 | 446 | ||
@@ -633,7 +634,7 @@ shutdown_task (void *cls) | |||
633 | } | 634 | } |
634 | if (NULL != gh) | 635 | if (NULL != gh) |
635 | { | 636 | { |
636 | GNUNET_TRANSPORT_get_hello_cancel (gh); | 637 | GNUNET_TRANSPORT_hello_get_cancel (gh); |
637 | gh = NULL; | 638 | gh = NULL; |
638 | } | 639 | } |
639 | while (NULL != (pc = pc_head)) | 640 | while (NULL != (pc = pc_head)) |
@@ -682,7 +683,7 @@ hello_callback (void *cls, | |||
682 | if (NULL == hello) | 683 | if (NULL == hello) |
683 | { | 684 | { |
684 | fprintf (stderr, | 685 | fprintf (stderr, |
685 | _("Failed to get my own HELLO from this peer!\n")); | 686 | "Failed to get my own HELLO from this peer!\n"); |
686 | GNUNET_SCHEDULER_shutdown (); | 687 | GNUNET_SCHEDULER_shutdown (); |
687 | return; | 688 | return; |
688 | } | 689 | } |
@@ -690,7 +691,7 @@ hello_callback (void *cls, | |||
690 | GNUNET_assert (GNUNET_OK == | 691 | GNUNET_assert (GNUNET_OK == |
691 | GNUNET_HELLO_get_id (my_hello, | 692 | GNUNET_HELLO_get_id (my_hello, |
692 | &my_peer_identity)); | 693 | &my_peer_identity)); |
693 | GNUNET_TRANSPORT_get_hello_cancel (gh); | 694 | GNUNET_TRANSPORT_hello_get_cancel (gh); |
694 | gh = NULL; | 695 | gh = NULL; |
695 | if (NULL != dump_hello) | 696 | if (NULL != dump_hello) |
696 | dump_my_hello (); | 697 | dump_my_hello (); |
@@ -712,7 +713,7 @@ testservice_task (void *cls, | |||
712 | if (GNUNET_YES != result) | 713 | if (GNUNET_YES != result) |
713 | { | 714 | { |
714 | FPRINTF (stderr, | 715 | FPRINTF (stderr, |
715 | _("Service `%s' is not running, please start GNUnet\n"), | 716 | "Service `%s' is not running, please start GNUnet\n", |
716 | "peerinfo"); | 717 | "peerinfo"); |
717 | return; | 718 | return; |
718 | } | 719 | } |
@@ -721,20 +722,22 @@ testservice_task (void *cls, | |||
721 | { | 722 | { |
722 | FPRINTF (stderr, | 723 | FPRINTF (stderr, |
723 | "%s", | 724 | "%s", |
724 | _("Could not access PEERINFO service. Exiting.\n")); | 725 | "Could not access PEERINFO service. Exiting.\n"); |
725 | return; | 726 | return; |
726 | } | 727 | } |
727 | if ( (GNUNET_YES == get_self) || | 728 | if ( (GNUNET_YES == get_self) || |
728 | (GNUNET_YES == get_uri) || | 729 | (GNUNET_YES == get_uri) || |
729 | (NULL != dump_hello) ) | 730 | (NULL != dump_hello) ) |
730 | { | 731 | { |
731 | gh = GNUNET_TRANSPORT_get_hello (cfg, | 732 | gh = GNUNET_TRANSPORT_hello_get (cfg, |
733 | GNUNET_TRANSPORT_AC_ANY, | ||
732 | &hello_callback, | 734 | &hello_callback, |
733 | NULL); | 735 | NULL); |
734 | } | 736 | } |
735 | else | 737 | else |
736 | { | 738 | { |
737 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); | 739 | tt = GNUNET_SCHEDULER_add_now (&state_machine, |
740 | NULL); | ||
738 | } | 741 | } |
739 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | 742 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
740 | NULL); | 743 | NULL); |
@@ -758,7 +761,8 @@ run (void *cls, | |||
758 | cfg = c; | 761 | cfg = c; |
759 | if ( (NULL != args[0]) && | 762 | if ( (NULL != args[0]) && |
760 | (NULL == put_uri) && | 763 | (NULL == put_uri) && |
761 | (args[0] == strcasestr (args[0], "gnunet://hello/")) ) | 764 | (args[0] == strcasestr (args[0], |
765 | "gnunet://hello/")) ) | ||
762 | { | 766 | { |
763 | put_uri = GNUNET_strdup (args[0]); | 767 | put_uri = GNUNET_strdup (args[0]); |
764 | args++; | 768 | args++; |
@@ -774,7 +778,8 @@ run (void *cls, | |||
774 | GNUNET_CLIENT_service_test ("peerinfo", | 778 | GNUNET_CLIENT_service_test ("peerinfo", |
775 | cfg, | 779 | cfg, |
776 | GNUNET_TIME_UNIT_SECONDS, | 780 | GNUNET_TIME_UNIT_SECONDS, |
777 | &testservice_task, (void *) cfg); | 781 | &testservice_task, |
782 | (void *) cfg); | ||
778 | } | 783 | } |
779 | 784 | ||
780 | 785 | ||
@@ -809,7 +814,8 @@ state_machine (void *cls) | |||
809 | pic = GNUNET_PEERINFO_iterate (peerinfo, | 814 | pic = GNUNET_PEERINFO_iterate (peerinfo, |
810 | include_friend_only, | 815 | include_friend_only, |
811 | NULL, | 816 | NULL, |
812 | &print_peer_info, NULL); | 817 | &print_peer_info, |
818 | NULL); | ||
813 | } | 819 | } |
814 | else if (GNUNET_YES == get_self) | 820 | else if (GNUNET_YES == get_self) |
815 | { | 821 | { |
@@ -820,7 +826,8 @@ state_machine (void *cls) | |||
820 | else | 826 | else |
821 | printf (_("I am peer `%s'.\n"), | 827 | printf (_("I am peer `%s'.\n"), |
822 | GNUNET_i2s_full (&my_peer_identity)); | 828 | GNUNET_i2s_full (&my_peer_identity)); |
823 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); | 829 | tt = GNUNET_SCHEDULER_add_now (&state_machine, |
830 | NULL); | ||
824 | } | 831 | } |
825 | else if (GNUNET_YES == get_uri) | 832 | else if (GNUNET_YES == get_uri) |
826 | { | 833 | { |
@@ -828,7 +835,8 @@ state_machine (void *cls) | |||
828 | pic = GNUNET_PEERINFO_iterate (peerinfo, | 835 | pic = GNUNET_PEERINFO_iterate (peerinfo, |
829 | include_friend_only, | 836 | include_friend_only, |
830 | &my_peer_identity, | 837 | &my_peer_identity, |
831 | &print_my_uri, NULL); | 838 | &print_my_uri, |
839 | NULL); | ||
832 | get_uri = GNUNET_NO; | 840 | get_uri = GNUNET_NO; |
833 | } | 841 | } |
834 | else if (GNUNET_YES == default_operation) | 842 | else if (GNUNET_YES == default_operation) |
@@ -836,7 +844,8 @@ state_machine (void *cls) | |||
836 | /* default operation list all */ | 844 | /* default operation list all */ |
837 | default_operation = GNUNET_NO; | 845 | default_operation = GNUNET_NO; |
838 | get_info = GNUNET_YES; | 846 | get_info = GNUNET_YES; |
839 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); | 847 | tt = GNUNET_SCHEDULER_add_now (&state_machine, |
848 | NULL); | ||
840 | } | 849 | } |
841 | else | 850 | else |
842 | { | 851 | { |
@@ -888,13 +897,18 @@ main (int argc, char *const *argv) | |||
888 | default_operation = GNUNET_YES; | 897 | default_operation = GNUNET_YES; |
889 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, | 898 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, |
890 | argv, | 899 | argv, |
891 | &argc, &argv)) | 900 | &argc, |
901 | &argv)) | ||
892 | return 2; | 902 | return 2; |
893 | 903 | ||
894 | ret = (GNUNET_OK == | 904 | ret = (GNUNET_OK == |
895 | GNUNET_PROGRAM_run (argc, argv, "gnunet-peerinfo", | 905 | GNUNET_PROGRAM_run (argc, |
906 | argv, | ||
907 | "gnunet-peerinfo", | ||
896 | gettext_noop ("Print information about peers."), | 908 | gettext_noop ("Print information about peers."), |
897 | options, &run, NULL)) ? 0 : 1; | 909 | options, |
910 | &run, | ||
911 | NULL)) ? 0 : 1; | ||
898 | GNUNET_free ((void*) argv); | 912 | GNUNET_free ((void*) argv); |
899 | return ret; | 913 | return ret; |
900 | } | 914 | } |