/* This file is part of GNUnet. (C) 2012 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-gns.c * @brief command line tool to access distributed GNS * @author Christian Grothoff * * TODO: * - everything */ #include "platform.h" #include #include #include #include /** * Handle to GNS service. */ static struct GNUNET_GNS_Handle *gns; /** * GNS name to shorten. (-s option) */ static char *shorten_name; /** * GNS name to lookup. (-u option) */ static char *lookup_name; /** * record type to look up (-t option) */ static char *lookup_type; /** * name to look up authority for (-a option) */ static char *auth_name; /** * raw output */ static int raw = 0; static enum GNUNET_GNS_RecordType rtype; /** * 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 != gns) { GNUNET_GNS_disconnect (gns); gns = NULL; } } static void process_shorten_result(void* cls, const char* nshort) { if (raw) printf("%s", nshort); else printf("%s shortened to %s\n", (char*) cls, nshort); GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); } static void process_lookup_result(void* cls, uint32_t rd_count, const struct GNUNET_NAMESTORE_RecordData *rd) { int i; char* name = (char*) cls; const char* typename; char* string_val; if (!raw) { if (rd_count == 0) printf("No results.\n"); else printf("%s:\n", name); } for (i=0; i