diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-04-04 12:02:43 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-04-04 12:02:43 +0000 |
commit | 425e9cdea733ca7be9a901abff7a070c460fa84d (patch) | |
tree | c4e2919e2f4183a324801c061fb2d57a3b232ddc /src/peerinfo-tool | |
parent | 6713f0ce7d70cdb5cb0172157e647b8dfb6852ff (diff) | |
download | gnunet-425e9cdea733ca7be9a901abff7a070c460fa84d.tar.gz gnunet-425e9cdea733ca7be9a901abff7a070c460fa84d.zip |
peerinfo API change + changes in code using api
Diffstat (limited to 'src/peerinfo-tool')
-rw-r--r-- | src/peerinfo-tool/gnunet-peerinfo.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c index 0cb434d89..39d6060c3 100644 --- a/src/peerinfo-tool/gnunet-peerinfo.c +++ b/src/peerinfo-tool/gnunet-peerinfo.c | |||
@@ -106,6 +106,11 @@ struct PrintContext | |||
106 | */ | 106 | */ |
107 | unsigned int off; | 107 | unsigned int off; |
108 | 108 | ||
109 | /** | ||
110 | * Hello was friend only, GNUNET_YES or GNUNET_NO | ||
111 | */ | ||
112 | int friend_only; | ||
113 | |||
109 | }; | 114 | }; |
110 | 115 | ||
111 | 116 | ||
@@ -120,6 +125,11 @@ static int no_resolve; | |||
120 | static int be_quiet; | 125 | static int be_quiet; |
121 | 126 | ||
122 | /** | 127 | /** |
128 | * Option '-f' | ||
129 | */ | ||
130 | static int include_friend_only; | ||
131 | |||
132 | /** | ||
123 | * Option '-s' | 133 | * Option '-s' |
124 | */ | 134 | */ |
125 | static int get_self; | 135 | static int get_self; |
@@ -211,7 +221,8 @@ dump_pc (struct PrintContext *pc) | |||
211 | unsigned int i; | 221 | unsigned int i; |
212 | 222 | ||
213 | GNUNET_CRYPTO_hash_to_enc (&pc->peer.hashPubKey, &enc); | 223 | GNUNET_CRYPTO_hash_to_enc (&pc->peer.hashPubKey, &enc); |
214 | printf (_("Peer `%s'\n"), | 224 | printf (_("%sPeer `%s'\n"), |
225 | (GNUNET_YES == pc->friend_only) ? "F2F: " : "", | ||
215 | (const char *) &enc); | 226 | (const char *) &enc); |
216 | for (i = 0; i < pc->num_addresses; i++) | 227 | for (i = 0; i < pc->num_addresses; i++) |
217 | { | 228 | { |
@@ -321,6 +332,7 @@ print_peer_info (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
321 | { | 332 | { |
322 | struct GNUNET_CRYPTO_HashAsciiEncoded enc; | 333 | struct GNUNET_CRYPTO_HashAsciiEncoded enc; |
323 | struct PrintContext *pc; | 334 | struct PrintContext *pc; |
335 | int friend_only; | ||
324 | 336 | ||
325 | if (NULL == peer) | 337 | if (NULL == peer) |
326 | { | 338 | { |
@@ -335,10 +347,13 @@ print_peer_info (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
335 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); | 347 | tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); |
336 | return; | 348 | return; |
337 | } | 349 | } |
350 | friend_only = GNUNET_HELLO_is_friend_only (hello); | ||
338 | if ((GNUNET_YES == be_quiet) || (NULL == hello)) | 351 | if ((GNUNET_YES == be_quiet) || (NULL == hello)) |
339 | { | 352 | { |
340 | GNUNET_CRYPTO_hash_to_enc (&peer->hashPubKey, &enc); | 353 | GNUNET_CRYPTO_hash_to_enc (&peer->hashPubKey, &enc); |
341 | printf ("%s\n", (const char *) &enc); | 354 | printf ("%s%s\n", |
355 | (GNUNET_YES == friend_only) ? "F2F: " : "", | ||
356 | (const char *) &enc); | ||
342 | return; | 357 | return; |
343 | } | 358 | } |
344 | pc = GNUNET_malloc (sizeof (struct PrintContext)); | 359 | pc = GNUNET_malloc (sizeof (struct PrintContext)); |
@@ -346,6 +361,7 @@ print_peer_info (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
346 | pc_tail, | 361 | pc_tail, |
347 | pc); | 362 | pc); |
348 | pc->peer = *peer; | 363 | pc->peer = *peer; |
364 | pc->friend_only = friend_only; | ||
349 | GNUNET_HELLO_iterate_addresses (hello, | 365 | GNUNET_HELLO_iterate_addresses (hello, |
350 | GNUNET_NO, | 366 | GNUNET_NO, |
351 | &count_address, | 367 | &count_address, |
@@ -608,7 +624,7 @@ state_machine (void *cls, | |||
608 | { | 624 | { |
609 | get_info = GNUNET_NO; | 625 | get_info = GNUNET_NO; |
610 | GPI_plugins_load (cfg); | 626 | GPI_plugins_load (cfg); |
611 | pic = GNUNET_PEERINFO_iterate (peerinfo, NULL, | 627 | pic = GNUNET_PEERINFO_iterate (peerinfo, include_friend_only, NULL, |
612 | TIMEOUT, | 628 | TIMEOUT, |
613 | &print_peer_info, NULL); | 629 | &print_peer_info, NULL); |
614 | return; | 630 | return; |
@@ -627,7 +643,7 @@ state_machine (void *cls, | |||
627 | if (GNUNET_YES == get_uri) | 643 | if (GNUNET_YES == get_uri) |
628 | { | 644 | { |
629 | GPI_plugins_load (cfg); | 645 | GPI_plugins_load (cfg); |
630 | pic = GNUNET_PEERINFO_iterate (peerinfo, &my_peer_identity, | 646 | pic = GNUNET_PEERINFO_iterate (peerinfo,include_friend_only, &my_peer_identity, |
631 | TIMEOUT, &print_my_uri, NULL); | 647 | TIMEOUT, &print_my_uri, NULL); |
632 | get_uri = GNUNET_NO; | 648 | get_uri = GNUNET_NO; |
633 | return; | 649 | return; |
@@ -653,6 +669,9 @@ main (int argc, char *const *argv) | |||
653 | {'q', "quiet", NULL, | 669 | {'q', "quiet", NULL, |
654 | gettext_noop ("output only the identity strings"), | 670 | gettext_noop ("output only the identity strings"), |
655 | 0, &GNUNET_GETOPT_set_one, &be_quiet}, | 671 | 0, &GNUNET_GETOPT_set_one, &be_quiet}, |
672 | {'f', "friends", NULL, | ||
673 | gettext_noop ("include friend-only information"), | ||
674 | 0, &GNUNET_GETOPT_set_one, &include_friend_only}, | ||
656 | {'s', "self", NULL, | 675 | {'s', "self", NULL, |
657 | gettext_noop ("output our own identity only"), | 676 | gettext_noop ("output our own identity only"), |
658 | 0, &GNUNET_GETOPT_set_one, &get_self}, | 677 | 0, &GNUNET_GETOPT_set_one, &get_self}, |