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