X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Ffs%2Fgnunet-pseudonym.c;h=38826d1de18ec18992d721994e600bbb5e733025;hb=1f09f4f7716db5939ec1c9a278b5661616dd72d6;hp=742111c4e6384ccd7bacec0dc3fe99002e7361b8;hpb=502af2167f7c218366666ca4944bd7cc54b5b19a;p=oweals%2Fgnunet.git diff --git a/src/fs/gnunet-pseudonym.c b/src/fs/gnunet-pseudonym.c index 742111c4e..38826d1de 100644 --- a/src/fs/gnunet-pseudonym.c +++ b/src/fs/gnunet-pseudonym.c @@ -100,28 +100,35 @@ 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, +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 *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; } @@ -135,7 +142,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) @@ -150,8 +157,8 @@ post_advertising (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg) set++; if (*set != ':') { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Invalid argument `%s'\n"), rating_change); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Invalid argument `%s'\n"), + rating_change); } else { @@ -164,8 +171,9 @@ post_advertising (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg) } else { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Namespace `%s' unknown.\n"), rating_change); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + ("Namespace `%s' unknown. Make sure you specify its numeric suffix, if any.\n"), + rating_change); } } GNUNET_free (rating_change); @@ -192,17 +200,14 @@ post_advertising (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg) * @param c configuration */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { char *emsg; cfg = c; - h = GNUNET_FS_start (cfg, - "gnunet-pseudonym", - &progress_cb, - NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); + h = GNUNET_FS_start (cfg, "gnunet-pseudonym", &progress_cb, NULL, + GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); if (NULL != delete_ns) { ns = GNUNET_FS_namespace_create (h, delete_ns); @@ -234,28 +239,24 @@ run (void *cls, ksk_uri = GNUNET_FS_uri_parse ("gnunet://fs/ksk/namespace", &emsg); GNUNET_assert (NULL == emsg); } - GNUNET_FS_namespace_advertise (h, - ksk_uri, - ns, - adv_metadata, - &bo, - root_identifier, - &post_advertising, NULL); + GNUNET_FS_namespace_advertise (h, ksk_uri, ns, adv_metadata, &bo, + root_identifier, &post_advertising, + NULL); return; } 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); @@ -284,9 +285,8 @@ main (int argc, char *const *argv) gettext_noop ("delete namespace NAME "), 1, &GNUNET_GETOPT_set_string, &delete_ns}, {'k', "keyword", "VALUE", - gettext_noop - ("add an additional keyword for the advertisment" - " (this option can be specified multiple times)"), + gettext_noop ("add an additional keyword for the advertisment" + " (this option can be specified multiple times)"), 1, &GNUNET_FS_getopt_set_keywords, &ksk_uri}, {'m', "meta", "TYPE:VALUE", gettext_noop ("set the meta-data for the given TYPE to the given VALUE"),