2 This file is part of GNUnet.
3 (C) 2012 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @brief command line tool to access distributed GNS
23 * @author Christian Grothoff
29 #include <gnunet_util_lib.h>
30 #include <gnunet_dnsparser_lib.h>
31 #include <gnunet_namestore_service.h>
32 #include <gnunet_gns_service.h>
35 * Handle to GNS service.
37 static struct GNUNET_GNS_Handle *gns;
40 * GNS name to shorten. (-s option)
42 static struct char *name;
45 * Task run on shutdown. Cleans up everything.
48 * @param tc scheduler context
51 do_shutdown (void *cls,
52 const struct GNUNET_SCHEDULER_TaskContext *tc)
56 GNUNET_GNS_disconnect (gns);
63 * Main function that will be run.
66 * @param args remaining command-line arguments
67 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
68 * @param cfg configuration
71 run (void *cls, char *const *args, const char *cfgfile,
72 const struct GNUNET_CONFIGURATION_Handle *cfg)
74 gns = GNUNET_GNS_connect (cfg);
77 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
78 _("Failed to connect to GNS\n"));
83 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
86 // FIXME: do work here...
87 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
92 * The main function for gnunet-gns.
94 * @param argc number of arguments from the command line
95 * @param argv command line arguments
96 * @return 0 ok, 1 on error
99 main (int argc, char *const *argv)
101 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
102 {'s', "shorten", NULL,
103 gettext_noop ("try to shorten a given GNS name"), 0,
104 &GNUNET_GETOPT_set_string, &name},
105 GNUNET_GETOPT_OPTION_END
110 GNUNET_log_setup ("gnunet-gns", "WARNING", NULL);
113 GNUNET_PROGRAM_run (argc, argv, "gnunet-gns",
114 _("GNUnet GNS access tool"),
116 &run, NULL)) ? 0 : 1;
121 /* end of gnunet-gns.c */