112 113/** 114 * nofork option description: 115 */ 116/** Descriptive text for the nofork option */ 117#define NOFORK_DESC (ntpsnmpd_opt_strs+1012) 118/** Upper-cased name for the nofork option */ 119#define NOFORK_NAME (ntpsnmpd_opt_strs+1024) 120/** Name string for the nofork option */ 121#define NOFORK_name (ntpsnmpd_opt_strs+1031) 122/** Compiled in flag settings for the nofork option */ 123#define NOFORK_FLAGS (OPTST_DISABLED) 124 125/** 126 * syslog option description: 127 */ 128/** Descriptive text for the syslog option */ 129#define SYSLOG_DESC (ntpsnmpd_opt_strs+1038) 130/** Upper-cased name for the syslog option */ 131#define SYSLOG_NAME (ntpsnmpd_opt_strs+1054) 132/** Name string for the syslog option */ 133#define SYSLOG_name (ntpsnmpd_opt_strs+1061) 134/** Compiled in flag settings for the syslog option */ 135#define SYSLOG_FLAGS (OPTST_DISABLED) 136 137/** 138 * agentXSocket option description: 139 */ 140/** Descriptive text for the agentXSocket option */ 141#define AGENTXSOCKET_DESC (ntpsnmpd_opt_strs+1068) 142/** Upper-cased name for the agentXSocket option */ 143#define AGENTXSOCKET_NAME (ntpsnmpd_opt_strs+1125) 144/** Name string for the agentXSocket option */ 145#define AGENTXSOCKET_name (ntpsnmpd_opt_strs+1138) 146/** The compiled in default value for the agentXSocket option argument */ 147#define AGENTXSOCKET_DFT_ARG (ntpsnmpd_opt_strs+1151) 148/** Compiled in flag settings for the agentXSocket option */ 149#define AGENTXSOCKET_FLAGS (OPTST_DISABLED \ 150 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) 151 152/* 153 * Help/More_Help/Version option descriptions: 154 */ 155#define HELP_DESC (ntpsnmpd_opt_strs+1175) 156#define HELP_name (ntpsnmpd_opt_strs+1219) 157#ifdef HAVE_WORKING_FORK 158#define MORE_HELP_DESC (ntpsnmpd_opt_strs+1224) 159#define MORE_HELP_name (ntpsnmpd_opt_strs+1269) 160#define MORE_HELP_FLAGS (OPTST_IMM | OPTST_NO_INIT) 161#else 162#define MORE_HELP_DESC HELP_DESC 163#define MORE_HELP_name HELP_name 164#define MORE_HELP_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) 165#endif 166#ifdef NO_OPTIONAL_OPT_ARGS 167# define VER_FLAGS (OPTST_IMM | OPTST_NO_INIT) 168#else 169# define VER_FLAGS (OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \ 170 OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT) 171#endif 172#define VER_DESC (ntpsnmpd_opt_strs+1279) 173#define VER_name (ntpsnmpd_opt_strs+1315) 174#define SAVE_OPTS_DESC (ntpsnmpd_opt_strs+1323) 175#define SAVE_OPTS_name (ntpsnmpd_opt_strs+1362) 176#define LOAD_OPTS_DESC (ntpsnmpd_opt_strs+1372) 177#define LOAD_OPTS_NAME (ntpsnmpd_opt_strs+1404) 178#define NO_LOAD_OPTS_name (ntpsnmpd_opt_strs+1414) 179#define LOAD_OPTS_pfx (ntpsnmpd_opt_strs+1427) 180#define LOAD_OPTS_name (NO_LOAD_OPTS_name + 3) 181/** 182 * Declare option callback procedures 183 */ 184extern tOptProc 185 ntpOptionPrintVersion, optionBooleanVal, optionNestedVal, 186 optionNumericVal, optionPagedUsage, optionResetOpt, 187 optionStackArg, optionTimeDate, optionTimeVal, 188 optionUnstackArg, optionVendorOption; 189static tOptProc 190 doUsageOpt; 191#define VER_PROC ntpOptionPrintVersion 192 193/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 194/** 195 * Define the ntpsnmpd Option Descriptions. 196 * This is an array of OPTION_CT entries, one for each 197 * option that the ntpsnmpd program responds to. 198 */ 199static tOptDesc optDesc[OPTION_CT] = { 200 { /* entry idx, value */ 0, VALUE_OPT_NOFORK, 201 /* equiv idx, value */ 0, VALUE_OPT_NOFORK, 202 /* equivalenced to */ NO_EQUIVALENT, 203 /* min, max, act ct */ 0, 1, 0, 204 /* opt state flags */ NOFORK_FLAGS, 0, 205 /* last opt argumnt */ { NULL }, /* --nofork */ 206 /* arg list/cookie */ NULL, 207 /* must/cannot opts */ NULL, NULL, 208 /* option proc */ NULL, 209 /* desc, NAME, name */ NOFORK_DESC, NOFORK_NAME, NOFORK_name, 210 /* disablement strs */ NULL, NULL }, 211 212 { /* entry idx, value */ 1, VALUE_OPT_SYSLOG, 213 /* equiv idx, value */ 1, VALUE_OPT_SYSLOG, 214 /* equivalenced to */ NO_EQUIVALENT, 215 /* min, max, act ct */ 0, 1, 0, 216 /* opt state flags */ SYSLOG_FLAGS, 0, 217 /* last opt argumnt */ { NULL }, /* --syslog */ 218 /* arg list/cookie */ NULL, 219 /* must/cannot opts */ NULL, NULL, 220 /* option proc */ NULL, 221 /* desc, NAME, name */ SYSLOG_DESC, SYSLOG_NAME, SYSLOG_name, 222 /* disablement strs */ NULL, NULL }, 223 224 { /* entry idx, value */ 2, VALUE_OPT_AGENTXSOCKET, 225 /* equiv idx, value */ 2, VALUE_OPT_AGENTXSOCKET, 226 /* equivalenced to */ NO_EQUIVALENT, 227 /* min, max, act ct */ 0, 1, 0, 228 /* opt state flags */ AGENTXSOCKET_FLAGS, 0, 229 /* last opt argumnt */ { AGENTXSOCKET_DFT_ARG }, 230 /* arg list/cookie */ NULL, 231 /* must/cannot opts */ NULL, NULL, 232 /* option proc */ NULL, 233 /* desc, NAME, name */ AGENTXSOCKET_DESC, AGENTXSOCKET_NAME, AGENTXSOCKET_name, 234 /* disablement strs */ NULL, NULL }, 235 236 { /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION, 237 /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_VERSION, 238 /* equivalenced to */ NO_EQUIVALENT, 239 /* min, max, act ct */ 0, 1, 0, 240 /* opt state flags */ VER_FLAGS, AOUSE_VERSION, 241 /* last opt argumnt */ { NULL }, 242 /* arg list/cookie */ NULL, 243 /* must/cannot opts */ NULL, NULL, 244 /* option proc */ VER_PROC, 245 /* desc, NAME, name */ VER_DESC, NULL, VER_name, 246 /* disablement strs */ NULL, NULL }, 247 248 249 250 { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP, 251 /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_HELP, 252 /* equivalenced to */ NO_EQUIVALENT, 253 /* min, max, act ct */ 0, 1, 0, 254 /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, AOUSE_HELP, 255 /* last opt argumnt */ { NULL }, 256 /* arg list/cookie */ NULL, 257 /* must/cannot opts */ NULL, NULL, 258 /* option proc */ doUsageOpt, 259 /* desc, NAME, name */ HELP_DESC, NULL, HELP_name, 260 /* disablement strs */ NULL, NULL }, 261 262 { /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP, 263 /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_MORE_HELP, 264 /* equivalenced to */ NO_EQUIVALENT, 265 /* min, max, act ct */ 0, 1, 0, 266 /* opt state flags */ MORE_HELP_FLAGS, AOUSE_MORE_HELP, 267 /* last opt argumnt */ { NULL }, 268 /* arg list/cookie */ NULL, 269 /* must/cannot opts */ NULL, NULL, 270 /* option proc */ optionPagedUsage, 271 /* desc, NAME, name */ MORE_HELP_DESC, NULL, MORE_HELP_name, 272 /* disablement strs */ NULL, NULL }, 273 274 { /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS, 275 /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_SAVE_OPTS, 276 /* equivalenced to */ NO_EQUIVALENT, 277 /* min, max, act ct */ 0, 1, 0, 278 /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) 279 | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, AOUSE_SAVE_OPTS, 280 /* last opt argumnt */ { NULL }, 281 /* arg list/cookie */ NULL, 282 /* must/cannot opts */ NULL, NULL, 283 /* option proc */ NULL, 284 /* desc, NAME, name */ SAVE_OPTS_DESC, NULL, SAVE_OPTS_name, 285 /* disablement strs */ NULL, NULL }, 286 287 { /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS, 288 /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_LOAD_OPTS, 289 /* equivalenced to */ NO_EQUIVALENT, 290 /* min, max, act ct */ 0, NOLIMIT, 0, 291 /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) 292 | OPTST_DISABLE_IMM, AOUSE_LOAD_OPTS, 293 /* last opt argumnt */ { NULL }, 294 /* arg list/cookie */ NULL, 295 /* must/cannot opts */ NULL, NULL, 296 /* option proc */ optionLoadOpt, 297 /* desc, NAME, name */ LOAD_OPTS_DESC, LOAD_OPTS_NAME, LOAD_OPTS_name, 298 /* disablement strs */ NO_LOAD_OPTS_name, LOAD_OPTS_pfx } 299}; 300 301 302/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 303/** Reference to the upper cased version of ntpsnmpd. */ 304#define zPROGNAME (ntpsnmpd_opt_strs+1430) 305/** Reference to the title line for ntpsnmpd usage. */ 306#define zUsageTitle (ntpsnmpd_opt_strs+1439) 307/** ntpsnmpd configuration file name. */ 308#define zRcName (ntpsnmpd_opt_strs+1550) 309/** Directories to search for ntpsnmpd config files. */ 310static char const * const apzHomeList[3] = { 311 ntpsnmpd_opt_strs+1542, 312 ntpsnmpd_opt_strs+1548, 313 NULL }; 314/** The ntpsnmpd program bug email address. */ 315#define zBugsAddr (ntpsnmpd_opt_strs+1557) 316/** Clarification/explanation of what ntpsnmpd does. */ 317#define zExplain (ntpsnmpd_opt_strs+1591) 318/** Extra detail explaining what ntpsnmpd does. */ 319#define zDetail (NULL) 320/** The full version string for ntpsnmpd. */ 321#define zFullVersion (ntpsnmpd_opt_strs+1593) 322/* extracted from optcode.tlib near line 364 */ 323 324#if defined(ENABLE_NLS) 325# define OPTPROC_BASE OPTPROC_TRANSLATE 326 static tOptionXlateProc translate_option_strings; 327#else 328# define OPTPROC_BASE OPTPROC_NONE 329# define translate_option_strings NULL 330#endif /* ENABLE_NLS */ 331 332#define ntpsnmpd_full_usage (NULL) 333#define ntpsnmpd_short_usage (NULL) 334 335#endif /* not defined __doxygen__ */ 336 337/* 338 * Create the static procedure(s) declared above. 339 */ 340/** 341 * The callout function that invokes the optionUsage function. 342 * 343 * @param[in] opts the AutoOpts option description structure 344 * @param[in] od the descriptor for the "help" (usage) option. 345 * @noreturn 346 */ 347static void 348doUsageOpt(tOptions * opts, tOptDesc * od) 349{ 350 int ex_code; 351 ex_code = NTPSNMPD_EXIT_SUCCESS; 352 optionUsage(&ntpsnmpdOptions, ex_code); 353 /* NOTREACHED */ 354 exit(1); 355 (void)opts; 356 (void)od; 357} 358/* extracted from optmain.tlib near line 1250 */ 359 360/** 361 * The directory containing the data associated with ntpsnmpd. 362 */ 363#ifndef PKGDATADIR 364# define PKGDATADIR "" 365#endif 366 367/** 368 * Information about the person or institution that packaged ntpsnmpd 369 * for the current distribution. 370 */ 371#ifndef WITH_PACKAGER 372# define ntpsnmpd_packager_info NULL 373#else 374/** Packager information for ntpsnmpd. */ 375static char const ntpsnmpd_packager_info[] = 376 "Packaged by " WITH_PACKAGER 377 378# ifdef WITH_PACKAGER_VERSION 379 " ("WITH_PACKAGER_VERSION")" 380# endif 381 382# ifdef WITH_PACKAGER_BUG_REPORTS 383 "\nReport ntpsnmpd bugs to " WITH_PACKAGER_BUG_REPORTS 384# endif 385 "\n"; 386#endif 387#ifndef __doxygen__ 388 389#endif /* __doxygen__ */ 390/** 391 * The option definitions for ntpsnmpd. The one structure that 392 * binds them all. 393 */ 394tOptions ntpsnmpdOptions = { 395 OPTIONS_STRUCT_VERSION, 396 0, NULL, /* original argc + argv */ 397 ( OPTPROC_BASE 398 + OPTPROC_ERRSTOP 399 + OPTPROC_SHORTOPT 400 + OPTPROC_LONGOPT 401 + OPTPROC_NO_REQ_OPT 402 + OPTPROC_ENVIRON 403 + OPTPROC_NO_ARGS 404 + OPTPROC_MISUSE ), 405 0, NULL, /* current option index, current option */ 406 NULL, NULL, zPROGNAME, 407 zRcName, zCopyright, zLicenseDescrip, 408 zFullVersion, apzHomeList, zUsageTitle, 409 zExplain, zDetail, optDesc, 410 zBugsAddr, /* address to send bugs to */ 411 NULL, NULL, /* extensions/saved state */ 412 optionUsage, /* usage procedure */ 413 translate_option_strings, /* translation procedure */ 414 /* 415 * Indexes to special options 416 */ 417 { INDEX_OPT_MORE_HELP, /* more-help option index */ 418 INDEX_OPT_SAVE_OPTS, /* save option index */ 419 NO_EQUIVALENT, /* '-#' option index */ 420 NO_EQUIVALENT /* index of default opt */ 421 }, 422 8 /* full option count */, 3 /* user option count */, 423 ntpsnmpd_full_usage, ntpsnmpd_short_usage, 424 NULL, NULL, 425 PKGDATADIR, ntpsnmpd_packager_info 426}; 427 428#if ENABLE_NLS 429/** 430 * This code is designed to translate translatable option text for the 431 * ntpsnmpd program. These translations happen upon entry 432 * to optionProcess(). 433 */ 434#include <stdio.h> 435#include <stdlib.h> 436#include <string.h> 437#include <unistd.h> 438#ifdef HAVE_DCGETTEXT 439# include <gettext.h> 440#endif 441#include <autoopts/usage-txt.h> 442 443static char * AO_gettext(char const * pz); 444static void coerce_it(void ** s); 445 446/** 447 * AutoGen specific wrapper function for gettext. It relies on the macro _() 448 * to convert from English to the target language, then strdup-duplicates the 449 * result string. It tries the "libopts" domain first, then whatever has been 450 * set via the \a textdomain(3) call. 451 * 452 * @param[in] pz the input text used as a lookup key. 453 * @returns the translated text (if there is one), 454 * or the original text (if not). 455 */ 456static char * 457AO_gettext(char const * pz) 458{ 459 char * res; 460 if (pz == NULL) 461 return NULL; 462#ifdef HAVE_DCGETTEXT 463 /* 464 * While processing the option_xlateable_txt data, try to use the 465 * "libopts" domain. Once we switch to the option descriptor data, 466 * do *not* use that domain. 467 */ 468 if (option_xlateable_txt.field_ct != 0) { 469 res = dgettext("libopts", pz); 470 if (res == pz) 471 res = (char *)VOIDP(_(pz)); 472 } else 473 res = (char *)VOIDP(_(pz)); 474#else 475 res = (char *)VOIDP(_(pz)); 476#endif 477 if (res == pz) 478 return res; 479 res = strdup(res); 480 if (res == NULL) { 481 fputs(_("No memory for duping translated strings\n"), stderr); 482 exit(NTPSNMPD_EXIT_FAILURE); 483 } 484 return res; 485} 486 487/** 488 * All the pointers we use are marked "* const", but they are stored in 489 * writable memory. Coerce the mutability and set the pointer. 490 */ 491static void coerce_it(void ** s) { *s = AO_gettext(*s); 492} 493 494/** 495 * Translate all the translatable strings in the ntpsnmpdOptions 496 * structure defined above. This is done only once. 497 */ 498static void 499translate_option_strings(void) 500{ 501 tOptions * const opts = &ntpsnmpdOptions; 502 503 /* 504 * Guard against re-translation. It won't work. The strings will have 505 * been changed by the first pass through this code. One shot only. 506 */ 507 if (option_xlateable_txt.field_ct != 0) { 508 /* 509 * Do the translations. The first pointer follows the field count 510 * field. The field count field is the size of a pointer. 511 */ 512 char ** ppz = (char**)VOIDP(&(option_xlateable_txt)); 513 int ix = option_xlateable_txt.field_ct; 514 515 do { 516 ppz++; /* skip over field_ct */ 517 *ppz = AO_gettext(*ppz); 518 } while (--ix > 0); 519 /* prevent re-translation and disable "libopts" domain lookup */ 520 option_xlateable_txt.field_ct = 0; 521 522 coerce_it(VOIDP(&(opts->pzCopyright))); 523 coerce_it(VOIDP(&(opts->pzCopyNotice))); 524 coerce_it(VOIDP(&(opts->pzFullVersion))); 525 coerce_it(VOIDP(&(opts->pzUsageTitle))); 526 coerce_it(VOIDP(&(opts->pzExplain))); 527 coerce_it(VOIDP(&(opts->pzDetail))); 528 { 529 tOptDesc * od = opts->pOptDesc; 530 for (ix = opts->optCt; ix > 0; ix--, od++) 531 coerce_it(VOIDP(&(od->pzText))); 532 } 533 } 534} 535#endif /* ENABLE_NLS */ 536 537#ifdef DO_NOT_COMPILE_THIS_CODE_IT_IS_FOR_GETTEXT 538/** I18N function strictly for xgettext. Do not compile. */ 539static void bogus_function(void) { 540 /* TRANSLATORS: 541 542 The following dummy function was crated solely so that xgettext can 543 extract the correct strings. These strings are actually referenced 544 by a field name in the ntpsnmpdOptions structure noted in the 545 comments below. The literal text is defined in ntpsnmpd_opt_strs. 546 547 NOTE: the strings below are segmented with respect to the source string 548 ntpsnmpd_opt_strs. The strings above are handed off for translation 549 at run time a paragraph at a time. Consequently, they are presented here 550 for translation a paragraph at a time. 551 552 ALSO: often the description for an option will reference another option 553 by name. These are set off with apostrophe quotes (I hope). Do not 554 translate option names. 555 */ 556 /* referenced via ntpsnmpdOptions.pzCopyright */
|