Separated DANE functionality from certtool and added danetool.
[gnutls.git] / src / danetool-args.c
blobc89443c7f0e5d5fa7754fe5dd60410380d9defbb
1 /* -*- buffer-read-only: t -*- vi: set ro:
2 *
3 * DO NOT EDIT THIS FILE (danetool-args.c)
4 *
5 * It has been AutoGen-ed October 12, 2012 at 09:16:57 AM by AutoGen 5.16
6 * From the definitions danetool-args.def
7 * and the template file options
9 * Generated from AutoOpts 36:4:11 templates.
11 * AutoOpts is a copyrighted work. This source file is not encumbered
12 * by AutoOpts licensing, but is provided under the licensing terms chosen
13 * by the danetool author or copyright holder. AutoOpts is
14 * licensed under the terms of the LGPL. The redistributable library
15 * (``libopts'') is licensed under the terms of either the LGPL or, at the
16 * users discretion, the BSD license. See the AutoOpts and/or libopts sources
17 * for details.
19 * The danetool program is copyrighted and licensed
20 * under the following terms:
22 * Copyright (C) 2000-2012 Free Software Foundation, all rights reserved.
23 * This is free software. It is licensed for use, modification and
24 * redistribution under the terms of the
25 * GNU General Public License, version 3 or later
26 * <http://gnu.org/licenses/gpl.html>
28 * danetool is free software: you can redistribute it and/or modify it
29 * under the terms of the GNU General Public License as published by the
30 * Free Software Foundation, either version 3 of the License, or
31 * (at your option) any later version.
33 * danetool is distributed in the hope that it will be useful, but
34 * WITHOUT ANY WARRANTY; without even the implied warranty of
35 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
36 * See the GNU General Public License for more details.
38 * You should have received a copy of the GNU General Public License along
39 * with this program. If not, see <http://www.gnu.org/licenses/>.
42 #ifndef __doxygen__
43 #define OPTION_CODE_COMPILE 1
44 #include "danetool-args.h"
45 #include <sys/types.h>
47 #include <limits.h>
48 #include <stdio.h>
49 #include <stdlib.h>
50 #include <errno.h>
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 extern FILE * option_usage_fp;
57 /* TRANSLATORS: choose the translation for option names wisely because you
58 cannot ever change your mind. */
59 #define zCopyright (danetool_opt_strs+0)
60 #define zLicenseDescrip (danetool_opt_strs+279)
63 #ifndef NULL
64 # define NULL 0
65 #endif
68 * danetool option static const strings
70 static char const danetool_opt_strs[2268] =
71 /* 0 */ "danetool @VERSION@\n"
72 "Copyright (C) 2000-2012 Free Software Foundation, all rights reserved.\n"
73 "This is free software. It is licensed for use, modification and\n"
74 "redistribution under the terms of the\n"
75 "GNU General Public License, version 3 or later\n"
76 " <http://gnu.org/licenses/gpl.html>\n\0"
77 /* 279 */ "danetool is free software: you can redistribute it and/or modify it under\n"
78 "the terms of the GNU General Public License as published by the Free\n"
79 "Software Foundation, either version 3 of the License, or (at your option)\n"
80 "any later version.\n\n"
81 "danetool is distributed in the hope that it will be useful, but WITHOUT ANY\n"
82 "WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n"
83 "FOR A PARTICULAR PURPOSE. See the GNU General Public License for more\n"
84 "details.\n\n"
85 "You should have received a copy of the GNU General Public License along\n"
86 "with this program. If not, see <http://www.gnu.org/licenses/>.\n\0"
87 /* 884 */ "Enable debugging.\0"
88 /* 902 */ "DEBUG\0"
89 /* 908 */ "debug\0"
90 /* 914 */ "More verbose output\0"
91 /* 934 */ "VERBOSE\0"
92 /* 942 */ "verbose\0"
93 /* 950 */ "Input file\0"
94 /* 961 */ "INFILE\0"
95 /* 968 */ "infile\0"
96 /* 975 */ "Output file\0"
97 /* 987 */ "OUTFILE\0"
98 /* 995 */ "outfile\0"
99 /* 1003 */ "Loads a public key file\0"
100 /* 1027 */ "LOAD_PUBKEY\0"
101 /* 1039 */ "load-pubkey\0"
102 /* 1051 */ "Loads a certificate file\0"
103 /* 1076 */ "LOAD_CERTIFICATE\0"
104 /* 1093 */ "load-certificate\0"
105 /* 1110 */ "Hash algorithm to use for signing.\0"
106 /* 1145 */ "HASH\0"
107 /* 1150 */ "hash\0"
108 /* 1155 */ "Use DER format for input certificates and private keys.\0"
109 /* 1211 */ "INDER\0"
110 /* 1217 */ "no-inder\0"
111 /* 1226 */ "no\0"
112 /* 1229 */ "This is an alias for 'inder'\0"
113 /* 1258 */ "inraw\0"
114 /* 1264 */ "Use DER format for output certificates and private keys\0"
115 /* 1320 */ "OUTDER\0"
116 /* 1327 */ "no-outder\0"
117 /* 1337 */ "This is an alias for 'outder'\0"
118 /* 1367 */ "outraw\0"
119 /* 1374 */ "Print the DANE RR data on a certificate or public key\0"
120 /* 1428 */ "TLSA_RR\0"
121 /* 1436 */ "tlsa-rr\0"
122 /* 1444 */ "Specify the hostname to be used in the DANE RR\0"
123 /* 1491 */ "HOST\0"
124 /* 1496 */ "host\0"
125 /* 1501 */ "The protocol set for DANE data (tcp, udp etc.)\0"
126 /* 1548 */ "PROTO\0"
127 /* 1554 */ "proto\0"
128 /* 1560 */ "Specify the port number for the DANE data.\0"
129 /* 1603 */ "PORT\0"
130 /* 1608 */ "port\0"
131 /* 1613 */ "Whether the provided certificate or public key is a Certificate\n"
132 "authority.\0"
133 /* 1688 */ "CA\0"
134 /* 1691 */ "ca\0"
135 /* 1694 */ "Use the hash of the X.509 certificate, rather than the public key.\0"
136 /* 1761 */ "X509\0"
137 /* 1766 */ "x509\0"
138 /* 1771 */ "The provided certificate or public key is a local entity.\0"
139 /* 1829 */ "LOCAL\0"
140 /* 1835 */ "local\0"
141 /* 1841 */ "Display extended usage information and exit\0"
142 /* 1885 */ "help\0"
143 /* 1890 */ "Extended usage information passed thru pager\0"
144 /* 1935 */ "more-help\0"
145 /* 1945 */ "Output version information and exit\0"
146 /* 1981 */ "version\0"
147 /* 1989 */ "DANETOOL\0"
148 /* 1998 */ "danetool - GnuTLS DANE tool - Ver. @VERSION@\n"
149 "USAGE: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n\0"
150 /* 2101 */ "bug-gnutls@gnu.org\0"
151 /* 2120 */ "\n\n\0"
152 /* 2123 */ "\n"
153 "Tool generate DNS resource records for the DANE protocol.\n\0"
154 /* 2183 */ "danetool @VERSION@\0"
155 /* 2202 */ "danetool [options] [url]\n"
156 "danetool --help for usage instructions.\n";
159 * debug option description:
161 #define DEBUG_DESC (danetool_opt_strs+884)
162 #define DEBUG_NAME (danetool_opt_strs+902)
163 #define DEBUG_name (danetool_opt_strs+908)
164 #define DEBUG_FLAGS (OPTST_DISABLED \
165 | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
168 * verbose option description:
170 #define VERBOSE_DESC (danetool_opt_strs+914)
171 #define VERBOSE_NAME (danetool_opt_strs+934)
172 #define VERBOSE_name (danetool_opt_strs+942)
173 #define VERBOSE_FLAGS (OPTST_DISABLED)
176 * infile option description:
178 #define INFILE_DESC (danetool_opt_strs+950)
179 #define INFILE_NAME (danetool_opt_strs+961)
180 #define INFILE_name (danetool_opt_strs+968)
181 #define INFILE_FLAGS (OPTST_DISABLED \
182 | OPTST_SET_ARGTYPE(OPARG_TYPE_FILE))
185 * outfile option description:
187 #define OUTFILE_DESC (danetool_opt_strs+975)
188 #define OUTFILE_NAME (danetool_opt_strs+987)
189 #define OUTFILE_name (danetool_opt_strs+995)
190 #define OUTFILE_FLAGS (OPTST_DISABLED \
191 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
194 * load-pubkey option description:
196 #define LOAD_PUBKEY_DESC (danetool_opt_strs+1003)
197 #define LOAD_PUBKEY_NAME (danetool_opt_strs+1027)
198 #define LOAD_PUBKEY_name (danetool_opt_strs+1039)
199 #define LOAD_PUBKEY_FLAGS (OPTST_DISABLED \
200 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
203 * load-certificate option description:
205 #define LOAD_CERTIFICATE_DESC (danetool_opt_strs+1051)
206 #define LOAD_CERTIFICATE_NAME (danetool_opt_strs+1076)
207 #define LOAD_CERTIFICATE_name (danetool_opt_strs+1093)
208 #define LOAD_CERTIFICATE_FLAGS (OPTST_DISABLED \
209 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
212 * hash option description:
214 #define HASH_DESC (danetool_opt_strs+1110)
215 #define HASH_NAME (danetool_opt_strs+1145)
216 #define HASH_name (danetool_opt_strs+1150)
217 #define HASH_FLAGS (OPTST_DISABLED \
218 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
221 * inder option description:
223 #define INDER_DESC (danetool_opt_strs+1155)
224 #define INDER_NAME (danetool_opt_strs+1211)
225 #define NOT_INDER_name (danetool_opt_strs+1217)
226 #define NOT_INDER_PFX (danetool_opt_strs+1226)
227 #define INDER_name (NOT_INDER_name + 3)
228 #define INDER_FLAGS (OPTST_DISABLED)
231 * inraw option description:
233 #define INRAW_DESC (danetool_opt_strs+1229)
234 #define INRAW_NAME NULL
235 #define INRAW_name (danetool_opt_strs+1258)
236 #define INRAW_FLAGS (INDER_FLAGS | OPTST_ALIAS)
239 * outder option description:
241 #define OUTDER_DESC (danetool_opt_strs+1264)
242 #define OUTDER_NAME (danetool_opt_strs+1320)
243 #define NOT_OUTDER_name (danetool_opt_strs+1327)
244 #define NOT_OUTDER_PFX (danetool_opt_strs+1226)
245 #define OUTDER_name (NOT_OUTDER_name + 3)
246 #define OUTDER_FLAGS (OPTST_DISABLED)
249 * outraw option description:
251 #define OUTRAW_DESC (danetool_opt_strs+1337)
252 #define OUTRAW_NAME NULL
253 #define OUTRAW_name (danetool_opt_strs+1367)
254 #define OUTRAW_FLAGS (OUTDER_FLAGS | OPTST_ALIAS)
257 * tlsa-rr option description with
258 * "Must also have options" and "Incompatible options":
260 #define TLSA_RR_DESC (danetool_opt_strs+1374)
261 #define TLSA_RR_NAME (danetool_opt_strs+1428)
262 #define TLSA_RR_name (danetool_opt_strs+1436)
263 static int const aTlsa_RrMustList[] = {
264 INDEX_OPT_HOST, NO_EQUIVALENT };
265 #define TLSA_RR_FLAGS (OPTST_DISABLED)
268 * host option description:
270 #define HOST_DESC (danetool_opt_strs+1444)
271 #define HOST_NAME (danetool_opt_strs+1491)
272 #define HOST_name (danetool_opt_strs+1496)
273 #define HOST_FLAGS (OPTST_DISABLED \
274 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
277 * proto option description:
279 #define PROTO_DESC (danetool_opt_strs+1501)
280 #define PROTO_NAME (danetool_opt_strs+1548)
281 #define PROTO_name (danetool_opt_strs+1554)
282 #define PROTO_FLAGS (OPTST_DISABLED \
283 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
286 * port option description:
288 #define PORT_DESC (danetool_opt_strs+1560)
289 #define PORT_NAME (danetool_opt_strs+1603)
290 #define PORT_name (danetool_opt_strs+1608)
291 #define PORT_FLAGS (OPTST_DISABLED \
292 | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
295 * ca option description:
297 #define CA_DESC (danetool_opt_strs+1613)
298 #define CA_NAME (danetool_opt_strs+1688)
299 #define CA_name (danetool_opt_strs+1691)
300 #define CA_FLAGS (OPTST_DISABLED)
303 * x509 option description:
305 #define X509_DESC (danetool_opt_strs+1694)
306 #define X509_NAME (danetool_opt_strs+1761)
307 #define X509_name (danetool_opt_strs+1766)
308 #define X509_FLAGS (OPTST_DISABLED)
311 * local option description:
313 #define LOCAL_DESC (danetool_opt_strs+1771)
314 #define LOCAL_NAME (danetool_opt_strs+1829)
315 #define LOCAL_name (danetool_opt_strs+1835)
316 #define LOCAL_FLAGS (OPTST_DISABLED)
319 * Help/More_Help/Version option descriptions:
321 #define HELP_DESC (danetool_opt_strs+1841)
322 #define HELP_name (danetool_opt_strs+1885)
323 #ifdef HAVE_WORKING_FORK
324 #define MORE_HELP_DESC (danetool_opt_strs+1890)
325 #define MORE_HELP_name (danetool_opt_strs+1935)
326 #define MORE_HELP_FLAGS (OPTST_IMM | OPTST_NO_INIT)
327 #else
328 #define MORE_HELP_DESC NULL
329 #define MORE_HELP_name NULL
330 #define MORE_HELP_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
331 #endif
332 #ifdef NO_OPTIONAL_OPT_ARGS
333 # define VER_FLAGS (OPTST_IMM | OPTST_NO_INIT)
334 #else
335 # define VER_FLAGS (OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
336 OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT)
337 #endif
338 #define VER_DESC (danetool_opt_strs+1945)
339 #define VER_name (danetool_opt_strs+1981)
341 * Declare option callback procedures
343 extern tOptProc
344 optionBooleanVal, optionNestedVal, optionNumericVal,
345 optionPagedUsage, optionPrintVersion, optionResetOpt,
346 optionStackArg, optionTimeDate, optionTimeVal,
347 optionUnstackArg, optionVendorOption;
348 static tOptProc
349 doOptDebug, doOptInfile, doOptInraw, doOptOutraw, doUsageOpt;
350 #define VER_PROC optionPrintVersion
352 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
354 * Define the danetool Option Descriptions.
355 * This is an array of OPTION_CT entries, one for each
356 * option that the danetool program responds to.
358 static tOptDesc optDesc[OPTION_CT] = {
359 { /* entry idx, value */ 0, VALUE_OPT_DEBUG,
360 /* equiv idx, value */ 0, VALUE_OPT_DEBUG,
361 /* equivalenced to */ NO_EQUIVALENT,
362 /* min, max, act ct */ 0, 1, 0,
363 /* opt state flags */ DEBUG_FLAGS, 0,
364 /* last opt argumnt */ { NULL }, /* --debug */
365 /* arg list/cookie */ NULL,
366 /* must/cannot opts */ NULL, NULL,
367 /* option proc */ doOptDebug,
368 /* desc, NAME, name */ DEBUG_DESC, DEBUG_NAME, DEBUG_name,
369 /* disablement strs */ NULL, NULL },
371 { /* entry idx, value */ 1, VALUE_OPT_VERBOSE,
372 /* equiv idx, value */ 1, VALUE_OPT_VERBOSE,
373 /* equivalenced to */ NO_EQUIVALENT,
374 /* min, max, act ct */ 0, NOLIMIT, 0,
375 /* opt state flags */ VERBOSE_FLAGS, 0,
376 /* last opt argumnt */ { NULL }, /* --verbose */
377 /* arg list/cookie */ NULL,
378 /* must/cannot opts */ NULL, NULL,
379 /* option proc */ NULL,
380 /* desc, NAME, name */ VERBOSE_DESC, VERBOSE_NAME, VERBOSE_name,
381 /* disablement strs */ NULL, NULL },
383 { /* entry idx, value */ 2, VALUE_OPT_INFILE,
384 /* equiv idx, value */ 2, VALUE_OPT_INFILE,
385 /* equivalenced to */ NO_EQUIVALENT,
386 /* min, max, act ct */ 0, 1, 0,
387 /* opt state flags */ INFILE_FLAGS, 0,
388 /* last opt argumnt */ { NULL }, /* --infile */
389 /* arg list/cookie */ NULL,
390 /* must/cannot opts */ NULL, NULL,
391 /* option proc */ doOptInfile,
392 /* desc, NAME, name */ INFILE_DESC, INFILE_NAME, INFILE_name,
393 /* disablement strs */ NULL, NULL },
395 { /* entry idx, value */ 3, VALUE_OPT_OUTFILE,
396 /* equiv idx, value */ 3, VALUE_OPT_OUTFILE,
397 /* equivalenced to */ NO_EQUIVALENT,
398 /* min, max, act ct */ 0, 1, 0,
399 /* opt state flags */ OUTFILE_FLAGS, 0,
400 /* last opt argumnt */ { NULL }, /* --outfile */
401 /* arg list/cookie */ NULL,
402 /* must/cannot opts */ NULL, NULL,
403 /* option proc */ NULL,
404 /* desc, NAME, name */ OUTFILE_DESC, OUTFILE_NAME, OUTFILE_name,
405 /* disablement strs */ NULL, NULL },
407 { /* entry idx, value */ 4, VALUE_OPT_LOAD_PUBKEY,
408 /* equiv idx, value */ 4, VALUE_OPT_LOAD_PUBKEY,
409 /* equivalenced to */ NO_EQUIVALENT,
410 /* min, max, act ct */ 0, 1, 0,
411 /* opt state flags */ LOAD_PUBKEY_FLAGS, 0,
412 /* last opt argumnt */ { NULL }, /* --load-pubkey */
413 /* arg list/cookie */ NULL,
414 /* must/cannot opts */ NULL, NULL,
415 /* option proc */ NULL,
416 /* desc, NAME, name */ LOAD_PUBKEY_DESC, LOAD_PUBKEY_NAME, LOAD_PUBKEY_name,
417 /* disablement strs */ NULL, NULL },
419 { /* entry idx, value */ 5, VALUE_OPT_LOAD_CERTIFICATE,
420 /* equiv idx, value */ 5, VALUE_OPT_LOAD_CERTIFICATE,
421 /* equivalenced to */ NO_EQUIVALENT,
422 /* min, max, act ct */ 0, 1, 0,
423 /* opt state flags */ LOAD_CERTIFICATE_FLAGS, 0,
424 /* last opt argumnt */ { NULL }, /* --load-certificate */
425 /* arg list/cookie */ NULL,
426 /* must/cannot opts */ NULL, NULL,
427 /* option proc */ NULL,
428 /* desc, NAME, name */ LOAD_CERTIFICATE_DESC, LOAD_CERTIFICATE_NAME, LOAD_CERTIFICATE_name,
429 /* disablement strs */ NULL, NULL },
431 { /* entry idx, value */ 6, VALUE_OPT_HASH,
432 /* equiv idx, value */ 6, VALUE_OPT_HASH,
433 /* equivalenced to */ NO_EQUIVALENT,
434 /* min, max, act ct */ 0, 1, 0,
435 /* opt state flags */ HASH_FLAGS, 0,
436 /* last opt argumnt */ { NULL }, /* --hash */
437 /* arg list/cookie */ NULL,
438 /* must/cannot opts */ NULL, NULL,
439 /* option proc */ NULL,
440 /* desc, NAME, name */ HASH_DESC, HASH_NAME, HASH_name,
441 /* disablement strs */ NULL, NULL },
443 { /* entry idx, value */ 7, VALUE_OPT_INDER,
444 /* equiv idx, value */ 7, VALUE_OPT_INDER,
445 /* equivalenced to */ NO_EQUIVALENT,
446 /* min, max, act ct */ 0, 1, 0,
447 /* opt state flags */ INDER_FLAGS, 0,
448 /* last opt argumnt */ { NULL }, /* --inder */
449 /* arg list/cookie */ NULL,
450 /* must/cannot opts */ NULL, NULL,
451 /* option proc */ NULL,
452 /* desc, NAME, name */ INDER_DESC, INDER_NAME, INDER_name,
453 /* disablement strs */ NOT_INDER_name, NOT_INDER_PFX },
455 { /* entry idx, value */ 8, VALUE_OPT_INRAW,
456 /* equiv idx, value */ 8, VALUE_OPT_INRAW,
457 /* equivalenced to */ NO_EQUIVALENT,
458 /* min, max, act ct */ 0, 1, 0,
459 /* opt state flags */ INRAW_FLAGS, 0,
460 /* last opt argumnt */ { NULL }, /* --inraw */
461 /* arg list/cookie */ NULL,
462 /* must/cannot opts */ NULL, NULL,
463 /* option proc */ doOptInraw,
464 /* desc, NAME, name */ INRAW_DESC, INRAW_NAME, INRAW_name,
465 /* disablement strs */ 0, 0 },
467 { /* entry idx, value */ 9, VALUE_OPT_OUTDER,
468 /* equiv idx, value */ 9, VALUE_OPT_OUTDER,
469 /* equivalenced to */ NO_EQUIVALENT,
470 /* min, max, act ct */ 0, 1, 0,
471 /* opt state flags */ OUTDER_FLAGS, 0,
472 /* last opt argumnt */ { NULL }, /* --outder */
473 /* arg list/cookie */ NULL,
474 /* must/cannot opts */ NULL, NULL,
475 /* option proc */ NULL,
476 /* desc, NAME, name */ OUTDER_DESC, OUTDER_NAME, OUTDER_name,
477 /* disablement strs */ NOT_OUTDER_name, NOT_OUTDER_PFX },
479 { /* entry idx, value */ 10, VALUE_OPT_OUTRAW,
480 /* equiv idx, value */ 10, VALUE_OPT_OUTRAW,
481 /* equivalenced to */ NO_EQUIVALENT,
482 /* min, max, act ct */ 0, 1, 0,
483 /* opt state flags */ OUTRAW_FLAGS, 0,
484 /* last opt argumnt */ { NULL }, /* --outraw */
485 /* arg list/cookie */ NULL,
486 /* must/cannot opts */ NULL, NULL,
487 /* option proc */ doOptOutraw,
488 /* desc, NAME, name */ OUTRAW_DESC, OUTRAW_NAME, OUTRAW_name,
489 /* disablement strs */ 0, 0 },
491 { /* entry idx, value */ 11, VALUE_OPT_TLSA_RR,
492 /* equiv idx, value */ 11, VALUE_OPT_TLSA_RR,
493 /* equivalenced to */ NO_EQUIVALENT,
494 /* min, max, act ct */ 0, 1, 0,
495 /* opt state flags */ TLSA_RR_FLAGS, 0,
496 /* last opt argumnt */ { NULL }, /* --tlsa-rr */
497 /* arg list/cookie */ NULL,
498 /* must/cannot opts */ aTlsa_RrMustList, NULL,
499 /* option proc */ NULL,
500 /* desc, NAME, name */ TLSA_RR_DESC, TLSA_RR_NAME, TLSA_RR_name,
501 /* disablement strs */ NULL, NULL },
503 { /* entry idx, value */ 12, VALUE_OPT_HOST,
504 /* equiv idx, value */ 12, VALUE_OPT_HOST,
505 /* equivalenced to */ NO_EQUIVALENT,
506 /* min, max, act ct */ 0, 1, 0,
507 /* opt state flags */ HOST_FLAGS, 0,
508 /* last opt argumnt */ { NULL }, /* --host */
509 /* arg list/cookie */ NULL,
510 /* must/cannot opts */ NULL, NULL,
511 /* option proc */ NULL,
512 /* desc, NAME, name */ HOST_DESC, HOST_NAME, HOST_name,
513 /* disablement strs */ NULL, NULL },
515 { /* entry idx, value */ 13, VALUE_OPT_PROTO,
516 /* equiv idx, value */ 13, VALUE_OPT_PROTO,
517 /* equivalenced to */ NO_EQUIVALENT,
518 /* min, max, act ct */ 0, 1, 0,
519 /* opt state flags */ PROTO_FLAGS, 0,
520 /* last opt argumnt */ { NULL }, /* --proto */
521 /* arg list/cookie */ NULL,
522 /* must/cannot opts */ NULL, NULL,
523 /* option proc */ NULL,
524 /* desc, NAME, name */ PROTO_DESC, PROTO_NAME, PROTO_name,
525 /* disablement strs */ NULL, NULL },
527 { /* entry idx, value */ 14, VALUE_OPT_PORT,
528 /* equiv idx, value */ 14, VALUE_OPT_PORT,
529 /* equivalenced to */ NO_EQUIVALENT,
530 /* min, max, act ct */ 0, 1, 0,
531 /* opt state flags */ PORT_FLAGS, 0,
532 /* last opt argumnt */ { NULL }, /* --port */
533 /* arg list/cookie */ NULL,
534 /* must/cannot opts */ NULL, NULL,
535 /* option proc */ optionNumericVal,
536 /* desc, NAME, name */ PORT_DESC, PORT_NAME, PORT_name,
537 /* disablement strs */ NULL, NULL },
539 { /* entry idx, value */ 15, VALUE_OPT_CA,
540 /* equiv idx, value */ 15, VALUE_OPT_CA,
541 /* equivalenced to */ NO_EQUIVALENT,
542 /* min, max, act ct */ 0, 1, 0,
543 /* opt state flags */ CA_FLAGS, 0,
544 /* last opt argumnt */ { NULL }, /* --ca */
545 /* arg list/cookie */ NULL,
546 /* must/cannot opts */ NULL, NULL,
547 /* option proc */ NULL,
548 /* desc, NAME, name */ CA_DESC, CA_NAME, CA_name,
549 /* disablement strs */ NULL, NULL },
551 { /* entry idx, value */ 16, VALUE_OPT_X509,
552 /* equiv idx, value */ 16, VALUE_OPT_X509,
553 /* equivalenced to */ NO_EQUIVALENT,
554 /* min, max, act ct */ 0, 1, 0,
555 /* opt state flags */ X509_FLAGS, 0,
556 /* last opt argumnt */ { NULL }, /* --x509 */
557 /* arg list/cookie */ NULL,
558 /* must/cannot opts */ NULL, NULL,
559 /* option proc */ NULL,
560 /* desc, NAME, name */ X509_DESC, X509_NAME, X509_name,
561 /* disablement strs */ NULL, NULL },
563 { /* entry idx, value */ 17, VALUE_OPT_LOCAL,
564 /* equiv idx, value */ 17, VALUE_OPT_LOCAL,
565 /* equivalenced to */ NO_EQUIVALENT,
566 /* min, max, act ct */ 0, 1, 0,
567 /* opt state flags */ LOCAL_FLAGS, 0,
568 /* last opt argumnt */ { NULL }, /* --local */
569 /* arg list/cookie */ NULL,
570 /* must/cannot opts */ NULL, NULL,
571 /* option proc */ NULL,
572 /* desc, NAME, name */ LOCAL_DESC, LOCAL_NAME, LOCAL_name,
573 /* disablement strs */ NULL, NULL },
575 { /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
576 /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_VERSION,
577 /* equivalenced to */ NO_EQUIVALENT,
578 /* min, max, act ct */ 0, 1, 0,
579 /* opt state flags */ VER_FLAGS, 0,
580 /* last opt argumnt */ { NULL },
581 /* arg list/cookie */ NULL,
582 /* must/cannot opts */ NULL, NULL,
583 /* option proc */ VER_PROC,
584 /* desc, NAME, name */ VER_DESC, NULL, VER_name,
585 /* disablement strs */ NULL, NULL },
589 { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
590 /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_HELP,
591 /* equivalenced to */ NO_EQUIVALENT,
592 /* min, max, act ct */ 0, 1, 0,
593 /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0,
594 /* last opt argumnt */ { NULL },
595 /* arg list/cookie */ NULL,
596 /* must/cannot opts */ NULL, NULL,
597 /* option proc */ doUsageOpt,
598 /* desc, NAME, name */ HELP_DESC, NULL, HELP_name,
599 /* disablement strs */ NULL, NULL },
601 { /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
602 /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_MORE_HELP,
603 /* equivalenced to */ NO_EQUIVALENT,
604 /* min, max, act ct */ 0, 1, 0,
605 /* opt state flags */ MORE_HELP_FLAGS, 0,
606 /* last opt argumnt */ { NULL },
607 /* arg list/cookie */ NULL,
608 /* must/cannot opts */ NULL, NULL,
609 /* option proc */ optionPagedUsage,
610 /* desc, NAME, name */ MORE_HELP_DESC, NULL, MORE_HELP_name,
611 /* disablement strs */ NULL, NULL }
615 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
617 * Define the danetool Option Environment
619 #define zPROGNAME (danetool_opt_strs+1989)
620 #define zUsageTitle (danetool_opt_strs+1998)
621 #define zRcName NULL
622 #define apzHomeList NULL
623 #define zBugsAddr (danetool_opt_strs+2101)
624 #define zExplain (danetool_opt_strs+2120)
625 #define zDetail (danetool_opt_strs+2123)
626 #define zFullVersion (danetool_opt_strs+2183)
627 /* extracted from optcode.tlib near line 350 */
629 #if defined(ENABLE_NLS)
630 # define OPTPROC_BASE OPTPROC_TRANSLATE | OPTPROC_NXLAT_OPT
631 static tOptionXlateProc translate_option_strings;
632 #else
633 # define OPTPROC_BASE OPTPROC_NONE
634 # define translate_option_strings NULL
635 #endif /* ENABLE_NLS */
638 #define danetool_full_usage (NULL)
640 #define danetool_short_usage (danetool_opt_strs+2202)
642 #endif /* not defined __doxygen__ */
645 * Create the static procedure(s) declared above.
648 * The callout function that invokes the optionUsage function.
650 * @param pOptions the AutoOpts option description structure
651 * @param pOptDesc the descriptor for the "help" (usage) option.
652 * @noreturn
654 static void
655 doUsageOpt(tOptions * pOptions, tOptDesc * pOptDesc)
657 optionUsage(&danetoolOptions, DANETOOL_EXIT_SUCCESS);
658 /* NOTREACHED */
659 (void)pOptDesc;
660 (void)pOptions;
663 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
665 * Code to handle the debug option.
667 * @param pOptions the danetool options data structure
668 * @param pOptDesc the option descriptor for this option.
670 static void
671 doOptDebug(tOptions* pOptions, tOptDesc* pOptDesc)
673 static struct {long rmin, rmax;} const rng[1] = {
674 { 0 , 9999 } };
675 int ix;
677 if (pOptions <= OPTPROC_EMIT_LIMIT)
678 goto emit_ranges;
679 optionNumericVal(pOptions, pOptDesc);
681 for (ix = 0; ix < 1; ix++) {
682 if (pOptDesc->optArg.argInt < rng[ix].rmin)
683 continue; /* ranges need not be ordered. */
684 if (pOptDesc->optArg.argInt == rng[ix].rmin)
685 return;
686 if (rng[ix].rmax == LONG_MIN)
687 continue;
688 if (pOptDesc->optArg.argInt <= rng[ix].rmax)
689 return;
692 option_usage_fp = stderr;
694 emit_ranges:
696 optionShowRange(pOptions, pOptDesc, (void *)rng, 1);
699 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
701 * Code to handle the infile option.
703 * @param pOptions the danetool options data structure
704 * @param pOptDesc the option descriptor for this option.
706 static void
707 doOptInfile(tOptions* pOptions, tOptDesc* pOptDesc)
709 static teOptFileType const type =
710 FTYPE_MODE_MUST_EXIST + FTYPE_MODE_NO_OPEN;
711 static tuFileMode mode;
712 #ifndef O_CLOEXEC
713 # define O_CLOEXEC 0
714 #endif
715 mode.file_flags = O_CLOEXEC;
717 optionFileCheck(pOptions, pOptDesc, type, mode);
720 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
722 * Code to handle the inraw option.
724 * @param pOptions the danetool options data structure
725 * @param pOptDesc the option descriptor for this option.
727 static void
728 doOptInraw(tOptions* pOptions, tOptDesc* pOptDesc)
730 int res = optionAlias(pOptions, pOptDesc, INDEX_OPT_INDER);
731 if ((res != 0) && ((pOptions->fOptSet & OPTPROC_ERRSTOP) != 0))
732 USAGE(DANETOOL_EXIT_FAILURE);
736 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
738 * Code to handle the outraw option.
740 * @param pOptions the danetool options data structure
741 * @param pOptDesc the option descriptor for this option.
743 static void
744 doOptOutraw(tOptions* pOptions, tOptDesc* pOptDesc)
746 int res = optionAlias(pOptions, pOptDesc, INDEX_OPT_OUTDER);
747 if ((res != 0) && ((pOptions->fOptSet & OPTPROC_ERRSTOP) != 0))
748 USAGE(DANETOOL_EXIT_FAILURE);
751 /* extracted from optmain.tlib near line 1113 */
754 * The directory containing the data associated with danetool.
756 #ifndef PKGDATADIR
757 # define PKGDATADIR ""
758 #endif
761 * Information about the person or institution that packaged danetool
762 * for the current distribution.
764 #ifndef WITH_PACKAGER
765 # define danetool_packager_info NULL
766 #else
767 static char const danetool_packager_info[] =
768 "Packaged by " WITH_PACKAGER
770 # ifdef WITH_PACKAGER_VERSION
771 " ("WITH_PACKAGER_VERSION")"
772 # endif
774 # ifdef WITH_PACKAGER_BUG_REPORTS
775 "\nReport danetool bugs to " WITH_PACKAGER_BUG_REPORTS
776 # endif
777 "\n";
778 #endif
779 #ifndef __doxygen__
781 #endif /* __doxygen__ */
783 * The option definitions for danetool. The one structure that
784 * binds them all.
786 tOptions danetoolOptions = {
787 OPTIONS_STRUCT_VERSION,
788 0, NULL, /* original argc + argv */
789 ( OPTPROC_BASE
790 + OPTPROC_ERRSTOP
791 + OPTPROC_SHORTOPT
792 + OPTPROC_LONGOPT
793 + OPTPROC_NO_REQ_OPT
794 + OPTPROC_NEGATIONS
795 + OPTPROC_NO_ARGS
796 + OPTPROC_GNUUSAGE
797 + OPTPROC_MISUSE ),
798 0, NULL, /* current option index, current option */
799 NULL, NULL, zPROGNAME,
800 zRcName, zCopyright, zLicenseDescrip,
801 zFullVersion, apzHomeList, zUsageTitle,
802 zExplain, zDetail, optDesc,
803 zBugsAddr, /* address to send bugs to */
804 NULL, NULL, /* extensions/saved state */
805 optionUsage, /* usage procedure */
806 translate_option_strings, /* translation procedure */
808 * Indexes to special options
810 { INDEX_OPT_MORE_HELP, /* more-help option index */
811 NO_EQUIVALENT, /* save option index */
812 NO_EQUIVALENT, /* '-#' option index */
813 NO_EQUIVALENT /* index of default opt */
815 21 /* full option count */, 18 /* user option count */,
816 danetool_full_usage, danetool_short_usage,
817 NULL, NULL,
818 PKGDATADIR, danetool_packager_info
821 #if ENABLE_NLS
822 #include <stdio.h>
823 #include <stdlib.h>
824 #include <string.h>
825 #include <unistd.h>
826 #include <autoopts/usage-txt.h>
828 static char* AO_gettext(char const* pz);
829 static void coerce_it(void** s);
832 * AutoGen specific wrapper function for gettext.
833 * It relies on the macro _() to convert from English to the target
834 * language, then strdup-duplicates the result string.
836 * @param[in] pz the input text used as a lookup key.
837 * @returns the translated text (if there is one),
838 * or the original text (if not).
840 static char *
841 AO_gettext(char const* pz)
843 char* pzRes;
844 if (pz == NULL)
845 return NULL;
846 pzRes = _(pz);
847 if (pzRes == pz)
848 return pzRes;
849 pzRes = strdup(pzRes);
850 if (pzRes == NULL) {
851 fputs(_("No memory for duping translated strings\n"), stderr);
852 exit(DANETOOL_EXIT_FAILURE);
854 return pzRes;
857 static void coerce_it(void** s) { *s = AO_gettext(*s);
861 * Translate all the translatable strings in the danetoolOptions
862 * structure defined above. This is done only once.
864 static void
865 translate_option_strings(void)
867 tOptions * const pOpt = &danetoolOptions;
870 * Guard against re-translation. It won't work. The strings will have
871 * been changed by the first pass through this code. One shot only.
873 if (option_usage_text.field_ct != 0) {
875 * Do the translations. The first pointer follows the field count
876 * field. The field count field is the size of a pointer.
878 tOptDesc * pOD = pOpt->pOptDesc;
879 char ** ppz = (char**)(void*)&(option_usage_text);
880 int ix = option_usage_text.field_ct;
882 do {
883 ppz++;
884 *ppz = AO_gettext(*ppz);
885 } while (--ix > 0);
887 coerce_it((void*)&(pOpt->pzCopyright));
888 coerce_it((void*)&(pOpt->pzCopyNotice));
889 coerce_it((void*)&(pOpt->pzFullVersion));
890 coerce_it((void*)&(pOpt->pzUsageTitle));
891 coerce_it((void*)&(pOpt->pzExplain));
892 coerce_it((void*)&(pOpt->pzDetail));
893 coerce_it((void*)&(pOpt->pzPackager));
894 coerce_it((void*)&(pOpt->pzShortUsage));
895 option_usage_text.field_ct = 0;
897 for (ix = pOpt->optCt; ix > 0; ix--, pOD++)
898 coerce_it((void*)&(pOD->pzText));
901 if ((pOpt->fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) {
902 tOptDesc * pOD = pOpt->pOptDesc;
903 int ix;
905 for (ix = pOpt->optCt; ix > 0; ix--, pOD++) {
906 coerce_it((void*)&(pOD->pz_Name));
907 coerce_it((void*)&(pOD->pz_DisableName));
908 coerce_it((void*)&(pOD->pz_DisablePfx));
910 /* prevent re-translation */
911 danetoolOptions.fOptSet |= OPTPROC_NXLAT_OPT_CFG | OPTPROC_NXLAT_OPT;
915 #endif /* ENABLE_NLS */
917 #ifdef __cplusplus
919 #endif
920 /* danetool-args.c ends here */