diff options
-rw-r--r-- | doc/man/Makefile.am | 1 | ||||
-rw-r--r-- | doc/man/gnunet-gns.1 | 36 | ||||
-rw-r--r-- | doc/man/gnunet-namestore.1 | 11 | ||||
-rw-r--r-- | src/gns/gnunet-gns.c | 121 |
4 files changed, 165 insertions, 4 deletions
diff --git a/doc/man/Makefile.am b/doc/man/Makefile.am index 4c9d6f7c7..629ab6d13 100644 --- a/doc/man/Makefile.am +++ b/doc/man/Makefile.am | |||
@@ -4,6 +4,7 @@ man_MANS = \ | |||
4 | gnunet-download.1 \ | 4 | gnunet-download.1 \ |
5 | gnunet-download-manager.1 \ | 5 | gnunet-download-manager.1 \ |
6 | gnunet-fs.1 \ | 6 | gnunet-fs.1 \ |
7 | gnunet-gns.1 \ | ||
7 | gnunet-namestore.1 \ | 8 | gnunet-namestore.1 \ |
8 | gnunet-nat-server.1 \ | 9 | gnunet-nat-server.1 \ |
9 | gnunet-peerinfo.1 \ | 10 | gnunet-peerinfo.1 \ |
diff --git a/doc/man/gnunet-gns.1 b/doc/man/gnunet-gns.1 new file mode 100644 index 000000000..4d00c82e3 --- /dev/null +++ b/doc/man/gnunet-gns.1 | |||
@@ -0,0 +1,36 @@ | |||
1 | .TH GNUNET\-GNS 1 "Mar 5, 2012" "GNUnet" | ||
2 | |||
3 | .SH NAME | ||
4 | gnunet\-gns \- manipulate GNUnet GNS zones | ||
5 | |||
6 | .SH SYNOPSIS | ||
7 | .B gnunet\-gns | ||
8 | .RI [ options ] -z ZONEFILE | ||
9 | .br | ||
10 | |||
11 | .SH DESCRIPTION | ||
12 | \fBgnunet\-gns\fP can be used to create and manipulate a GNS zone. | ||
13 | |||
14 | .SH OPTIONS | ||
15 | .B | ||
16 | .IP "\-c FILENAME, \-\-config=FILENAME" | ||
17 | Use the configuration file FILENAME. | ||
18 | .B | ||
19 | .IP "\-h, \-\-help" | ||
20 | Print short help on options. | ||
21 | .B | ||
22 | .IP "\-L LOGLEVEL, \-\-loglevel=LOGLEVEL" | ||
23 | Use LOGLEVEL for logging. Valid values are DEBUG, INFO, WARNING and ERROR. | ||
24 | .B | ||
25 | .IP "\-s NAME, \-\-shorten=NAME" | ||
26 | GNS domain name to shorten | ||
27 | .B | ||
28 | .IP "\-v, \-\-version" | ||
29 | Print GNUnet version number. | ||
30 | |||
31 | .SH BUGS | ||
32 | Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <gnunet\-developers@gnu.org> | ||
33 | |||
34 | |||
35 | .SH "SEE ALSO" | ||
36 | \fBgnunet\-namestore\fP(1) | ||
diff --git a/doc/man/gnunet-namestore.1 b/doc/man/gnunet-namestore.1 index 8fd4b33e4..4ecdbb0a6 100644 --- a/doc/man/gnunet-namestore.1 +++ b/doc/man/gnunet-namestore.1 | |||
@@ -1,15 +1,15 @@ | |||
1 | .TH GNUNET\-GNS 1 "Jan 4, 2012" "GNUnet" | 1 | .TH GNUNET\-NAMESTORE 1 "Mar 5, 2012" "GNUnet" |
2 | 2 | ||
3 | .SH NAME | 3 | .SH NAME |
4 | gnunet\-gns \- manipulate GNUnet GNS zones | 4 | gnunet\-namestore \- manipulate GNUnet zones |
5 | 5 | ||
6 | .SH SYNOPSIS | 6 | .SH SYNOPSIS |
7 | .B gnunet\-gns | 7 | .B gnunet\-namestore |
8 | .RI [ options ] -z ZONEFILE | 8 | .RI [ options ] -z ZONEFILE |
9 | .br | 9 | .br |
10 | 10 | ||
11 | .SH DESCRIPTION | 11 | .SH DESCRIPTION |
12 | \fBgnunet\-gns\fP can be used to create and manipulate a GNS zone. | 12 | \fBgnunet\-namestore\fP can be used to create and manipulate a GNS zone. |
13 | 13 | ||
14 | .SH OPTIONS | 14 | .SH OPTIONS |
15 | .B | 15 | .B |
@@ -53,3 +53,6 @@ Specifies the filename with the private key for the zone (mandatory option) | |||
53 | .SH BUGS | 53 | .SH BUGS |
54 | Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <gnunet\-developers@gnu.org> | 54 | Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <gnunet\-developers@gnu.org> |
55 | 55 | ||
56 | |||
57 | .SH "SEE ALSO" | ||
58 | \fBgnunet\-gns\fP(1) | ||
diff --git a/src/gns/gnunet-gns.c b/src/gns/gnunet-gns.c new file mode 100644 index 000000000..3fdd8d29f --- /dev/null +++ b/src/gns/gnunet-gns.c | |||
@@ -0,0 +1,121 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2012 Christian Grothoff (and other contributing authors) | ||
4 | |||
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. | ||
9 | |||
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. | ||
14 | |||
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. | ||
19 | */ | ||
20 | /** | ||
21 | * @file gnunet-gns.c | ||
22 | * @brief command line tool to access distributed GNS | ||
23 | * @author Christian Grothoff | ||
24 | * | ||
25 | * TODO: | ||
26 | * - everything | ||
27 | */ | ||
28 | #include "platform.h" | ||
29 | #include <gnunet_util_lib.h> | ||
30 | #include <gnunet_dnsparser_lib.h> | ||
31 | #include <gnunet_namestore_service.h> | ||
32 | #include <gnunet_gns_service.h> | ||
33 | |||
34 | /** | ||
35 | * Handle to GNS service. | ||
36 | */ | ||
37 | static struct GNUNET_GNS_Handle *gns; | ||
38 | |||
39 | /** | ||
40 | * GNS name to shorten. (-s option) | ||
41 | */ | ||
42 | static struct char *name; | ||
43 | |||
44 | /** | ||
45 | * Task run on shutdown. Cleans up everything. | ||
46 | * | ||
47 | * @param cls unused | ||
48 | * @param tc scheduler context | ||
49 | */ | ||
50 | static void | ||
51 | do_shutdown (void *cls, | ||
52 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
53 | { | ||
54 | if (NULL != gns) | ||
55 | { | ||
56 | GNUNET_GNS_disconnect (gns); | ||
57 | gns = NULL; | ||
58 | } | ||
59 | } | ||
60 | |||
61 | |||
62 | /** | ||
63 | * Main function that will be run. | ||
64 | * | ||
65 | * @param cls closure | ||
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 | ||
69 | */ | ||
70 | static void | ||
71 | run (void *cls, char *const *args, const char *cfgfile, | ||
72 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
73 | { | ||
74 | gns = GNUNET_GNS_connect (cfg); | ||
75 | if (NULL == gns) | ||
76 | { | ||
77 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
78 | _("Failed to connect to GNS\n")); | ||
79 | return; | ||
80 | } | ||
81 | if (NULL == s) | ||
82 | { | ||
83 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
84 | return; | ||
85 | } | ||
86 | // FIXME: do work here... | ||
87 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
88 | } | ||
89 | |||
90 | |||
91 | /** | ||
92 | * The main function for gnunet-gns. | ||
93 | * | ||
94 | * @param argc number of arguments from the command line | ||
95 | * @param argv command line arguments | ||
96 | * @return 0 ok, 1 on error | ||
97 | */ | ||
98 | int | ||
99 | main (int argc, char *const *argv) | ||
100 | { | ||
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 | ||
106 | }; | ||
107 | |||
108 | int ret; | ||
109 | |||
110 | GNUNET_log_setup ("gnunet-gns", "WARNING", NULL); | ||
111 | ret = | ||
112 | (GNUNET_OK == | ||
113 | GNUNET_PROGRAM_run (argc, argv, "gnunet-gns", | ||
114 | _("GNUnet GNS access tool"), | ||
115 | options, | ||
116 | &run, NULL)) ? 0 : 1; | ||
117 | |||
118 | return ret; | ||
119 | } | ||
120 | |||
121 | /* end of gnunet-gns.c */ | ||