-check return values, fix leak
[oweals/gnunet.git] / src / fs / gnunet-pseudonym.c
index ce0d24506e2a67bd26a98fe12447c919a8706723..247a5a0d85e34ffff98dbef569daeecd9104bfa1 100644 (file)
@@ -100,26 +100,34 @@ ns_printer (void *cls, const char *name, const GNUNET_HashCode * id)
   struct GNUNET_CRYPTO_HashAsciiEncoded enc;
 
   GNUNET_CRYPTO_hash_to_enc (id, &enc);
-  fprintf (stdout, "%s (%s)\n", name, (const char *) &enc);
+  FPRINTF (stdout, "%s (%s)\n", name, (const char *) &enc);
 }
 
 
 static int
 pseudo_printer (void *cls, const GNUNET_HashCode * pseudonym,
+                const char *name, const char *unique_name,
                 const struct GNUNET_CONTAINER_MetaData *md, int rating)
 {
-  char *id;
-
-  id = GNUNET_PSEUDONYM_id_to_name (cfg, pseudonym);
-  if (id == NULL)
+  char *id, *unique_id;
+  int getinfo_result;
+
+  /* While we get a name from the caller, it might be NULL.
+   * GNUNET_PSEUDONYM_get_info () never returns NULL.
+   */
+  getinfo_result = GNUNET_PSEUDONYM_get_info (cfg, pseudonym,
+      NULL, NULL, &id, NULL);
+  if (getinfo_result != GNUNET_OK)
   {
     GNUNET_break (0);
     return GNUNET_OK;
   }
-  fprintf (stdout, "%s (%d):\n", id, rating);
-  GNUNET_CONTAINER_meta_data_iterate (md, &EXTRACTOR_meta_data_print, stdout);
-  fprintf (stdout, "\n");
+  unique_id = GNUNET_PSEUDONYM_name_uniquify (cfg, pseudonym, id, NULL);
   GNUNET_free (id);
+  FPRINTF (stdout, "%s (%d):\n", unique_id, rating);
+  GNUNET_CONTAINER_meta_data_iterate (md, &EXTRACTOR_meta_data_print, stdout);
+  FPRINTF (stdout, "%s",  "\n");
+  GNUNET_free (unique_id);
   return GNUNET_OK;
 }
 
@@ -133,7 +141,7 @@ post_advertising (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
 
   if (emsg != NULL)
   {
-    fprintf (stderr, "%s", emsg);
+    FPRINTF (stderr, "%s", emsg);
     ret = 1;
   }
   if (ns != NULL)
@@ -162,7 +170,8 @@ post_advertising (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
       }
       else
       {
-        GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Namespace `%s' unknown.\n"),
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 
+                    ("Namespace `%s' unknown. Make sure you specify its numeric suffix, if any.\n"),
                     rating_change);
       }
     }
@@ -237,16 +246,16 @@ run (void *cls, char *const *args, const char *cfgfile,
       else
       {
         if (ksk_uri != NULL)
-          fprintf (stderr, _("Option `%s' ignored\n"), "-k");
+          FPRINTF (stderr, _("Option `%s' ignored\n"), "-k");
       }
     }
   }
   else
   {
     if (root_identifier != NULL)
-      fprintf (stderr, _("Option `%s' ignored\n"), "-r");
+      FPRINTF (stderr, _("Option `%s' ignored\n"), "-r");
     if (ksk_uri != NULL)
-      fprintf (stderr, _("Option `%s' ignored\n"), "-k");
+      FPRINTF (stderr, _("Option `%s' ignored\n"), "-k");
   }
 
   post_advertising (NULL, NULL, NULL);