Imported Upstream version 3.0.21
[platform/upstream/gnutls.git] / src / srptool-args.c
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  July  3, 2012 at 12:06:00 AM by AutoGen 5.16
6  *  From the definitions    srptool-args.def
7  *  and the template file   options
8  *
9  * Generated from AutoOpts 36:4:11 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-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>
27  *
28  *  srptool 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.
32  *  
33  *  srptool 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.
37  *  
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/>.
40  */
41
42 #ifndef __doxygen__
43 #define OPTION_CODE_COMPILE 1
44 #include "srptool-args.h"
45 #include <sys/types.h>
46
47 #include <limits.h>
48 #include <stdio.h>
49 #include <stdlib.h>
50 #include <errno.h>
51
52 #ifdef  __cplusplus
53 extern "C" {
54 #endif
55 extern FILE * option_usage_fp;
56
57 /* TRANSLATORS: choose the translation for option names wisely because you
58                 cannot ever change your mind. */
59 #define zCopyright      (srptool_opt_strs+0)
60 #define zLicenseDescrip (srptool_opt_strs+275)
61
62
63 #ifndef NULL
64 #  define NULL 0
65 #endif
66
67 /*
68  *  srptool option static const strings
69  */
70 static char const srptool_opt_strs[2040] =
71 /*     0 */ "srptool 3.0.21\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 /*   275 */ "srptool is free software: you can redistribute it and/or modify it under\n"
78             "the terms of the GNU General Public License as published by the Free\n"
79             "Software Foundation, either version 3 of the License, or (at your option)\n"
80             "any later version.\n\n"
81             "srptool is distributed in the hope that it will be useful, but WITHOUT ANY\n"
82             "WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n"
83             "FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more\n"
84             "details.\n\n"
85             "You should have received a copy of the GNU General Public License along\n"
86             "with this program.  If not, see <http://www.gnu.org/licenses/>.\n\0"
87 /*   878 */ "Enable debugging.\0"
88 /*   896 */ "DEBUG\0"
89 /*   902 */ "debug\0"
90 /*   908 */ "specify the index of the group parameters in tpasswd.conf to use.\0"
91 /*   974 */ "INDEX\0"
92 /*   980 */ "index\0"
93 /*   986 */ "specify a username\0"
94 /*  1005 */ "USERNAME\0"
95 /*  1014 */ "username\0"
96 /*  1023 */ "specify a password file.\0"
97 /*  1048 */ "PASSWD\0"
98 /*  1055 */ "passwd\0"
99 /*  1062 */ "specify salt size.\0"
100 /*  1081 */ "SALT\0"
101 /*  1086 */ "salt\0"
102 /*  1091 */ "just verify the password.\0"
103 /*  1117 */ "VERIFY\0"
104 /*  1124 */ "verify\0"
105 /*  1131 */ "specify a password conf file.\0"
106 /*  1161 */ "PASSWD_CONF\0"
107 /*  1173 */ "passwd-conf\0"
108 /*  1185 */ "Generate a password configuration file.\0"
109 /*  1225 */ "CREATE_CONF\0"
110 /*  1237 */ "create-conf\0"
111 /*  1249 */ "Display extended usage information and exit\0"
112 /*  1293 */ "help\0"
113 /*  1298 */ "Extended usage information passed thru pager\0"
114 /*  1343 */ "more-help\0"
115 /*  1353 */ "Output version information and exit\0"
116 /*  1389 */ "version\0"
117 /*  1397 */ "SRPTOOL\0"
118 /*  1405 */ "srptool - GnuTLS SRP tool - Ver. 3.0.21\n"
119             "USAGE:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n\0"
120 /*  1503 */ "bug-gnutls@gnu.org\0"
121 /*  1522 */ "\n\n\0"
122 /*  1525 */ "\n"
123             "Simple program that emulates the programs in the Stanford SRP (Secure\n"
124             "Remote Password) libraries using GnuTLS.  It is intended for use in places\n"
125             "where you don't expect SRP authentication to be the used for system users.\n\n"
126             "In brief, to use SRP you need to create two files.  These are the password\n"
127             "file that holds the users and the verifiers associated with them and the\n"
128             "configuration file to hold the group parameters (called tpasswd.conf).\n\0"
129 /*  1967 */ "srptool 3.0.21\0"
130 /*  1982 */ "srptool [options]\n"
131             "srptool --help for usage instructions.\n";
132
133 /*
134  *  debug option description:
135  */
136 #define DEBUG_DESC      (srptool_opt_strs+878)
137 #define DEBUG_NAME      (srptool_opt_strs+896)
138 #define DEBUG_name      (srptool_opt_strs+902)
139 #define DEBUG_FLAGS     (OPTST_DISABLED \
140         | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
141
142 /*
143  *  index option description:
144  */
145 #define INDEX_DESC      (srptool_opt_strs+908)
146 #define INDEX_NAME      (srptool_opt_strs+974)
147 #define INDEX_name      (srptool_opt_strs+980)
148 #define INDEX_FLAGS     (OPTST_DISABLED)
149
150 /*
151  *  username option description:
152  */
153 #define USERNAME_DESC      (srptool_opt_strs+986)
154 #define USERNAME_NAME      (srptool_opt_strs+1005)
155 #define USERNAME_name      (srptool_opt_strs+1014)
156 #define USERNAME_FLAGS     (OPTST_DISABLED \
157         | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
158
159 /*
160  *  passwd option description:
161  */
162 #define PASSWD_DESC      (srptool_opt_strs+1023)
163 #define PASSWD_NAME      (srptool_opt_strs+1048)
164 #define PASSWD_name      (srptool_opt_strs+1055)
165 #define PASSWD_FLAGS     (OPTST_DISABLED \
166         | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
167
168 /*
169  *  salt option description:
170  */
171 #define SALT_DESC      (srptool_opt_strs+1062)
172 #define SALT_NAME      (srptool_opt_strs+1081)
173 #define SALT_name      (srptool_opt_strs+1086)
174 #define SALT_FLAGS     (OPTST_DISABLED \
175         | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
176
177 /*
178  *  verify option description:
179  */
180 #define VERIFY_DESC      (srptool_opt_strs+1091)
181 #define VERIFY_NAME      (srptool_opt_strs+1117)
182 #define VERIFY_name      (srptool_opt_strs+1124)
183 #define VERIFY_FLAGS     (OPTST_DISABLED)
184
185 /*
186  *  passwd-conf option description:
187  */
188 #define PASSWD_CONF_DESC      (srptool_opt_strs+1131)
189 #define PASSWD_CONF_NAME      (srptool_opt_strs+1161)
190 #define PASSWD_CONF_name      (srptool_opt_strs+1173)
191 #define PASSWD_CONF_FLAGS     (OPTST_DISABLED \
192         | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
193
194 /*
195  *  create-conf option description:
196  */
197 #define CREATE_CONF_DESC      (srptool_opt_strs+1185)
198 #define CREATE_CONF_NAME      (srptool_opt_strs+1225)
199 #define CREATE_CONF_name      (srptool_opt_strs+1237)
200 #define CREATE_CONF_FLAGS     (OPTST_DISABLED \
201         | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
202
203 /*
204  *  Help/More_Help/Version option descriptions:
205  */
206 #define HELP_DESC       (srptool_opt_strs+1249)
207 #define HELP_name       (srptool_opt_strs+1293)
208 #ifdef HAVE_WORKING_FORK
209 #define MORE_HELP_DESC  (srptool_opt_strs+1298)
210 #define MORE_HELP_name  (srptool_opt_strs+1343)
211 #define MORE_HELP_FLAGS (OPTST_IMM | OPTST_NO_INIT)
212 #else
213 #define MORE_HELP_DESC  NULL
214 #define MORE_HELP_name  NULL
215 #define MORE_HELP_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
216 #endif
217 #ifdef NO_OPTIONAL_OPT_ARGS
218 #  define VER_FLAGS     (OPTST_IMM | OPTST_NO_INIT)
219 #else
220 #  define VER_FLAGS     (OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
221                          OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT)
222 #endif
223 #define VER_DESC        (srptool_opt_strs+1353)
224 #define VER_name        (srptool_opt_strs+1389)
225 /*
226  *  Declare option callback procedures
227  */
228 extern tOptProc
229     optionBooleanVal,   optionNestedVal,    optionNumericVal,
230     optionPagedUsage,   optionPrintVersion, optionResetOpt,
231     optionStackArg,     optionTimeDate,     optionTimeVal,
232     optionUnstackArg,   optionVendorOption;
233 static tOptProc
234     doOptDebug, doUsageOpt;
235 #define VER_PROC        optionPrintVersion
236
237 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
238 /**
239  *  Define the srptool Option Descriptions.
240  * This is an array of OPTION_CT entries, one for each
241  * option that the srptool program responds to.
242  */
243 static tOptDesc optDesc[OPTION_CT] = {
244   {  /* entry idx, value */ 0, VALUE_OPT_DEBUG,
245      /* equiv idx, value */ 0, VALUE_OPT_DEBUG,
246      /* equivalenced to  */ NO_EQUIVALENT,
247      /* min, max, act ct */ 0, 1, 0,
248      /* opt state flags  */ DEBUG_FLAGS, 0,
249      /* last opt argumnt */ { NULL }, /* --debug */
250      /* arg list/cookie  */ NULL,
251      /* must/cannot opts */ NULL, NULL,
252      /* option proc      */ doOptDebug,
253      /* desc, NAME, name */ DEBUG_DESC, DEBUG_NAME, DEBUG_name,
254      /* disablement strs */ NULL, NULL },
255
256   {  /* entry idx, value */ 1, VALUE_OPT_INDEX,
257      /* equiv idx, value */ 1, VALUE_OPT_INDEX,
258      /* equivalenced to  */ NO_EQUIVALENT,
259      /* min, max, act ct */ 0, 1, 0,
260      /* opt state flags  */ INDEX_FLAGS, 0,
261      /* last opt argumnt */ { NULL }, /* --index */
262      /* arg list/cookie  */ NULL,
263      /* must/cannot opts */ NULL, NULL,
264      /* option proc      */ NULL,
265      /* desc, NAME, name */ INDEX_DESC, INDEX_NAME, INDEX_name,
266      /* disablement strs */ NULL, NULL },
267
268   {  /* entry idx, value */ 2, VALUE_OPT_USERNAME,
269      /* equiv idx, value */ 2, VALUE_OPT_USERNAME,
270      /* equivalenced to  */ NO_EQUIVALENT,
271      /* min, max, act ct */ 0, 1, 0,
272      /* opt state flags  */ USERNAME_FLAGS, 0,
273      /* last opt argumnt */ { NULL }, /* --username */
274      /* arg list/cookie  */ NULL,
275      /* must/cannot opts */ NULL, NULL,
276      /* option proc      */ NULL,
277      /* desc, NAME, name */ USERNAME_DESC, USERNAME_NAME, USERNAME_name,
278      /* disablement strs */ NULL, NULL },
279
280   {  /* entry idx, value */ 3, VALUE_OPT_PASSWD,
281      /* equiv idx, value */ 3, VALUE_OPT_PASSWD,
282      /* equivalenced to  */ NO_EQUIVALENT,
283      /* min, max, act ct */ 0, 1, 0,
284      /* opt state flags  */ PASSWD_FLAGS, 0,
285      /* last opt argumnt */ { NULL }, /* --passwd */
286      /* arg list/cookie  */ NULL,
287      /* must/cannot opts */ NULL, NULL,
288      /* option proc      */ NULL,
289      /* desc, NAME, name */ PASSWD_DESC, PASSWD_NAME, PASSWD_name,
290      /* disablement strs */ NULL, NULL },
291
292   {  /* entry idx, value */ 4, VALUE_OPT_SALT,
293      /* equiv idx, value */ 4, VALUE_OPT_SALT,
294      /* equivalenced to  */ NO_EQUIVALENT,
295      /* min, max, act ct */ 0, 1, 0,
296      /* opt state flags  */ SALT_FLAGS, 0,
297      /* last opt argumnt */ { NULL }, /* --salt */
298      /* arg list/cookie  */ NULL,
299      /* must/cannot opts */ NULL, NULL,
300      /* option proc      */ optionNumericVal,
301      /* desc, NAME, name */ SALT_DESC, SALT_NAME, SALT_name,
302      /* disablement strs */ NULL, NULL },
303
304   {  /* entry idx, value */ 5, VALUE_OPT_VERIFY,
305      /* equiv idx, value */ 5, VALUE_OPT_VERIFY,
306      /* equivalenced to  */ NO_EQUIVALENT,
307      /* min, max, act ct */ 0, 1, 0,
308      /* opt state flags  */ VERIFY_FLAGS, 0,
309      /* last opt argumnt */ { NULL }, /* --verify */
310      /* arg list/cookie  */ NULL,
311      /* must/cannot opts */ NULL, NULL,
312      /* option proc      */ NULL,
313      /* desc, NAME, name */ VERIFY_DESC, VERIFY_NAME, VERIFY_name,
314      /* disablement strs */ NULL, NULL },
315
316   {  /* entry idx, value */ 6, VALUE_OPT_PASSWD_CONF,
317      /* equiv idx, value */ 6, VALUE_OPT_PASSWD_CONF,
318      /* equivalenced to  */ NO_EQUIVALENT,
319      /* min, max, act ct */ 0, 1, 0,
320      /* opt state flags  */ PASSWD_CONF_FLAGS, 0,
321      /* last opt argumnt */ { NULL }, /* --passwd-conf */
322      /* arg list/cookie  */ NULL,
323      /* must/cannot opts */ NULL, NULL,
324      /* option proc      */ NULL,
325      /* desc, NAME, name */ PASSWD_CONF_DESC, PASSWD_CONF_NAME, PASSWD_CONF_name,
326      /* disablement strs */ NULL, NULL },
327
328   {  /* entry idx, value */ 7, VALUE_OPT_CREATE_CONF,
329      /* equiv idx, value */ 7, VALUE_OPT_CREATE_CONF,
330      /* equivalenced to  */ NO_EQUIVALENT,
331      /* min, max, act ct */ 0, 1, 0,
332      /* opt state flags  */ CREATE_CONF_FLAGS, 0,
333      /* last opt argumnt */ { NULL }, /* --create-conf */
334      /* arg list/cookie  */ NULL,
335      /* must/cannot opts */ NULL, NULL,
336      /* option proc      */ NULL,
337      /* desc, NAME, name */ CREATE_CONF_DESC, CREATE_CONF_NAME, CREATE_CONF_name,
338      /* disablement strs */ NULL, NULL },
339
340   {  /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
341      /* equiv idx value  */ NO_EQUIVALENT, VALUE_OPT_VERSION,
342      /* equivalenced to  */ NO_EQUIVALENT,
343      /* min, max, act ct */ 0, 1, 0,
344      /* opt state flags  */ VER_FLAGS, 0,
345      /* last opt argumnt */ { NULL },
346      /* arg list/cookie  */ NULL,
347      /* must/cannot opts */ NULL, NULL,
348      /* option proc      */ VER_PROC,
349      /* desc, NAME, name */ VER_DESC, NULL, VER_name,
350      /* disablement strs */ NULL, NULL },
351
352
353
354   {  /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
355      /* equiv idx value  */ NO_EQUIVALENT, VALUE_OPT_HELP,
356      /* equivalenced to  */ NO_EQUIVALENT,
357      /* min, max, act ct */ 0, 1, 0,
358      /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
359      /* last opt argumnt */ { NULL },
360      /* arg list/cookie  */ NULL,
361      /* must/cannot opts */ NULL, NULL,
362      /* option proc      */ doUsageOpt,
363      /* desc, NAME, name */ HELP_DESC, NULL, HELP_name,
364      /* disablement strs */ NULL, NULL },
365
366   {  /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
367      /* equiv idx value  */ NO_EQUIVALENT, VALUE_OPT_MORE_HELP,
368      /* equivalenced to  */ NO_EQUIVALENT,
369      /* min, max, act ct */ 0, 1, 0,
370      /* opt state flags  */ MORE_HELP_FLAGS, 0,
371      /* last opt argumnt */ { NULL },
372      /* arg list/cookie  */ NULL,
373      /* must/cannot opts */ NULL,  NULL,
374      /* option proc      */ optionPagedUsage,
375      /* desc, NAME, name */ MORE_HELP_DESC, NULL, MORE_HELP_name,
376      /* disablement strs */ NULL, NULL }
377 };
378
379
380 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
381  *
382  *  Define the srptool Option Environment
383  */
384 #define zPROGNAME       (srptool_opt_strs+1397)
385 #define zUsageTitle     (srptool_opt_strs+1405)
386 #define zRcName         NULL
387 #define apzHomeList     NULL
388 #define zBugsAddr       (srptool_opt_strs+1503)
389 #define zExplain        (srptool_opt_strs+1522)
390 #define zDetail         (srptool_opt_strs+1525)
391 #define zFullVersion    (srptool_opt_strs+1967)
392 /* extracted from optcode.tlib near line 350 */
393
394 #if defined(ENABLE_NLS)
395 # define OPTPROC_BASE OPTPROC_TRANSLATE | OPTPROC_NXLAT_OPT
396   static tOptionXlateProc translate_option_strings;
397 #else
398 # define OPTPROC_BASE OPTPROC_NONE
399 # define translate_option_strings NULL
400 #endif /* ENABLE_NLS */
401
402
403 #define srptool_full_usage (NULL)
404
405 #define srptool_short_usage (srptool_opt_strs+1982)
406
407 #endif /* not defined __doxygen__ */
408
409 /*
410  *  Create the static procedure(s) declared above.
411  */
412 /**
413  * The callout function that invokes the optionUsage function.
414  *
415  * @param pOptions the AutoOpts option description structure
416  * @param pOptDesc the descriptor for the "help" (usage) option.
417  * @noreturn
418  */
419 static void
420 doUsageOpt(tOptions * pOptions, tOptDesc * pOptDesc)
421 {
422     optionUsage(&srptoolOptions, SRPTOOL_EXIT_SUCCESS);
423     /* NOTREACHED */
424     (void)pOptDesc;
425     (void)pOptions;
426 }
427
428 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
429 /**
430  * Code to handle the debug option.
431  *
432  * @param pOptions the srptool options data structure
433  * @param pOptDesc the option descriptor for this option.
434  */
435 static void
436 doOptDebug(tOptions* pOptions, tOptDesc* pOptDesc)
437 {
438     static struct {long rmin, rmax;} const rng[1] = {
439         { 0 ,  9999 } };
440     int  ix;
441
442     if (pOptions <= OPTPROC_EMIT_LIMIT)
443         goto emit_ranges;
444     optionNumericVal(pOptions, pOptDesc);
445
446     for (ix = 0; ix < 1; ix++) {
447         if (pOptDesc->optArg.argInt < rng[ix].rmin)
448             continue;  /* ranges need not be ordered. */
449         if (pOptDesc->optArg.argInt == rng[ix].rmin)
450             return;
451         if (rng[ix].rmax == LONG_MIN)
452             continue;
453         if (pOptDesc->optArg.argInt <= rng[ix].rmax)
454             return;
455     }
456
457     option_usage_fp = stderr;
458
459 emit_ranges:
460
461     optionShowRange(pOptions, pOptDesc, (void *)rng, 1);
462 }
463 /* extracted from optmain.tlib near line 1113 */
464
465 /**
466  * The directory containing the data associated with srptool.
467  */
468 #ifndef  PKGDATADIR
469 # define PKGDATADIR ""
470 #endif
471
472 /**
473  * Information about the person or institution that packaged srptool
474  * for the current distribution.
475  */
476 #ifndef  WITH_PACKAGER
477 # define srptool_packager_info NULL
478 #else
479 static char const srptool_packager_info[] =
480     "Packaged by " WITH_PACKAGER
481
482 # ifdef WITH_PACKAGER_VERSION
483         " ("WITH_PACKAGER_VERSION")"
484 # endif
485
486 # ifdef WITH_PACKAGER_BUG_REPORTS
487     "\nReport srptool bugs to " WITH_PACKAGER_BUG_REPORTS
488 # endif
489     "\n";
490 #endif
491 #ifndef __doxygen__
492
493 #endif /* __doxygen__ */
494 /**
495  * The option definitions for srptool.  The one structure that
496  * binds them all.
497  */
498 tOptions srptoolOptions = {
499     OPTIONS_STRUCT_VERSION,
500     0, NULL,                    /* original argc + argv    */
501     ( OPTPROC_BASE
502     + OPTPROC_ERRSTOP
503     + OPTPROC_SHORTOPT
504     + OPTPROC_LONGOPT
505     + OPTPROC_NO_REQ_OPT
506     + OPTPROC_NO_ARGS
507     + OPTPROC_GNUUSAGE
508     + OPTPROC_MISUSE ),
509     0, NULL,                    /* current option index, current option */
510     NULL,         NULL,         zPROGNAME,
511     zRcName,      zCopyright,   zLicenseDescrip,
512     zFullVersion, apzHomeList,  zUsageTitle,
513     zExplain,     zDetail,      optDesc,
514     zBugsAddr,                  /* address to send bugs to */
515     NULL, NULL,                 /* extensions/saved state  */
516     optionUsage, /* usage procedure */
517     translate_option_strings,   /* translation procedure */
518     /*
519      *  Indexes to special options
520      */
521     { INDEX_OPT_MORE_HELP, /* more-help option index */
522       NO_EQUIVALENT, /* save option index */
523       NO_EQUIVALENT, /* '-#' option index */
524       NO_EQUIVALENT /* index of default opt */
525     },
526     11 /* full option count */, 8 /* user option count */,
527     srptool_full_usage, srptool_short_usage,
528     NULL, NULL,
529     PKGDATADIR, srptool_packager_info
530 };
531
532 #if ENABLE_NLS
533 #include <stdio.h>
534 #include <stdlib.h>
535 #include <string.h>
536 #include <unistd.h>
537 #include <autoopts/usage-txt.h>
538
539 static char* AO_gettext(char const* pz);
540 static void  coerce_it(void** s);
541
542 /**
543  * AutoGen specific wrapper function for gettext.
544  * It relies on the macro _() to convert from English to the target
545  * language, then strdup-duplicates the result string.
546  *
547  * @param[in] pz the input text used as a lookup key.
548  * @returns the translated text (if there is one),
549  *   or the original text (if not).
550  */
551 static char *
552 AO_gettext(char const* pz)
553 {
554     char* pzRes;
555     if (pz == NULL)
556         return NULL;
557     pzRes = _(pz);
558     if (pzRes == pz)
559         return pzRes;
560     pzRes = strdup(pzRes);
561     if (pzRes == NULL) {
562         fputs(_("No memory for duping translated strings\n"), stderr);
563         exit(SRPTOOL_EXIT_FAILURE);
564     }
565     return pzRes;
566 }
567
568 static void coerce_it(void** s) { *s = AO_gettext(*s);
569 }
570
571 /**
572  * Translate all the translatable strings in the srptoolOptions
573  * structure defined above.  This is done only once.
574  */
575 static void
576 translate_option_strings(void)
577 {
578     tOptions * const pOpt = &srptoolOptions;
579
580     /*
581      *  Guard against re-translation.  It won't work.  The strings will have
582      *  been changed by the first pass through this code.  One shot only.
583      */
584     if (option_usage_text.field_ct != 0) {
585         /*
586          *  Do the translations.  The first pointer follows the field count
587          *  field.  The field count field is the size of a pointer.
588          */
589         tOptDesc * pOD = pOpt->pOptDesc;
590         char **    ppz = (char**)(void*)&(option_usage_text);
591         int        ix  = option_usage_text.field_ct;
592
593         do {
594             ppz++;
595             *ppz = AO_gettext(*ppz);
596         } while (--ix > 0);
597
598         coerce_it((void*)&(pOpt->pzCopyright));
599         coerce_it((void*)&(pOpt->pzCopyNotice));
600         coerce_it((void*)&(pOpt->pzFullVersion));
601         coerce_it((void*)&(pOpt->pzUsageTitle));
602         coerce_it((void*)&(pOpt->pzExplain));
603         coerce_it((void*)&(pOpt->pzDetail));
604         coerce_it((void*)&(pOpt->pzPackager));
605         coerce_it((void*)&(pOpt->pzShortUsage));
606         option_usage_text.field_ct = 0;
607
608         for (ix = pOpt->optCt; ix > 0; ix--, pOD++)
609             coerce_it((void*)&(pOD->pzText));
610     }
611
612     if ((pOpt->fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) {
613         tOptDesc * pOD = pOpt->pOptDesc;
614         int        ix;
615
616         for (ix = pOpt->optCt; ix > 0; ix--, pOD++) {
617             coerce_it((void*)&(pOD->pz_Name));
618             coerce_it((void*)&(pOD->pz_DisableName));
619             coerce_it((void*)&(pOD->pz_DisablePfx));
620         }
621         /* prevent re-translation */
622         srptoolOptions.fOptSet |= OPTPROC_NXLAT_OPT_CFG | OPTPROC_NXLAT_OPT;
623     }
624 }
625
626 #endif /* ENABLE_NLS */
627
628 #ifdef  __cplusplus
629 }
630 #endif
631 /* srptool-args.c ends here */