Home | History | Annotate | Line # | Download | only in ntpsnmpd
ntpsnmpd-opts.c revision 1.2
      1 /*	$NetBSD: ntpsnmpd-opts.c,v 1.2 2014/12/19 20:43:18 christos Exp $	*/
      2 
      3 /*
      4  *  EDIT THIS FILE WITH CAUTION  (ntpsnmpd-opts.c)
      5  *
      6  *  It has been AutoGen-ed  December 19, 2014 at 07:50:22 AM by AutoGen 5.18.5pre4
      7  *  From the definitions    ntpsnmpd-opts.def
      8  *  and the template file   options
      9  *
     10  * Generated from AutoOpts 41:0:16 templates.
     11  *
     12  *  AutoOpts is a copyrighted work.  This source file is not encumbered
     13  *  by AutoOpts licensing, but is provided under the licensing terms chosen
     14  *  by the ntpsnmpd author or copyright holder.  AutoOpts is
     15  *  licensed under the terms of the LGPL.  The redistributable library
     16  *  (``libopts'') is licensed under the terms of either the LGPL or, at the
     17  *  users discretion, the BSD license.  See the AutoOpts and/or libopts sources
     18  *  for details.
     19  *
     20  * The ntpsnmpd program is copyrighted and licensed
     21  * under the following terms:
     22  *
     23  *  Copyright (C) 1970-2014 The University of Delaware, all rights reserved.
     24  *  This is free software. It is licensed for use, modification and
     25  *  redistribution under the terms of the NTP License, copies of which
     26  *  can be seen at:
     27  *    <http://ntp.org/license>
     28  *    <http://opensource.org/licenses/ntp-license.php>
     29  *
     30  *  Permission to use, copy, modify, and distribute this software and its
     31  *  documentation for any purpose with or without fee is hereby granted,
     32  *  provided that the above copyright notice appears in all copies and that
     33  *  both the copyright notice and this permission notice appear in
     34  *  supporting documentation, and that the name The University of Delaware not be used in
     35  *  advertising or publicity pertaining to distribution of the software
     36  *  without specific, written prior permission. The University of Delaware makes no
     37  *  representations about the suitability this software for any purpose. It
     38  *  is provided "as is" without express or implied warranty.
     39  */
     40 
     41 #ifndef __doxygen__
     42 #define OPTION_CODE_COMPILE 1
     43 #include "ntpsnmpd-opts.h"
     44 #include <sys/types.h>
     45 
     46 #include <limits.h>
     47 #include <stdio.h>
     48 #include <stdlib.h>
     49 
     50 #ifdef  __cplusplus
     51 extern "C" {
     52 #endif
     53 extern FILE * option_usage_fp;
     54 #define zCopyright      (ntpsnmpd_opt_strs+0)
     55 #define zLicenseDescrip (ntpsnmpd_opt_strs+314)
     56 
     57 
     58 #ifndef NULL
     59 #  define NULL 0
     60 #endif
     61 
     62 /**
     63  *  static const strings for ntpsnmpd options
     64  */
     65 static char const ntpsnmpd_opt_strs[1548] =
     66 /*     0 */ "ntpsnmpd 4.2.8\n"
     67             "Copyright (C) 1970-2014 The University of Delaware, all rights reserved.\n"
     68             "This is free software. It is licensed for use, modification and\n"
     69             "redistribution under the terms of the NTP License, copies of which\n"
     70             "can be seen at:\n"
     71             "  <http://ntp.org/license>\n"
     72             "  <http://opensource.org/licenses/ntp-license.php>\n\0"
     73 /*   314 */ "Permission to use, copy, modify, and distribute this software and its\n"
     74             "documentation for any purpose with or without fee is hereby granted,\n"
     75             "provided that the above copyright notice appears in all copies and that\n"
     76             "both the copyright notice and this permission notice appear in supporting\n"
     77             "documentation, and that the name The University of Delaware not be used in\n"
     78             "advertising or publicity pertaining to distribution of the software without\n"
     79             "specific, written prior permission.  The University of Delaware makes no\n"
     80             "representations about the suitability this software for any purpose.  It is\n"
     81             "provided \"as is\" without express or implied warranty.\n\0"
     82 /*   954 */ "Do not fork\0"
     83 /*   966 */ "NOFORK\0"
     84 /*   973 */ "nofork\0"
     85 /*   980 */ "Log to syslog()\0"
     86 /*   996 */ "SYSLOG\0"
     87 /*  1003 */ "syslog\0"
     88 /*  1010 */ "The socket address ntpsnmpd uses to connect to net-snmpd\0"
     89 /*  1067 */ "AGENTXSOCKET\0"
     90 /*  1080 */ "agentxsocket\0"
     91 /*  1093 */ "unix:/var/agentx/master\0"
     92 /*  1117 */ "display extended usage information and exit\0"
     93 /*  1161 */ "help\0"
     94 /*  1166 */ "extended usage information passed thru pager\0"
     95 /*  1211 */ "more-help\0"
     96 /*  1221 */ "output version information and exit\0"
     97 /*  1257 */ "version\0"
     98 /*  1265 */ "save the option state to a config file\0"
     99 /*  1304 */ "save-opts\0"
    100 /*  1314 */ "load options from a config file\0"
    101 /*  1346 */ "LOAD_OPTS\0"
    102 /*  1356 */ "no-load-opts\0"
    103 /*  1369 */ "no\0"
    104 /*  1372 */ "NTPSNMPD\0"
    105 /*  1381 */ "ntpsnmpd - NTP SNMP MIB agent - Ver. 4.2.8\n"
    106             "Usage:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n\0"
    107 /*  1482 */ "$HOME\0"
    108 /*  1488 */ ".\0"
    109 /*  1490 */ ".ntprc\0"
    110 /*  1497 */ "http://bugs.ntp.org, bugs (at) ntp.org\0"
    111 /*  1531 */ "\n\0"
    112 /*  1533 */ "ntpsnmpd 4.2.8";
    113 
    114 /**
    115  *  nofork option description:
    116  */
    117 /** Descriptive text for the nofork option */
    118 #define NOFORK_DESC      (ntpsnmpd_opt_strs+954)
    119 /** Upper-cased name for the nofork option */
    120 #define NOFORK_NAME      (ntpsnmpd_opt_strs+966)
    121 /** Name string for the nofork option */
    122 #define NOFORK_name      (ntpsnmpd_opt_strs+973)
    123 /** Compiled in flag settings for the nofork option */
    124 #define NOFORK_FLAGS     (OPTST_DISABLED)
    125 
    126 /**
    127  *  syslog option description:
    128  */
    129 /** Descriptive text for the syslog option */
    130 #define SYSLOG_DESC      (ntpsnmpd_opt_strs+980)
    131 /** Upper-cased name for the syslog option */
    132 #define SYSLOG_NAME      (ntpsnmpd_opt_strs+996)
    133 /** Name string for the syslog option */
    134 #define SYSLOG_name      (ntpsnmpd_opt_strs+1003)
    135 /** Compiled in flag settings for the syslog option */
    136 #define SYSLOG_FLAGS     (OPTST_DISABLED)
    137 
    138 /**
    139  *  agentXSocket option description:
    140  */
    141 /** Descriptive text for the agentXSocket option */
    142 #define AGENTXSOCKET_DESC      (ntpsnmpd_opt_strs+1010)
    143 /** Upper-cased name for the agentXSocket option */
    144 #define AGENTXSOCKET_NAME      (ntpsnmpd_opt_strs+1067)
    145 /** Name string for the agentXSocket option */
    146 #define AGENTXSOCKET_name      (ntpsnmpd_opt_strs+1080)
    147 /** The compiled in default value for the agentXSocket option argument */
    148 #define AGENTXSOCKET_DFT_ARG   (ntpsnmpd_opt_strs+1093)
    149 /** Compiled in flag settings for the agentXSocket option */
    150 #define AGENTXSOCKET_FLAGS     (OPTST_DISABLED \
    151         | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
    152 
    153 /*
    154  *  Help/More_Help/Version option descriptions:
    155  */
    156 #define HELP_DESC       (ntpsnmpd_opt_strs+1117)
    157 #define HELP_name       (ntpsnmpd_opt_strs+1161)
    158 #ifdef HAVE_WORKING_FORK
    159 #define MORE_HELP_DESC  (ntpsnmpd_opt_strs+1166)
    160 #define MORE_HELP_name  (ntpsnmpd_opt_strs+1211)
    161 #define MORE_HELP_FLAGS (OPTST_IMM | OPTST_NO_INIT)
    162 #else
    163 #define MORE_HELP_DESC  HELP_DESC
    164 #define MORE_HELP_name  HELP_name
    165 #define MORE_HELP_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
    166 #endif
    167 #ifdef NO_OPTIONAL_OPT_ARGS
    168 #  define VER_FLAGS     (OPTST_IMM | OPTST_NO_INIT)
    169 #else
    170 #  define VER_FLAGS     (OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
    171                          OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT)
    172 #endif
    173 #define VER_DESC        (ntpsnmpd_opt_strs+1221)
    174 #define VER_name        (ntpsnmpd_opt_strs+1257)
    175 #define SAVE_OPTS_DESC  (ntpsnmpd_opt_strs+1265)
    176 #define SAVE_OPTS_name  (ntpsnmpd_opt_strs+1304)
    177 #define LOAD_OPTS_DESC     (ntpsnmpd_opt_strs+1314)
    178 #define LOAD_OPTS_NAME     (ntpsnmpd_opt_strs+1346)
    179 #define NO_LOAD_OPTS_name  (ntpsnmpd_opt_strs+1356)
    180 #define LOAD_OPTS_pfx      (ntpsnmpd_opt_strs+1369)
    181 #define LOAD_OPTS_name     (NO_LOAD_OPTS_name + 3)
    182 /**
    183  *  Declare option callback procedures
    184  */
    185 extern tOptProc
    186     ntpOptionPrintVersion, optionBooleanVal,      optionNestedVal,
    187     optionNumericVal,      optionPagedUsage,      optionResetOpt,
    188     optionStackArg,        optionTimeDate,        optionTimeVal,
    189     optionUnstackArg,      optionVendorOption;
    190 static tOptProc
    191     doUsageOpt;
    192 #define VER_PROC        ntpOptionPrintVersion
    193 
    194 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    195 /**
    196  *  Define the ntpsnmpd Option Descriptions.
    197  * This is an array of OPTION_CT entries, one for each
    198  * option that the ntpsnmpd program responds to.
    199  */
    200 static tOptDesc optDesc[OPTION_CT] = {
    201   {  /* entry idx, value */ 0, VALUE_OPT_NOFORK,
    202      /* equiv idx, value */ 0, VALUE_OPT_NOFORK,
    203      /* equivalenced to  */ NO_EQUIVALENT,
    204      /* min, max, act ct */ 0, 1, 0,
    205      /* opt state flags  */ NOFORK_FLAGS, 0,
    206      /* last opt argumnt */ { NULL }, /* --nofork */
    207      /* arg list/cookie  */ NULL,
    208      /* must/cannot opts */ NULL, NULL,
    209      /* option proc      */ NULL,
    210      /* desc, NAME, name */ NOFORK_DESC, NOFORK_NAME, NOFORK_name,
    211      /* disablement strs */ NULL, NULL },
    212 
    213   {  /* entry idx, value */ 1, VALUE_OPT_SYSLOG,
    214      /* equiv idx, value */ 1, VALUE_OPT_SYSLOG,
    215      /* equivalenced to  */ NO_EQUIVALENT,
    216      /* min, max, act ct */ 0, 1, 0,
    217      /* opt state flags  */ SYSLOG_FLAGS, 0,
    218      /* last opt argumnt */ { NULL }, /* --syslog */
    219      /* arg list/cookie  */ NULL,
    220      /* must/cannot opts */ NULL, NULL,
    221      /* option proc      */ NULL,
    222      /* desc, NAME, name */ SYSLOG_DESC, SYSLOG_NAME, SYSLOG_name,
    223      /* disablement strs */ NULL, NULL },
    224 
    225   {  /* entry idx, value */ 2, VALUE_OPT_AGENTXSOCKET,
    226      /* equiv idx, value */ 2, VALUE_OPT_AGENTXSOCKET,
    227      /* equivalenced to  */ NO_EQUIVALENT,
    228      /* min, max, act ct */ 0, 1, 0,
    229      /* opt state flags  */ AGENTXSOCKET_FLAGS, 0,
    230      /* last opt argumnt */ { AGENTXSOCKET_DFT_ARG },
    231      /* arg list/cookie  */ NULL,
    232      /* must/cannot opts */ NULL, NULL,
    233      /* option proc      */ NULL,
    234      /* desc, NAME, name */ AGENTXSOCKET_DESC, AGENTXSOCKET_NAME, AGENTXSOCKET_name,
    235      /* disablement strs */ NULL, NULL },
    236 
    237   {  /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
    238      /* equiv idx value  */ NO_EQUIVALENT, VALUE_OPT_VERSION,
    239      /* equivalenced to  */ NO_EQUIVALENT,
    240      /* min, max, act ct */ 0, 1, 0,
    241      /* opt state flags  */ VER_FLAGS, AOUSE_VERSION,
    242      /* last opt argumnt */ { NULL },
    243      /* arg list/cookie  */ NULL,
    244      /* must/cannot opts */ NULL, NULL,
    245      /* option proc      */ VER_PROC,
    246      /* desc, NAME, name */ VER_DESC, NULL, VER_name,
    247      /* disablement strs */ NULL, NULL },
    248 
    249 
    250 
    251   {  /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
    252      /* equiv idx value  */ NO_EQUIVALENT, VALUE_OPT_HELP,
    253      /* equivalenced to  */ NO_EQUIVALENT,
    254      /* min, max, act ct */ 0, 1, 0,
    255      /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, AOUSE_HELP,
    256      /* last opt argumnt */ { NULL },
    257      /* arg list/cookie  */ NULL,
    258      /* must/cannot opts */ NULL, NULL,
    259      /* option proc      */ doUsageOpt,
    260      /* desc, NAME, name */ HELP_DESC, NULL, HELP_name,
    261      /* disablement strs */ NULL, NULL },
    262 
    263   {  /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
    264      /* equiv idx value  */ NO_EQUIVALENT, VALUE_OPT_MORE_HELP,
    265      /* equivalenced to  */ NO_EQUIVALENT,
    266      /* min, max, act ct */ 0, 1, 0,
    267      /* opt state flags  */ MORE_HELP_FLAGS, AOUSE_MORE_HELP,
    268      /* last opt argumnt */ { NULL },
    269      /* arg list/cookie  */ NULL,
    270      /* must/cannot opts */ NULL,  NULL,
    271      /* option proc      */ optionPagedUsage,
    272      /* desc, NAME, name */ MORE_HELP_DESC, NULL, MORE_HELP_name,
    273      /* disablement strs */ NULL, NULL },
    274 
    275   {  /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS,
    276      /* equiv idx value  */ NO_EQUIVALENT, VALUE_OPT_SAVE_OPTS,
    277      /* equivalenced to  */ NO_EQUIVALENT,
    278      /* min, max, act ct */ 0, 1, 0,
    279      /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
    280                        | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, AOUSE_SAVE_OPTS,
    281      /* last opt argumnt */ { NULL },
    282      /* arg list/cookie  */ NULL,
    283      /* must/cannot opts */ NULL,  NULL,
    284      /* option proc      */ NULL,
    285      /* desc, NAME, name */ SAVE_OPTS_DESC, NULL, SAVE_OPTS_name,
    286      /* disablement strs */ NULL, NULL },
    287 
    288   {  /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS,
    289      /* equiv idx value  */ NO_EQUIVALENT, VALUE_OPT_LOAD_OPTS,
    290      /* equivalenced to  */ NO_EQUIVALENT,
    291      /* min, max, act ct */ 0, NOLIMIT, 0,
    292      /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
    293 			  | OPTST_DISABLE_IMM, AOUSE_LOAD_OPTS,
    294      /* last opt argumnt */ { NULL },
    295      /* arg list/cookie  */ NULL,
    296      /* must/cannot opts */ NULL, NULL,
    297      /* option proc      */ optionLoadOpt,
    298      /* desc, NAME, name */ LOAD_OPTS_DESC, LOAD_OPTS_NAME, LOAD_OPTS_name,
    299      /* disablement strs */ NO_LOAD_OPTS_name, LOAD_OPTS_pfx }
    300 };
    301 
    302 
    303 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    304 /** Reference to the upper cased version of ntpsnmpd. */
    305 #define zPROGNAME       (ntpsnmpd_opt_strs+1372)
    306 /** Reference to the title line for ntpsnmpd usage. */
    307 #define zUsageTitle     (ntpsnmpd_opt_strs+1381)
    308 /** ntpsnmpd configuration file name. */
    309 #define zRcName         (ntpsnmpd_opt_strs+1490)
    310 /** Directories to search for ntpsnmpd config files. */
    311 static char const * const apzHomeList[3] = {
    312     ntpsnmpd_opt_strs+1482,
    313     ntpsnmpd_opt_strs+1488,
    314     NULL };
    315 /** The ntpsnmpd program bug email address. */
    316 #define zBugsAddr       (ntpsnmpd_opt_strs+1497)
    317 /** Clarification/explanation of what ntpsnmpd does. */
    318 #define zExplain        (ntpsnmpd_opt_strs+1531)
    319 /** Extra detail explaining what ntpsnmpd does. */
    320 #define zDetail         (NULL)
    321 /** The full version string for ntpsnmpd. */
    322 #define zFullVersion    (ntpsnmpd_opt_strs+1533)
    323 /* extracted from optcode.tlib near line 364 */
    324 
    325 #if defined(ENABLE_NLS)
    326 # define OPTPROC_BASE OPTPROC_TRANSLATE
    327   static tOptionXlateProc translate_option_strings;
    328 #else
    329 # define OPTPROC_BASE OPTPROC_NONE
    330 # define translate_option_strings NULL
    331 #endif /* ENABLE_NLS */
    332 
    333 #define ntpsnmpd_full_usage (NULL)
    334 #define ntpsnmpd_short_usage (NULL)
    335 
    336 #endif /* not defined __doxygen__ */
    337 
    338 /*
    339  *  Create the static procedure(s) declared above.
    340  */
    341 /**
    342  * The callout function that invokes the optionUsage function.
    343  *
    344  * @param[in] opts the AutoOpts option description structure
    345  * @param[in] od   the descriptor for the "help" (usage) option.
    346  * @noreturn
    347  */
    348 static void
    349 doUsageOpt(tOptions * opts, tOptDesc * od)
    350 {
    351     int ex_code;
    352     ex_code = NTPSNMPD_EXIT_SUCCESS;
    353     optionUsage(&ntpsnmpdOptions, ex_code);
    354     /* NOTREACHED */
    355     exit(1);
    356     (void)opts;
    357     (void)od;
    358 }
    359 /* extracted from optmain.tlib near line 1245 */
    360 
    361 /**
    362  * The directory containing the data associated with ntpsnmpd.
    363  */
    364 #ifndef  PKGDATADIR
    365 # define PKGDATADIR ""
    366 #endif
    367 
    368 /**
    369  * Information about the person or institution that packaged ntpsnmpd
    370  * for the current distribution.
    371  */
    372 #ifndef  WITH_PACKAGER
    373 # define ntpsnmpd_packager_info NULL
    374 #else
    375 /** Packager information for ntpsnmpd. */
    376 static char const ntpsnmpd_packager_info[] =
    377     "Packaged by " WITH_PACKAGER
    378 
    379 # ifdef WITH_PACKAGER_VERSION
    380         " ("WITH_PACKAGER_VERSION")"
    381 # endif
    382 
    383 # ifdef WITH_PACKAGER_BUG_REPORTS
    384     "\nReport ntpsnmpd bugs to " WITH_PACKAGER_BUG_REPORTS
    385 # endif
    386     "\n";
    387 #endif
    388 #ifndef __doxygen__
    389 
    390 #endif /* __doxygen__ */
    391 /**
    392  * The option definitions for ntpsnmpd.  The one structure that
    393  * binds them all.
    394  */
    395 tOptions ntpsnmpdOptions = {
    396     OPTIONS_STRUCT_VERSION,
    397     0, NULL,                    /* original argc + argv    */
    398     ( OPTPROC_BASE
    399     + OPTPROC_ERRSTOP
    400     + OPTPROC_SHORTOPT
    401     + OPTPROC_LONGOPT
    402     + OPTPROC_NO_REQ_OPT
    403     + OPTPROC_ENVIRON
    404     + OPTPROC_NO_ARGS
    405     + OPTPROC_MISUSE ),
    406     0, NULL,                    /* current option index, current option */
    407     NULL,         NULL,         zPROGNAME,
    408     zRcName,      zCopyright,   zLicenseDescrip,
    409     zFullVersion, apzHomeList,  zUsageTitle,
    410     zExplain,     zDetail,      optDesc,
    411     zBugsAddr,                  /* address to send bugs to */
    412     NULL, NULL,                 /* extensions/saved state  */
    413     optionUsage, /* usage procedure */
    414     translate_option_strings,   /* translation procedure */
    415     /*
    416      *  Indexes to special options
    417      */
    418     { INDEX_OPT_MORE_HELP, /* more-help option index */
    419       INDEX_OPT_SAVE_OPTS, /* save option index */
    420       NO_EQUIVALENT, /* '-#' option index */
    421       NO_EQUIVALENT /* index of default opt */
    422     },
    423     8 /* full option count */, 3 /* user option count */,
    424     ntpsnmpd_full_usage, ntpsnmpd_short_usage,
    425     NULL, NULL,
    426     PKGDATADIR, ntpsnmpd_packager_info
    427 };
    428 
    429 #if ENABLE_NLS
    430 /**
    431  * This code is designed to translate translatable option text for the
    432  * ntpsnmpd program.  These translations happen upon entry
    433  * to optionProcess().
    434  */
    435 #include <stdio.h>
    436 #include <stdlib.h>
    437 #include <string.h>
    438 #include <unistd.h>
    439 #ifdef HAVE_DCGETTEXT
    440 # include <gettext.h>
    441 #endif
    442 #include <autoopts/usage-txt.h>
    443 
    444 static char * AO_gettext(char const * pz);
    445 static void   coerce_it(void ** s);
    446 
    447 /**
    448  * AutoGen specific wrapper function for gettext.  It relies on the macro _()
    449  * to convert from English to the target language, then strdup-duplicates the
    450  * result string.  It tries the "libopts" domain first, then whatever has been
    451  * set via the \a textdomain(3) call.
    452  *
    453  * @param[in] pz the input text used as a lookup key.
    454  * @returns the translated text (if there is one),
    455  *   or the original text (if not).
    456  */
    457 static char *
    458 AO_gettext(char const * pz)
    459 {
    460     char * res;
    461     if (pz == NULL)
    462         return NULL;
    463 #ifdef HAVE_DCGETTEXT
    464     /*
    465      * While processing the option_xlateable_txt data, try to use the
    466      * "libopts" domain.  Once we switch to the option descriptor data,
    467      * do *not* use that domain.
    468      */
    469     if (option_xlateable_txt.field_ct != 0) {
    470         res = dgettext("libopts", pz);
    471         if (res == pz)
    472             res = (char *)(void *)_(pz);
    473     } else
    474         res = (char *)(void *)_(pz);
    475 #else
    476     res = (char *)(void *)_(pz);
    477 #endif
    478     if (res == pz)
    479         return res;
    480     res = strdup(res);
    481     if (res == NULL) {
    482         fputs(_("No memory for duping translated strings\n"), stderr);
    483         exit(NTPSNMPD_EXIT_FAILURE);
    484     }
    485     return res;
    486 }
    487 
    488 /**
    489  * All the pointers we use are marked "* const", but they are stored in
    490  * writable memory.  Coerce the mutability and set the pointer.
    491  */
    492 static void coerce_it(void ** s) { *s = AO_gettext(*s);
    493 }
    494 
    495 /**
    496  * Translate all the translatable strings in the ntpsnmpdOptions
    497  * structure defined above.  This is done only once.
    498  */
    499 static void
    500 translate_option_strings(void)
    501 {
    502     tOptions * const opts = &ntpsnmpdOptions;
    503 
    504     /*
    505      *  Guard against re-translation.  It won't work.  The strings will have
    506      *  been changed by the first pass through this code.  One shot only.
    507      */
    508     if (option_xlateable_txt.field_ct != 0) {
    509         /*
    510          *  Do the translations.  The first pointer follows the field count
    511          *  field.  The field count field is the size of a pointer.
    512          */
    513         char ** ppz = (char**)(void*)&(option_xlateable_txt);
    514         int     ix  = option_xlateable_txt.field_ct;
    515 
    516         do {
    517             ppz++; /* skip over field_ct */
    518             *ppz = AO_gettext(*ppz);
    519         } while (--ix > 0);
    520         /* prevent re-translation and disable "libopts" domain lookup */
    521         option_xlateable_txt.field_ct = 0;
    522 
    523         coerce_it((void*)&(opts->pzCopyright));
    524         coerce_it((void*)&(opts->pzCopyNotice));
    525         coerce_it((void*)&(opts->pzFullVersion));
    526         coerce_it((void*)&(opts->pzUsageTitle));
    527         coerce_it((void*)&(opts->pzExplain));
    528         coerce_it((void*)&(opts->pzDetail));
    529         {
    530             tOptDesc * od = opts->pOptDesc;
    531             for (ix = opts->optCt; ix > 0; ix--, od++)
    532                 coerce_it((void*)&(od->pzText));
    533         }
    534     }
    535 }
    536 #endif /* ENABLE_NLS */
    537 
    538 #ifdef DO_NOT_COMPILE_THIS_CODE_IT_IS_FOR_GETTEXT
    539 /** I18N function strictly for xgettext.  Do not compile. */
    540 static void bogus_function(void) {
    541   /* TRANSLATORS:
    542 
    543      The following dummy function was crated solely so that xgettext can
    544      extract the correct strings.  These strings are actually referenced
    545      by a field name in the ntpsnmpdOptions structure noted in the
    546      comments below.  The literal text is defined in ntpsnmpd_opt_strs.
    547 
    548      NOTE: the strings below are segmented with respect to the source string
    549      ntpsnmpd_opt_strs.  The strings above are handed off for translation
    550      at run time a paragraph at a time.  Consequently, they are presented here
    551      for translation a paragraph at a time.
    552 
    553      ALSO: often the description for an option will reference another option
    554      by name.  These are set off with apostrophe quotes (I hope).  Do not
    555      translate option names.
    556    */
    557   /* referenced via ntpsnmpdOptions.pzCopyright */
    558   puts(_("ntpsnmpd 4.2.8\n\
    559 Copyright (C) 1970-2014 The University of Delaware, all rights reserved.\n\
    560 This is free software. It is licensed for use, modification and\n\
    561 redistribution under the terms of the NTP License, copies of which\n\
    562 can be seen at:\n"));
    563   puts(_("  <http://ntp.org/license>\n\
    564   <http://opensource.org/licenses/ntp-license.php>\n"));
    565 
    566   /* referenced via ntpsnmpdOptions.pzCopyNotice */
    567   puts(_("Permission to use, copy, modify, and distribute this software and its\n\
    568 documentation for any purpose with or without fee is hereby granted,\n\
    569 provided that the above copyright notice appears in all copies and that\n\
    570 both the copyright notice and this permission notice appear in supporting\n\
    571 documentation, and that the name The University of Delaware not be used in\n\
    572 advertising or publicity pertaining to distribution of the software without\n\
    573 specific, written prior permission.  The University of Delaware makes no\n\
    574 representations about the suitability this software for any purpose.  It is\n\
    575 provided \"as is\" without express or implied warranty.\n"));
    576 
    577   /* referenced via ntpsnmpdOptions.pOptDesc->pzText */
    578   puts(_("Do not fork"));
    579 
    580   /* referenced via ntpsnmpdOptions.pOptDesc->pzText */
    581   puts(_("Log to syslog()"));
    582 
    583   /* referenced via ntpsnmpdOptions.pOptDesc->pzText */
    584   puts(_("The socket address ntpsnmpd uses to connect to net-snmpd"));
    585 
    586   /* referenced via ntpsnmpdOptions.pOptDesc->pzText */
    587   puts(_("display extended usage information and exit"));
    588 
    589   /* referenced via ntpsnmpdOptions.pOptDesc->pzText */
    590   puts(_("extended usage information passed thru pager"));
    591 
    592   /* referenced via ntpsnmpdOptions.pOptDesc->pzText */
    593   puts(_("output version information and exit"));
    594 
    595   /* referenced via ntpsnmpdOptions.pOptDesc->pzText */
    596   puts(_("save the option state to a config file"));
    597 
    598   /* referenced via ntpsnmpdOptions.pOptDesc->pzText */
    599   puts(_("load options from a config file"));
    600 
    601   /* referenced via ntpsnmpdOptions.pzUsageTitle */
    602   puts(_("ntpsnmpd - NTP SNMP MIB agent - Ver. 4.2.8\n\
    603 Usage:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n"));
    604 
    605   /* referenced via ntpsnmpdOptions.pzExplain */
    606   puts(_("\n"));
    607 
    608   /* referenced via ntpsnmpdOptions.pzFullVersion */
    609   puts(_("ntpsnmpd 4.2.8"));
    610 
    611   /* referenced via ntpsnmpdOptions.pzFullUsage */
    612   puts(_("<<<NOT-FOUND>>>"));
    613 
    614   /* referenced via ntpsnmpdOptions.pzShortUsage */
    615   puts(_("<<<NOT-FOUND>>>"));
    616   /* LIBOPTS-MESSAGES: */
    617 #line 67 "../autoopts.c"
    618   puts(_("allocation of %d bytes failed\n"));
    619 #line 93 "../autoopts.c"
    620   puts(_("allocation of %d bytes failed\n"));
    621 #line 53 "../init.c"
    622   puts(_("AutoOpts function called without option descriptor\n"));
    623 #line 86 "../init.c"
    624   puts(_("\tThis exceeds the compiled library version:  "));
    625 #line 84 "../init.c"
    626   puts(_("Automated Options Processing Error!\n"
    627        "\t%s called AutoOpts function with structure version %d:%d:%d.\n"));
    628 #line 80 "../autoopts.c"
    629   puts(_("realloc of %d bytes at 0x%p failed\n"));
    630 #line 88 "../init.c"
    631   puts(_("\tThis is less than the minimum library version:  "));
    632 #line 121 "../version.c"
    633   puts(_("Automated Options version %s\n"
    634        "\tCopyright (C) 1999-2014 by Bruce Korb - all rights reserved\n"));
    635 #line 82 "../makeshell.c"
    636   puts(_("(AutoOpts bug):  %s.\n"));
    637 #line 90 "../reset.c"
    638   puts(_("optionResetOpt() called, but reset-option not configured"));
    639 #line 292 "../usage.c"
    640   puts(_("could not locate the 'help' option"));
    641 #line 336 "../autoopts.c"
    642   puts(_("optionProcess() was called with invalid data"));
    643 #line 748 "../usage.c"
    644   puts(_("invalid argument type specified"));
    645 #line 598 "../find.c"
    646   puts(_("defaulted to option with optional arg"));
    647 #line 76 "../alias.c"
    648   puts(_("aliasing option is out of range."));
    649 #line 234 "../enum.c"
    650   puts(_("%s error:  the keyword '%s' is ambiguous for %s\n"));
    651 #line 108 "../find.c"
    652   puts(_("  The following options match:\n"));
    653 #line 293 "../find.c"
    654   puts(_("%s: ambiguous option name: %s (matches %d options)\n"));
    655 #line 161 "../check.c"
    656   puts(_("%s: Command line arguments required\n"));
    657 #line 43 "../alias.c"
    658   puts(_("%d %s%s options allowed\n"));
    659 #line 89 "../makeshell.c"
    660   puts(_("%s error %d (%s) calling %s for '%s'\n"));
    661 #line 301 "../makeshell.c"
    662   puts(_("interprocess pipe"));
    663 #line 168 "../version.c"
    664   puts(_("error: version option argument '%c' invalid.  Use:\n"
    665        "\t'v' - version only\n"
    666        "\t'c' - version and copyright\n"
    667        "\t'n' - version and full copyright notice\n"));
    668 #line 58 "../check.c"
    669   puts(_("%s error:  the '%s' and '%s' options conflict\n"));
    670 #line 217 "../find.c"
    671   puts(_("%s: The '%s' option has been disabled."));
    672 #line 430 "../find.c"
    673   puts(_("%s: The '%s' option has been disabled."));
    674 #line 38 "../alias.c"
    675   puts(_("-equivalence"));
    676 #line 469 "../find.c"
    677   puts(_("%s: illegal option -- %c\n"));
    678 #line 110 "../reset.c"
    679   puts(_("%s: illegal option -- %c\n"));
    680 #line 271 "../find.c"
    681   puts(_("%s: illegal option -- %s\n"));
    682 #line 755 "../find.c"
    683   puts(_("%s: illegal option -- %s\n"));
    684 #line 118 "../reset.c"
    685   puts(_("%s: illegal option -- %s\n"));
    686 #line 335 "../find.c"
    687   puts(_("%s: unknown vendor extension option -- %s\n"));
    688 #line 159 "../enum.c"
    689   puts(_("  or an integer from %d through %d\n"));
    690 #line 169 "../enum.c"
    691   puts(_("  or an integer from %d through %d\n"));
    692 #line 747 "../usage.c"
    693   puts(_("%s error:  invalid option descriptor for %s\n"));
    694 #line 1081 "../usage.c"
    695   puts(_("%s error:  invalid option descriptor for %s\n"));
    696 #line 385 "../find.c"
    697   puts(_("%s: invalid option name: %s\n"));
    698 #line 527 "../find.c"
    699   puts(_("%s: The '%s' option requires an argument.\n"));
    700 #line 156 "../autoopts.c"
    701   puts(_("(AutoOpts bug):  Equivalenced option '%s' was equivalenced to both\n"
    702        "\t'%s' and '%s'."));
    703 #line 94 "../check.c"
    704   puts(_("%s error:  The %s option is required\n"));
    705 #line 632 "../find.c"
    706   puts(_("%s: The '%s' option cannot have an argument.\n"));
    707 #line 151 "../check.c"
    708   puts(_("%s: Command line arguments are not allowed.\n"));
    709 #line 535 "../save.c"
    710   puts(_("error %d (%s) creating %s\n"));
    711 #line 234 "../enum.c"
    712   puts(_("%s error:  '%s' does not match any %s keywords.\n"));
    713 #line 93 "../reset.c"
    714   puts(_("%s error: The '%s' option requires an argument.\n"));
    715 #line 184 "../save.c"
    716   puts(_("error %d (%s) stat-ing %s\n"));
    717 #line 238 "../save.c"
    718   puts(_("error %d (%s) stat-ing %s\n"));
    719 #line 143 "../restore.c"
    720   puts(_("%s error: no saved option state\n"));
    721 #line 231 "../autoopts.c"
    722   puts(_("'%s' is not a command line option.\n"));
    723 #line 111 "../time.c"
    724   puts(_("%s error:  '%s' is not a recognizable date/time.\n"));
    725 #line 132 "../save.c"
    726   puts(_("'%s' not defined\n"));
    727 #line 50 "../time.c"
    728   puts(_("%s error:  '%s' is not a recognizable time duration.\n"));
    729 #line 92 "../check.c"
    730   puts(_("%s error:  The %s option must appear %d times.\n"));
    731 #line 164 "../numeric.c"
    732   puts(_("%s error:  '%s' is not a recognizable number.\n"));
    733 #line 200 "../enum.c"
    734   puts(_("%s error:  %s exceeds %s keyword count\n"));
    735 #line 330 "../usage.c"
    736   puts(_("Try '%s %s' for more information.\n"));
    737 #line 45 "../alias.c"
    738   puts(_("one %s%s option allowed\n"));
    739 #line 203 "../makeshell.c"
    740   puts(_("standard output"));
    741 #line 938 "../makeshell.c"
    742   puts(_("standard output"));
    743 #line 274 "../usage.c"
    744   puts(_("standard output"));
    745 #line 415 "../usage.c"
    746   puts(_("standard output"));
    747 #line 625 "../usage.c"
    748   puts(_("standard output"));
    749 #line 175 "../version.c"
    750   puts(_("standard output"));
    751 #line 274 "../usage.c"
    752   puts(_("standard error"));
    753 #line 415 "../usage.c"
    754   puts(_("standard error"));
    755 #line 625 "../usage.c"
    756   puts(_("standard error"));
    757 #line 175 "../version.c"
    758   puts(_("standard error"));
    759 #line 203 "../makeshell.c"
    760   puts(_("write"));
    761 #line 938 "../makeshell.c"
    762   puts(_("write"));
    763 #line 273 "../usage.c"
    764   puts(_("write"));
    765 #line 414 "../usage.c"
    766   puts(_("write"));
    767 #line 624 "../usage.c"
    768   puts(_("write"));
    769 #line 174 "../version.c"
    770   puts(_("write"));
    771 #line 60 "../numeric.c"
    772   puts(_("%s error:  %s option value %ld is out of range.\n"));
    773 #line 44 "../check.c"
    774   puts(_("%s error:  %s option requires the %s option\n"));
    775 #line 131 "../save.c"
    776   puts(_("%s warning:  cannot save options - %s not regular file\n"));
    777 #line 183 "../save.c"
    778   puts(_("%s warning:  cannot save options - %s not regular file\n"));
    779 #line 237 "../save.c"
    780   puts(_("%s warning:  cannot save options - %s not regular file\n"));
    781 #line 256 "../save.c"
    782   puts(_("%s warning:  cannot save options - %s not regular file\n"));
    783 #line 534 "../save.c"
    784   puts(_("%s warning:  cannot save options - %s not regular file\n"));
    785   /* END-LIBOPTS-MESSAGES */
    786 
    787   /* USAGE-TEXT: */
    788 #line 873 "../usage.c"
    789   puts(_("\t\t\t\t- an alternate for '%s'\n"));
    790 #line 1148 "../usage.c"
    791   puts(_("Version, usage and configuration options:"));
    792 #line 924 "../usage.c"
    793   puts(_("\t\t\t\t- default option for unnamed options\n"));
    794 #line 837 "../usage.c"
    795   puts(_("\t\t\t\t- disabled as '--%s'\n"));
    796 #line 1117 "../usage.c"
    797   puts(_(" --- %-14s %s\n"));
    798 #line 1115 "../usage.c"
    799   puts(_("This option has been disabled"));
    800 #line 864 "../usage.c"
    801   puts(_("\t\t\t\t- enabled by default\n"));
    802 #line 40 "../alias.c"
    803   puts(_("%s error:  only "));
    804 #line 1194 "../usage.c"
    805   puts(_(" - examining environment variables named %s_*\n"));
    806 #line 168 "../file.c"
    807   puts(_("\t\t\t\t- file must not pre-exist\n"));
    808 #line 172 "../file.c"
    809   puts(_("\t\t\t\t- file must pre-exist\n"));
    810 #line 380 "../usage.c"
    811   puts(_("Options are specified by doubled hyphens and their name or by a single\n"
    812        "hyphen and the flag character.\n"));
    813 #line 916 "../makeshell.c"
    814   puts(_("\n"
    815        "= = = = = = = =\n\n"
    816        "This incarnation of genshell will produce\n"
    817        "a shell script to parse the options for %s:\n\n"));
    818 #line 166 "../enum.c"
    819   puts(_("  or an integer mask with any of the lower %d bits set\n"));
    820 #line 897 "../usage.c"
    821   puts(_("\t\t\t\t- is a set membership option\n"));
    822 #line 918 "../usage.c"
    823   puts(_("\t\t\t\t- must appear between %d and %d times\n"));
    824 #line 382 "../usage.c"
    825   puts(_("Options are specified by single or double hyphens and their name.\n"));
    826 #line 904 "../usage.c"
    827   puts(_("\t\t\t\t- may appear multiple times\n"));
    828 #line 891 "../usage.c"
    829   puts(_("\t\t\t\t- may not be preset\n"));
    830 #line 1309 "../usage.c"
    831   puts(_("   Arg Option-Name    Description\n"));
    832 #line 1245 "../usage.c"
    833   puts(_("  Flg Arg Option-Name    Description\n"));
    834 #line 1303 "../usage.c"
    835   puts(_("  Flg Arg Option-Name    Description\n"));
    836 #line 1304 "../usage.c"
    837   puts(_(" %3s %s"));
    838 #line 1310 "../usage.c"
    839   puts(_(" %3s %s"));
    840 #line 387 "../usage.c"
    841   puts(_("The '-#<number>' option may omit the hash char\n"));
    842 #line 383 "../usage.c"
    843   puts(_("All arguments are named options.\n"));
    844 #line 971 "../usage.c"
    845   puts(_(" - reading file %s"));
    846 #line 409 "../usage.c"
    847   puts(_("\n"
    848        "Please send bug reports to:  <%s>\n"));
    849 #line 100 "../version.c"
    850   puts(_("\n"
    851        "Please send bug reports to:  <%s>\n"));
    852 #line 129 "../version.c"
    853   puts(_("\n"
    854        "Please send bug reports to:  <%s>\n"));
    855 #line 903 "../usage.c"
    856   puts(_("\t\t\t\t- may NOT appear - preset only\n"));
    857 #line 944 "../usage.c"
    858   puts(_("\n"
    859        "The following option preset mechanisms are supported:\n"));
    860 #line 1192 "../usage.c"
    861   puts(_("\n"
    862        "The following option preset mechanisms are supported:\n"));
    863 #line 682 "../usage.c"
    864   puts(_("prohibits these options:\n"));
    865 #line 677 "../usage.c"
    866   puts(_("prohibits the option '%s'\n"));
    867 #line 81 "../numeric.c"
    868   puts(_("%s%ld to %ld"));
    869 #line 79 "../numeric.c"
    870   puts(_("%sgreater than or equal to %ld"));
    871 #line 75 "../numeric.c"
    872   puts(_("%s%ld exactly"));
    873 #line 68 "../numeric.c"
    874   puts(_("%sit must lie in one of the ranges:\n"));
    875 #line 68 "../numeric.c"
    876   puts(_("%sit must be in the range:\n"));
    877 #line 88 "../numeric.c"
    878   puts(_(", or\n"));
    879 #line 66 "../numeric.c"
    880   puts(_("%sis scalable with a suffix: k/K/m/M/g/G/t/T\n"));
    881 #line 77 "../numeric.c"
    882   puts(_("%sless than or equal to %ld"));
    883 #line 390 "../usage.c"
    884   puts(_("Operands and options may be intermixed.  They will be reordered.\n"));
    885 #line 652 "../usage.c"
    886   puts(_("requires the option '%s'\n"));
    887 #line 655 "../usage.c"
    888   puts(_("requires these options:\n"));
    889 #line 1321 "../usage.c"
    890   puts(_("   Arg Option-Name   Req?  Description\n"));
    891 #line 1315 "../usage.c"
    892   puts(_("  Flg Arg Option-Name   Req?  Description\n"));
    893 #line 167 "../enum.c"
    894   puts(_("or you may use a numeric representation.  Preceding these with a '!'\n"
    895        "will clear the bits, specifying 'none' will clear all bits, and 'all'\n"
    896        "will set them all.  Multiple entries may be passed as an option\n"
    897        "argument list.\n"));
    898 #line 910 "../usage.c"
    899   puts(_("\t\t\t\t- may appear up to %d times\n"));
    900 #line 77 "../enum.c"
    901   puts(_("The valid \"%s\" option keywords are:\n"));
    902 #line 1152 "../usage.c"
    903   puts(_("The next option supports vendor supported extra options:"));
    904 #line 773 "../usage.c"
    905   puts(_("These additional options are:"));
    906   /* END-USAGE-TEXT */
    907 }
    908 #endif /* uncompilable code */
    909 #ifdef  __cplusplus
    910 }
    911 #endif
    912 /* ntpsnmpd-opts.c ends here */
    913