1181834Sroberto/*   -*- buffer-read-only: t -*- vi: set ro:
2280849Scy *
3181834Sroberto *  DO NOT EDIT THIS FILE   (genshell.c)
4280849Scy *
5280849Scy *  It has been AutoGen-ed
6181834Sroberto *  From the definitions    genshell.def
7181834Sroberto *  and the template file   options
8181834Sroberto *
9280849Scy * Generated from AutoOpts 41:0:16 templates.
10181834Sroberto *
11280849Scy *  AutoOpts is a copyrighted work.  This source file is not encumbered
12280849Scy *  by AutoOpts licensing, but is provided under the licensing terms chosen
13280849Scy *  by the genshellopt author or copyright holder.  AutoOpts is
14280849Scy *  licensed under the terms of the LGPL.  The redistributable library
15280849Scy *  (``libopts'') is licensed under the terms of either the LGPL or, at the
16280849Scy *  users discretion, the BSD license.  See the AutoOpts and/or libopts sources
17280849Scy *  for details.
18181834Sroberto *
19280849Scy * The genshellopt program is copyrighted and licensed
20280849Scy * under the following terms:
21181834Sroberto *
22280849Scy *  Copyright (C) 1999-2014 Bruce Korb, all rights reserved.
23280849Scy *  This is free software. It is licensed for use, modification and
24280849Scy *  redistribution under the terms of the GNU Lesser General Public License,
25280849Scy *  version 2 or later <http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>
26280849Scy *
27280849Scy *  The genshellopt library is free software; you can redistribute it and/or
28280849Scy *  modify it under the terms of the GNU Library General Public License as
29280849Scy *  published by the Free Software Foundation; either version 2 of the
30280849Scy *  License, or (at your option) any later version.
31280849Scy *
32280849Scy *  This library is distributed in the hope that it will be useful, but
33280849Scy *  WITHOUT ANY WARRANTY; without even the implied warranty of
34280849Scy *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
35280849Scy *  Library General Public License for more details.
36280849Scy *
37280849Scy *  You should have received a copy of the GNU Library General Public
38280849Scy *  License along with this library; if not, see
39280849Scy *  <http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>
40181834Sroberto */
41181834Sroberto
42280849Scy#ifndef __doxygen__
43280849Scy#define OPTION_CODE_COMPILE 1
44280849Scy#include "genshell.h"
45280849Scy#include <sys/types.h>
46181834Sroberto
47181834Sroberto#include <limits.h>
48280849Scy#include <stdio.h>
49280849Scy#include <stdlib.h>
50181834Sroberto
51181834Sroberto#ifdef  __cplusplus
52181834Srobertoextern "C" {
53181834Sroberto#endif
54280849Scyextern FILE * option_usage_fp;
55280849Scy#define zCopyright      (genshellopt_opt_strs+0)
56280849Scy#define zLicenseDescrip (genshellopt_opt_strs+285)
57280849Scy
58181834Srobertoextern tUsageProc genshelloptUsage;
59181834Sroberto
60181834Sroberto#ifndef NULL
61181834Sroberto#  define NULL 0
62181834Sroberto#endif
63280849Scy
64280849Scy/**
65280849Scy *  static const strings for genshellopt options
66181834Sroberto */
67280849Scystatic char const genshellopt_opt_strs[1769] =
68280849Scy/*     0 */ "genshellopt 1\n"
69280849Scy            "Copyright (C) 1999-2014 Bruce Korb, all rights reserved.\n"
70280849Scy            "This is free software. It is licensed for use, modification and\n"
71280849Scy            "redistribution under the terms of the GNU Lesser General Public License,\n"
72280849Scy            "version 2 or later <http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>\n\0"
73280849Scy/*   285 */ "The genshellopt library is free software; you can redistribute it and/or\n"
74280849Scy            "modify it under the terms of the GNU Library General Public License as\n"
75280849Scy            "published by the Free Software Foundation; either version 2 of the License,\n"
76280849Scy            "or (at your option) any later version.\n\n"
77280849Scy            "This library is distributed in the hope that it will be useful, but WITHOUT\n"
78280849Scy            "ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n"
79280849Scy            "FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public\n"
80280849Scy            "License for more details.\n\n"
81280849Scy            "You should have received a copy of the GNU Library General Public License\n"
82280849Scy            "along with this library; if not, see\n"
83280849Scy            "<http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>\n\0"
84280849Scy/*   957 */ "Output Script File\0"
85280849Scy/*   976 */ "SCRIPT\0"
86280849Scy/*   983 */ "script\0"
87280849Scy/*   990 */ "Shell name (follows \"#!\" magic)\0"
88280849Scy/*  1022 */ "SHELL\0"
89280849Scy/*  1028 */ "no-shell\0"
90280849Scy/*  1037 */ "no\0"
91280849Scy/*  1040 */ "display extended usage information and exit\0"
92280849Scy/*  1084 */ "help\0"
93280849Scy/*  1089 */ "extended usage information passed thru pager\0"
94280849Scy/*  1134 */ "more-help\0"
95280849Scy/*  1144 */ "output version information and exit\0"
96280849Scy/*  1180 */ "version\0"
97280849Scy/*  1188 */ "GENSHELLOPT\0"
98280849Scy/*  1200 */ "genshellopt - Generate Shell Option Processing Script - Ver. 1\n"
99280849Scy            "Usage:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n\0"
100280849Scy/*  1321 */ "autogen-users@lists.sourceforge.net\0"
101280849Scy/*  1357 */ "Note that 'shell' is only useful if the output file does not already exist.\n"
102280849Scy            "If it does, then the shell name and optional first argument will be\n"
103280849Scy            "extracted from the script file.\n\0"
104280849Scy/*  1534 */ "If the script file already exists and contains Automated Option Processing\n"
105280849Scy            "text, the second line of the file through the ending tag will be replaced\n"
106280849Scy            "by the newly generated text.  The first '#!' line will be regenerated.\n\0"
107280849Scy/*  1755 */ "genshellopt 1";
108280849Scy
109280849Scy/**
110280849Scy *  script option description:
111280849Scy */
112280849Scy/** Descriptive text for the script option */
113280849Scy#define SCRIPT_DESC      (genshellopt_opt_strs+957)
114280849Scy/** Upper-cased name for the script option */
115280849Scy#define SCRIPT_NAME      (genshellopt_opt_strs+976)
116280849Scy/** Name string for the script option */
117280849Scy#define SCRIPT_name      (genshellopt_opt_strs+983)
118280849Scy/** Compiled in flag settings for the script option */
119280849Scy#define SCRIPT_FLAGS     (OPTST_DISABLED \
120181834Sroberto        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
121181834Sroberto
122280849Scy/**
123280849Scy *  shell option description:
124181834Sroberto */
125280849Scy/** Descriptive text for the shell option */
126280849Scy#define SHELL_DESC      (genshellopt_opt_strs+990)
127280849Scy/** Upper-cased name for the shell option */
128280849Scy#define SHELL_NAME      (genshellopt_opt_strs+1022)
129280849Scy/** disablement name for the shell option */
130280849Scy#define NOT_SHELL_name  (genshellopt_opt_strs+1028)
131280849Scy/** disablement prefix for the shell option */
132280849Scy#define NOT_SHELL_PFX   (genshellopt_opt_strs+1037)
133280849Scy/** Name string for the shell option */
134280849Scy#define SHELL_name      (NOT_SHELL_name + 3)
135280849Scy/** Compiled in flag settings for the shell option */
136280849Scy#define SHELL_FLAGS     (OPTST_INITENABLED \
137181834Sroberto        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
138181834Sroberto
139181834Sroberto/*
140181834Sroberto *  Help/More_Help/Version option descriptions:
141181834Sroberto */
142280849Scy#define HELP_DESC       (genshellopt_opt_strs+1040)
143280849Scy#define HELP_name       (genshellopt_opt_strs+1084)
144280849Scy#ifdef HAVE_WORKING_FORK
145280849Scy#define MORE_HELP_DESC  (genshellopt_opt_strs+1089)
146280849Scy#define MORE_HELP_name  (genshellopt_opt_strs+1134)
147280849Scy#define MORE_HELP_FLAGS (OPTST_IMM | OPTST_NO_INIT)
148280849Scy#else
149280849Scy#define MORE_HELP_DESC  HELP_DESC
150280849Scy#define MORE_HELP_name  HELP_name
151280849Scy#define MORE_HELP_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
152280849Scy#endif
153280849Scy#ifdef NO_OPTIONAL_OPT_ARGS
154280849Scy#  define VER_FLAGS     (OPTST_IMM | OPTST_NO_INIT)
155280849Scy#else
156280849Scy#  define VER_FLAGS     (OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
157280849Scy                         OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT)
158280849Scy#endif
159280849Scy#define VER_DESC        (genshellopt_opt_strs+1144)
160280849Scy#define VER_name        (genshellopt_opt_strs+1180)
161280849Scy/**
162181834Sroberto *  Declare option callback procedures
163181834Sroberto */
164181834Srobertoextern tOptProc
165280849Scy    optionBooleanVal,   optionNestedVal,    optionNumericVal,
166280849Scy    optionPagedUsage,   optionPrintVersion, optionResetOpt,
167280849Scy    optionStackArg,     optionTimeDate,     optionTimeVal,
168280849Scy    optionUnstackArg,   optionVendorOption;
169181834Srobertostatic tOptProc
170181834Sroberto    doUsageOpt;
171280849Scy#define VER_PROC        optionPrintVersion
172181834Sroberto
173280849Scy/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
174280849Scy/**
175280849Scy *  Define the genshellopt Option Descriptions.
176280849Scy * This is an array of GENSHELL_OPTION_CT entries, one for each
177280849Scy * option that the genshellopt program responds to.
178181834Sroberto */
179280849Scystatic tOptDesc optDesc[GENSHELL_OPTION_CT] = {
180280849Scy  {  /* entry idx, value */ 0, VALUE_GENSHELL_OPT_SCRIPT,
181280849Scy     /* equiv idx, value */ 0, VALUE_GENSHELL_OPT_SCRIPT,
182181834Sroberto     /* equivalenced to  */ NO_EQUIVALENT,
183181834Sroberto     /* min, max, act ct */ 0, 1, 0,
184181834Sroberto     /* opt state flags  */ SCRIPT_FLAGS, 0,
185280849Scy     /* last opt argumnt */ { NULL }, /* --script */
186181834Sroberto     /* arg list/cookie  */ NULL,
187181834Sroberto     /* must/cannot opts */ NULL, NULL,
188181834Sroberto     /* option proc      */ NULL,
189280849Scy     /* desc, NAME, name */ SCRIPT_DESC, SCRIPT_NAME, SCRIPT_name,
190181834Sroberto     /* disablement strs */ NULL, NULL },
191181834Sroberto
192280849Scy  {  /* entry idx, value */ 1, VALUE_GENSHELL_OPT_SHELL,
193280849Scy     /* equiv idx, value */ 1, VALUE_GENSHELL_OPT_SHELL,
194181834Sroberto     /* equivalenced to  */ NO_EQUIVALENT,
195181834Sroberto     /* min, max, act ct */ 0, 1, 0,
196181834Sroberto     /* opt state flags  */ SHELL_FLAGS, 0,
197280849Scy     /* last opt argumnt */ { NULL }, /* --shell */
198181834Sroberto     /* arg list/cookie  */ NULL,
199181834Sroberto     /* must/cannot opts */ NULL, NULL,
200181834Sroberto     /* option proc      */ NULL,
201280849Scy     /* desc, NAME, name */ SHELL_DESC, SHELL_NAME, SHELL_name,
202280849Scy     /* disablement strs */ NOT_SHELL_name, NOT_SHELL_PFX },
203181834Sroberto
204280849Scy  {  /* entry idx, value */ INDEX_GENSHELL_OPT_VERSION, VALUE_GENSHELL_OPT_VERSION,
205280849Scy     /* equiv idx value  */ NO_EQUIVALENT, VALUE_GENSHELL_OPT_VERSION,
206181834Sroberto     /* equivalenced to  */ NO_EQUIVALENT,
207181834Sroberto     /* min, max, act ct */ 0, 1, 0,
208280849Scy     /* opt state flags  */ VER_FLAGS, AOUSE_VERSION,
209181834Sroberto     /* last opt argumnt */ { NULL },
210181834Sroberto     /* arg list/cookie  */ NULL,
211181834Sroberto     /* must/cannot opts */ NULL, NULL,
212280849Scy     /* option proc      */ VER_PROC,
213280849Scy     /* desc, NAME, name */ VER_DESC, NULL, VER_name,
214181834Sroberto     /* disablement strs */ NULL, NULL },
215181834Sroberto
216181834Sroberto
217181834Sroberto
218280849Scy  {  /* entry idx, value */ INDEX_GENSHELL_OPT_HELP, VALUE_GENSHELL_OPT_HELP,
219280849Scy     /* equiv idx value  */ NO_EQUIVALENT, VALUE_GENSHELL_OPT_HELP,
220181834Sroberto     /* equivalenced to  */ NO_EQUIVALENT,
221181834Sroberto     /* min, max, act ct */ 0, 1, 0,
222280849Scy     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, AOUSE_HELP,
223181834Sroberto     /* last opt argumnt */ { NULL },
224181834Sroberto     /* arg list/cookie  */ NULL,
225181834Sroberto     /* must/cannot opts */ NULL, NULL,
226181834Sroberto     /* option proc      */ doUsageOpt,
227280849Scy     /* desc, NAME, name */ HELP_DESC, NULL, HELP_name,
228181834Sroberto     /* disablement strs */ NULL, NULL },
229181834Sroberto
230280849Scy  {  /* entry idx, value */ INDEX_GENSHELL_OPT_MORE_HELP, VALUE_GENSHELL_OPT_MORE_HELP,
231280849Scy     /* equiv idx value  */ NO_EQUIVALENT, VALUE_GENSHELL_OPT_MORE_HELP,
232181834Sroberto     /* equivalenced to  */ NO_EQUIVALENT,
233181834Sroberto     /* min, max, act ct */ 0, 1, 0,
234280849Scy     /* opt state flags  */ MORE_HELP_FLAGS, AOUSE_MORE_HELP,
235181834Sroberto     /* last opt argumnt */ { NULL },
236181834Sroberto     /* arg list/cookie  */ NULL,
237181834Sroberto     /* must/cannot opts */ NULL,  NULL,
238181834Sroberto     /* option proc      */ optionPagedUsage,
239280849Scy     /* desc, NAME, name */ MORE_HELP_DESC, NULL, MORE_HELP_name,
240181834Sroberto     /* disablement strs */ NULL, NULL }
241181834Sroberto};
242181834Sroberto
243181834Sroberto
244280849Scy/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
245280849Scy/** Reference to the upper cased version of genshellopt. */
246280849Scy#define zPROGNAME       (genshellopt_opt_strs+1188)
247280849Scy/** Reference to the title line for genshellopt usage. */
248280849Scy#define zUsageTitle     (genshellopt_opt_strs+1200)
249280849Scy/** There is no genshellopt configuration file. */
250280849Scy#define zRcName         NULL
251280849Scy/** There are no directories to search for genshellopt config files. */
252280849Scy#define apzHomeList     NULL
253280849Scy/** The genshellopt program bug email address. */
254280849Scy#define zBugsAddr       (genshellopt_opt_strs+1321)
255280849Scy/** Clarification/explanation of what genshellopt does. */
256280849Scy#define zExplain        (genshellopt_opt_strs+1357)
257280849Scy/** Extra detail explaining what genshellopt does. */
258280849Scy#define zDetail         (genshellopt_opt_strs+1534)
259280849Scy/** The full version string for genshellopt. */
260280849Scy#define zFullVersion    (genshellopt_opt_strs+1755)
261280849Scy/* extracted from optcode.tlib near line 364 */
262181834Sroberto
263181834Sroberto#if defined(ENABLE_NLS)
264181834Sroberto# define OPTPROC_BASE OPTPROC_TRANSLATE
265181834Sroberto  static tOptionXlateProc translate_option_strings;
266181834Sroberto#else
267181834Sroberto# define OPTPROC_BASE OPTPROC_NONE
268181834Sroberto# define translate_option_strings NULL
269181834Sroberto#endif /* ENABLE_NLS */
270181834Sroberto
271280849Scy#define genshellopt_full_usage (NULL)
272280849Scy#define genshellopt_short_usage (NULL)
273280849Scy
274280849Scy#endif /* not defined __doxygen__ */
275280849Scy
276280849Scy/*
277280849Scy *  Create the static procedure(s) declared above.
278280849Scy */
279280849Scy/**
280280849Scy * The callout function that invokes the genshelloptUsage function.
281280849Scy *
282280849Scy * @param[in] opts the AutoOpts option description structure
283280849Scy * @param[in] od   the descriptor for the "help" (usage) option.
284280849Scy * @noreturn
285280849Scy */
286280849Scystatic void
287280849ScydoUsageOpt(tOptions * opts, tOptDesc * od)
288280849Scy{
289280849Scy    int ex_code;
290280849Scy    ex_code = GENSHELLOPT_EXIT_SUCCESS;
291280849Scy    genshelloptUsage(&genshelloptOptions, ex_code);
292280849Scy    /* NOTREACHED */
293280849Scy    exit(1);
294280849Scy    (void)opts;
295280849Scy    (void)od;
296280849Scy}
297285169Scy/* extracted from optmain.tlib near line 1250 */
298280849Scy
299280849Scy/**
300280849Scy * The directory containing the data associated with genshellopt.
301280849Scy */
302280849Scy#ifndef  PKGDATADIR
303280849Scy# define PKGDATADIR ""
304280849Scy#endif
305280849Scy
306280849Scy/**
307280849Scy * Information about the person or institution that packaged genshellopt
308280849Scy * for the current distribution.
309280849Scy */
310280849Scy#ifndef  WITH_PACKAGER
311280849Scy# define genshellopt_packager_info NULL
312280849Scy#else
313280849Scy/** Packager information for genshellopt. */
314280849Scystatic char const genshellopt_packager_info[] =
315280849Scy    "Packaged by " WITH_PACKAGER
316280849Scy
317280849Scy# ifdef WITH_PACKAGER_VERSION
318280849Scy        " ("WITH_PACKAGER_VERSION")"
319280849Scy# endif
320280849Scy
321280849Scy# ifdef WITH_PACKAGER_BUG_REPORTS
322280849Scy    "\nReport genshellopt bugs to " WITH_PACKAGER_BUG_REPORTS
323280849Scy# endif
324280849Scy    "\n";
325280849Scy#endif
326280849Scy#ifndef __doxygen__
327280849Scy
328280849Scy#endif /* __doxygen__ */
329280849Scy/**
330280849Scy * The option definitions for genshellopt.  The one structure that
331280849Scy * binds them all.
332280849Scy */
333181834SrobertotOptions genshelloptOptions = {
334181834Sroberto    OPTIONS_STRUCT_VERSION,
335181834Sroberto    0, NULL,                    /* original argc + argv    */
336181834Sroberto    ( OPTPROC_BASE
337181834Sroberto    + OPTPROC_ERRSTOP
338181834Sroberto    + OPTPROC_SHORTOPT
339181834Sroberto    + OPTPROC_LONGOPT
340181834Sroberto    + OPTPROC_NO_REQ_OPT
341181834Sroberto    + OPTPROC_NEGATIONS
342181834Sroberto    + OPTPROC_NO_ARGS ),
343181834Sroberto    0, NULL,                    /* current option index, current option */
344181834Sroberto    NULL,         NULL,         zPROGNAME,
345280849Scy    zRcName,      zCopyright,   zLicenseDescrip,
346181834Sroberto    zFullVersion, apzHomeList,  zUsageTitle,
347181834Sroberto    zExplain,     zDetail,      optDesc,
348181834Sroberto    zBugsAddr,                  /* address to send bugs to */
349181834Sroberto    NULL, NULL,                 /* extensions/saved state  */
350280849Scy    genshelloptUsage, /* usage procedure */
351181834Sroberto    translate_option_strings,   /* translation procedure */
352181834Sroberto    /*
353181834Sroberto     *  Indexes to special options
354181834Sroberto     */
355280849Scy    { INDEX_GENSHELL_OPT_MORE_HELP, /* more-help option index */
356280849Scy      NO_EQUIVALENT, /* save option index */
357280849Scy      NO_EQUIVALENT, /* '-#' option index */
358181834Sroberto      NO_EQUIVALENT /* index of default opt */
359181834Sroberto    },
360280849Scy    5 /* full option count */, 2 /* user option count */,
361280849Scy    genshellopt_full_usage, genshellopt_short_usage,
362280849Scy    NULL, NULL,
363280849Scy    PKGDATADIR, genshellopt_packager_info
364181834Sroberto};
365181834Sroberto
366280849Scy#if ENABLE_NLS
367280849Scy/**
368280849Scy * This code is designed to translate translatable option text for the
369280849Scy * genshellopt program.  These translations happen upon entry
370280849Scy * to optionProcess().
371181834Sroberto */
372181834Sroberto#include <stdio.h>
373181834Sroberto#include <stdlib.h>
374181834Sroberto#include <string.h>
375181834Sroberto#include <unistd.h>
376280849Scy#ifdef HAVE_DCGETTEXT
377280849Scy# include <gettext.h>
378280849Scy#endif
379181834Sroberto#include <autoopts/usage-txt.h>
380181834Sroberto
381280849Scystatic char * AO_gettext(char const * pz);
382280849Scystatic void   coerce_it(void ** s);
383181834Sroberto
384280849Scy/**
385280849Scy * AutoGen specific wrapper function for gettext.  It relies on the macro _()
386280849Scy * to convert from English to the target language, then strdup-duplicates the
387280849Scy * result string.  It tries the "libopts" domain first, then whatever has been
388280849Scy * set via the \a textdomain(3) call.
389280849Scy *
390280849Scy * @param[in] pz the input text used as a lookup key.
391280849Scy * @returns the translated text (if there is one),
392280849Scy *   or the original text (if not).
393280849Scy */
394280849Scystatic char *
395280849ScyAO_gettext(char const * pz)
396181834Sroberto{
397280849Scy    char * res;
398181834Sroberto    if (pz == NULL)
399181834Sroberto        return NULL;
400280849Scy#ifdef HAVE_DCGETTEXT
401280849Scy    /*
402280849Scy     * While processing the option_xlateable_txt data, try to use the
403280849Scy     * "libopts" domain.  Once we switch to the option descriptor data,
404280849Scy     * do *not* use that domain.
405280849Scy     */
406280849Scy    if (option_xlateable_txt.field_ct != 0) {
407280849Scy        res = dgettext("libopts", pz);
408280849Scy        if (res == pz)
409285169Scy            res = (char *)VOIDP(_(pz));
410280849Scy    } else
411285169Scy        res = (char *)VOIDP(_(pz));
412280849Scy#else
413285169Scy    res = (char *)VOIDP(_(pz));
414280849Scy#endif
415280849Scy    if (res == pz)
416280849Scy        return res;
417280849Scy    res = strdup(res);
418280849Scy    if (res == NULL) {
419280849Scy        fputs(_("No memory for duping translated strings\n"), stderr);
420280849Scy        exit(GENSHELLOPT_EXIT_FAILURE);
421181834Sroberto    }
422280849Scy    return res;
423181834Sroberto}
424181834Sroberto
425280849Scy/**
426280849Scy * All the pointers we use are marked "* const", but they are stored in
427280849Scy * writable memory.  Coerce the mutability and set the pointer.
428280849Scy */
429280849Scystatic void coerce_it(void ** s) { *s = AO_gettext(*s);
430280849Scy}
431181834Sroberto
432280849Scy/**
433280849Scy * Translate all the translatable strings in the genshelloptOptions
434280849Scy * structure defined above.  This is done only once.
435181834Sroberto */
436181834Srobertostatic void
437280849Scytranslate_option_strings(void)
438181834Sroberto{
439280849Scy    tOptions * const opts = &genshelloptOptions;
440280849Scy
441181834Sroberto    /*
442181834Sroberto     *  Guard against re-translation.  It won't work.  The strings will have
443181834Sroberto     *  been changed by the first pass through this code.  One shot only.
444181834Sroberto     */
445280849Scy    if (option_xlateable_txt.field_ct != 0) {
446280849Scy        /*
447280849Scy         *  Do the translations.  The first pointer follows the field count
448280849Scy         *  field.  The field count field is the size of a pointer.
449280849Scy         */
450285169Scy        char ** ppz = (char**)VOIDP(&(option_xlateable_txt));
451280849Scy        int     ix  = option_xlateable_txt.field_ct;
452181834Sroberto
453181834Sroberto        do {
454280849Scy            ppz++; /* skip over field_ct */
455181834Sroberto            *ppz = AO_gettext(*ppz);
456181834Sroberto        } while (--ix > 0);
457280849Scy        /* prevent re-translation and disable "libopts" domain lookup */
458280849Scy        option_xlateable_txt.field_ct = 0;
459181834Sroberto
460285169Scy        coerce_it(VOIDP(&(opts->pzCopyright)));
461285169Scy        coerce_it(VOIDP(&(opts->pzCopyNotice)));
462285169Scy        coerce_it(VOIDP(&(opts->pzFullVersion)));
463285169Scy        coerce_it(VOIDP(&(opts->pzUsageTitle)));
464285169Scy        coerce_it(VOIDP(&(opts->pzExplain)));
465285169Scy        coerce_it(VOIDP(&(opts->pzDetail)));
466280849Scy        {
467280849Scy            tOptDesc * od = opts->pOptDesc;
468280849Scy            for (ix = opts->optCt; ix > 0; ix--, od++)
469285169Scy                coerce_it(VOIDP(&(od->pzText)));
470181834Sroberto        }
471181834Sroberto    }
472181834Sroberto}
473181834Sroberto#endif /* ENABLE_NLS */
474181834Sroberto
475280849Scy#ifdef DO_NOT_COMPILE_THIS_CODE_IT_IS_FOR_GETTEXT
476280849Scy/** I18N function strictly for xgettext.  Do not compile. */
477280849Scystatic void bogus_function(void) {
478280849Scy  /* TRANSLATORS:
479280849Scy
480280849Scy     The following dummy function was crated solely so that xgettext can
481280849Scy     extract the correct strings.  These strings are actually referenced
482280849Scy     by a field name in the genshelloptOptions structure noted in the
483280849Scy     comments below.  The literal text is defined in genshellopt_opt_strs.
484280849Scy
485280849Scy     NOTE: the strings below are segmented with respect to the source string
486280849Scy     genshellopt_opt_strs.  The strings above are handed off for translation
487280849Scy     at run time a paragraph at a time.  Consequently, they are presented here
488280849Scy     for translation a paragraph at a time.
489280849Scy
490280849Scy     ALSO: often the description for an option will reference another option
491280849Scy     by name.  These are set off with apostrophe quotes (I hope).  Do not
492280849Scy     translate option names.
493280849Scy   */
494280849Scy  /* referenced via genshelloptOptions.pzCopyright */
495280849Scy  puts(_("genshellopt 1\n\
496280849ScyCopyright (C) 1999-2014 Bruce Korb, all rights reserved.\n\
497280849ScyThis is free software. It is licensed for use, modification and\n\
498280849Scyredistribution under the terms of the GNU Lesser General Public License,\n\
499280849Scyversion 2 or later <http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>\n"));
500280849Scy
501280849Scy  /* referenced via genshelloptOptions.pzCopyNotice */
502280849Scy  puts(_("The genshellopt library is free software; you can redistribute it and/or\n\
503280849Scymodify it under the terms of the GNU Library General Public License as\n\
504280849Scypublished by the Free Software Foundation; either version 2 of the License,\n\
505280849Scyor (at your option) any later version.\n\n"));
506280849Scy  puts(_("This library is distributed in the hope that it will be useful, but WITHOUT\n\
507280849ScyANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n\
508280849ScyFITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public\n\
509280849ScyLicense for more details.\n\n"));
510280849Scy  puts(_("You should have received a copy of the GNU Library General Public License\n\
511280849Scyalong with this library; if not, see\n\
512280849Scy<http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>\n"));
513280849Scy
514280849Scy  /* referenced via genshelloptOptions.pOptDesc->pzText */
515280849Scy  puts(_("Output Script File"));
516280849Scy
517280849Scy  /* referenced via genshelloptOptions.pOptDesc->pzText */
518280849Scy  puts(_("Shell name (follows \"#!\" magic)"));
519280849Scy
520280849Scy  /* referenced via genshelloptOptions.pOptDesc->pzText */
521280849Scy  puts(_("display extended usage information and exit"));
522280849Scy
523280849Scy  /* referenced via genshelloptOptions.pOptDesc->pzText */
524280849Scy  puts(_("extended usage information passed thru pager"));
525280849Scy
526280849Scy  /* referenced via genshelloptOptions.pOptDesc->pzText */
527280849Scy  puts(_("output version information and exit"));
528280849Scy
529280849Scy  /* referenced via genshelloptOptions.pzUsageTitle */
530280849Scy  puts(_("genshellopt - Generate Shell Option Processing Script - Ver. 1\n\
531280849ScyUsage:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n"));
532280849Scy
533280849Scy  /* referenced via genshelloptOptions.pzExplain */
534280849Scy  puts(_("Note that 'shell' is only useful if the output file does not already exist.\n\
535280849ScyIf it does, then the shell name and optional first argument will be\n\
536280849Scyextracted from the script file.\n"));
537280849Scy
538280849Scy  /* referenced via genshelloptOptions.pzDetail */
539280849Scy  puts(_("If the script file already exists and contains Automated Option Processing\n\
540280849Scytext, the second line of the file through the ending tag will be replaced\n\
541280849Scyby the newly generated text.  The first '#!' line will be regenerated.\n"));
542280849Scy
543280849Scy  /* referenced via genshelloptOptions.pzFullVersion */
544280849Scy  puts(_("genshellopt 1"));
545280849Scy
546280849Scy  /* referenced via genshelloptOptions.pzFullUsage */
547280849Scy  puts(_("<<<NOT-FOUND>>>"));
548280849Scy
549280849Scy  /* referenced via genshelloptOptions.pzShortUsage */
550280849Scy  puts(_("<<<NOT-FOUND>>>"));
551280849Scy  /* LIBOPTS-MESSAGES: */
552280849Scy#line 67 "../autoopts.c"
553280849Scy  puts(_("allocation of %d bytes failed\n"));
554280849Scy#line 93 "../autoopts.c"
555280849Scy  puts(_("allocation of %d bytes failed\n"));
556280849Scy#line 53 "../init.c"
557280849Scy  puts(_("AutoOpts function called without option descriptor\n"));
558285169Scy#line 86 "../init.c"
559280849Scy  puts(_("\tThis exceeds the compiled library version:  "));
560285169Scy#line 84 "../init.c"
561280849Scy  puts(_("Automated Options Processing Error!\n"
562280849Scy       "\t%s called AutoOpts function with structure version %d:%d:%d.\n"));
563280849Scy#line 80 "../autoopts.c"
564280849Scy  puts(_("realloc of %d bytes at 0x%p failed\n"));
565285169Scy#line 88 "../init.c"
566280849Scy  puts(_("\tThis is less than the minimum library version:  "));
567280849Scy#line 121 "../version.c"
568280849Scy  puts(_("Automated Options version %s\n"
569280849Scy       "\tCopyright (C) 1999-2014 by Bruce Korb - all rights reserved\n"));
570285169Scy#line 87 "../makeshell.c"
571280849Scy  puts(_("(AutoOpts bug):  %s.\n"));
572280849Scy#line 90 "../reset.c"
573280849Scy  puts(_("optionResetOpt() called, but reset-option not configured"));
574280849Scy#line 292 "../usage.c"
575280849Scy  puts(_("could not locate the 'help' option"));
576280849Scy#line 336 "../autoopts.c"
577280849Scy  puts(_("optionProcess() was called with invalid data"));
578280849Scy#line 748 "../usage.c"
579280849Scy  puts(_("invalid argument type specified"));
580280849Scy#line 598 "../find.c"
581280849Scy  puts(_("defaulted to option with optional arg"));
582280849Scy#line 76 "../alias.c"
583280849Scy  puts(_("aliasing option is out of range."));
584280849Scy#line 234 "../enum.c"
585280849Scy  puts(_("%s error:  the keyword '%s' is ambiguous for %s\n"));
586280849Scy#line 108 "../find.c"
587280849Scy  puts(_("  The following options match:\n"));
588280849Scy#line 293 "../find.c"
589280849Scy  puts(_("%s: ambiguous option name: %s (matches %d options)\n"));
590280849Scy#line 161 "../check.c"
591280849Scy  puts(_("%s: Command line arguments required\n"));
592280849Scy#line 43 "../alias.c"
593280849Scy  puts(_("%d %s%s options allowed\n"));
594285169Scy#line 94 "../makeshell.c"
595280849Scy  puts(_("%s error %d (%s) calling %s for '%s'\n"));
596285169Scy#line 306 "../makeshell.c"
597280849Scy  puts(_("interprocess pipe"));
598280849Scy#line 168 "../version.c"
599280849Scy  puts(_("error: version option argument '%c' invalid.  Use:\n"
600280849Scy       "\t'v' - version only\n"
601280849Scy       "\t'c' - version and copyright\n"
602280849Scy       "\t'n' - version and full copyright notice\n"));
603280849Scy#line 58 "../check.c"
604280849Scy  puts(_("%s error:  the '%s' and '%s' options conflict\n"));
605280849Scy#line 217 "../find.c"
606280849Scy  puts(_("%s: The '%s' option has been disabled."));
607280849Scy#line 430 "../find.c"
608280849Scy  puts(_("%s: The '%s' option has been disabled."));
609280849Scy#line 38 "../alias.c"
610280849Scy  puts(_("-equivalence"));
611280849Scy#line 469 "../find.c"
612280849Scy  puts(_("%s: illegal option -- %c\n"));
613280849Scy#line 110 "../reset.c"
614280849Scy  puts(_("%s: illegal option -- %c\n"));
615280849Scy#line 271 "../find.c"
616280849Scy  puts(_("%s: illegal option -- %s\n"));
617280849Scy#line 755 "../find.c"
618280849Scy  puts(_("%s: illegal option -- %s\n"));
619280849Scy#line 118 "../reset.c"
620280849Scy  puts(_("%s: illegal option -- %s\n"));
621280849Scy#line 335 "../find.c"
622280849Scy  puts(_("%s: unknown vendor extension option -- %s\n"));
623280849Scy#line 159 "../enum.c"
624280849Scy  puts(_("  or an integer from %d through %d\n"));
625280849Scy#line 169 "../enum.c"
626280849Scy  puts(_("  or an integer from %d through %d\n"));
627280849Scy#line 747 "../usage.c"
628280849Scy  puts(_("%s error:  invalid option descriptor for %s\n"));
629280849Scy#line 1081 "../usage.c"
630280849Scy  puts(_("%s error:  invalid option descriptor for %s\n"));
631280849Scy#line 385 "../find.c"
632280849Scy  puts(_("%s: invalid option name: %s\n"));
633280849Scy#line 527 "../find.c"
634280849Scy  puts(_("%s: The '%s' option requires an argument.\n"));
635280849Scy#line 156 "../autoopts.c"
636280849Scy  puts(_("(AutoOpts bug):  Equivalenced option '%s' was equivalenced to both\n"
637280849Scy       "\t'%s' and '%s'."));
638280849Scy#line 94 "../check.c"
639280849Scy  puts(_("%s error:  The %s option is required\n"));
640280849Scy#line 632 "../find.c"
641280849Scy  puts(_("%s: The '%s' option cannot have an argument.\n"));
642280849Scy#line 151 "../check.c"
643280849Scy  puts(_("%s: Command line arguments are not allowed.\n"));
644280849Scy#line 535 "../save.c"
645280849Scy  puts(_("error %d (%s) creating %s\n"));
646280849Scy#line 234 "../enum.c"
647280849Scy  puts(_("%s error:  '%s' does not match any %s keywords.\n"));
648280849Scy#line 93 "../reset.c"
649280849Scy  puts(_("%s error: The '%s' option requires an argument.\n"));
650280849Scy#line 184 "../save.c"
651280849Scy  puts(_("error %d (%s) stat-ing %s\n"));
652280849Scy#line 238 "../save.c"
653280849Scy  puts(_("error %d (%s) stat-ing %s\n"));
654280849Scy#line 143 "../restore.c"
655280849Scy  puts(_("%s error: no saved option state\n"));
656280849Scy#line 231 "../autoopts.c"
657280849Scy  puts(_("'%s' is not a command line option.\n"));
658280849Scy#line 111 "../time.c"
659280849Scy  puts(_("%s error:  '%s' is not a recognizable date/time.\n"));
660280849Scy#line 132 "../save.c"
661280849Scy  puts(_("'%s' not defined\n"));
662280849Scy#line 50 "../time.c"
663280849Scy  puts(_("%s error:  '%s' is not a recognizable time duration.\n"));
664280849Scy#line 92 "../check.c"
665280849Scy  puts(_("%s error:  The %s option must appear %d times.\n"));
666280849Scy#line 164 "../numeric.c"
667280849Scy  puts(_("%s error:  '%s' is not a recognizable number.\n"));
668280849Scy#line 200 "../enum.c"
669280849Scy  puts(_("%s error:  %s exceeds %s keyword count\n"));
670280849Scy#line 330 "../usage.c"
671280849Scy  puts(_("Try '%s %s' for more information.\n"));
672280849Scy#line 45 "../alias.c"
673280849Scy  puts(_("one %s%s option allowed\n"));
674285169Scy#line 208 "../makeshell.c"
675280849Scy  puts(_("standard output"));
676285169Scy#line 943 "../makeshell.c"
677280849Scy  puts(_("standard output"));
678280849Scy#line 274 "../usage.c"
679280849Scy  puts(_("standard output"));
680280849Scy#line 415 "../usage.c"
681280849Scy  puts(_("standard output"));
682280849Scy#line 625 "../usage.c"
683280849Scy  puts(_("standard output"));
684280849Scy#line 175 "../version.c"
685280849Scy  puts(_("standard output"));
686280849Scy#line 274 "../usage.c"
687280849Scy  puts(_("standard error"));
688280849Scy#line 415 "../usage.c"
689280849Scy  puts(_("standard error"));
690280849Scy#line 625 "../usage.c"
691280849Scy  puts(_("standard error"));
692280849Scy#line 175 "../version.c"
693280849Scy  puts(_("standard error"));
694285169Scy#line 208 "../makeshell.c"
695280849Scy  puts(_("write"));
696285169Scy#line 943 "../makeshell.c"
697280849Scy  puts(_("write"));
698280849Scy#line 273 "../usage.c"
699280849Scy  puts(_("write"));
700280849Scy#line 414 "../usage.c"
701280849Scy  puts(_("write"));
702280849Scy#line 624 "../usage.c"
703280849Scy  puts(_("write"));
704280849Scy#line 174 "../version.c"
705280849Scy  puts(_("write"));
706280849Scy#line 60 "../numeric.c"
707280849Scy  puts(_("%s error:  %s option value %ld is out of range.\n"));
708280849Scy#line 44 "../check.c"
709280849Scy  puts(_("%s error:  %s option requires the %s option\n"));
710280849Scy#line 131 "../save.c"
711280849Scy  puts(_("%s warning:  cannot save options - %s not regular file\n"));
712280849Scy#line 183 "../save.c"
713280849Scy  puts(_("%s warning:  cannot save options - %s not regular file\n"));
714280849Scy#line 237 "../save.c"
715280849Scy  puts(_("%s warning:  cannot save options - %s not regular file\n"));
716280849Scy#line 256 "../save.c"
717280849Scy  puts(_("%s warning:  cannot save options - %s not regular file\n"));
718280849Scy#line 534 "../save.c"
719280849Scy  puts(_("%s warning:  cannot save options - %s not regular file\n"));
720280849Scy  /* END-LIBOPTS-MESSAGES */
721280849Scy
722280849Scy  /* USAGE-TEXT: */
723280849Scy#line 873 "../usage.c"
724280849Scy  puts(_("\t\t\t\t- an alternate for '%s'\n"));
725280849Scy#line 1148 "../usage.c"
726280849Scy  puts(_("Version, usage and configuration options:"));
727280849Scy#line 924 "../usage.c"
728280849Scy  puts(_("\t\t\t\t- default option for unnamed options\n"));
729280849Scy#line 837 "../usage.c"
730280849Scy  puts(_("\t\t\t\t- disabled as '--%s'\n"));
731280849Scy#line 1117 "../usage.c"
732280849Scy  puts(_(" --- %-14s %s\n"));
733280849Scy#line 1115 "../usage.c"
734280849Scy  puts(_("This option has been disabled"));
735280849Scy#line 864 "../usage.c"
736280849Scy  puts(_("\t\t\t\t- enabled by default\n"));
737280849Scy#line 40 "../alias.c"
738280849Scy  puts(_("%s error:  only "));
739280849Scy#line 1194 "../usage.c"
740280849Scy  puts(_(" - examining environment variables named %s_*\n"));
741280849Scy#line 168 "../file.c"
742280849Scy  puts(_("\t\t\t\t- file must not pre-exist\n"));
743280849Scy#line 172 "../file.c"
744280849Scy  puts(_("\t\t\t\t- file must pre-exist\n"));
745280849Scy#line 380 "../usage.c"
746280849Scy  puts(_("Options are specified by doubled hyphens and their name or by a single\n"
747280849Scy       "hyphen and the flag character.\n"));
748285169Scy#line 921 "../makeshell.c"
749280849Scy  puts(_("\n"
750280849Scy       "= = = = = = = =\n\n"
751280849Scy       "This incarnation of genshell will produce\n"
752280849Scy       "a shell script to parse the options for %s:\n\n"));
753280849Scy#line 166 "../enum.c"
754280849Scy  puts(_("  or an integer mask with any of the lower %d bits set\n"));
755280849Scy#line 897 "../usage.c"
756280849Scy  puts(_("\t\t\t\t- is a set membership option\n"));
757280849Scy#line 918 "../usage.c"
758280849Scy  puts(_("\t\t\t\t- must appear between %d and %d times\n"));
759280849Scy#line 382 "../usage.c"
760280849Scy  puts(_("Options are specified by single or double hyphens and their name.\n"));
761280849Scy#line 904 "../usage.c"
762280849Scy  puts(_("\t\t\t\t- may appear multiple times\n"));
763280849Scy#line 891 "../usage.c"
764280849Scy  puts(_("\t\t\t\t- may not be preset\n"));
765280849Scy#line 1309 "../usage.c"
766280849Scy  puts(_("   Arg Option-Name    Description\n"));
767280849Scy#line 1245 "../usage.c"
768280849Scy  puts(_("  Flg Arg Option-Name    Description\n"));
769280849Scy#line 1303 "../usage.c"
770280849Scy  puts(_("  Flg Arg Option-Name    Description\n"));
771280849Scy#line 1304 "../usage.c"
772280849Scy  puts(_(" %3s %s"));
773280849Scy#line 1310 "../usage.c"
774280849Scy  puts(_(" %3s %s"));
775280849Scy#line 387 "../usage.c"
776280849Scy  puts(_("The '-#<number>' option may omit the hash char\n"));
777280849Scy#line 383 "../usage.c"
778280849Scy  puts(_("All arguments are named options.\n"));
779280849Scy#line 971 "../usage.c"
780280849Scy  puts(_(" - reading file %s"));
781280849Scy#line 409 "../usage.c"
782280849Scy  puts(_("\n"
783280849Scy       "Please send bug reports to:  <%s>\n"));
784280849Scy#line 100 "../version.c"
785280849Scy  puts(_("\n"
786280849Scy       "Please send bug reports to:  <%s>\n"));
787280849Scy#line 129 "../version.c"
788280849Scy  puts(_("\n"
789280849Scy       "Please send bug reports to:  <%s>\n"));
790280849Scy#line 903 "../usage.c"
791280849Scy  puts(_("\t\t\t\t- may NOT appear - preset only\n"));
792280849Scy#line 944 "../usage.c"
793280849Scy  puts(_("\n"
794280849Scy       "The following option preset mechanisms are supported:\n"));
795280849Scy#line 1192 "../usage.c"
796280849Scy  puts(_("\n"
797280849Scy       "The following option preset mechanisms are supported:\n"));
798280849Scy#line 682 "../usage.c"
799280849Scy  puts(_("prohibits these options:\n"));
800280849Scy#line 677 "../usage.c"
801280849Scy  puts(_("prohibits the option '%s'\n"));
802280849Scy#line 81 "../numeric.c"
803280849Scy  puts(_("%s%ld to %ld"));
804280849Scy#line 79 "../numeric.c"
805280849Scy  puts(_("%sgreater than or equal to %ld"));
806280849Scy#line 75 "../numeric.c"
807280849Scy  puts(_("%s%ld exactly"));
808280849Scy#line 68 "../numeric.c"
809280849Scy  puts(_("%sit must lie in one of the ranges:\n"));
810280849Scy#line 68 "../numeric.c"
811280849Scy  puts(_("%sit must be in the range:\n"));
812280849Scy#line 88 "../numeric.c"
813280849Scy  puts(_(", or\n"));
814280849Scy#line 66 "../numeric.c"
815280849Scy  puts(_("%sis scalable with a suffix: k/K/m/M/g/G/t/T\n"));
816280849Scy#line 77 "../numeric.c"
817280849Scy  puts(_("%sless than or equal to %ld"));
818280849Scy#line 390 "../usage.c"
819280849Scy  puts(_("Operands and options may be intermixed.  They will be reordered.\n"));
820280849Scy#line 652 "../usage.c"
821280849Scy  puts(_("requires the option '%s'\n"));
822280849Scy#line 655 "../usage.c"
823280849Scy  puts(_("requires these options:\n"));
824280849Scy#line 1321 "../usage.c"
825280849Scy  puts(_("   Arg Option-Name   Req?  Description\n"));
826280849Scy#line 1315 "../usage.c"
827280849Scy  puts(_("  Flg Arg Option-Name   Req?  Description\n"));
828280849Scy#line 167 "../enum.c"
829280849Scy  puts(_("or you may use a numeric representation.  Preceding these with a '!'\n"
830280849Scy       "will clear the bits, specifying 'none' will clear all bits, and 'all'\n"
831280849Scy       "will set them all.  Multiple entries may be passed as an option\n"
832280849Scy       "argument list.\n"));
833280849Scy#line 910 "../usage.c"
834280849Scy  puts(_("\t\t\t\t- may appear up to %d times\n"));
835280849Scy#line 77 "../enum.c"
836280849Scy  puts(_("The valid \"%s\" option keywords are:\n"));
837280849Scy#line 1152 "../usage.c"
838280849Scy  puts(_("The next option supports vendor supported extra options:"));
839280849Scy#line 773 "../usage.c"
840280849Scy  puts(_("These additional options are:"));
841280849Scy  /* END-USAGE-TEXT */
842280849Scy}
843280849Scy#endif /* uncompilable code */
844181834Sroberto#ifdef  __cplusplus
845181834Sroberto}
846181834Sroberto#endif
847181834Sroberto/* genshell.c ends here */
848