Fix CVE-2017-6891 in minitasn1 code
[platform/upstream/gnutls.git] / src / cli-debug-args.c.bak
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
6  *  From the definitions    cli-debug-args.def
7  *  and the template file   options
8  *
9  * Generated from AutoOpts 41:1:16 templates.
10  *
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.
18  *
19  * The gnutls-cli-debug program is copyrighted and licensed
20  * under the following terms:
21  *
22  *  Copyright (C) 2000-2017 Free Software Foundation, and others, all rights reserved.
23  *  This is free software. It is licensed for use, modification and
24  *  redistribution under the terms of the GNU General Public License,
25  *  version 3 or later <http://gnu.org/licenses/gpl.html>
26  *
27  *  gnutls-cli-debug is free software: you can redistribute it and/or modify it
28  *  under the terms of the GNU General Public License as published by the
29  *  Free Software Foundation, either version 3 of the License, or
30  *  (at your option) any later version.
31  *
32  *  gnutls-cli-debug is distributed in the hope that it will be useful, but
33  *  WITHOUT ANY WARRANTY; without even the implied warranty of
34  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
35  *  See the GNU General Public License for more details.
36  *
37  *  You should have received a copy of the GNU General Public License along
38  *  with this program.  If not, see <http://www.gnu.org/licenses/>.
39  */
40
41 #ifndef __doxygen__
42 #define OPTION_CODE_COMPILE 1
43 #include "cli-debug-args.h"
44 #include <sys/types.h>
45
46 #include <limits.h>
47 #include <stdio.h>
48 #include <stdlib.h>
49 #include <errno.h>
50
51 #ifdef  __cplusplus
52 extern "C" {
53 #endif
54 extern FILE * option_usage_fp;
55 #define zCopyright      (gnutls_cli_debug_opt_strs+0)
56 #define zLicenseDescrip (gnutls_cli_debug_opt_strs+292)
57
58
59 #ifndef NULL
60 #  define NULL 0
61 #endif
62
63 /**
64  *  static const strings for gnutls-cli-debug options
65  */
66 static char const gnutls_cli_debug_opt_strs[1936] =
67 /*     0 */ "gnutls-cli-debug 3.3.27\n"
68             "Copyright (C) 2000-2017 Free Software Foundation, and others, all rights reserved.\n"
69             "This is free software. It is licensed for use, modification and\n"
70             "redistribution under the terms of the GNU General Public License,\n"
71             "version 3 or later <http://gnu.org/licenses/gpl.html>\n\0"
72 /*   292 */ "gnutls-cli-debug is free software: you can redistribute it and/or modify it\n"
73             "under the terms of the GNU General Public License as published by the Free\n"
74             "Software Foundation, either version 3 of the License, or (at your option)\n"
75             "any later version.\n\n"
76             "gnutls-cli-debug is distributed in the hope that it will be useful, but\n"
77             "WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\n"
78             "or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\n"
79             "for more details.\n\n"
80             "You should have received a copy of the GNU General Public License along\n"
81             "with this program.  If not, see <http://www.gnu.org/licenses/>.\n\0"
82 /*   913 */ "Enable debugging\0"
83 /*   930 */ "DEBUG\0"
84 /*   936 */ "debug\0"
85 /*   942 */ "More verbose output\0"
86 /*   962 */ "VERBOSE\0"
87 /*   970 */ "verbose\0"
88 /*   978 */ "The port to connect to\0"
89 /*  1001 */ "PORT\0"
90 /*  1006 */ "port\0"
91 /*  1011 */ "The application protocol to be used to obtain the server's certificate\n"
92             "(https, ftp, smtp, imap)\0"
93 /*  1107 */ "APP_PROTO\0"
94 /*  1117 */ "app-proto\0"
95 /*  1127 */ "display extended usage information and exit\0"
96 /*  1171 */ "help\0"
97 /*  1176 */ "extended usage information passed thru pager\0"
98 /*  1221 */ "more-help\0"
99 /*  1231 */ "output version information and exit\0"
100 /*  1267 */ "version\0"
101 /*  1275 */ "GNUTLS_CLI_DEBUG\0"
102 /*  1292 */ "gnutls-cli-debug - GnuTLS debug client\n"
103             "Usage:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \n\0"
104 /*  1390 */ "bugs@gnutls.org\0"
105 /*  1406 */ "\n\0"
106 /*  1408 */ "TLS debug client.  It sets up multiple TLS connections to a server and\n"
107             "queries its capabilities.  It was created to assist in debugging GnuTLS,\n"
108             "but it might be useful to extract a TLS server's capabilities.  It connects\n"
109             "to a TLS server, performs tests and print the server's capabilities.  If\n"
110             "called with the `-v' parameter more checks will be performed.  Can be used\n"
111             "to check for servers with special needs or bugs.\n\0"
112 /*  1826 */ "gnutls-cli-debug 3.3.27\0"
113 /*  1850 */ "Usage: gnutls-cli-debug [options] hostname\n"
114             "gnutls-cli --help for usage instructions.\n";
115
116 /**
117  *  debug option description:
118  */
119 /** Descriptive text for the debug option */
120 #define DEBUG_DESC      (gnutls_cli_debug_opt_strs+913)
121 /** Upper-cased name for the debug option */
122 #define DEBUG_NAME      (gnutls_cli_debug_opt_strs+930)
123 /** Name string for the debug option */
124 #define DEBUG_name      (gnutls_cli_debug_opt_strs+936)
125 /** Compiled in flag settings for the debug option */
126 #define DEBUG_FLAGS     (OPTST_DISABLED \
127         | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
128
129 /**
130  *  verbose option description:
131  */
132 /** Descriptive text for the verbose option */
133 #define VERBOSE_DESC      (gnutls_cli_debug_opt_strs+942)
134 /** Upper-cased name for the verbose option */
135 #define VERBOSE_NAME      (gnutls_cli_debug_opt_strs+962)
136 /** Name string for the verbose option */
137 #define VERBOSE_name      (gnutls_cli_debug_opt_strs+970)
138 /** Compiled in flag settings for the verbose option */
139 #define VERBOSE_FLAGS     (OPTST_DISABLED)
140
141 /**
142  *  port option description:
143  */
144 /** Descriptive text for the port option */
145 #define PORT_DESC      (gnutls_cli_debug_opt_strs+978)
146 /** Upper-cased name for the port option */
147 #define PORT_NAME      (gnutls_cli_debug_opt_strs+1001)
148 /** Name string for the port option */
149 #define PORT_name      (gnutls_cli_debug_opt_strs+1006)
150 /** Compiled in flag settings for the port option */
151 #define PORT_FLAGS     (OPTST_DISABLED \
152         | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
153
154 /**
155  *  app-proto option description:
156  */
157 /** Descriptive text for the app-proto option */
158 #define APP_PROTO_DESC      (gnutls_cli_debug_opt_strs+1011)
159 /** Upper-cased name for the app-proto option */
160 #define APP_PROTO_NAME      (gnutls_cli_debug_opt_strs+1107)
161 /** Name string for the app-proto option */
162 #define APP_PROTO_name      (gnutls_cli_debug_opt_strs+1117)
163 /** Compiled in flag settings for the app-proto option */
164 #define APP_PROTO_FLAGS     (OPTST_DISABLED \
165         | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
166
167 /*
168  *  Help/More_Help/Version option descriptions:
169  */
170 #define HELP_DESC       (gnutls_cli_debug_opt_strs+1127)
171 #define HELP_name       (gnutls_cli_debug_opt_strs+1171)
172 #ifdef HAVE_WORKING_FORK
173 #define MORE_HELP_DESC  (gnutls_cli_debug_opt_strs+1176)
174 #define MORE_HELP_name  (gnutls_cli_debug_opt_strs+1221)
175 #define MORE_HELP_FLAGS (OPTST_IMM | OPTST_NO_INIT)
176 #else
177 #define MORE_HELP_DESC  HELP_DESC
178 #define MORE_HELP_name  HELP_name
179 #define MORE_HELP_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
180 #endif
181 #ifdef NO_OPTIONAL_OPT_ARGS
182 #  define VER_FLAGS     (OPTST_IMM | OPTST_NO_INIT)
183 #else
184 #  define VER_FLAGS     (OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
185                          OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT)
186 #endif
187 #define VER_DESC        (gnutls_cli_debug_opt_strs+1231)
188 #define VER_name        (gnutls_cli_debug_opt_strs+1267)
189 /**
190  *  Declare option callback procedures
191  */
192 extern tOptProc
193     optionBooleanVal,   optionNestedVal,    optionNumericVal,
194     optionPagedUsage,   optionPrintVersion, optionResetOpt,
195     optionStackArg,     optionTimeDate,     optionTimeVal,
196     optionUnstackArg,   optionVendorOption;
197 static tOptProc
198     doOptDebug, doOptPort, doUsageOpt;
199 #define VER_PROC        optionPrintVersion
200
201 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
202 /**
203  *  Define the gnutls-cli-debug Option Descriptions.
204  * This is an array of OPTION_CT entries, one for each
205  * option that the gnutls-cli-debug program responds to.
206  */
207 static tOptDesc optDesc[OPTION_CT] = {
208   {  /* entry idx, value */ 0, VALUE_OPT_DEBUG,
209      /* equiv idx, value */ 0, VALUE_OPT_DEBUG,
210      /* equivalenced to  */ NO_EQUIVALENT,
211      /* min, max, act ct */ 0, 1, 0,
212      /* opt state flags  */ DEBUG_FLAGS, 0,
213      /* last opt argumnt */ { NULL }, /* --debug */
214      /* arg list/cookie  */ NULL,
215      /* must/cannot opts */ NULL, NULL,
216      /* option proc      */ doOptDebug,
217      /* desc, NAME, name */ DEBUG_DESC, DEBUG_NAME, DEBUG_name,
218      /* disablement strs */ NULL, NULL },
219
220   {  /* entry idx, value */ 1, VALUE_OPT_VERBOSE,
221      /* equiv idx, value */ 1, VALUE_OPT_VERBOSE,
222      /* equivalenced to  */ NO_EQUIVALENT,
223      /* min, max, act ct */ 0, NOLIMIT, 0,
224      /* opt state flags  */ VERBOSE_FLAGS, 0,
225      /* last opt argumnt */ { NULL }, /* --verbose */
226      /* arg list/cookie  */ NULL,
227      /* must/cannot opts */ NULL, NULL,
228      /* option proc      */ NULL,
229      /* desc, NAME, name */ VERBOSE_DESC, VERBOSE_NAME, VERBOSE_name,
230      /* disablement strs */ NULL, NULL },
231
232   {  /* entry idx, value */ 2, VALUE_OPT_PORT,
233      /* equiv idx, value */ 2, VALUE_OPT_PORT,
234      /* equivalenced to  */ NO_EQUIVALENT,
235      /* min, max, act ct */ 0, 1, 0,
236      /* opt state flags  */ PORT_FLAGS, 0,
237      /* last opt argumnt */ { NULL }, /* --port */
238      /* arg list/cookie  */ NULL,
239      /* must/cannot opts */ NULL, NULL,
240      /* option proc      */ doOptPort,
241      /* desc, NAME, name */ PORT_DESC, PORT_NAME, PORT_name,
242      /* disablement strs */ NULL, NULL },
243
244   {  /* entry idx, value */ 3, VALUE_OPT_APP_PROTO,
245      /* equiv idx, value */ 3, VALUE_OPT_APP_PROTO,
246      /* equivalenced to  */ NO_EQUIVALENT,
247      /* min, max, act ct */ 0, 1, 0,
248      /* opt state flags  */ APP_PROTO_FLAGS, 0,
249      /* last opt argumnt */ { NULL }, /* --app-proto */
250      /* arg list/cookie  */ NULL,
251      /* must/cannot opts */ NULL, NULL,
252      /* option proc      */ NULL,
253      /* desc, NAME, name */ APP_PROTO_DESC, APP_PROTO_NAME, APP_PROTO_name,
254      /* disablement strs */ NULL, NULL },
255
256   {  /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
257      /* equiv idx value  */ NO_EQUIVALENT, VALUE_OPT_VERSION,
258      /* equivalenced to  */ NO_EQUIVALENT,
259      /* min, max, act ct */ 0, 1, 0,
260      /* opt state flags  */ VER_FLAGS, AOUSE_VERSION,
261      /* last opt argumnt */ { NULL },
262      /* arg list/cookie  */ NULL,
263      /* must/cannot opts */ NULL, NULL,
264      /* option proc      */ VER_PROC,
265      /* desc, NAME, name */ VER_DESC, NULL, VER_name,
266      /* disablement strs */ NULL, NULL },
267
268
269
270   {  /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
271      /* equiv idx value  */ NO_EQUIVALENT, VALUE_OPT_HELP,
272      /* equivalenced to  */ NO_EQUIVALENT,
273      /* min, max, act ct */ 0, 1, 0,
274      /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, AOUSE_HELP,
275      /* last opt argumnt */ { NULL },
276      /* arg list/cookie  */ NULL,
277      /* must/cannot opts */ NULL, NULL,
278      /* option proc      */ doUsageOpt,
279      /* desc, NAME, name */ HELP_DESC, NULL, HELP_name,
280      /* disablement strs */ NULL, NULL },
281
282   {  /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
283      /* equiv idx value  */ NO_EQUIVALENT, VALUE_OPT_MORE_HELP,
284      /* equivalenced to  */ NO_EQUIVALENT,
285      /* min, max, act ct */ 0, 1, 0,
286      /* opt state flags  */ MORE_HELP_FLAGS, AOUSE_MORE_HELP,
287      /* last opt argumnt */ { NULL },
288      /* arg list/cookie  */ NULL,
289      /* must/cannot opts */ NULL,  NULL,
290      /* option proc      */ optionPagedUsage,
291      /* desc, NAME, name */ MORE_HELP_DESC, NULL, MORE_HELP_name,
292      /* disablement strs */ NULL, NULL }
293 };
294
295
296 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
297 /** Reference to the upper cased version of gnutls-cli-debug. */
298 #define zPROGNAME       (gnutls_cli_debug_opt_strs+1275)
299 /** Reference to the title line for gnutls-cli-debug usage. */
300 #define zUsageTitle     (gnutls_cli_debug_opt_strs+1292)
301 /** There is no gnutls-cli-debug configuration file. */
302 #define zRcName         NULL
303 /** There are no directories to search for gnutls-cli-debug config files. */
304 #define apzHomeList     NULL
305 /** The gnutls-cli-debug program bug email address. */
306 #define zBugsAddr       (gnutls_cli_debug_opt_strs+1390)
307 /** Clarification/explanation of what gnutls-cli-debug does. */
308 #define zExplain        (gnutls_cli_debug_opt_strs+1406)
309 /** Extra detail explaining what gnutls-cli-debug does. */
310 #define zDetail         (gnutls_cli_debug_opt_strs+1408)
311 /** The full version string for gnutls-cli-debug. */
312 #define zFullVersion    (gnutls_cli_debug_opt_strs+1826)
313 /* extracted from optcode.tlib near line 364 */
314
315 #if defined(ENABLE_NLS)
316 # define OPTPROC_BASE OPTPROC_TRANSLATE | OPTPROC_NXLAT_OPT
317   static tOptionXlateProc translate_option_strings;
318 #else
319 # define OPTPROC_BASE OPTPROC_NONE
320 # define translate_option_strings NULL
321 #endif /* ENABLE_NLS */
322
323 #define gnutls_cli_debug_full_usage (NULL)
324 #define gnutls_cli_debug_short_usage (gnutls_cli_debug_opt_strs+1850)
325
326 #endif /* not defined __doxygen__ */
327
328 /*
329  *  Create the static procedure(s) declared above.
330  */
331 /**
332  * The callout function that invokes the optionUsage function.
333  *
334  * @param[in] opts the AutoOpts option description structure
335  * @param[in] od   the descriptor for the "help" (usage) option.
336  * @noreturn
337  */
338 static void
339 doUsageOpt(tOptions * opts, tOptDesc * od)
340 {
341     int ex_code;
342     ex_code = GNUTLS_CLI_DEBUG_EXIT_SUCCESS;
343     optionUsage(&gnutls_cli_debugOptions, ex_code);
344     /* NOTREACHED */
345     exit(GNUTLS_CLI_DEBUG_EXIT_FAILURE);
346     (void)opts;
347     (void)od;
348 }
349
350 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
351 /**
352  * Code to handle the debug option.
353  * Specifies the debug level.
354  * @param[in] pOptions the gnutls-cli-debug options data structure
355  * @param[in,out] pOptDesc the option descriptor for this option.
356  */
357 static void
358 doOptDebug(tOptions* pOptions, tOptDesc* pOptDesc)
359 {
360     static struct {long rmin, rmax;} const rng[1] = {
361         { 0 ,  9999 } };
362     int  ix;
363
364     if (pOptions <= OPTPROC_EMIT_LIMIT)
365         goto emit_ranges;
366     optionNumericVal(pOptions, pOptDesc);
367
368     for (ix = 0; ix < 1; ix++) {
369         if (pOptDesc->optArg.argInt < rng[ix].rmin)
370             continue;  /* ranges need not be ordered. */
371         if (pOptDesc->optArg.argInt == rng[ix].rmin)
372             return;
373         if (rng[ix].rmax == LONG_MIN)
374             continue;
375         if (pOptDesc->optArg.argInt <= rng[ix].rmax)
376             return;
377     }
378
379     option_usage_fp = stderr;
380
381  emit_ranges:
382 optionShowRange(pOptions, pOptDesc, VOIDP(rng), 1);
383 }
384
385 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
386 /**
387  * Code to handle the port option.
388  *
389  * @param[in] pOptions the gnutls-cli-debug options data structure
390  * @param[in,out] pOptDesc the option descriptor for this option.
391  */
392 static void
393 doOptPort(tOptions* pOptions, tOptDesc* pOptDesc)
394 {
395     static struct {long rmin, rmax;} const rng[1] = {
396         { 0 ,  65536 } };
397     int  ix;
398
399     if (pOptions <= OPTPROC_EMIT_LIMIT)
400         goto emit_ranges;
401     optionNumericVal(pOptions, pOptDesc);
402
403     for (ix = 0; ix < 1; ix++) {
404         if (pOptDesc->optArg.argInt < rng[ix].rmin)
405             continue;  /* ranges need not be ordered. */
406         if (pOptDesc->optArg.argInt == rng[ix].rmin)
407             return;
408         if (rng[ix].rmax == LONG_MIN)
409             continue;
410         if (pOptDesc->optArg.argInt <= rng[ix].rmax)
411             return;
412     }
413
414     option_usage_fp = stderr;
415
416  emit_ranges:
417 optionShowRange(pOptions, pOptDesc, VOIDP(rng), 1);
418 }
419 /* extracted from optmain.tlib near line 1250 */
420
421 /**
422  * The directory containing the data associated with gnutls-cli-debug.
423  */
424 #ifndef  PKGDATADIR
425 # define PKGDATADIR ""
426 #endif
427
428 /**
429  * Information about the person or institution that packaged gnutls-cli-debug
430  * for the current distribution.
431  */
432 #ifndef  WITH_PACKAGER
433 # define gnutls_cli_debug_packager_info NULL
434 #else
435 /** Packager information for gnutls-cli-debug. */
436 static char const gnutls_cli_debug_packager_info[] =
437     "Packaged by " WITH_PACKAGER
438
439 # ifdef WITH_PACKAGER_VERSION
440         " ("WITH_PACKAGER_VERSION")"
441 # endif
442
443 # ifdef WITH_PACKAGER_BUG_REPORTS
444     "\nReport gnutls_cli_debug bugs to " WITH_PACKAGER_BUG_REPORTS
445 # endif
446     "\n";
447 #endif
448 #ifndef __doxygen__
449
450 #endif /* __doxygen__ */
451 /**
452  * The option definitions for gnutls-cli-debug.  The one structure that
453  * binds them all.
454  */
455 tOptions gnutls_cli_debugOptions = {
456     OPTIONS_STRUCT_VERSION,
457     0, NULL,                    /* original argc + argv    */
458     ( OPTPROC_BASE
459     + OPTPROC_ERRSTOP
460     + OPTPROC_SHORTOPT
461     + OPTPROC_LONGOPT
462     + OPTPROC_NO_REQ_OPT
463     + OPTPROC_ARGS_REQ
464     + OPTPROC_REORDER
465     + OPTPROC_GNUUSAGE
466     + OPTPROC_MISUSE ),
467     0, NULL,                    /* current option index, current option */
468     NULL,         NULL,         zPROGNAME,
469     zRcName,      zCopyright,   zLicenseDescrip,
470     zFullVersion, apzHomeList,  zUsageTitle,
471     zExplain,     zDetail,      optDesc,
472     zBugsAddr,                  /* address to send bugs to */
473     NULL, NULL,                 /* extensions/saved state  */
474     optionUsage, /* usage procedure */
475     translate_option_strings,   /* translation procedure */
476     /*
477      *  Indexes to special options
478      */
479     { INDEX_OPT_MORE_HELP, /* more-help option index */
480       NO_EQUIVALENT, /* save option index */
481       NO_EQUIVALENT, /* '-#' option index */
482       NO_EQUIVALENT /* index of default opt */
483     },
484     7 /* full option count */, 4 /* user option count */,
485     gnutls_cli_debug_full_usage, gnutls_cli_debug_short_usage,
486     NULL, NULL,
487     PKGDATADIR, gnutls_cli_debug_packager_info
488 };
489
490 #if ENABLE_NLS
491 /**
492  * This code is designed to translate translatable option text for the
493  * gnutls-cli-debug program.  These translations happen upon entry
494  * to optionProcess().
495  */
496 #include <stdio.h>
497 #include <stdlib.h>
498 #include <string.h>
499 #include <unistd.h>
500 #ifdef HAVE_DCGETTEXT
501 # include <gettext.h>
502 #endif
503 #include <autoopts/usage-txt.h>
504
505 static char * AO_gettext(char const * pz);
506 static void   coerce_it(void ** s);
507
508 /**
509  * AutoGen specific wrapper function for gettext.  It relies on the macro _()
510  * to convert from English to the target language, then strdup-duplicates the
511  * result string.  It tries the "libopts" domain first, then whatever has been
512  * set via the \a textdomain(3) call.
513  *
514  * @param[in] pz the input text used as a lookup key.
515  * @returns the translated text (if there is one),
516  *   or the original text (if not).
517  */
518 static char *
519 AO_gettext(char const * pz)
520 {
521     char * res;
522     if (pz == NULL)
523         return NULL;
524 #ifdef HAVE_DCGETTEXT
525     /*
526      * While processing the option_xlateable_txt data, try to use the
527      * "libopts" domain.  Once we switch to the option descriptor data,
528      * do *not* use that domain.
529      */
530     if (option_xlateable_txt.field_ct != 0) {
531         res = dgettext("libopts", pz);
532         if (res == pz)
533             res = (char *)VOIDP(_(pz));
534     } else
535         res = (char *)VOIDP(_(pz));
536 #else
537     res = (char *)VOIDP(_(pz));
538 #endif
539     if (res == pz)
540         return res;
541     res = strdup(res);
542     if (res == NULL) {
543         fputs(_("No memory for duping translated strings\n"), stderr);
544         exit(GNUTLS_CLI_DEBUG_EXIT_FAILURE);
545     }
546     return res;
547 }
548
549 /**
550  * All the pointers we use are marked "* const", but they are stored in
551  * writable memory.  Coerce the mutability and set the pointer.
552  */
553 static void coerce_it(void ** s) { *s = AO_gettext(*s);
554 }
555
556 /**
557  * Translate all the translatable strings in the gnutls_cli_debugOptions
558  * structure defined above.  This is done only once.
559  */
560 static void
561 translate_option_strings(void)
562 {
563     tOptions * const opts = &gnutls_cli_debugOptions;
564
565     /*
566      *  Guard against re-translation.  It won't work.  The strings will have
567      *  been changed by the first pass through this code.  One shot only.
568      */
569     if (option_xlateable_txt.field_ct != 0) {
570         /*
571          *  Do the translations.  The first pointer follows the field count
572          *  field.  The field count field is the size of a pointer.
573          */
574         char ** ppz = (char**)VOIDP(&(option_xlateable_txt));
575         int     ix  = option_xlateable_txt.field_ct;
576
577         do {
578             ppz++; /* skip over field_ct */
579             *ppz = AO_gettext(*ppz);
580         } while (--ix > 0);
581         /* prevent re-translation and disable "libopts" domain lookup */
582         option_xlateable_txt.field_ct = 0;
583
584         coerce_it(VOIDP(&(opts->pzCopyright)));
585         coerce_it(VOIDP(&(opts->pzCopyNotice)));
586         coerce_it(VOIDP(&(opts->pzFullVersion)));
587         coerce_it(VOIDP(&(opts->pzUsageTitle)));
588         coerce_it(VOIDP(&(opts->pzExplain)));
589         coerce_it(VOIDP(&(opts->pzDetail)));
590         {
591             tOptDesc * od = opts->pOptDesc;
592             for (ix = opts->optCt; ix > 0; ix--, od++)
593                 coerce_it(VOIDP(&(od->pzText)));
594         }
595     }
596 }
597 #endif /* ENABLE_NLS */
598
599 #ifdef DO_NOT_COMPILE_THIS_CODE_IT_IS_FOR_GETTEXT
600 /** I18N function strictly for xgettext.  Do not compile. */
601 static void bogus_function(void) {
602   /* TRANSLATORS:
603
604      The following dummy function was crated solely so that xgettext can
605      extract the correct strings.  These strings are actually referenced
606      by a field name in the gnutls_cli_debugOptions structure noted in the
607      comments below.  The literal text is defined in gnutls_cli_debug_opt_strs.
608    
609      NOTE: the strings below are segmented with respect to the source string
610      gnutls_cli_debug_opt_strs.  The strings above are handed off for translation
611      at run time a paragraph at a time.  Consequently, they are presented here
612      for translation a paragraph at a time.
613    
614      ALSO: often the description for an option will reference another option
615      by name.  These are set off with apostrophe quotes (I hope).  Do not
616      translate option names.
617    */
618   /* referenced via gnutls_cli_debugOptions.pzCopyright */
619   puts(_("gnutls-cli-debug 3.3.27\n\
620 Copyright (C) 2000-2017 Free Software Foundation, and others, all rights reserved.\n\
621 This is free software. It is licensed for use, modification and\n\
622 redistribution under the terms of the GNU General Public License,\n\
623 version 3 or later <http://gnu.org/licenses/gpl.html>\n"));
624
625   /* referenced via gnutls_cli_debugOptions.pzCopyNotice */
626   puts(_("gnutls-cli-debug is free software: you can redistribute it and/or modify it\n\
627 under the terms of the GNU General Public License as published by the Free\n\
628 Software Foundation, either version 3 of the License, or (at your option)\n\
629 any later version.\n\n"));
630   puts(_("gnutls-cli-debug is distributed in the hope that it will be useful, but\n\
631 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\n\
632 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\n\
633 for more details.\n\n"));
634   puts(_("You should have received a copy of the GNU General Public License along\n\
635 with this program.  If not, see <http://www.gnu.org/licenses/>.\n"));
636
637   /* referenced via gnutls_cli_debugOptions.pOptDesc->pzText */
638   puts(_("Enable debugging"));
639
640   /* referenced via gnutls_cli_debugOptions.pOptDesc->pzText */
641   puts(_("More verbose output"));
642
643   /* referenced via gnutls_cli_debugOptions.pOptDesc->pzText */
644   puts(_("The port to connect to"));
645
646   /* referenced via gnutls_cli_debugOptions.pOptDesc->pzText */
647   puts(_("The application protocol to be used to obtain the server's certificate\n\
648 (https, ftp, smtp, imap)"));
649
650   /* referenced via gnutls_cli_debugOptions.pOptDesc->pzText */
651   puts(_("display extended usage information and exit"));
652
653   /* referenced via gnutls_cli_debugOptions.pOptDesc->pzText */
654   puts(_("extended usage information passed thru pager"));
655
656   /* referenced via gnutls_cli_debugOptions.pOptDesc->pzText */
657   puts(_("output version information and exit"));
658
659   /* referenced via gnutls_cli_debugOptions.pzUsageTitle */
660   puts(_("gnutls-cli-debug - GnuTLS debug client\n\
661 Usage:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \n"));
662
663   /* referenced via gnutls_cli_debugOptions.pzExplain */
664   puts(_("\n"));
665
666   /* referenced via gnutls_cli_debugOptions.pzDetail */
667   puts(_("TLS debug client.  It sets up multiple TLS connections to a server and\n\
668 queries its capabilities.  It was created to assist in debugging GnuTLS,\n\
669 but it might be useful to extract a TLS server's capabilities.  It connects\n\
670 to a TLS server, performs tests and print the server's capabilities.  If\n\
671 called with the `-v' parameter more checks will be performed.  Can be used\n\
672 to check for servers with special needs or bugs.\n"));
673
674   /* referenced via gnutls_cli_debugOptions.pzFullVersion */
675   puts(_("gnutls-cli-debug 3.3.27"));
676
677   /* referenced via gnutls_cli_debugOptions.pzFullUsage */
678   puts(_("<<<NOT-FOUND>>>"));
679
680   /* referenced via gnutls_cli_debugOptions.pzShortUsage */
681   puts(_("Usage: gnutls-cli-debug [options] hostname\n\
682 gnutls-cli --help for usage instructions.\n"));
683   /* LIBOPTS-MESSAGES: */
684 #line 67 "../autoopts.c"
685   puts(_("allocation of %d bytes failed\n"));
686 #line 93 "../autoopts.c"
687   puts(_("allocation of %d bytes failed\n"));
688 #line 53 "../init.c"
689   puts(_("AutoOpts function called without option descriptor\n"));
690 #line 86 "../init.c"
691   puts(_("\tThis exceeds the compiled library version:  "));
692 #line 84 "../init.c"
693   puts(_("Automated Options Processing Error!\n"
694        "\t%s called AutoOpts function with structure version %d:%d:%d.\n"));
695 #line 80 "../autoopts.c"
696   puts(_("realloc of %d bytes at 0x%p failed\n"));
697 #line 88 "../init.c"
698   puts(_("\tThis is less than the minimum library version:  "));
699 #line 121 "../version.c"
700   puts(_("Automated Options version %s\n"
701        "\tCopyright (C) 1999-2014 by Bruce Korb - all rights reserved\n"));
702 #line 87 "../makeshell.c"
703   puts(_("(AutoOpts bug):  %s.\n"));
704 #line 90 "../reset.c"
705   puts(_("optionResetOpt() called, but reset-option not configured"));
706 #line 295 "../usage.c"
707   puts(_("could not locate the 'help' option"));
708 #line 336 "../autoopts.c"
709   puts(_("optionProcess() was called with invalid data"));
710 #line 751 "../usage.c"
711   puts(_("invalid argument type specified"));
712 #line 598 "../find.c"
713   puts(_("defaulted to option with optional arg"));
714 #line 76 "../alias.c"
715   puts(_("aliasing option is out of range."));
716 #line 235 "../enum.c"
717   puts(_("%s error:  the keyword '%s' is ambiguous for %s\n"));
718 #line 108 "../find.c"
719   puts(_("  The following options match:\n"));
720 #line 293 "../find.c"
721   puts(_("%s: ambiguous option name: %s (matches %d options)\n"));
722 #line 161 "../check.c"
723   puts(_("%s: Command line arguments required\n"));
724 #line 43 "../alias.c"
725   puts(_("%d %s%s options allowed\n"));
726 #line 94 "../makeshell.c"
727   puts(_("%s error %d (%s) calling %s for '%s'\n"));
728 #line 306 "../makeshell.c"
729   puts(_("interprocess pipe"));
730 #line 168 "../version.c"
731   puts(_("error: version option argument '%c' invalid.  Use:\n"
732        "\t'v' - version only\n"
733        "\t'c' - version and copyright\n"
734        "\t'n' - version and full copyright notice\n"));
735 #line 58 "../check.c"
736   puts(_("%s error:  the '%s' and '%s' options conflict\n"));
737 #line 217 "../find.c"
738   puts(_("%s: The '%s' option has been disabled."));
739 #line 430 "../find.c"
740   puts(_("%s: The '%s' option has been disabled."));
741 #line 38 "../alias.c"
742   puts(_("-equivalence"));
743 #line 469 "../find.c"
744   puts(_("%s: illegal option -- %c\n"));
745 #line 110 "../reset.c"
746   puts(_("%s: illegal option -- %c\n"));
747 #line 271 "../find.c"
748   puts(_("%s: illegal option -- %s\n"));
749 #line 755 "../find.c"
750   puts(_("%s: illegal option -- %s\n"));
751 #line 118 "../reset.c"
752   puts(_("%s: illegal option -- %s\n"));
753 #line 335 "../find.c"
754   puts(_("%s: unknown vendor extension option -- %s\n"));
755 #line 160 "../enum.c"
756   puts(_("  or an integer from %d through %d\n"));
757 #line 170 "../enum.c"
758   puts(_("  or an integer from %d through %d\n"));
759 #line 750 "../usage.c"
760   puts(_("%s error:  invalid option descriptor for %s\n"));
761 #line 1084 "../usage.c"
762   puts(_("%s error:  invalid option descriptor for %s\n"));
763 #line 385 "../find.c"
764   puts(_("%s: invalid option name: %s\n"));
765 #line 527 "../find.c"
766   puts(_("%s: The '%s' option requires an argument.\n"));
767 #line 156 "../autoopts.c"
768   puts(_("(AutoOpts bug):  Equivalenced option '%s' was equivalenced to both\n"
769        "\t'%s' and '%s'."));
770 #line 94 "../check.c"
771   puts(_("%s error:  The %s option is required\n"));
772 #line 632 "../find.c"
773   puts(_("%s: The '%s' option cannot have an argument.\n"));
774 #line 151 "../check.c"
775   puts(_("%s: Command line arguments are not allowed.\n"));
776 #line 536 "../save.c"
777   puts(_("error %d (%s) creating %s\n"));
778 #line 235 "../enum.c"
779   puts(_("%s error:  '%s' does not match any %s keywords.\n"));
780 #line 93 "../reset.c"
781   puts(_("%s error: The '%s' option requires an argument.\n"));
782 #line 186 "../save.c"
783   puts(_("error %d (%s) stat-ing %s\n"));
784 #line 239 "../save.c"
785   puts(_("error %d (%s) stat-ing %s\n"));
786 #line 143 "../restore.c"
787   puts(_("%s error: no saved option state\n"));
788 #line 231 "../autoopts.c"
789   puts(_("'%s' is not a command line option.\n"));
790 #line 113 "../time.c"
791   puts(_("%s error:  '%s' is not a recognizable date/time.\n"));
792 #line 131 "../save.c"
793   puts(_("'%s' not defined\n"));
794 #line 50 "../time.c"
795   puts(_("%s error:  '%s' is not a recognizable time duration.\n"));
796 #line 92 "../check.c"
797   puts(_("%s error:  The %s option must appear %d times.\n"));
798 #line 165 "../numeric.c"
799   puts(_("%s error:  '%s' is not a recognizable number.\n"));
800 #line 201 "../enum.c"
801   puts(_("%s error:  %s exceeds %s keyword count\n"));
802 #line 333 "../usage.c"
803   puts(_("Try '%s %s' for more information.\n"));
804 #line 45 "../alias.c"
805   puts(_("one %s%s option allowed\n"));
806 #line 208 "../makeshell.c"
807   puts(_("standard output"));
808 #line 943 "../makeshell.c"
809   puts(_("standard output"));
810 #line 277 "../usage.c"
811   puts(_("standard output"));
812 #line 418 "../usage.c"
813   puts(_("standard output"));
814 #line 628 "../usage.c"
815   puts(_("standard output"));
816 #line 175 "../version.c"
817   puts(_("standard output"));
818 #line 277 "../usage.c"
819   puts(_("standard error"));
820 #line 418 "../usage.c"
821   puts(_("standard error"));
822 #line 628 "../usage.c"
823   puts(_("standard error"));
824 #line 175 "../version.c"
825   puts(_("standard error"));
826 #line 208 "../makeshell.c"
827   puts(_("write"));
828 #line 943 "../makeshell.c"
829   puts(_("write"));
830 #line 276 "../usage.c"
831   puts(_("write"));
832 #line 417 "../usage.c"
833   puts(_("write"));
834 #line 627 "../usage.c"
835   puts(_("write"));
836 #line 174 "../version.c"
837   puts(_("write"));
838 #line 60 "../numeric.c"
839   puts(_("%s error:  %s option value %ld is out of range.\n"));
840 #line 44 "../check.c"
841   puts(_("%s error:  %s option requires the %s option\n"));
842 #line 130 "../save.c"
843   puts(_("%s warning:  cannot save options - %s not regular file\n"));
844 #line 185 "../save.c"
845   puts(_("%s warning:  cannot save options - %s not regular file\n"));
846 #line 238 "../save.c"
847   puts(_("%s warning:  cannot save options - %s not regular file\n"));
848 #line 257 "../save.c"
849   puts(_("%s warning:  cannot save options - %s not regular file\n"));
850 #line 535 "../save.c"
851   puts(_("%s warning:  cannot save options - %s not regular file\n"));
852   /* END-LIBOPTS-MESSAGES */
853
854   /* USAGE-TEXT: */
855 #line 876 "../usage.c"
856   puts(_("\t\t\t\t- an alternate for '%s'\n"));
857 #line 1151 "../usage.c"
858   puts(_("Version, usage and configuration options:"));
859 #line 927 "../usage.c"
860   puts(_("\t\t\t\t- default option for unnamed options\n"));
861 #line 840 "../usage.c"
862   puts(_("\t\t\t\t- disabled as '--%s'\n"));
863 #line 1120 "../usage.c"
864   puts(_(" --- %-14s %s\n"));
865 #line 1118 "../usage.c"
866   puts(_("This option has been disabled"));
867 #line 867 "../usage.c"
868   puts(_("\t\t\t\t- enabled by default\n"));
869 #line 40 "../alias.c"
870   puts(_("%s error:  only "));
871 #line 1197 "../usage.c"
872   puts(_(" - examining environment variables named %s_*\n"));
873 #line 168 "../file.c"
874   puts(_("\t\t\t\t- file must not pre-exist\n"));
875 #line 172 "../file.c"
876   puts(_("\t\t\t\t- file must pre-exist\n"));
877 #line 383 "../usage.c"
878   puts(_("Options are specified by doubled hyphens and their name or by a single\n"
879        "hyphen and the flag character.\n"));
880 #line 921 "../makeshell.c"
881   puts(_("\n"
882        "= = = = = = = =\n\n"
883        "This incarnation of genshell will produce\n"
884        "a shell script to parse the options for %s:\n\n"));
885 #line 167 "../enum.c"
886   puts(_("  or an integer mask with any of the lower %d bits set\n"));
887 #line 900 "../usage.c"
888   puts(_("\t\t\t\t- is a set membership option\n"));
889 #line 921 "../usage.c"
890   puts(_("\t\t\t\t- must appear between %d and %d times\n"));
891 #line 385 "../usage.c"
892   puts(_("Options are specified by single or double hyphens and their name.\n"));
893 #line 907 "../usage.c"
894   puts(_("\t\t\t\t- may appear multiple times\n"));
895 #line 894 "../usage.c"
896   puts(_("\t\t\t\t- may not be preset\n"));
897 #line 1312 "../usage.c"
898   puts(_("   Arg Option-Name    Description\n"));
899 #line 1248 "../usage.c"
900   puts(_("  Flg Arg Option-Name    Description\n"));
901 #line 1306 "../usage.c"
902   puts(_("  Flg Arg Option-Name    Description\n"));
903 #line 1307 "../usage.c"
904   puts(_(" %3s %s"));
905 #line 1313 "../usage.c"
906   puts(_(" %3s %s"));
907 #line 390 "../usage.c"
908   puts(_("The '-#<number>' option may omit the hash char\n"));
909 #line 386 "../usage.c"
910   puts(_("All arguments are named options.\n"));
911 #line 974 "../usage.c"
912   puts(_(" - reading file %s"));
913 #line 412 "../usage.c"
914   puts(_("\n"
915        "Please send bug reports to:  <%s>\n"));
916 #line 100 "../version.c"
917   puts(_("\n"
918        "Please send bug reports to:  <%s>\n"));
919 #line 129 "../version.c"
920   puts(_("\n"
921        "Please send bug reports to:  <%s>\n"));
922 #line 906 "../usage.c"
923   puts(_("\t\t\t\t- may NOT appear - preset only\n"));
924 #line 947 "../usage.c"
925   puts(_("\n"
926        "The following option preset mechanisms are supported:\n"));
927 #line 1195 "../usage.c"
928   puts(_("\n"
929        "The following option preset mechanisms are supported:\n"));
930 #line 685 "../usage.c"
931   puts(_("prohibits these options:\n"));
932 #line 680 "../usage.c"
933   puts(_("prohibits the option '%s'\n"));
934 #line 81 "../numeric.c"
935   puts(_("%s%ld to %ld"));
936 #line 79 "../numeric.c"
937   puts(_("%sgreater than or equal to %ld"));
938 #line 75 "../numeric.c"
939   puts(_("%s%ld exactly"));
940 #line 68 "../numeric.c"
941   puts(_("%sit must lie in one of the ranges:\n"));
942 #line 68 "../numeric.c"
943   puts(_("%sit must be in the range:\n"));
944 #line 88 "../numeric.c"
945   puts(_(", or\n"));
946 #line 66 "../numeric.c"
947   puts(_("%sis scalable with a suffix: k/K/m/M/g/G/t/T\n"));
948 #line 77 "../numeric.c"
949   puts(_("%sless than or equal to %ld"));
950 #line 393 "../usage.c"
951   puts(_("Operands and options may be intermixed.  They will be reordered.\n"));
952 #line 655 "../usage.c"
953   puts(_("requires the option '%s'\n"));
954 #line 658 "../usage.c"
955   puts(_("requires these options:\n"));
956 #line 1324 "../usage.c"
957   puts(_("   Arg Option-Name   Req?  Description\n"));
958 #line 1318 "../usage.c"
959   puts(_("  Flg Arg Option-Name   Req?  Description\n"));
960 #line 168 "../enum.c"
961   puts(_("or you may use a numeric representation.  Preceding these with a '!'\n"
962        "will clear the bits, specifying 'none' will clear all bits, and 'all'\n"
963        "will set them all.  Multiple entries may be passed as an option\n"
964        "argument list.\n"));
965 #line 913 "../usage.c"
966   puts(_("\t\t\t\t- may appear up to %d times\n"));
967 #line 77 "../enum.c"
968   puts(_("The valid \"%s\" option keywords are:\n"));
969 #line 1155 "../usage.c"
970   puts(_("The next option supports vendor supported extra options:"));
971 #line 776 "../usage.c"
972   puts(_("These additional options are:"));
973   /* END-USAGE-TEXT */
974 }
975 #endif /* uncompilable code */
976 #ifdef  __cplusplus
977 }
978 #endif
979 /* cli-debug-args.c ends here */