/* This file is part of GNUnet. Copyright (C) 2012, 2013 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, 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 General Public License for more details. You should have received a copy of the GNU General Public License along with GNUnet; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** * @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 * @param tc scheduler context */ static void do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { 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