File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / ntp / ntpsnmpd / ntpsnmpd-opts.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:08:38 2012 UTC (12 years, 5 months ago) by misho
Branches: ntp, MAIN
CVS tags: v4_2_6p5p0, v4_2_6p5, HEAD
ntp 4.2.6p5

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

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