/* This file is part of GNUnet. Copyright (C) 2012, 2013 GNUnet e.V. GNUnet is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . SPDX-License-Identifier: AGPL3.0-or-later */ /** * @file gnunet-namecache.c * @brief command line tool to inspect the name cache * @author Christian Grothoff * * TODO: * - test */ #include "platform.h" #include "gnunet_util_lib.h" #include "gnunet_dnsparser_lib.h" #include "gnunet_identity_service.h" #include "gnunet_gnsrecord_lib.h" #include "gnunet_namecache_service.h" /** * Handle to the namecache. */ static struct GNUNET_NAMECACHE_Handle *ns; /** * Queue entry for the 'query' operation. */ static struct GNUNET_NAMECACHE_QueueEntry *qe; /** * Name (label) of the records to list. */ static char *name; /** * Public key of the zone to look in. */ static struct GNUNET_CRYPTO_EcdsaPublicKey pubkey; /** * Public key of the zone to look in, in ASCII. */ static char *pkey; /** * Global return value */ static int ret; /** * Task run on shutdown. Cleans up everything. * * @param cls unused */ static void do_shutdown (void *cls) { if (NULL != qe) { GNUNET_NAMECACHE_cancel (qe); qe = NULL; } if (NULL != ns) { GNUNET_NAMECACHE_disconnect (ns); ns = NULL; } } /** * Process a record that was stored in the namecache in a block. * * @param cls closure, NULL * @param rd_len number of entries in @a rd array * @param rd array of records with data to store */ static void display_records_from_block (void *cls, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd) { const char *typestring; char *s; unsigned int i; if (0 == rd_len) { FPRINTF (stdout, _("No records found for `%s'"), name); return; } FPRINTF (stdout, "%s:\n", name); for (i=0;i