ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/gvpectrl.C
(Generate patch)

Comparing gvpe/src/gvpectrl.C (file contents):
Revision 1.4 by pcg, Tue Apr 26 00:55:56 2005 UTC vs.
Revision 1.9 by pcg, Fri Nov 21 05:02:08 2008 UTC

1/* 1/*
2 gvpectrl.C -- the main file for gvpectrl 2 gvpectrl.C -- the main file for gvpectrl
3 Copyright (C) 1998-2002 Ivo Timmermans <ivo@o2w.nl> 3 Copyright (C) 1998-2002 Ivo Timmermans <ivo@o2w.nl>
4 2000-2002 Guus Sliepen <guus@sliepen.eu.org> 4 2000-2002 Guus Sliepen <guus@sliepen.eu.org>
5 2003-2005 Marc Lehmann <gvpe@schmorp.de> 5 2003-2008 Marc Lehmann <gvpe@schmorp.de>
6 6
7 This file is part of GVPE. 7 This file is part of GVPE.
8 8
9 GVPE is free software; you can redistribute it and/or modify 9 GVPE is free software; you can redistribute it and/or modify it
10 it under the terms of the GNU General Public License as published by 10 under the terms of the GNU General Public License as published by the
11 the Free Software Foundation; either version 2 of the License, or 11 Free Software Foundation; either version 3 of the License, or (at your
12 (at your option) any later version. 12 option) any later version.
13 13
14 This program is distributed in the hope that it will be useful, 14 This program is distributed in the hope that it will be useful, but
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17 GNU General Public License for more details. 17 Public License for more details.
18 18
19 You should have received a copy of the GNU General Public License 19 You should have received a copy of the GNU General Public License along
20 along with gvpe; if not, write to the Free Software 20 with this program; if not, see <http://www.gnu.org/licenses/>.
21 Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21
22 Additional permission under GNU GPL version 3 section 7
23
24 If you modify this Program, or any covered work, by linking or
25 combining it with the OpenSSL project's OpenSSL library (or a modified
26 version of that library), containing parts covered by the terms of the
27 OpenSSL or SSLeay licenses, the licensors of this Program grant you
28 additional permission to convey the resulting work. Corresponding
29 Source for a non-source form of such a combination shall include the
30 source code for the parts of OpenSSL used as well as that of the
31 covered work.
22*/ 32*/
23 33
24#include "config.h" 34#include "config.h"
25 35
26#include <cstdio> 36#include <cstdio>
58static int kill_gvpe; 68static int kill_gvpe;
59 69
60/* If nonzero, it will attempt to kill a running gvpe and exit. */ 70/* If nonzero, it will attempt to kill a running gvpe and exit. */
61static int show_config; 71static int show_config;
62 72
73/* If nonzero, do not output anything but warnings/errors/very unusual conditions */
74static int quiet;
75
63/* If nonzero, generate public/private keypair for this net. */ 76/* If nonzero, generate public/private keypair for this net. */
64static int generate_keys; 77static int generate_keys;
65 78
66static struct option const long_options[] = 79static struct option const long_options[] =
67 { 80 {
68 {"config", required_argument, NULL, 'c'}, 81 {"config", required_argument, NULL, 'c'},
69 {"kill", optional_argument, NULL, 'k'}, 82 {"kill", optional_argument, NULL, 'k'},
70 {"help", no_argument, &show_help, 1}, 83 {"help", no_argument, &show_help, 1},
71 {"version", no_argument, &show_version, 1}, 84 {"version", no_argument, &show_version, 1},
72 {"generate-keys", no_argument, NULL, 'g'}, 85 {"generate-keys", no_argument, NULL, 'g'},
86 {"quiet", no_argument, &quiet, 1},
73 {"show-config", no_argument, &show_config, 's'}, 87 {"show-config", no_argument, &show_config, 's'},
74 {NULL, 0, NULL, 0} 88 {NULL, 0, NULL, 0}
75 }; 89 };
76 90
77static void 91static void
85 printf (_ 99 printf (_
86 (" -c, --config=DIR Read configuration options from DIR.\n" 100 (" -c, --config=DIR Read configuration options from DIR.\n"
87 " -k, --kill[=SIGNAL] Attempt to kill a running gvpe and exit.\n" 101 " -k, --kill[=SIGNAL] Attempt to kill a running gvpe and exit.\n"
88 " -g, --generate-keys Generate public/private RSA keypair.\n" 102 " -g, --generate-keys Generate public/private RSA keypair.\n"
89 " -s, --show-config Display the configuration information.\n" 103 " -s, --show-config Display the configuration information.\n"
104 " -q, --quiet Be quite quiet.\n"
90 " --help Display this help and exit.\n" 105 " --help Display this help and exit.\n"
91 " --version Output version information and exit.\n\n")); 106 " --version Output version information and exit.\n\n"));
92 printf (_("Report bugs to <vpe@plan9.de>.\n")); 107 printf (_("Report bugs to <gvpe@schmorp.de>.\n"));
93 } 108 }
94 109
95 exit (status); 110 exit (status);
96} 111}
97 112
99parse_options (int argc, char **argv, char **envp) 114parse_options (int argc, char **argv, char **envp)
100{ 115{
101 int r; 116 int r;
102 int option_index = 0; 117 int option_index = 0;
103 118
104 while ((r = 119 while ((r = getopt_long (argc, argv, "c:k::qgs", long_options, &option_index)) != EOF)
105 getopt_long (argc, argv, "c:k::gs", long_options,
106 &option_index)) != EOF)
107 { 120 {
108 switch (r) 121 switch (r)
109 { 122 {
110 case 0: /* long option */ 123 case 0: /* long option */
111 break; 124 break;
156 169
157 case 's': 170 case 's':
158 show_config = 1; 171 show_config = 1;
159 break; 172 break;
160 173
174 case 'q':
175 quiet = 1;
176 break;
177
161 case '?': 178 case '?':
162 usage (1); 179 usage (1);
163 180
164 default: 181 default:
165 break; 182 break;
170/* This function prettyprints the key generation process */ 187/* This function prettyprints the key generation process */
171 188
172void 189void
173indicator (int a, int b, void *p) 190indicator (int a, int b, void *p)
174{ 191{
192 if (quiet)
193 return;
194
175 switch (a) 195 switch (a)
176 { 196 {
177 case 0: 197 case 0:
178 fprintf (stderr, "."); 198 fprintf (stderr, ".");
179 break; 199 break;
240 exit (EXIT_FAILURE); 260 exit (EXIT_FAILURE);
241 } 261 }
242 262
243 if (ftell (f)) 263 if (ftell (f))
244 { 264 {
265 if (!quiet)
245 fprintf (stderr, "'%s' already exists, skipping this node\n", 266 fprintf (stderr, "'%s' already exists, skipping this node %d\n",
246 fname); 267 fname, quiet);
268
247 fclose (f); 269 fclose (f);
248 continue; 270 continue;
249 } 271 }
250 272
251 fprintf (stderr, _("generating %d bits key for %s:\n"), bits, 273 fprintf (stderr, _("generating %d bits key for %s:\n"), bits,
294 316
295 parse_options (argc, argv, envp); 317 parse_options (argc, argv, envp);
296 318
297 if (show_version) 319 if (show_version)
298 { 320 {
299 printf (_("%s version %s (built %s %s, protocol %d.%d)\n"), get_identity (), 321 printf (_("%s version %s (built %s %s, protocol version %d.%d)\n"), get_identity (),
300 VERSION, __DATE__, __TIME__, PROTOCOL_MAJOR, PROTOCOL_MINOR); 322 VERSION, __DATE__, __TIME__, PROTOCOL_MAJOR, PROTOCOL_MINOR);
301 printf (_("Built with kernel interface %s/%s.\n"), IFTYPE, IFSUBTYPE); 323 printf (_("Built with kernel interface %s/%s.\n"), IFTYPE, IFSUBTYPE);
302 printf (_ 324 printf (_
303 ("Copyright (C) 2003 Marc Lehmann <vpe@plan9.de> and others.\n" 325 ("Copyright (C) 2003-2008 Marc Lehmann <gvpe@schmorp.de> and others.\n"
304 "See the AUTHORS file for a complete list.\n\n" 326 "See the AUTHORS file for a complete list.\n\n"
305 "vpe comes with ABSOLUTELY NO WARRANTY. This is free software,\n" 327 "vpe comes with ABSOLUTELY NO WARRANTY. This is free software,\n"
306 "and you are welcome to redistribute it under certain conditions;\n" 328 "and you are welcome to redistribute it under certain conditions;\n"
307 "see the file COPYING for details.\n")); 329 "see the file COPYING for details.\n"));
308 330

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines