Home | History | Annotate | Line # | Download | only in ntpsnmpd
ntpsnmpd-opts.c revision 1.1.1.2
      1      1.1  kardel /*	$NetBSD: ntpsnmpd-opts.c,v 1.1.1.2 2012/01/31 21:27:05 kardel Exp $	*/
      2      1.1  kardel 
      3      1.1  kardel /*
      4      1.1  kardel  *  EDIT THIS FILE WITH CAUTION  (ntpsnmpd-opts.c)
      5      1.1  kardel  *
      6  1.1.1.2  kardel  *  It has been AutoGen-ed  December 24, 2011 at 06:34:36 PM by AutoGen 5.12
      7      1.1  kardel  *  From the definitions    ntpsnmpd-opts.def
      8      1.1  kardel  *  and the template file   options
      9      1.1  kardel  *
     10  1.1.1.2  kardel  * Generated from AutoOpts 35:0:10 templates.
     11      1.1  kardel  *
     12  1.1.1.2  kardel  *  AutoOpts is a copyrighted work.  This source file is not encumbered
     13  1.1.1.2  kardel  *  by AutoOpts licensing, but is provided under the licensing terms chosen
     14  1.1.1.2  kardel  *  by the ntpsnmpd author or copyright holder.  AutoOpts is
     15  1.1.1.2  kardel  *  licensed under the terms of the LGPL.  The redistributable library
     16  1.1.1.2  kardel  *  (``libopts'') is licensed under the terms of either the LGPL or, at the
     17  1.1.1.2  kardel  *  users discretion, the BSD license.  See the AutoOpts and/or libopts sources
     18  1.1.1.2  kardel  *  for details.
     19      1.1  kardel  *
     20  1.1.1.2  kardel  * This source file is copyrighted and licensed under the following terms:
     21      1.1  kardel  *
     22  1.1.1.2  kardel  *  see html/copyright.html
     23  1.1.1.2  kardel  *
     24      1.1  kardel  */
     25      1.1  kardel 
     26      1.1  kardel #include <sys/types.h>
     27  1.1.1.2  kardel 
     28      1.1  kardel #include <limits.h>
     29      1.1  kardel #include <stdio.h>
     30      1.1  kardel #include <stdlib.h>
     31      1.1  kardel 
     32      1.1  kardel #define OPTION_CODE_COMPILE 1
     33      1.1  kardel #include "ntpsnmpd-opts.h"
     34      1.1  kardel 
     35      1.1  kardel #ifdef  __cplusplus
     36      1.1  kardel extern "C" {
     37      1.1  kardel #endif
     38  1.1.1.2  kardel extern FILE * option_usage_fp;
     39      1.1  kardel 
     40      1.1  kardel /* TRANSLATORS: choose the translation for option names wisely because you
     41      1.1  kardel                 cannot ever change your mind. */
     42  1.1.1.2  kardel static char const zCopyright[42] =
     43  1.1.1.2  kardel "ntpsnmpd 4.2.6p5\n\
     44  1.1.1.2  kardel see html/copyright.html\n";
     45  1.1.1.2  kardel static char const zLicenseDescrip[25] =
     46  1.1.1.2  kardel "see html/copyright.html\n";
     47      1.1  kardel 
     48      1.1  kardel extern tUsageProc optionUsage;
     49      1.1  kardel 
     50      1.1  kardel #ifndef NULL
     51      1.1  kardel #  define NULL 0
     52      1.1  kardel #endif
     53      1.1  kardel 
     54      1.1  kardel /*
     55      1.1  kardel  *  Nofork option description:
     56      1.1  kardel  */
     57  1.1.1.2  kardel static char const zNoforkText[] =
     58      1.1  kardel         "Do not fork";
     59  1.1.1.2  kardel static char const zNofork_NAME[]             = "NOFORK";
     60  1.1.1.2  kardel static char const zNofork_Name[]             = "nofork";
     61      1.1  kardel #define NOFORK_FLAGS       (OPTST_DISABLED)
     62      1.1  kardel 
     63      1.1  kardel /*
     64      1.1  kardel  *  Syslog option description:
     65      1.1  kardel  */
     66  1.1.1.2  kardel static char const zSyslogText[] =
     67      1.1  kardel         "Log to syslog()";
     68  1.1.1.2  kardel static char const zSyslog_NAME[]             = "SYSLOG";
     69  1.1.1.2  kardel static char const zSyslog_Name[]             = "syslog";
     70      1.1  kardel #define SYSLOG_FLAGS       (OPTST_DISABLED)
     71      1.1  kardel 
     72      1.1  kardel /*
     73  1.1.1.2  kardel  *  Agentxsocket option description:
     74  1.1.1.2  kardel  */
     75  1.1.1.2  kardel static char const zAgentxsocketText[] =
     76  1.1.1.2  kardel         "The socket address ntpsnmpd uses to connect to net-snmpd";
     77  1.1.1.2  kardel static char const zAgentxsocket_NAME[]       = "AGENTXSOCKET";
     78  1.1.1.2  kardel static char const zAgentxsocket_Name[]       = "agentxsocket";
     79  1.1.1.2  kardel static char const zAgentxsocketDefaultArg[]    = "unix:/var/agentx/master";
     80  1.1.1.2  kardel #define AGENTXSOCKET_FLAGS       (OPTST_DISABLED \
     81  1.1.1.2  kardel         | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
     82  1.1.1.2  kardel 
     83  1.1.1.2  kardel /*
     84      1.1  kardel  *  Help/More_Help/Version option descriptions:
     85      1.1  kardel  */
     86  1.1.1.2  kardel static char const zHelpText[]          = "Display extended usage information and exit";
     87  1.1.1.2  kardel static char const zHelp_Name[]         = "help";
     88      1.1  kardel #ifdef HAVE_WORKING_FORK
     89      1.1  kardel #define OPTST_MORE_HELP_FLAGS   (OPTST_IMM | OPTST_NO_INIT)
     90  1.1.1.2  kardel static char const zMore_Help_Name[]    = "more-help";
     91  1.1.1.2  kardel static char const zMore_HelpText[]     = "Extended usage information passed thru pager";
     92      1.1  kardel #else
     93      1.1  kardel #define OPTST_MORE_HELP_FLAGS   (OPTST_OMITTED | OPTST_NO_INIT)
     94      1.1  kardel #define zMore_Help_Name   NULL
     95      1.1  kardel #define zMore_HelpText    NULL
     96      1.1  kardel #endif
     97      1.1  kardel #ifdef NO_OPTIONAL_OPT_ARGS
     98      1.1  kardel #  define OPTST_VERSION_FLAGS   OPTST_IMM | OPTST_NO_INIT
     99      1.1  kardel #else
    100      1.1  kardel #  define OPTST_VERSION_FLAGS   OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
    101      1.1  kardel                                 OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
    102      1.1  kardel #endif
    103      1.1  kardel 
    104  1.1.1.2  kardel static char const zVersionText[]       = "Output version information and exit";
    105  1.1.1.2  kardel static char const zVersion_Name[]      = "version";
    106  1.1.1.2  kardel static char const zSave_OptsText[]     = "Save the option state to a config file";
    107  1.1.1.2  kardel static char const zSave_Opts_Name[]    = "save-opts";
    108  1.1.1.2  kardel static char const zLoad_OptsText[]     = "Load options from a config file";
    109  1.1.1.2  kardel static char const zLoad_Opts_NAME[]    = "LOAD_OPTS";
    110  1.1.1.2  kardel static char const zNotLoad_Opts_Name[] = "no-load-opts";
    111  1.1.1.2  kardel static char const zNotLoad_Opts_Pfx[]  = "no";
    112      1.1  kardel #define zLoad_Opts_Name   (zNotLoad_Opts_Name + 3)
    113      1.1  kardel /*
    114      1.1  kardel  *  Declare option callback procedures
    115      1.1  kardel  */
    116      1.1  kardel #if defined(TEST_NTPSNMPD_OPTS)
    117      1.1  kardel /*
    118      1.1  kardel  *  Under test, omit argument processing, or call optionStackArg,
    119      1.1  kardel  *  if multiple copies are allowed.
    120      1.1  kardel  */
    121      1.1  kardel static tOptProc
    122      1.1  kardel     doUsageOpt;
    123      1.1  kardel 
    124      1.1  kardel #else /* NOT defined TEST_NTPSNMPD_OPTS */
    125      1.1  kardel /*
    126      1.1  kardel  *  When not under test, there are different procs to use
    127      1.1  kardel  */
    128      1.1  kardel extern tOptProc
    129  1.1.1.2  kardel     optionBooleanVal,    optionNestedVal,     optionNumericVal,
    130  1.1.1.2  kardel     optionPagedUsage,    optionPrintVersion,  optionResetOpt,
    131  1.1.1.2  kardel     optionStackArg,      optionTimeDate,      optionTimeVal,
    132  1.1.1.2  kardel     optionUnstackArg,    optionVersionStderr;
    133      1.1  kardel static tOptProc
    134      1.1  kardel     doUsageOpt;
    135      1.1  kardel #endif /* defined(TEST_NTPSNMPD_OPTS) */
    136      1.1  kardel #ifdef TEST_NTPSNMPD_OPTS
    137      1.1  kardel # define DOVERPROC optionVersionStderr
    138      1.1  kardel #else
    139      1.1  kardel # define DOVERPROC optionPrintVersion
    140      1.1  kardel #endif /* TEST_NTPSNMPD_OPTS */
    141      1.1  kardel 
    142      1.1  kardel /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    143      1.1  kardel  *
    144      1.1  kardel  *  Define the Ntpsnmpd Option Descriptions.
    145      1.1  kardel  */
    146  1.1.1.2  kardel static tOptDesc optDesc[OPTION_CT] = {
    147      1.1  kardel   {  /* entry idx, value */ 0, VALUE_OPT_NOFORK,
    148      1.1  kardel      /* equiv idx, value */ 0, VALUE_OPT_NOFORK,
    149      1.1  kardel      /* equivalenced to  */ NO_EQUIVALENT,
    150      1.1  kardel      /* min, max, act ct */ 0, 1, 0,
    151      1.1  kardel      /* opt state flags  */ NOFORK_FLAGS, 0,
    152      1.1  kardel      /* last opt argumnt */ { NULL },
    153      1.1  kardel      /* arg list/cookie  */ NULL,
    154      1.1  kardel      /* must/cannot opts */ NULL, NULL,
    155      1.1  kardel      /* option proc      */ NULL,
    156      1.1  kardel      /* desc, NAME, name */ zNoforkText, zNofork_NAME, zNofork_Name,
    157      1.1  kardel      /* disablement strs */ NULL, NULL },
    158      1.1  kardel 
    159      1.1  kardel   {  /* entry idx, value */ 1, VALUE_OPT_SYSLOG,
    160      1.1  kardel      /* equiv idx, value */ 1, VALUE_OPT_SYSLOG,
    161      1.1  kardel      /* equivalenced to  */ NO_EQUIVALENT,
    162      1.1  kardel      /* min, max, act ct */ 0, 1, 0,
    163      1.1  kardel      /* opt state flags  */ SYSLOG_FLAGS, 0,
    164      1.1  kardel      /* last opt argumnt */ { NULL },
    165      1.1  kardel      /* arg list/cookie  */ NULL,
    166      1.1  kardel      /* must/cannot opts */ NULL, NULL,
    167      1.1  kardel      /* option proc      */ NULL,
    168      1.1  kardel      /* desc, NAME, name */ zSyslogText, zSyslog_NAME, zSyslog_Name,
    169      1.1  kardel      /* disablement strs */ NULL, NULL },
    170      1.1  kardel 
    171  1.1.1.2  kardel   {  /* entry idx, value */ 2, VALUE_OPT_AGENTXSOCKET,
    172  1.1.1.2  kardel      /* equiv idx, value */ 2, VALUE_OPT_AGENTXSOCKET,
    173  1.1.1.2  kardel      /* equivalenced to  */ NO_EQUIVALENT,
    174  1.1.1.2  kardel      /* min, max, act ct */ 0, 1, 0,
    175  1.1.1.2  kardel      /* opt state flags  */ AGENTXSOCKET_FLAGS, 0,
    176  1.1.1.2  kardel      /* last opt argumnt */ { zAgentxsocketDefaultArg },
    177  1.1.1.2  kardel      /* arg list/cookie  */ NULL,
    178  1.1.1.2  kardel      /* must/cannot opts */ NULL, NULL,
    179  1.1.1.2  kardel      /* option proc      */ NULL,
    180  1.1.1.2  kardel      /* desc, NAME, name */ zAgentxsocketText, zAgentxsocket_NAME, zAgentxsocket_Name,
    181  1.1.1.2  kardel      /* disablement strs */ NULL, NULL },
    182  1.1.1.2  kardel 
    183      1.1  kardel   {  /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
    184      1.1  kardel      /* equiv idx value  */ NO_EQUIVALENT, 0,
    185      1.1  kardel      /* equivalenced to  */ NO_EQUIVALENT,
    186      1.1  kardel      /* min, max, act ct */ 0, 1, 0,
    187      1.1  kardel      /* opt state flags  */ OPTST_VERSION_FLAGS, 0,
    188      1.1  kardel      /* last opt argumnt */ { NULL },
    189      1.1  kardel      /* arg list/cookie  */ NULL,
    190      1.1  kardel      /* must/cannot opts */ NULL, NULL,
    191      1.1  kardel      /* option proc      */ DOVERPROC,
    192      1.1  kardel      /* desc, NAME, name */ zVersionText, NULL, zVersion_Name,
    193      1.1  kardel      /* disablement strs */ NULL, NULL },
    194      1.1  kardel 
    195      1.1  kardel 
    196      1.1  kardel 
    197      1.1  kardel   {  /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
    198      1.1  kardel      /* equiv idx value  */ NO_EQUIVALENT, 0,
    199      1.1  kardel      /* equivalenced to  */ NO_EQUIVALENT,
    200      1.1  kardel      /* min, max, act ct */ 0, 1, 0,
    201      1.1  kardel      /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
    202      1.1  kardel      /* last opt argumnt */ { NULL },
    203      1.1  kardel      /* arg list/cookie  */ NULL,
    204      1.1  kardel      /* must/cannot opts */ NULL, NULL,
    205      1.1  kardel      /* option proc      */ doUsageOpt,
    206      1.1  kardel      /* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
    207      1.1  kardel      /* disablement strs */ NULL, NULL },
    208      1.1  kardel 
    209      1.1  kardel   {  /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
    210      1.1  kardel      /* equiv idx value  */ NO_EQUIVALENT, 0,
    211      1.1  kardel      /* equivalenced to  */ NO_EQUIVALENT,
    212      1.1  kardel      /* min, max, act ct */ 0, 1, 0,
    213      1.1  kardel      /* opt state flags  */ OPTST_MORE_HELP_FLAGS, 0,
    214      1.1  kardel      /* last opt argumnt */ { NULL },
    215      1.1  kardel      /* arg list/cookie  */ NULL,
    216      1.1  kardel      /* must/cannot opts */ NULL,  NULL,
    217      1.1  kardel      /* option proc      */ optionPagedUsage,
    218      1.1  kardel      /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
    219      1.1  kardel      /* disablement strs */ NULL, NULL },
    220      1.1  kardel 
    221      1.1  kardel   {  /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS,
    222      1.1  kardel      /* equiv idx value  */ NO_EQUIVALENT, 0,
    223      1.1  kardel      /* equivalenced to  */ NO_EQUIVALENT,
    224      1.1  kardel      /* min, max, act ct */ 0, 1, 0,
    225      1.1  kardel      /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
    226      1.1  kardel                           | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0,
    227      1.1  kardel      /* last opt argumnt */ { NULL },
    228      1.1  kardel      /* arg list/cookie  */ NULL,
    229      1.1  kardel      /* must/cannot opts */ NULL,  NULL,
    230      1.1  kardel      /* option proc      */ NULL,
    231      1.1  kardel      /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name,
    232      1.1  kardel      /* disablement strs */ NULL, NULL },
    233      1.1  kardel 
    234      1.1  kardel   {  /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS,
    235      1.1  kardel      /* equiv idx value  */ NO_EQUIVALENT, 0,
    236      1.1  kardel      /* equivalenced to  */ NO_EQUIVALENT,
    237      1.1  kardel      /* min, max, act ct */ 0, NOLIMIT, 0,
    238      1.1  kardel      /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
    239      1.1  kardel 			  | OPTST_DISABLE_IMM, 0,
    240      1.1  kardel      /* last opt argumnt */ { NULL },
    241      1.1  kardel      /* arg list/cookie  */ NULL,
    242      1.1  kardel      /* must/cannot opts */ NULL, NULL,
    243      1.1  kardel      /* option proc      */ optionLoadOpt,
    244      1.1  kardel      /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name,
    245      1.1  kardel      /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx }
    246      1.1  kardel };
    247      1.1  kardel 
    248      1.1  kardel /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    249      1.1  kardel  *
    250      1.1  kardel  *  Define the Ntpsnmpd Option Environment
    251      1.1  kardel  */
    252  1.1.1.2  kardel static char const zPROGNAME[9] = "NTPSNMPD";
    253  1.1.1.2  kardel static char const zUsageTitle[103] =
    254  1.1.1.2  kardel "ntpsnmpd - NTP SNMP MIB agent - Ver. 4.2.6p5\n\
    255  1.1.1.2  kardel USAGE:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n";
    256  1.1.1.2  kardel static char const zRcName[7] = ".ntprc";
    257  1.1.1.2  kardel static char const * const apzHomeList[3] = {
    258  1.1.1.2  kardel     "$HOME",
    259  1.1.1.2  kardel     ".",
    260  1.1.1.2  kardel     NULL };
    261      1.1  kardel 
    262  1.1.1.2  kardel static char const zBugsAddr[34]    = "http://bugs.ntp.org, bugs (at) ntp.org";
    263      1.1  kardel #define zExplain NULL
    264      1.1  kardel #define zDetail         NULL
    265  1.1.1.2  kardel static char const zFullVersion[] = NTPSNMPD_FULL_VERSION;
    266  1.1.1.2  kardel /* extracted from optcode.tlib near line 515 */
    267      1.1  kardel 
    268      1.1  kardel #if defined(ENABLE_NLS)
    269      1.1  kardel # define OPTPROC_BASE OPTPROC_TRANSLATE
    270      1.1  kardel   static tOptionXlateProc translate_option_strings;
    271      1.1  kardel #else
    272      1.1  kardel # define OPTPROC_BASE OPTPROC_NONE
    273      1.1  kardel # define translate_option_strings NULL
    274      1.1  kardel #endif /* ENABLE_NLS */
    275      1.1  kardel 
    276      1.1  kardel 
    277      1.1  kardel #define ntpsnmpd_full_usage NULL
    278      1.1  kardel #define ntpsnmpd_short_usage NULL
    279  1.1.1.2  kardel #ifndef  PKGDATADIR
    280  1.1.1.2  kardel # define PKGDATADIR ""
    281  1.1.1.2  kardel #endif
    282  1.1.1.2  kardel 
    283  1.1.1.2  kardel #ifndef  WITH_PACKAGER
    284  1.1.1.2  kardel # define ntpsnmpd_packager_info NULL
    285  1.1.1.2  kardel #else
    286  1.1.1.2  kardel static char const ntpsnmpd_packager_info[] =
    287  1.1.1.2  kardel     "Packaged by " WITH_PACKAGER
    288  1.1.1.2  kardel 
    289  1.1.1.2  kardel # ifdef WITH_PACKAGER_VERSION
    290  1.1.1.2  kardel         " ("WITH_PACKAGER_VERSION")"
    291  1.1.1.2  kardel # endif
    292  1.1.1.2  kardel 
    293  1.1.1.2  kardel # ifdef WITH_PACKAGER_BUG_REPORTS
    294  1.1.1.2  kardel     "\nReport ntpsnmpd bugs to " WITH_PACKAGER_BUG_REPORTS
    295  1.1.1.2  kardel # endif
    296  1.1.1.2  kardel     "\n";
    297  1.1.1.2  kardel #endif
    298  1.1.1.2  kardel 
    299      1.1  kardel tOptions ntpsnmpdOptions = {
    300      1.1  kardel     OPTIONS_STRUCT_VERSION,
    301      1.1  kardel     0, NULL,                    /* original argc + argv    */
    302      1.1  kardel     ( OPTPROC_BASE
    303      1.1  kardel     + OPTPROC_ERRSTOP
    304      1.1  kardel     + OPTPROC_SHORTOPT
    305      1.1  kardel     + OPTPROC_LONGOPT
    306      1.1  kardel     + OPTPROC_NO_REQ_OPT
    307      1.1  kardel     + OPTPROC_ENVIRON
    308  1.1.1.2  kardel     + OPTPROC_NO_ARGS
    309  1.1.1.2  kardel     + OPTPROC_MISUSE ),
    310      1.1  kardel     0, NULL,                    /* current option index, current option */
    311      1.1  kardel     NULL,         NULL,         zPROGNAME,
    312  1.1.1.2  kardel     zRcName,      zCopyright,   zLicenseDescrip,
    313      1.1  kardel     zFullVersion, apzHomeList,  zUsageTitle,
    314      1.1  kardel     zExplain,     zDetail,      optDesc,
    315      1.1  kardel     zBugsAddr,                  /* address to send bugs to */
    316      1.1  kardel     NULL, NULL,                 /* extensions/saved state  */
    317  1.1.1.2  kardel     optionUsage, /* usage procedure */
    318      1.1  kardel     translate_option_strings,   /* translation procedure */
    319      1.1  kardel     /*
    320      1.1  kardel      *  Indexes to special options
    321      1.1  kardel      */
    322      1.1  kardel     { INDEX_OPT_MORE_HELP, /* more-help option index */
    323      1.1  kardel       INDEX_OPT_SAVE_OPTS, /* save option index */
    324      1.1  kardel       NO_EQUIVALENT, /* '-#' option index */
    325      1.1  kardel       NO_EQUIVALENT /* index of default opt */
    326      1.1  kardel     },
    327  1.1.1.2  kardel     8 /* full option count */, 3 /* user option count */,
    328      1.1  kardel     ntpsnmpd_full_usage, ntpsnmpd_short_usage,
    329  1.1.1.2  kardel     NULL, NULL,
    330  1.1.1.2  kardel     PKGDATADIR, ntpsnmpd_packager_info
    331      1.1  kardel };
    332      1.1  kardel 
    333      1.1  kardel /*
    334      1.1  kardel  *  Create the static procedure(s) declared above.
    335      1.1  kardel  */
    336      1.1  kardel static void
    337  1.1.1.2  kardel doUsageOpt(tOptions * pOptions, tOptDesc * pOptDesc)
    338      1.1  kardel {
    339      1.1  kardel     (void)pOptions;
    340  1.1.1.2  kardel     USAGE(NTPSNMPD_EXIT_SUCCESS);
    341      1.1  kardel }
    342  1.1.1.2  kardel /* extracted from optmain.tlib near line 128 */
    343      1.1  kardel 
    344      1.1  kardel #if defined(TEST_NTPSNMPD_OPTS) /* TEST MAIN PROCEDURE: */
    345      1.1  kardel 
    346  1.1.1.2  kardel extern void optionPutShell(tOptions*);
    347      1.1  kardel 
    348      1.1  kardel int
    349  1.1.1.2  kardel main(int argc, char ** argv)
    350      1.1  kardel {
    351  1.1.1.2  kardel     int res = NTPSNMPD_EXIT_SUCCESS;
    352  1.1.1.2  kardel     (void)optionProcess(&ntpsnmpdOptions, argc, argv);
    353  1.1.1.2  kardel     optionPutShell(&ntpsnmpdOptions);
    354  1.1.1.2  kardel     res = ferror(stdout);
    355  1.1.1.2  kardel     if (res != 0)
    356  1.1.1.2  kardel         fputs("output error writing to stdout\n", stderr);
    357      1.1  kardel     return res;
    358      1.1  kardel }
    359      1.1  kardel #endif  /* defined TEST_NTPSNMPD_OPTS */
    360  1.1.1.2  kardel /* extracted from optcode.tlib near line 666 */
    361      1.1  kardel 
    362      1.1  kardel #if ENABLE_NLS
    363      1.1  kardel #include <stdio.h>
    364      1.1  kardel #include <stdlib.h>
    365      1.1  kardel #include <string.h>
    366      1.1  kardel #include <unistd.h>
    367      1.1  kardel #include <autoopts/usage-txt.h>
    368      1.1  kardel 
    369  1.1.1.2  kardel static char* AO_gettext(char const* pz);
    370      1.1  kardel static void  coerce_it(void** s);
    371      1.1  kardel 
    372      1.1  kardel static char*
    373  1.1.1.2  kardel AO_gettext(char const* pz)
    374      1.1  kardel {
    375      1.1  kardel     char* pzRes;
    376      1.1  kardel     if (pz == NULL)
    377      1.1  kardel         return NULL;
    378      1.1  kardel     pzRes = _(pz);
    379      1.1  kardel     if (pzRes == pz)
    380      1.1  kardel         return pzRes;
    381  1.1.1.2  kardel     pzRes = strdup(pzRes);
    382      1.1  kardel     if (pzRes == NULL) {
    383  1.1.1.2  kardel         fputs(_("No memory for duping translated strings\n"), stderr);
    384  1.1.1.2  kardel         exit(NTPSNMPD_EXIT_FAILURE);
    385      1.1  kardel     }
    386      1.1  kardel     return pzRes;
    387      1.1  kardel }
    388      1.1  kardel 
    389  1.1.1.2  kardel static void coerce_it(void** s) { *s = AO_gettext(*s);
    390  1.1.1.2  kardel }
    391      1.1  kardel 
    392      1.1  kardel /*
    393      1.1  kardel  *  This invokes the translation code (e.g. gettext(3)).
    394      1.1  kardel  */
    395      1.1  kardel static void
    396  1.1.1.2  kardel translate_option_strings(void)
    397      1.1  kardel {
    398  1.1.1.2  kardel     tOptions * const pOpt = &ntpsnmpdOptions;
    399  1.1.1.2  kardel 
    400      1.1  kardel     /*
    401      1.1  kardel      *  Guard against re-translation.  It won't work.  The strings will have
    402      1.1  kardel      *  been changed by the first pass through this code.  One shot only.
    403      1.1  kardel      */
    404      1.1  kardel     if (option_usage_text.field_ct != 0) {
    405      1.1  kardel         /*
    406      1.1  kardel          *  Do the translations.  The first pointer follows the field count
    407      1.1  kardel          *  field.  The field count field is the size of a pointer.
    408      1.1  kardel          */
    409  1.1.1.2  kardel         tOptDesc * pOD = pOpt->pOptDesc;
    410  1.1.1.2  kardel         char **    ppz = (char**)(void*)&(option_usage_text);
    411  1.1.1.2  kardel         int        ix  = option_usage_text.field_ct;
    412      1.1  kardel 
    413      1.1  kardel         do {
    414      1.1  kardel             ppz++;
    415      1.1  kardel             *ppz = AO_gettext(*ppz);
    416      1.1  kardel         } while (--ix > 0);
    417      1.1  kardel 
    418  1.1.1.2  kardel         coerce_it((void*)&(pOpt->pzCopyright));
    419  1.1.1.2  kardel         coerce_it((void*)&(pOpt->pzCopyNotice));
    420  1.1.1.2  kardel         coerce_it((void*)&(pOpt->pzFullVersion));
    421  1.1.1.2  kardel         coerce_it((void*)&(pOpt->pzUsageTitle));
    422  1.1.1.2  kardel         coerce_it((void*)&(pOpt->pzExplain));
    423  1.1.1.2  kardel         coerce_it((void*)&(pOpt->pzDetail));
    424  1.1.1.2  kardel         coerce_it((void*)&(pOpt->pzPackager));
    425      1.1  kardel         option_usage_text.field_ct = 0;
    426      1.1  kardel 
    427  1.1.1.2  kardel         for (ix = pOpt->optCt; ix > 0; ix--, pOD++)
    428      1.1  kardel             coerce_it((void*)&(pOD->pzText));
    429      1.1  kardel     }
    430      1.1  kardel 
    431  1.1.1.2  kardel     if ((pOpt->fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) {
    432  1.1.1.2  kardel         tOptDesc * pOD = pOpt->pOptDesc;
    433  1.1.1.2  kardel         int        ix;
    434      1.1  kardel 
    435  1.1.1.2  kardel         for (ix = pOpt->optCt; ix > 0; ix--, pOD++) {
    436      1.1  kardel             coerce_it((void*)&(pOD->pz_Name));
    437      1.1  kardel             coerce_it((void*)&(pOD->pz_DisableName));
    438      1.1  kardel             coerce_it((void*)&(pOD->pz_DisablePfx));
    439      1.1  kardel         }
    440      1.1  kardel         /* prevent re-translation */
    441      1.1  kardel         ntpsnmpdOptions.fOptSet |= OPTPROC_NXLAT_OPT_CFG | OPTPROC_NXLAT_OPT;
    442      1.1  kardel     }
    443      1.1  kardel }
    444      1.1  kardel 
    445      1.1  kardel #endif /* ENABLE_NLS */
    446      1.1  kardel 
    447      1.1  kardel #ifdef  __cplusplus
    448      1.1  kardel }
    449      1.1  kardel #endif
    450      1.1  kardel /* ntpsnmpd-opts.c ends here */
    451