-fix #2598
[oweals/gnunet.git] / src / fs / gnunet-pseudonym.c
index 412ddd2b068f46553d7ca5ecfb79bf3076aecbc3..02b71b5138de854f7a6ff0c7cbd2d8dceaeca5fc 100644 (file)
@@ -95,7 +95,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
 
 
 static void
-ns_printer (void *cls, const char *name, const GNUNET_HashCode * id)
+ns_printer (void *cls, const char *name, const struct GNUNET_HashCode * id)
 {
   struct GNUNET_CRYPTO_HashAsciiEncoded enc;
 
@@ -105,21 +105,30 @@ ns_printer (void *cls, const char *name, const GNUNET_HashCode * id)
 
 
 static int
-pseudo_printer (void *cls, const GNUNET_HashCode * pseudonym,
+pseudo_printer (void *cls, const struct 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 *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);
+  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 (id);
+  GNUNET_free (unique_id);
   return GNUNET_OK;
 }
 
@@ -127,7 +136,7 @@ pseudo_printer (void *cls, const GNUNET_HashCode * pseudonym,
 static void
 post_advertising (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
 {
-  GNUNET_HashCode nsid;
+  struct GNUNET_HashCode nsid;
   char *set;
   int delta;
 
@@ -162,7 +171,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);
       }
     }
@@ -303,6 +313,10 @@ main (int argc, char *const *argv)
   };
   bo.expiration_time =
       GNUNET_FS_year_to_time (GNUNET_FS_get_current_year () + 2);
+
+  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+    return 2;
+
   return (GNUNET_OK ==
           GNUNET_PROGRAM_run (argc, argv, "gnunet-pseudonym [OPTIONS]",
                               gettext_noop ("Manage GNUnet pseudonyms."),