corrected news entry.
[gnutls.git] / src / cli-debug-args.c
blobdbee34154055317c0d73e301bb1ecd3a7a4142da
1 /* -*- buffer-read-only: t -*- vi: set ro:
2 *
3 * DO NOT EDIT THIS FILE (cli-debug-args.c)
4 *
5 * It has been AutoGen-ed May 9, 2012 at 08:05:27 PM by AutoGen 5.16
6 * From the definitions cli-debug-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 gnutls-cli-debug 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 gnutls-cli-debug 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 * gnutls-cli-debug 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 * gnutls-cli-debug 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 "cli-debug-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 (gnutls_cli_debug_opt_strs+0)
60 #define zLicenseDescrip (gnutls_cli_debug_opt_strs+287)
63 #ifndef NULL
64 # define NULL 0
65 #endif
68 * gnutls-cli-debug option static const strings
70 static char const gnutls_cli_debug_opt_strs[1841] =
71 /* 0 */ "gnutls-cli-debug @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 /* 287 */ "gnutls-cli-debug is free software: you can redistribute it and/or modify it\n"
78 "under 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 "gnutls-cli-debug is distributed in the hope that it will be useful, but\n"
82 "WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\n"
83 "or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\n"
84 "for more 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 /* 908 */ "Enable debugging.\0"
88 /* 926 */ "DEBUG\0"
89 /* 932 */ "debug\0"
90 /* 938 */ "More verbose output\0"
91 /* 958 */ "VERBOSE\0"
92 /* 966 */ "verbose\0"
93 /* 974 */ "The port to connect to\0"
94 /* 997 */ "PORT\0"
95 /* 1002 */ "port\0"
96 /* 1007 */ "Display extended usage information and exit\0"
97 /* 1051 */ "help\0"
98 /* 1056 */ "Extended usage information passed thru pager\0"
99 /* 1101 */ "more-help\0"
100 /* 1111 */ "Output version information and exit\0"
101 /* 1147 */ "version\0"
102 /* 1155 */ "GNUTLS_CLI_DEBUG\0"
103 /* 1172 */ "gnutls-cli-debug - GnuTLS debug client - Ver. @VERSION@\n"
104 "USAGE: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \n\0"
105 /* 1287 */ "bug-gnutls@gnu.org\0"
106 /* 1306 */ "\n\n\0"
107 /* 1309 */ "\n"
108 "TLS debug client. It sets up multiple TLS connections to a server and\n"
109 "queries its capabilities. It was created to assist in debugging GnuTLS,\n"
110 "but it might be useful to extract a TLS server's capabilities. It connects\n"
111 "to a TLS server, performs tests and print the server's capabilities. If\n"
112 "called with the `-v' parameter more checks will be performed. Can be used\n"
113 "to check for servers with special needs or bugs.\n\0"
114 /* 1728 */ "gnutls-cli-debug @VERSION@\0"
115 /* 1755 */ "Usage: gnutls-cli-debug [options] hostname\n"
116 "gnutls-cli --help for usage instructions.\n";
119 * debug option description:
121 #define DEBUG_DESC (gnutls_cli_debug_opt_strs+908)
122 #define DEBUG_NAME (gnutls_cli_debug_opt_strs+926)
123 #define DEBUG_name (gnutls_cli_debug_opt_strs+932)
124 #define DEBUG_FLAGS (OPTST_DISABLED \
125 | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
128 * verbose option description:
130 #define VERBOSE_DESC (gnutls_cli_debug_opt_strs+938)
131 #define VERBOSE_NAME (gnutls_cli_debug_opt_strs+958)
132 #define VERBOSE_name (gnutls_cli_debug_opt_strs+966)
133 #define VERBOSE_FLAGS (OPTST_DISABLED)
136 * port option description:
138 #define PORT_DESC (gnutls_cli_debug_opt_strs+974)
139 #define PORT_NAME (gnutls_cli_debug_opt_strs+997)
140 #define PORT_name (gnutls_cli_debug_opt_strs+1002)
141 #define PORT_FLAGS (OPTST_DISABLED \
142 | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
145 * Help/More_Help/Version option descriptions:
147 #define HELP_DESC (gnutls_cli_debug_opt_strs+1007)
148 #define HELP_name (gnutls_cli_debug_opt_strs+1051)
149 #ifdef HAVE_WORKING_FORK
150 #define MORE_HELP_DESC (gnutls_cli_debug_opt_strs+1056)
151 #define MORE_HELP_name (gnutls_cli_debug_opt_strs+1101)
152 #define MORE_HELP_FLAGS (OPTST_IMM | OPTST_NO_INIT)
153 #else
154 #define MORE_HELP_DESC NULL
155 #define MORE_HELP_name NULL
156 #define MORE_HELP_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
157 #endif
158 #ifdef NO_OPTIONAL_OPT_ARGS
159 # define VER_FLAGS (OPTST_IMM | OPTST_NO_INIT)
160 #else
161 # define VER_FLAGS (OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
162 OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT)
163 #endif
164 #define VER_DESC (gnutls_cli_debug_opt_strs+1111)
165 #define VER_name (gnutls_cli_debug_opt_strs+1147)
167 * Declare option callback procedures
169 extern tOptProc
170 optionBooleanVal, optionNestedVal, optionNumericVal,
171 optionPagedUsage, optionPrintVersion, optionResetOpt,
172 optionStackArg, optionTimeDate, optionTimeVal,
173 optionUnstackArg, optionVendorOption;
174 static tOptProc
175 doOptDebug, doOptPort, doUsageOpt;
176 #define VER_PROC optionPrintVersion
178 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
180 * Define the gnutls-cli-debug Option Descriptions.
181 * This is an array of OPTION_CT entries, one for each
182 * option that the gnutls-cli-debug program responds to.
184 static tOptDesc optDesc[OPTION_CT] = {
185 { /* entry idx, value */ 0, VALUE_OPT_DEBUG,
186 /* equiv idx, value */ 0, VALUE_OPT_DEBUG,
187 /* equivalenced to */ NO_EQUIVALENT,
188 /* min, max, act ct */ 0, 1, 0,
189 /* opt state flags */ DEBUG_FLAGS, 0,
190 /* last opt argumnt */ { NULL }, /* --debug */
191 /* arg list/cookie */ NULL,
192 /* must/cannot opts */ NULL, NULL,
193 /* option proc */ doOptDebug,
194 /* desc, NAME, name */ DEBUG_DESC, DEBUG_NAME, DEBUG_name,
195 /* disablement strs */ NULL, NULL },
197 { /* entry idx, value */ 1, VALUE_OPT_VERBOSE,
198 /* equiv idx, value */ 1, VALUE_OPT_VERBOSE,
199 /* equivalenced to */ NO_EQUIVALENT,
200 /* min, max, act ct */ 0, NOLIMIT, 0,
201 /* opt state flags */ VERBOSE_FLAGS, 0,
202 /* last opt argumnt */ { NULL }, /* --verbose */
203 /* arg list/cookie */ NULL,
204 /* must/cannot opts */ NULL, NULL,
205 /* option proc */ NULL,
206 /* desc, NAME, name */ VERBOSE_DESC, VERBOSE_NAME, VERBOSE_name,
207 /* disablement strs */ NULL, NULL },
209 { /* entry idx, value */ 2, VALUE_OPT_PORT,
210 /* equiv idx, value */ 2, VALUE_OPT_PORT,
211 /* equivalenced to */ NO_EQUIVALENT,
212 /* min, max, act ct */ 0, 1, 0,
213 /* opt state flags */ PORT_FLAGS, 0,
214 /* last opt argumnt */ { NULL }, /* --port */
215 /* arg list/cookie */ NULL,
216 /* must/cannot opts */ NULL, NULL,
217 /* option proc */ doOptPort,
218 /* desc, NAME, name */ PORT_DESC, PORT_NAME, PORT_name,
219 /* disablement strs */ NULL, NULL },
221 { /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
222 /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_VERSION,
223 /* equivalenced to */ NO_EQUIVALENT,
224 /* min, max, act ct */ 0, 1, 0,
225 /* opt state flags */ VER_FLAGS, 0,
226 /* last opt argumnt */ { NULL },
227 /* arg list/cookie */ NULL,
228 /* must/cannot opts */ NULL, NULL,
229 /* option proc */ VER_PROC,
230 /* desc, NAME, name */ VER_DESC, NULL, VER_name,
231 /* disablement strs */ NULL, NULL },
235 { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
236 /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_HELP,
237 /* equivalenced to */ NO_EQUIVALENT,
238 /* min, max, act ct */ 0, 1, 0,
239 /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0,
240 /* last opt argumnt */ { NULL },
241 /* arg list/cookie */ NULL,
242 /* must/cannot opts */ NULL, NULL,
243 /* option proc */ doUsageOpt,
244 /* desc, NAME, name */ HELP_DESC, NULL, HELP_name,
245 /* disablement strs */ NULL, NULL },
247 { /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
248 /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_MORE_HELP,
249 /* equivalenced to */ NO_EQUIVALENT,
250 /* min, max, act ct */ 0, 1, 0,
251 /* opt state flags */ MORE_HELP_FLAGS, 0,
252 /* last opt argumnt */ { NULL },
253 /* arg list/cookie */ NULL,
254 /* must/cannot opts */ NULL, NULL,
255 /* option proc */ optionPagedUsage,
256 /* desc, NAME, name */ MORE_HELP_DESC, NULL, MORE_HELP_name,
257 /* disablement strs */ NULL, NULL }
261 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
263 * Define the gnutls-cli-debug Option Environment
265 #define zPROGNAME (gnutls_cli_debug_opt_strs+1155)
266 #define zUsageTitle (gnutls_cli_debug_opt_strs+1172)
267 #define zRcName NULL
268 #define apzHomeList NULL
269 #define zBugsAddr (gnutls_cli_debug_opt_strs+1287)
270 #define zExplain (gnutls_cli_debug_opt_strs+1306)
271 #define zDetail (gnutls_cli_debug_opt_strs+1309)
272 #define zFullVersion (gnutls_cli_debug_opt_strs+1728)
273 /* extracted from optcode.tlib near line 350 */
275 #if defined(ENABLE_NLS)
276 # define OPTPROC_BASE OPTPROC_TRANSLATE | OPTPROC_NXLAT_OPT
277 static tOptionXlateProc translate_option_strings;
278 #else
279 # define OPTPROC_BASE OPTPROC_NONE
280 # define translate_option_strings NULL
281 #endif /* ENABLE_NLS */
284 #define gnutls_cli_debug_full_usage (NULL)
286 #define gnutls_cli_debug_short_usage (gnutls_cli_debug_opt_strs+1755)
288 #endif /* not defined __doxygen__ */
291 * Create the static procedure(s) declared above.
294 * The callout function that invokes the optionUsage function.
296 * @param pOptions the AutoOpts option description structure
297 * @param pOptDesc the descriptor for the "help" (usage) option.
298 * @noreturn
300 static void
301 doUsageOpt(tOptions * pOptions, tOptDesc * pOptDesc)
303 optionUsage(&gnutls_cli_debugOptions, GNUTLS_CLI_DEBUG_EXIT_SUCCESS);
304 /* NOTREACHED */
305 (void)pOptDesc;
306 (void)pOptions;
309 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
311 * Code to handle the debug option.
313 * @param pOptions the gnutls-cli-debug options data structure
314 * @param pOptDesc the option descriptor for this option.
316 static void
317 doOptDebug(tOptions* pOptions, tOptDesc* pOptDesc)
319 static struct {long rmin, rmax;} const rng[1] = {
320 { 0 , 9999 } };
321 int ix;
323 if (pOptions <= OPTPROC_EMIT_LIMIT)
324 goto emit_ranges;
325 optionNumericVal(pOptions, pOptDesc);
327 for (ix = 0; ix < 1; ix++) {
328 if (pOptDesc->optArg.argInt < rng[ix].rmin)
329 continue; /* ranges need not be ordered. */
330 if (pOptDesc->optArg.argInt == rng[ix].rmin)
331 return;
332 if (rng[ix].rmax == LONG_MIN)
333 continue;
334 if (pOptDesc->optArg.argInt <= rng[ix].rmax)
335 return;
338 option_usage_fp = stderr;
340 emit_ranges:
342 optionShowRange(pOptions, pOptDesc, (void *)rng, 1);
345 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
347 * Code to handle the port option.
349 * @param pOptions the gnutls-cli-debug options data structure
350 * @param pOptDesc the option descriptor for this option.
352 static void
353 doOptPort(tOptions* pOptions, tOptDesc* pOptDesc)
355 static struct {long rmin, rmax;} const rng[1] = {
356 { 0 , 65536 } };
357 int ix;
359 if (pOptions <= OPTPROC_EMIT_LIMIT)
360 goto emit_ranges;
361 optionNumericVal(pOptions, pOptDesc);
363 for (ix = 0; ix < 1; ix++) {
364 if (pOptDesc->optArg.argInt < rng[ix].rmin)
365 continue; /* ranges need not be ordered. */
366 if (pOptDesc->optArg.argInt == rng[ix].rmin)
367 return;
368 if (rng[ix].rmax == LONG_MIN)
369 continue;
370 if (pOptDesc->optArg.argInt <= rng[ix].rmax)
371 return;
374 option_usage_fp = stderr;
376 emit_ranges:
378 optionShowRange(pOptions, pOptDesc, (void *)rng, 1);
380 /* extracted from optmain.tlib near line 1113 */
383 * The directory containing the data associated with gnutls-cli-debug.
385 #ifndef PKGDATADIR
386 # define PKGDATADIR ""
387 #endif
390 * Information about the person or institution that packaged gnutls-cli-debug
391 * for the current distribution.
393 #ifndef WITH_PACKAGER
394 # define gnutls_cli_debug_packager_info NULL
395 #else
396 static char const gnutls_cli_debug_packager_info[] =
397 "Packaged by " WITH_PACKAGER
399 # ifdef WITH_PACKAGER_VERSION
400 " ("WITH_PACKAGER_VERSION")"
401 # endif
403 # ifdef WITH_PACKAGER_BUG_REPORTS
404 "\nReport gnutls_cli_debug bugs to " WITH_PACKAGER_BUG_REPORTS
405 # endif
406 "\n";
407 #endif
408 #ifndef __doxygen__
410 #endif /* __doxygen__ */
412 * The option definitions for gnutls-cli-debug. The one structure that
413 * binds them all.
415 tOptions gnutls_cli_debugOptions = {
416 OPTIONS_STRUCT_VERSION,
417 0, NULL, /* original argc + argv */
418 ( OPTPROC_BASE
419 + OPTPROC_ERRSTOP
420 + OPTPROC_SHORTOPT
421 + OPTPROC_LONGOPT
422 + OPTPROC_NO_REQ_OPT
423 + OPTPROC_ARGS_REQ
424 + OPTPROC_REORDER
425 + OPTPROC_GNUUSAGE
426 + OPTPROC_MISUSE ),
427 0, NULL, /* current option index, current option */
428 NULL, NULL, zPROGNAME,
429 zRcName, zCopyright, zLicenseDescrip,
430 zFullVersion, apzHomeList, zUsageTitle,
431 zExplain, zDetail, optDesc,
432 zBugsAddr, /* address to send bugs to */
433 NULL, NULL, /* extensions/saved state */
434 optionUsage, /* usage procedure */
435 translate_option_strings, /* translation procedure */
437 * Indexes to special options
439 { INDEX_OPT_MORE_HELP, /* more-help option index */
440 NO_EQUIVALENT, /* save option index */
441 NO_EQUIVALENT, /* '-#' option index */
442 NO_EQUIVALENT /* index of default opt */
444 6 /* full option count */, 3 /* user option count */,
445 gnutls_cli_debug_full_usage, gnutls_cli_debug_short_usage,
446 NULL, NULL,
447 PKGDATADIR, gnutls_cli_debug_packager_info
450 #if ENABLE_NLS
451 #include <stdio.h>
452 #include <stdlib.h>
453 #include <string.h>
454 #include <unistd.h>
455 #include <autoopts/usage-txt.h>
457 static char* AO_gettext(char const* pz);
458 static void coerce_it(void** s);
461 * AutoGen specific wrapper function for gettext.
462 * It relies on the macro _() to convert from English to the target
463 * language, then strdup-duplicates the result string.
465 * @param[in] pz the input text used as a lookup key.
466 * @returns the translated text (if there is one),
467 * or the original text (if not).
469 static char *
470 AO_gettext(char const* pz)
472 char* pzRes;
473 if (pz == NULL)
474 return NULL;
475 pzRes = _(pz);
476 if (pzRes == pz)
477 return pzRes;
478 pzRes = strdup(pzRes);
479 if (pzRes == NULL) {
480 fputs(_("No memory for duping translated strings\n"), stderr);
481 exit(GNUTLS_CLI_DEBUG_EXIT_FAILURE);
483 return pzRes;
486 static void coerce_it(void** s) { *s = AO_gettext(*s);
490 * Translate all the translatable strings in the gnutls_cli_debugOptions
491 * structure defined above. This is done only once.
493 static void
494 translate_option_strings(void)
496 tOptions * const pOpt = &gnutls_cli_debugOptions;
499 * Guard against re-translation. It won't work. The strings will have
500 * been changed by the first pass through this code. One shot only.
502 if (option_usage_text.field_ct != 0) {
504 * Do the translations. The first pointer follows the field count
505 * field. The field count field is the size of a pointer.
507 tOptDesc * pOD = pOpt->pOptDesc;
508 char ** ppz = (char**)(void*)&(option_usage_text);
509 int ix = option_usage_text.field_ct;
511 do {
512 ppz++;
513 *ppz = AO_gettext(*ppz);
514 } while (--ix > 0);
516 coerce_it((void*)&(pOpt->pzCopyright));
517 coerce_it((void*)&(pOpt->pzCopyNotice));
518 coerce_it((void*)&(pOpt->pzFullVersion));
519 coerce_it((void*)&(pOpt->pzUsageTitle));
520 coerce_it((void*)&(pOpt->pzExplain));
521 coerce_it((void*)&(pOpt->pzDetail));
522 coerce_it((void*)&(pOpt->pzPackager));
523 coerce_it((void*)&(pOpt->pzShortUsage));
524 option_usage_text.field_ct = 0;
526 for (ix = pOpt->optCt; ix > 0; ix--, pOD++)
527 coerce_it((void*)&(pOD->pzText));
530 if ((pOpt->fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) {
531 tOptDesc * pOD = pOpt->pOptDesc;
532 int ix;
534 for (ix = pOpt->optCt; ix > 0; ix--, pOD++) {
535 coerce_it((void*)&(pOD->pz_Name));
536 coerce_it((void*)&(pOD->pz_DisableName));
537 coerce_it((void*)&(pOD->pz_DisablePfx));
539 /* prevent re-translation */
540 gnutls_cli_debugOptions.fOptSet |= OPTPROC_NXLAT_OPT_CFG | OPTPROC_NXLAT_OPT;
544 #endif /* ENABLE_NLS */
546 #ifdef __cplusplus
548 #endif
549 /* cli-debug-args.c ends here */