Annotation of embedaddon/ntp/ntpdc/ntpdc-opts.c, revision 1.1.1.1

1.1       misho       1: /*  
                      2:  *  EDIT THIS FILE WITH CAUTION  (ntpdc-opts.c)
                      3:  *  
                      4:  *  It has been AutoGen-ed  December 24, 2011 at 06:34:16 PM by AutoGen 5.12
                      5:  *  From the definitions    ntpdc-opts.def
                      6:  *  and the template file   options
                      7:  *
                      8:  * Generated from AutoOpts 35:0:10 templates.
                      9:  *
                     10:  *  AutoOpts is a copyrighted work.  This source file is not encumbered
                     11:  *  by AutoOpts licensing, but is provided under the licensing terms chosen
                     12:  *  by the ntpdc author or copyright holder.  AutoOpts is
                     13:  *  licensed under the terms of the LGPL.  The redistributable library
                     14:  *  (``libopts'') is licensed under the terms of either the LGPL or, at the
                     15:  *  users discretion, the BSD license.  See the AutoOpts and/or libopts sources
                     16:  *  for details.
                     17:  *
                     18:  * This source file is copyrighted and licensed under the following terms:
                     19:  *
                     20:  *  see html/copyright.html
                     21:  *  
                     22:  */
                     23: 
                     24: #include <sys/types.h>
                     25: 
                     26: #include <limits.h>
                     27: #include <stdio.h>
                     28: #include <stdlib.h>
                     29: 
                     30: #define OPTION_CODE_COMPILE 1
                     31: #include "ntpdc-opts.h"
                     32: 
                     33: #ifdef  __cplusplus
                     34: extern "C" {
                     35: #endif
                     36: extern FILE * option_usage_fp;
                     37: 
                     38: /* TRANSLATORS: choose the translation for option names wisely because you
                     39:                 cannot ever change your mind. */
                     40: static char const zCopyright[39] =
                     41: "ntpdc 4.2.6p5\n\
                     42: see html/copyright.html\n";
                     43: static char const zLicenseDescrip[25] =
                     44: "see html/copyright.html\n";
                     45: 
                     46: extern tUsageProc optionUsage;
                     47: 
                     48: /*
                     49:  *  global included definitions
                     50:  */
                     51: #ifdef __windows
                     52:   extern int atoi(const char*);
                     53: #else
                     54: # include <stdlib.h>
                     55: #endif
                     56: 
                     57: #ifndef NULL
                     58: #  define NULL 0
                     59: #endif
                     60: 
                     61: /*
                     62:  *  Ipv4 option description with
                     63:  *  "Must also have options" and "Incompatible options":
                     64:  */
                     65: static char const zIpv4Text[] =
                     66:         "Force IPv4 DNS name resolution";
                     67: static char const zIpv4_NAME[]               = "IPV4";
                     68: static char const zIpv4_Name[]               = "ipv4";
                     69: static const int
                     70:     aIpv4CantList[] = {
                     71:     INDEX_OPT_IPV6, NO_EQUIVALENT };
                     72: #define IPV4_FLAGS       (OPTST_DISABLED)
                     73: 
                     74: /*
                     75:  *  Ipv6 option description with
                     76:  *  "Must also have options" and "Incompatible options":
                     77:  */
                     78: static char const zIpv6Text[] =
                     79:         "Force IPv6 DNS name resolution";
                     80: static char const zIpv6_NAME[]               = "IPV6";
                     81: static char const zIpv6_Name[]               = "ipv6";
                     82: static const int
                     83:     aIpv6CantList[] = {
                     84:     INDEX_OPT_IPV4, NO_EQUIVALENT };
                     85: #define IPV6_FLAGS       (OPTST_DISABLED)
                     86: 
                     87: /*
                     88:  *  Command option description:
                     89:  */
                     90: static char const zCommandText[] =
                     91:         "run a command and exit";
                     92: static char const zCommand_NAME[]            = "COMMAND";
                     93: static char const zCommand_Name[]            = "command";
                     94: #define COMMAND_FLAGS       (OPTST_DISABLED | OPTST_STACKED \
                     95:         | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
                     96: 
                     97: /*
                     98:  *  Listpeers option description with
                     99:  *  "Must also have options" and "Incompatible options":
                    100:  */
                    101: static char const zListpeersText[] =
                    102:         "Print a list of the peers";
                    103: static char const zListpeers_NAME[]          = "LISTPEERS";
                    104: static char const zListpeers_Name[]          = "listpeers";
                    105: static const int
                    106:     aListpeersCantList[] = {
                    107:     INDEX_OPT_COMMAND, NO_EQUIVALENT };
                    108: #define LISTPEERS_FLAGS       (OPTST_DISABLED)
                    109: 
                    110: /*
                    111:  *  Peers option description with
                    112:  *  "Must also have options" and "Incompatible options":
                    113:  */
                    114: static char const zPeersText[] =
                    115:         "Print a list of the peers";
                    116: static char const zPeers_NAME[]              = "PEERS";
                    117: static char const zPeers_Name[]              = "peers";
                    118: static const int
                    119:     aPeersCantList[] = {
                    120:     INDEX_OPT_COMMAND, NO_EQUIVALENT };
                    121: #define PEERS_FLAGS       (OPTST_DISABLED)
                    122: 
                    123: /*
                    124:  *  Showpeers option description with
                    125:  *  "Must also have options" and "Incompatible options":
                    126:  */
                    127: static char const zShowpeersText[] =
                    128:         "Show a list of the peers";
                    129: static char const zShowpeers_NAME[]          = "SHOWPEERS";
                    130: static char const zShowpeers_Name[]          = "showpeers";
                    131: static const int
                    132:     aShowpeersCantList[] = {
                    133:     INDEX_OPT_COMMAND, NO_EQUIVALENT };
                    134: #define SHOWPEERS_FLAGS       (OPTST_DISABLED)
                    135: 
                    136: /*
                    137:  *  Interactive option description with
                    138:  *  "Must also have options" and "Incompatible options":
                    139:  */
                    140: static char const zInteractiveText[] =
                    141:         "Force ntpq to operate in interactive mode";
                    142: static char const zInteractive_NAME[]        = "INTERACTIVE";
                    143: static char const zInteractive_Name[]        = "interactive";
                    144: static const int
                    145:     aInteractiveCantList[] = {
                    146:     INDEX_OPT_COMMAND,
                    147:     INDEX_OPT_LISTPEERS,
                    148:     INDEX_OPT_PEERS,
                    149:     INDEX_OPT_SHOWPEERS, NO_EQUIVALENT };
                    150: #define INTERACTIVE_FLAGS       (OPTST_DISABLED)
                    151: 
                    152: /*
                    153:  *  Debug_Level option description:
                    154:  */
                    155: static char const zDebug_LevelText[] =
                    156:         "Increase output debug message level";
                    157: static char const zDebug_Level_NAME[]        = "DEBUG_LEVEL";
                    158: static char const zDebug_Level_Name[]        = "debug-level";
                    159: #define DEBUG_LEVEL_FLAGS       (OPTST_DISABLED)
                    160: 
                    161: /*
                    162:  *  Set_Debug_Level option description:
                    163:  */
                    164: static char const zSet_Debug_LevelText[] =
                    165:         "Set the output debug message level";
                    166: static char const zSet_Debug_Level_NAME[]    = "SET_DEBUG_LEVEL";
                    167: static char const zSet_Debug_Level_Name[]    = "set-debug-level";
                    168: #define SET_DEBUG_LEVEL_FLAGS       (OPTST_DISABLED \
                    169:         | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
                    170: 
                    171: /*
                    172:  *  Numeric option description:
                    173:  */
                    174: static char const zNumericText[] =
                    175:         "numeric host addresses";
                    176: static char const zNumeric_NAME[]            = "NUMERIC";
                    177: static char const zNumeric_Name[]            = "numeric";
                    178: #define NUMERIC_FLAGS       (OPTST_DISABLED)
                    179: 
                    180: /*
                    181:  *  Help/More_Help/Version option descriptions:
                    182:  */
                    183: static char const zHelpText[]          = "Display extended usage information and exit";
                    184: static char const zHelp_Name[]         = "help";
                    185: #ifdef HAVE_WORKING_FORK
                    186: #define OPTST_MORE_HELP_FLAGS   (OPTST_IMM | OPTST_NO_INIT)
                    187: static char const zMore_Help_Name[]    = "more-help";
                    188: static char const zMore_HelpText[]     = "Extended usage information passed thru pager";
                    189: #else
                    190: #define OPTST_MORE_HELP_FLAGS   (OPTST_OMITTED | OPTST_NO_INIT)
                    191: #define zMore_Help_Name   NULL
                    192: #define zMore_HelpText    NULL
                    193: #endif
                    194: #ifdef NO_OPTIONAL_OPT_ARGS
                    195: #  define OPTST_VERSION_FLAGS   OPTST_IMM | OPTST_NO_INIT
                    196: #else
                    197: #  define OPTST_VERSION_FLAGS   OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
                    198:                                 OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
                    199: #endif
                    200: 
                    201: static char const zVersionText[]       = "Output version information and exit";
                    202: static char const zVersion_Name[]      = "version";
                    203: static char const zSave_OptsText[]     = "Save the option state to a config file";
                    204: static char const zSave_Opts_Name[]    = "save-opts";
                    205: static char const zLoad_OptsText[]     = "Load options from a config file";
                    206: static char const zLoad_Opts_NAME[]    = "LOAD_OPTS";
                    207: static char const zNotLoad_Opts_Name[] = "no-load-opts";
                    208: static char const zNotLoad_Opts_Pfx[]  = "no";
                    209: #define zLoad_Opts_Name   (zNotLoad_Opts_Name + 3)
                    210: /*
                    211:  *  Declare option callback procedures
                    212:  */
                    213: #if defined(TEST_NTPDC_OPTS)
                    214: /*
                    215:  *  Under test, omit argument processing, or call optionStackArg,
                    216:  *  if multiple copies are allowed.
                    217:  */
                    218: static tOptProc
                    219:     doUsageOpt;
                    220: 
                    221: /*
                    222:  *  #define map the "normal" callout procs to the test ones...
                    223:  */
                    224: #define SET_DEBUG_LEVEL_OPT_PROC optionStackArg
                    225: 
                    226: 
                    227: #else /* NOT defined TEST_NTPDC_OPTS */
                    228: /*
                    229:  *  When not under test, there are different procs to use
                    230:  */
                    231: extern tOptProc
                    232:     optionBooleanVal,    optionNestedVal,     optionNumericVal,
                    233:     optionPagedUsage,    optionPrintVersion,  optionResetOpt,
                    234:     optionStackArg,      optionTimeDate,      optionTimeVal,
                    235:     optionUnstackArg,    optionVersionStderr;
                    236: static tOptProc
                    237:     doOptSet_Debug_Level, doUsageOpt;
                    238: 
                    239: /*
                    240:  *  #define map the "normal" callout procs
                    241:  */
                    242: #define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level
                    243: 
                    244: #define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level
                    245: #endif /* defined(TEST_NTPDC_OPTS) */
                    246: #ifdef TEST_NTPDC_OPTS
                    247: # define DOVERPROC optionVersionStderr
                    248: #else
                    249: # define DOVERPROC optionPrintVersion
                    250: #endif /* TEST_NTPDC_OPTS */
                    251: 
                    252: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
                    253:  *
                    254:  *  Define the Ntpdc Option Descriptions.
                    255:  */
                    256: static tOptDesc optDesc[OPTION_CT] = {
                    257:   {  /* entry idx, value */ 0, VALUE_OPT_IPV4,
                    258:      /* equiv idx, value */ 0, VALUE_OPT_IPV4,
                    259:      /* equivalenced to  */ NO_EQUIVALENT,
                    260:      /* min, max, act ct */ 0, 1, 0,
                    261:      /* opt state flags  */ IPV4_FLAGS, 0,
                    262:      /* last opt argumnt */ { NULL },
                    263:      /* arg list/cookie  */ NULL,
                    264:      /* must/cannot opts */ NULL, aIpv4CantList,
                    265:      /* option proc      */ NULL,
                    266:      /* desc, NAME, name */ zIpv4Text, zIpv4_NAME, zIpv4_Name,
                    267:      /* disablement strs */ NULL, NULL },
                    268: 
                    269:   {  /* entry idx, value */ 1, VALUE_OPT_IPV6,
                    270:      /* equiv idx, value */ 1, VALUE_OPT_IPV6,
                    271:      /* equivalenced to  */ NO_EQUIVALENT,
                    272:      /* min, max, act ct */ 0, 1, 0,
                    273:      /* opt state flags  */ IPV6_FLAGS, 0,
                    274:      /* last opt argumnt */ { NULL },
                    275:      /* arg list/cookie  */ NULL,
                    276:      /* must/cannot opts */ NULL, aIpv6CantList,
                    277:      /* option proc      */ NULL,
                    278:      /* desc, NAME, name */ zIpv6Text, zIpv6_NAME, zIpv6_Name,
                    279:      /* disablement strs */ NULL, NULL },
                    280: 
                    281:   {  /* entry idx, value */ 2, VALUE_OPT_COMMAND,
                    282:      /* equiv idx, value */ 2, VALUE_OPT_COMMAND,
                    283:      /* equivalenced to  */ NO_EQUIVALENT,
                    284:      /* min, max, act ct */ 0, NOLIMIT, 0,
                    285:      /* opt state flags  */ COMMAND_FLAGS, 0,
                    286:      /* last opt argumnt */ { NULL },
                    287:      /* arg list/cookie  */ NULL,
                    288:      /* must/cannot opts */ NULL, NULL,
                    289:      /* option proc      */ optionStackArg,
                    290:      /* desc, NAME, name */ zCommandText, zCommand_NAME, zCommand_Name,
                    291:      /* disablement strs */ NULL, NULL },
                    292: 
                    293:   {  /* entry idx, value */ 3, VALUE_OPT_LISTPEERS,
                    294:      /* equiv idx, value */ 3, VALUE_OPT_LISTPEERS,
                    295:      /* equivalenced to  */ NO_EQUIVALENT,
                    296:      /* min, max, act ct */ 0, 1, 0,
                    297:      /* opt state flags  */ LISTPEERS_FLAGS, 0,
                    298:      /* last opt argumnt */ { NULL },
                    299:      /* arg list/cookie  */ NULL,
                    300:      /* must/cannot opts */ NULL, aListpeersCantList,
                    301:      /* option proc      */ NULL,
                    302:      /* desc, NAME, name */ zListpeersText, zListpeers_NAME, zListpeers_Name,
                    303:      /* disablement strs */ NULL, NULL },
                    304: 
                    305:   {  /* entry idx, value */ 4, VALUE_OPT_PEERS,
                    306:      /* equiv idx, value */ 4, VALUE_OPT_PEERS,
                    307:      /* equivalenced to  */ NO_EQUIVALENT,
                    308:      /* min, max, act ct */ 0, 1, 0,
                    309:      /* opt state flags  */ PEERS_FLAGS, 0,
                    310:      /* last opt argumnt */ { NULL },
                    311:      /* arg list/cookie  */ NULL,
                    312:      /* must/cannot opts */ NULL, aPeersCantList,
                    313:      /* option proc      */ NULL,
                    314:      /* desc, NAME, name */ zPeersText, zPeers_NAME, zPeers_Name,
                    315:      /* disablement strs */ NULL, NULL },
                    316: 
                    317:   {  /* entry idx, value */ 5, VALUE_OPT_SHOWPEERS,
                    318:      /* equiv idx, value */ 5, VALUE_OPT_SHOWPEERS,
                    319:      /* equivalenced to  */ NO_EQUIVALENT,
                    320:      /* min, max, act ct */ 0, 1, 0,
                    321:      /* opt state flags  */ SHOWPEERS_FLAGS, 0,
                    322:      /* last opt argumnt */ { NULL },
                    323:      /* arg list/cookie  */ NULL,
                    324:      /* must/cannot opts */ NULL, aShowpeersCantList,
                    325:      /* option proc      */ NULL,
                    326:      /* desc, NAME, name */ zShowpeersText, zShowpeers_NAME, zShowpeers_Name,
                    327:      /* disablement strs */ NULL, NULL },
                    328: 
                    329:   {  /* entry idx, value */ 6, VALUE_OPT_INTERACTIVE,
                    330:      /* equiv idx, value */ 6, VALUE_OPT_INTERACTIVE,
                    331:      /* equivalenced to  */ NO_EQUIVALENT,
                    332:      /* min, max, act ct */ 0, 1, 0,
                    333:      /* opt state flags  */ INTERACTIVE_FLAGS, 0,
                    334:      /* last opt argumnt */ { NULL },
                    335:      /* arg list/cookie  */ NULL,
                    336:      /* must/cannot opts */ NULL, aInteractiveCantList,
                    337:      /* option proc      */ NULL,
                    338:      /* desc, NAME, name */ zInteractiveText, zInteractive_NAME, zInteractive_Name,
                    339:      /* disablement strs */ NULL, NULL },
                    340: 
                    341:   {  /* entry idx, value */ 7, VALUE_OPT_DEBUG_LEVEL,
                    342:      /* equiv idx, value */ 7, VALUE_OPT_DEBUG_LEVEL,
                    343:      /* equivalenced to  */ NO_EQUIVALENT,
                    344:      /* min, max, act ct */ 0, NOLIMIT, 0,
                    345:      /* opt state flags  */ DEBUG_LEVEL_FLAGS, 0,
                    346:      /* last opt argumnt */ { NULL },
                    347:      /* arg list/cookie  */ NULL,
                    348:      /* must/cannot opts */ NULL, NULL,
                    349:      /* option proc      */ NULL,
                    350:      /* desc, NAME, name */ zDebug_LevelText, zDebug_Level_NAME, zDebug_Level_Name,
                    351:      /* disablement strs */ NULL, NULL },
                    352: 
                    353:   {  /* entry idx, value */ 8, VALUE_OPT_SET_DEBUG_LEVEL,
                    354:      /* equiv idx, value */ 8, VALUE_OPT_SET_DEBUG_LEVEL,
                    355:      /* equivalenced to  */ NO_EQUIVALENT,
                    356:      /* min, max, act ct */ 0, NOLIMIT, 0,
                    357:      /* opt state flags  */ SET_DEBUG_LEVEL_FLAGS, 0,
                    358:      /* last opt argumnt */ { NULL },
                    359:      /* arg list/cookie  */ NULL,
                    360:      /* must/cannot opts */ NULL, NULL,
                    361:      /* option proc      */ SET_DEBUG_LEVEL_OPT_PROC,
                    362:      /* desc, NAME, name */ zSet_Debug_LevelText, zSet_Debug_Level_NAME, zSet_Debug_Level_Name,
                    363:      /* disablement strs */ NULL, NULL },
                    364: 
                    365:   {  /* entry idx, value */ 9, VALUE_OPT_NUMERIC,
                    366:      /* equiv idx, value */ 9, VALUE_OPT_NUMERIC,
                    367:      /* equivalenced to  */ NO_EQUIVALENT,
                    368:      /* min, max, act ct */ 0, 1, 0,
                    369:      /* opt state flags  */ NUMERIC_FLAGS, 0,
                    370:      /* last opt argumnt */ { NULL },
                    371:      /* arg list/cookie  */ NULL,
                    372:      /* must/cannot opts */ NULL, NULL,
                    373:      /* option proc      */ NULL,
                    374:      /* desc, NAME, name */ zNumericText, zNumeric_NAME, zNumeric_Name,
                    375:      /* disablement strs */ NULL, NULL },
                    376: 
                    377:   {  /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
                    378:      /* equiv idx value  */ NO_EQUIVALENT, 0,
                    379:      /* equivalenced to  */ NO_EQUIVALENT,
                    380:      /* min, max, act ct */ 0, 1, 0,
                    381:      /* opt state flags  */ OPTST_VERSION_FLAGS, 0,
                    382:      /* last opt argumnt */ { NULL },
                    383:      /* arg list/cookie  */ NULL,
                    384:      /* must/cannot opts */ NULL, NULL,
                    385:      /* option proc      */ DOVERPROC,
                    386:      /* desc, NAME, name */ zVersionText, NULL, zVersion_Name,
                    387:      /* disablement strs */ NULL, NULL },
                    388: 
                    389: 
                    390: 
                    391:   {  /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
                    392:      /* equiv idx value  */ NO_EQUIVALENT, 0,
                    393:      /* equivalenced to  */ NO_EQUIVALENT,
                    394:      /* min, max, act ct */ 0, 1, 0,
                    395:      /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
                    396:      /* last opt argumnt */ { NULL },
                    397:      /* arg list/cookie  */ NULL,
                    398:      /* must/cannot opts */ NULL, NULL,
                    399:      /* option proc      */ doUsageOpt,
                    400:      /* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
                    401:      /* disablement strs */ NULL, NULL },
                    402: 
                    403:   {  /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
                    404:      /* equiv idx value  */ NO_EQUIVALENT, 0,
                    405:      /* equivalenced to  */ NO_EQUIVALENT,
                    406:      /* min, max, act ct */ 0, 1, 0,
                    407:      /* opt state flags  */ OPTST_MORE_HELP_FLAGS, 0,
                    408:      /* last opt argumnt */ { NULL },
                    409:      /* arg list/cookie  */ NULL,
                    410:      /* must/cannot opts */ NULL,  NULL,
                    411:      /* option proc      */ optionPagedUsage,
                    412:      /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
                    413:      /* disablement strs */ NULL, NULL },
                    414: 
                    415:   {  /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS,
                    416:      /* equiv idx value  */ NO_EQUIVALENT, 0,
                    417:      /* equivalenced to  */ NO_EQUIVALENT,
                    418:      /* min, max, act ct */ 0, 1, 0,
                    419:      /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
                    420:                           | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0,
                    421:      /* last opt argumnt */ { NULL },
                    422:      /* arg list/cookie  */ NULL,
                    423:      /* must/cannot opts */ NULL,  NULL,
                    424:      /* option proc      */ NULL,
                    425:      /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name,
                    426:      /* disablement strs */ NULL, NULL },
                    427: 
                    428:   {  /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS,
                    429:      /* equiv idx value  */ NO_EQUIVALENT, 0,
                    430:      /* equivalenced to  */ NO_EQUIVALENT,
                    431:      /* min, max, act ct */ 0, NOLIMIT, 0,
                    432:      /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
                    433:                          | OPTST_DISABLE_IMM, 0,
                    434:      /* last opt argumnt */ { NULL },
                    435:      /* arg list/cookie  */ NULL,
                    436:      /* must/cannot opts */ NULL, NULL,
                    437:      /* option proc      */ optionLoadOpt,
                    438:      /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name,
                    439:      /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx }
                    440: };
                    441: 
                    442: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
                    443:  *
                    444:  *  Define the Ntpdc Option Environment
                    445:  */
                    446: static char const zPROGNAME[6] = "NTPDC";
                    447: static char const zUsageTitle[127] =
                    448: "ntpdc - vendor-specific NTP query program - Ver. 4.2.6p5\n\
                    449: USAGE:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ host ...]\n";
                    450: static char const zRcName[7] = ".ntprc";
                    451: static char const * const apzHomeList[3] = {
                    452:     "$HOME",
                    453:     ".",
                    454:     NULL };
                    455: 
                    456: static char const zBugsAddr[34]    = "http://bugs.ntp.org, bugs@ntp.org";
                    457: #define zExplain NULL
                    458: static char const zDetail[601] = "\n\
                    459: The [= prog-name =] utility program is used to query an NTP daemon about\n\
                    460: its current state and to request changes in that state.  It uses NTP mode\n\
                    461: 7 control message formats described in the source code.  The program may\n\
                    462: be run either in interactive mode or controlled using command line\n\
                    463: arguments.  Extensive state and statistics information is available\n\
                    464: through the [= prog-name =] interface.  In addition, nearly all the\n\
                    465: configuration options which can be specified at startup using ntpd's\n\
                    466: configuration file may also be specified at run time using [= prog-name =]\n\
                    467: .\n";
                    468: static char const zFullVersion[] = NTPDC_FULL_VERSION;
                    469: /* extracted from optcode.tlib near line 515 */
                    470: 
                    471: #if defined(ENABLE_NLS)
                    472: # define OPTPROC_BASE OPTPROC_TRANSLATE
                    473:   static tOptionXlateProc translate_option_strings;
                    474: #else
                    475: # define OPTPROC_BASE OPTPROC_NONE
                    476: # define translate_option_strings NULL
                    477: #endif /* ENABLE_NLS */
                    478: 
                    479: 
                    480: #define ntpdc_full_usage NULL
                    481: #define ntpdc_short_usage NULL
                    482: #ifndef  PKGDATADIR
                    483: # define PKGDATADIR ""
                    484: #endif
                    485: 
                    486: #ifndef  WITH_PACKAGER
                    487: # define ntpdc_packager_info NULL
                    488: #else
                    489: static char const ntpdc_packager_info[] =
                    490:     "Packaged by " WITH_PACKAGER
                    491: 
                    492: # ifdef WITH_PACKAGER_VERSION
                    493:         " ("WITH_PACKAGER_VERSION")"
                    494: # endif
                    495: 
                    496: # ifdef WITH_PACKAGER_BUG_REPORTS
                    497:     "\nReport ntpdc bugs to " WITH_PACKAGER_BUG_REPORTS
                    498: # endif
                    499:     "\n";
                    500: #endif
                    501: 
                    502: tOptions ntpdcOptions = {
                    503:     OPTIONS_STRUCT_VERSION,
                    504:     0, NULL,                    /* original argc + argv    */
                    505:     ( OPTPROC_BASE
                    506:     + OPTPROC_ERRSTOP
                    507:     + OPTPROC_SHORTOPT
                    508:     + OPTPROC_LONGOPT
                    509:     + OPTPROC_NO_REQ_OPT
                    510:     + OPTPROC_ENVIRON
                    511:     + OPTPROC_MISUSE ),
                    512:     0, NULL,                    /* current option index, current option */
                    513:     NULL,         NULL,         zPROGNAME,
                    514:     zRcName,      zCopyright,   zLicenseDescrip,
                    515:     zFullVersion, apzHomeList,  zUsageTitle,
                    516:     zExplain,     zDetail,      optDesc,
                    517:     zBugsAddr,                  /* address to send bugs to */
                    518:     NULL, NULL,                 /* extensions/saved state  */
                    519:     optionUsage, /* usage procedure */
                    520:     translate_option_strings,   /* translation procedure */
                    521:     /*
                    522:      *  Indexes to special options
                    523:      */
                    524:     { INDEX_OPT_MORE_HELP, /* more-help option index */
                    525:       INDEX_OPT_SAVE_OPTS, /* save option index */
                    526:       NO_EQUIVALENT, /* '-#' option index */
                    527:       NO_EQUIVALENT /* index of default opt */
                    528:     },
                    529:     15 /* full option count */, 10 /* user option count */,
                    530:     ntpdc_full_usage, ntpdc_short_usage,
                    531:     NULL, NULL,
                    532:     PKGDATADIR, ntpdc_packager_info
                    533: };
                    534: 
                    535: /*
                    536:  *  Create the static procedure(s) declared above.
                    537:  */
                    538: static void
                    539: doUsageOpt(tOptions * pOptions, tOptDesc * pOptDesc)
                    540: {
                    541:     (void)pOptions;
                    542:     USAGE(NTPDC_EXIT_SUCCESS);
                    543: }
                    544: 
                    545: #if ! defined(TEST_NTPDC_OPTS)
                    546: 
                    547: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
                    548:  *
                    549:  *   For the set-debug-level option.
                    550:  */
                    551: static void
                    552: doOptSet_Debug_Level(tOptions* pOptions, tOptDesc* pOptDesc)
                    553: {
                    554:     /* extracted from debug-opt.def, line 27 */
                    555: DESC(DEBUG_LEVEL).optOccCt = atoi( pOptDesc->pzLastArg );
                    556: }
                    557: #endif /* defined(TEST_NTPDC_OPTS) */
                    558: /* extracted from optmain.tlib near line 128 */
                    559: 
                    560: #if defined(TEST_NTPDC_OPTS) /* TEST MAIN PROCEDURE: */
                    561: 
                    562: extern void optionPutShell(tOptions*);
                    563: 
                    564: int
                    565: main(int argc, char ** argv)
                    566: {
                    567:     int res = NTPDC_EXIT_SUCCESS;
                    568:     (void)optionProcess(&ntpdcOptions, argc, argv);
                    569:     optionPutShell(&ntpdcOptions);
                    570:     res = ferror(stdout);
                    571:     if (res != 0)
                    572:         fputs("output error writing to stdout\n", stderr);
                    573:     return res;
                    574: }
                    575: #endif  /* defined TEST_NTPDC_OPTS */
                    576: /* extracted from optcode.tlib near line 666 */
                    577: 
                    578: #if ENABLE_NLS
                    579: #include <stdio.h>
                    580: #include <stdlib.h>
                    581: #include <string.h>
                    582: #include <unistd.h>
                    583: #include <autoopts/usage-txt.h>
                    584: 
                    585: static char* AO_gettext(char const* pz);
                    586: static void  coerce_it(void** s);
                    587: 
                    588: static char*
                    589: AO_gettext(char const* pz)
                    590: {
                    591:     char* pzRes;
                    592:     if (pz == NULL)
                    593:         return NULL;
                    594:     pzRes = _(pz);
                    595:     if (pzRes == pz)
                    596:         return pzRes;
                    597:     pzRes = strdup(pzRes);
                    598:     if (pzRes == NULL) {
                    599:         fputs(_("No memory for duping translated strings\n"), stderr);
                    600:         exit(NTPDC_EXIT_FAILURE);
                    601:     }
                    602:     return pzRes;
                    603: }
                    604: 
                    605: static void coerce_it(void** s) { *s = AO_gettext(*s);
                    606: }
                    607: 
                    608: /*
                    609:  *  This invokes the translation code (e.g. gettext(3)).
                    610:  */
                    611: static void
                    612: translate_option_strings(void)
                    613: {
                    614:     tOptions * const pOpt = &ntpdcOptions;
                    615: 
                    616:     /*
                    617:      *  Guard against re-translation.  It won't work.  The strings will have
                    618:      *  been changed by the first pass through this code.  One shot only.
                    619:      */
                    620:     if (option_usage_text.field_ct != 0) {
                    621:         /*
                    622:          *  Do the translations.  The first pointer follows the field count
                    623:          *  field.  The field count field is the size of a pointer.
                    624:          */
                    625:         tOptDesc * pOD = pOpt->pOptDesc;
                    626:         char **    ppz = (char**)(void*)&(option_usage_text);
                    627:         int        ix  = option_usage_text.field_ct;
                    628: 
                    629:         do {
                    630:             ppz++;
                    631:             *ppz = AO_gettext(*ppz);
                    632:         } while (--ix > 0);
                    633: 
                    634:         coerce_it((void*)&(pOpt->pzCopyright));
                    635:         coerce_it((void*)&(pOpt->pzCopyNotice));
                    636:         coerce_it((void*)&(pOpt->pzFullVersion));
                    637:         coerce_it((void*)&(pOpt->pzUsageTitle));
                    638:         coerce_it((void*)&(pOpt->pzExplain));
                    639:         coerce_it((void*)&(pOpt->pzDetail));
                    640:         coerce_it((void*)&(pOpt->pzPackager));
                    641:         option_usage_text.field_ct = 0;
                    642: 
                    643:         for (ix = pOpt->optCt; ix > 0; ix--, pOD++)
                    644:             coerce_it((void*)&(pOD->pzText));
                    645:     }
                    646: 
                    647:     if ((pOpt->fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) {
                    648:         tOptDesc * pOD = pOpt->pOptDesc;
                    649:         int        ix;
                    650: 
                    651:         for (ix = pOpt->optCt; ix > 0; ix--, pOD++) {
                    652:             coerce_it((void*)&(pOD->pz_Name));
                    653:             coerce_it((void*)&(pOD->pz_DisableName));
                    654:             coerce_it((void*)&(pOD->pz_DisablePfx));
                    655:         }
                    656:         /* prevent re-translation */
                    657:         ntpdcOptions.fOptSet |= OPTPROC_NXLAT_OPT_CFG | OPTPROC_NXLAT_OPT;
                    658:     }
                    659: }
                    660: 
                    661: #endif /* ENABLE_NLS */
                    662: 
                    663: #ifdef  __cplusplus
                    664: }
                    665: #endif
                    666: /* ntpdc-opts.c ends here */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>