… | |
… | |
68 | static int kill_gvpe; |
68 | static int kill_gvpe; |
69 | |
69 | |
70 | /* 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. */ |
71 | static int show_config; |
71 | static int show_config; |
72 | |
72 | |
|
|
73 | /* If nonzero, do not output anything but warnings/errors/very unusual conditions */ |
|
|
74 | static int quiet; |
|
|
75 | |
73 | /* If nonzero, generate public/private keypair for this net. */ |
76 | /* If nonzero, generate public/private keypair for this net. */ |
74 | static int generate_keys; |
77 | static int generate_keys; |
75 | |
78 | |
76 | static struct option const long_options[] = |
79 | static struct option const long_options[] = |
77 | { |
80 | { |
78 | {"config", required_argument, NULL, 'c'}, |
81 | {"config", required_argument, NULL, 'c'}, |
79 | {"kill", optional_argument, NULL, 'k'}, |
82 | {"kill", optional_argument, NULL, 'k'}, |
80 | {"help", no_argument, &show_help, 1}, |
83 | {"help", no_argument, &show_help, 1}, |
81 | {"version", no_argument, &show_version, 1}, |
84 | {"version", no_argument, &show_version, 1}, |
82 | {"generate-keys", no_argument, NULL, 'g'}, |
85 | {"generate-keys", no_argument, NULL, 'g'}, |
|
|
86 | {"quiet", no_argument, &quiet, 1}, |
83 | {"show-config", no_argument, &show_config, 's'}, |
87 | {"show-config", no_argument, &show_config, 's'}, |
84 | {NULL, 0, NULL, 0} |
88 | {NULL, 0, NULL, 0} |
85 | }; |
89 | }; |
86 | |
90 | |
87 | static void |
91 | static void |
… | |
… | |
95 | printf (_ |
99 | printf (_ |
96 | (" -c, --config=DIR Read configuration options from DIR.\n" |
100 | (" -c, --config=DIR Read configuration options from DIR.\n" |
97 | " -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" |
98 | " -g, --generate-keys Generate public/private RSA keypair.\n" |
102 | " -g, --generate-keys Generate public/private RSA keypair.\n" |
99 | " -s, --show-config Display the configuration information.\n" |
103 | " -s, --show-config Display the configuration information.\n" |
|
|
104 | " -q, --quiet Be quite quiet.\n" |
100 | " --help Display this help and exit.\n" |
105 | " --help Display this help and exit.\n" |
101 | " --version Output version information and exit.\n\n")); |
106 | " --version Output version information and exit.\n\n")); |
102 | printf (_("Report bugs to <gvpe@schmorp.de>.\n")); |
107 | printf (_("Report bugs to <gvpe@schmorp.de>.\n")); |
103 | } |
108 | } |
104 | |
109 | |
… | |
… | |
109 | parse_options (int argc, char **argv, char **envp) |
114 | parse_options (int argc, char **argv, char **envp) |
110 | { |
115 | { |
111 | int r; |
116 | int r; |
112 | int option_index = 0; |
117 | int option_index = 0; |
113 | |
118 | |
114 | while ((r = |
119 | while ((r = getopt_long (argc, argv, "c:k::qgs", long_options, &option_index)) != EOF) |
115 | getopt_long (argc, argv, "c:k::gs", long_options, |
|
|
116 | &option_index)) != EOF) |
|
|
117 | { |
120 | { |
118 | switch (r) |
121 | switch (r) |
119 | { |
122 | { |
120 | case 0: /* long option */ |
123 | case 0: /* long option */ |
121 | break; |
124 | break; |
… | |
… | |
166 | |
169 | |
167 | case 's': |
170 | case 's': |
168 | show_config = 1; |
171 | show_config = 1; |
169 | break; |
172 | break; |
170 | |
173 | |
|
|
174 | case 'q': |
|
|
175 | quiet = 1; |
|
|
176 | break; |
|
|
177 | |
171 | case '?': |
178 | case '?': |
172 | usage (1); |
179 | usage (1); |
173 | |
180 | |
174 | default: |
181 | default: |
175 | break; |
182 | break; |
… | |
… | |
180 | /* This function prettyprints the key generation process */ |
187 | /* This function prettyprints the key generation process */ |
181 | |
188 | |
182 | void |
189 | void |
183 | indicator (int a, int b, void *p) |
190 | indicator (int a, int b, void *p) |
184 | { |
191 | { |
|
|
192 | if (quiet) |
|
|
193 | return; |
|
|
194 | |
185 | switch (a) |
195 | switch (a) |
186 | { |
196 | { |
187 | case 0: |
197 | case 0: |
188 | fprintf (stderr, "."); |
198 | fprintf (stderr, "."); |
189 | break; |
199 | break; |
… | |
… | |
250 | exit (EXIT_FAILURE); |
260 | exit (EXIT_FAILURE); |
251 | } |
261 | } |
252 | |
262 | |
253 | if (ftell (f)) |
263 | if (ftell (f)) |
254 | { |
264 | { |
|
|
265 | if (!quiet) |
255 | fprintf (stderr, "'%s' already exists, skipping this node\n", |
266 | fprintf (stderr, "'%s' already exists, skipping this node %d\n", |
256 | fname); |
267 | fname, quiet); |
|
|
268 | |
257 | fclose (f); |
269 | fclose (f); |
258 | continue; |
270 | continue; |
259 | } |
271 | } |
260 | |
272 | |
261 | fprintf (stderr, _("generating %d bits key for %s:\n"), bits, |
273 | fprintf (stderr, _("generating %d bits key for %s:\n"), bits, |