- update default values, eliminate obsolete ones
[oweals/gnunet.git] / src / peerinfo-tool / gnunet-peerinfo.c
index 9f2370731da81c55a2bc79084bdc16fd9f548ffa..d826a805082f688517d789d6ad13886cba34e83a 100644 (file)
@@ -261,13 +261,17 @@ dump_pc (struct PrintContext *pc)
  *
  * @param cls closure
  * @param address NULL on error, otherwise 0-terminated printable UTF-8 string
+ * @param res result of the address to string conversion:
+ *        if #GNUNET_OK: address was valid (conversion to
+ *                       string might still have failed)
+ *        if #GNUNET_SYSERR: address is invalid
  */
 static void
 process_resolved_address (void *cls,
                           const char *address,
                           int res)
 {
-  struct AddressRecord * ar = cls;
+  struct AddressRecord *ar = cls;
   struct PrintContext *pc = ar->pc;
 
   if (NULL != address)
@@ -276,18 +280,12 @@ process_resolved_address (void *cls,
       ar->result = GNUNET_strdup (address);
     return;
   }
-
   ar->atsc = NULL;
   if (GNUNET_SYSERR == res)
-  {
-    FPRINTF (stderr,
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
              _("Failure: Cannot convert address to string for peer `%s'\n"),
              GNUNET_i2s (&ar->pc->peer));
-  }
-  else
-  {
-    pc->num_addresses++;
-  }
+  pc->num_addresses++;
   if (pc->num_addresses == pc->address_list_size)
     dump_pc (pc);
 }
@@ -328,6 +326,7 @@ print_address (void *cls,
 {
   struct PrintContext *pc = cls;
   struct AddressRecord *ar;
+
   GNUNET_assert (0 < pc->off);
   ar = &pc->address_list[--pc->off];
   ar->pc = pc;
@@ -335,8 +334,7 @@ print_address (void *cls,
   ar->atsc = GNUNET_TRANSPORT_address_to_string (cfg,
                                                  address,
                                                  no_resolve,
-                                                GNUNET_TIME_relative_multiply
-                                                (GNUNET_TIME_UNIT_SECONDS, 10),
+                                                TIMEOUT,
                                                 &process_resolved_address, ar);
   return GNUNET_OK;
 }
@@ -376,7 +374,8 @@ print_peer_info (void *cls,
   friend_only = GNUNET_NO;
   if (NULL != hello)
        friend_only = GNUNET_HELLO_is_friend_only (hello);
-  if ((GNUNET_YES == be_quiet) || (NULL == hello))
+  if ( (GNUNET_YES == be_quiet) ||
+       (NULL == hello) )
   {
     printf ("%s%s\n",
            (GNUNET_YES == friend_only) ? "F2F: " : "",
@@ -400,8 +399,10 @@ print_peer_info (void *cls,
   }
   pc->address_list_size = pc->off;
   pc->address_list = GNUNET_malloc (sizeof (struct AddressRecord) * pc->off);
-  GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO,
-                                 &print_address, pc);
+  GNUNET_HELLO_iterate_addresses (hello,
+                                  GNUNET_NO,
+                                 &print_address,
+                                  pc);
 }
 
 /* ************************* DUMP Hello  ************************** */
@@ -427,7 +428,7 @@ count_addr (void *cls,
 
 
 /**
- * Write Hello of my peer to a file.
+ * Write HELLO of my peer to a file.
  *
  * @param cls the `struct GetUriContext *`
  * @param peer identity of the peer (unused)
@@ -586,10 +587,10 @@ parse_hello_uri (const char *put_uri)
 {
   struct GNUNET_HELLO_Message *hello = NULL;
 
-  int ret = GNUNET_HELLO_parse_uri(put_uri,
-                                   &my_peer_identity.public_key,
-                                  &hello,
-                                   &GPI_plugins_find);
+  int ret = GNUNET_HELLO_parse_uri (put_uri,
+                                    &my_peer_identity.public_key,
+                                    &hello,
+                                    &GPI_plugins_find);
 
   if (NULL != hello)
   {
@@ -602,10 +603,6 @@ parse_hello_uri (const char *put_uri)
       tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL);
     GNUNET_free (hello);
   }
-
-  /* wait 1s to give peerinfo operation a chance to succeed */
-  /* FIXME: current peerinfo API sucks to require this; not to mention
-     that we get no feedback to determine if the operation actually succeeded */
   return ret;
 }