2
2
* EDIT THIS FILE WITH CAUTION (ntp-keygen-opts.c)
4
* It has been AutoGen-ed January 3, 2011 at 09:18:50 PM by AutoGen 5.11.6pre7
4
* It has been AutoGen-ed December 24, 2011 at 06:34:40 PM by AutoGen 5.12
5
5
* From the definitions ntp-keygen-opts.def
6
6
* and the template file options
8
* Generated from AutoOpts 34:0:9 templates.
8
* Generated from AutoOpts 35:0:10 templates.
10
10
* AutoOpts is a copyrighted work. This source file is not encumbered
11
11
* by AutoOpts licensing, but is provided under the licensing terms chosen
18
18
* This source file is copyrighted and licensed under the following terms:
20
* ntp-keygen copyright (c) 1970-2011 David L. Mills and/or others - all rights reserved
22
* see html/copyright.html
20
* see html/copyright.html
25
24
#include <sys/types.h>
26
26
#include <limits.h>
28
28
#include <stdlib.h>
30
extern FILE * option_usage_fp;
31
30
#define OPTION_CODE_COMPILE 1
32
31
#include "ntp-keygen-opts.h"
36
extern FILE * option_usage_fp;
38
38
/* TRANSLATORS: choose the translation for option names wisely because you
39
39
cannot ever change your mind. */
41
"ntp-keygen copyright (c) 1970-2011 David L. Mills and/or others, all rights reserved"
42
/* extracted from ../include/copyright.def near line 8 */
44
tSCC zCopyrightNotice[24] =
45
"see html/copyright.html";
40
static char const zCopyright[50] =
41
"ntp-keygen (ntp) 4.2.6p5\n\
42
see html/copyright.html\n";
43
static char const zLicenseDescrip[25] =
44
"see html/copyright.html\n";
47
46
extern tUsageProc optionUsage;
418
411
optionBooleanVal, optionNestedVal, optionNumericVal,
419
412
optionPagedUsage, optionPrintVersion, optionResetOpt,
420
optionStackArg, optionTimeVal, optionUnstackArg,
413
optionStackArg, optionTimeDate, optionTimeVal,
414
optionUnstackArg, optionVersionStderr;
423
416
doOptSet_Debug_Level, doUsageOpt;
440
433
* Define the Ntp_Keygen Option Descriptions.
442
static tOptDesc optDesc[ OPTION_CT ] = {
435
static tOptDesc optDesc[OPTION_CT] = {
443
436
{ /* entry idx, value */ 0, VALUE_OPT_CERTIFICATE,
444
437
/* equiv idx, value */ 0, VALUE_OPT_CERTIFICATE,
445
438
/* equivalenced to */ NO_EQUIVALENT,
728
721
static char const zPROGNAME[11] = "NTP_KEYGEN";
729
722
static char const zUsageTitle[114] =
730
"ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.6p3\n\
723
"ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.6p5\n\
731
724
USAGE: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n";
732
725
static char const zRcName[7] = ".ntprc";
733
726
static char const * const apzHomeList[3] = {
738
731
static char const zBugsAddr[34] = "http://bugs.ntp.org, bugs@ntp.org";
739
732
#define zExplain NULL
740
static char const zDetail[98] = "\n\
741
If there is no new host key, look for an existing one.\n\
742
If one is not found, create it.\n";
733
static char const zDetail[99] = "\n\
734
If there is no new host key, look for an existing one. If one is not\n\
735
found, create it.\n";
743
736
static char const zFullVersion[] = NTP_KEYGEN_FULL_VERSION;
744
/* extracted from /usr/local/gnu/share/autogen/optcode.tpl near line 504 */
737
/* extracted from optcode.tlib near line 515 */
746
739
#if defined(ENABLE_NLS)
747
740
# define OPTPROC_BASE OPTPROC_TRANSLATE
758
751
# define PKGDATADIR ""
754
#ifndef WITH_PACKAGER
755
# define ntp_keygen_packager_info NULL
757
static char const ntp_keygen_packager_info[] =
758
"Packaged by " WITH_PACKAGER
760
# ifdef WITH_PACKAGER_VERSION
761
" ("WITH_PACKAGER_VERSION")"
764
# ifdef WITH_PACKAGER_BUG_REPORTS
765
"\nReport ntp_keygen bugs to " WITH_PACKAGER_BUG_REPORTS
761
770
tOptions ntp_keygenOptions = {
762
771
OPTIONS_STRUCT_VERSION,
763
772
0, NULL, /* original argc + argv */
771
780
+ OPTPROC_MISUSE ),
772
781
0, NULL, /* current option index, current option */
773
782
NULL, NULL, zPROGNAME,
774
zRcName, zCopyright, zCopyrightNotice,
783
zRcName, zCopyright, zLicenseDescrip,
775
784
zFullVersion, apzHomeList, zUsageTitle,
776
785
zExplain, zDetail, optDesc,
777
786
zBugsAddr, /* address to send bugs to */
778
787
NULL, NULL, /* extensions/saved state */
779
optionUsage, /* usage procedure */
788
optionUsage, /* usage procedure */
780
789
translate_option_strings, /* translation procedure */
782
791
* Indexes to special options
789
798
23 /* full option count */, 18 /* user option count */,
790
799
ntp_keygen_full_usage, ntp_keygen_short_usage,
801
PKGDATADIR, ntp_keygen_packager_info
796
805
* Create the static procedure(s) declared above.
808
doUsageOpt(tOptions * pOptions, tOptDesc * pOptDesc)
811
USAGE(NTP_KEYGEN_EXIT_SUCCESS);
807
814
#if ! defined(TEST_NTP_KEYGEN_OPTS)
814
821
doOptSet_Debug_Level(tOptions* pOptions, tOptDesc* pOptDesc)
816
/* extracted from ../include/debug-opt.def, line 27 */
823
/* extracted from debug-opt.def, line 27 */
817
824
DESC(DEBUG_LEVEL).optOccCt = atoi( pOptDesc->pzLastArg );
819
826
#endif /* defined(TEST_NTP_KEYGEN_OPTS) */
829
836
static const struct {long const rmin, rmax;} rng[1] = {
835
840
if (pOptions <= OPTPROC_EMIT_LIMIT)
836
841
goto emit_ranges;
839
val = strtol(pOptDesc->optArg.argString, &pzEnd, 0);
840
if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0))
842
optionNumericVal(pOptions, pOptDesc);
845
844
for (ix = 0; ix < 1; ix++) {
846
if (val < rng[ix].rmin)
845
if (pOptDesc->optArg.argInt < rng[ix].rmin)
847
846
continue; /* ranges need not be ordered. */
848
if (val == rng[ix].rmin)
847
if (pOptDesc->optArg.argInt == rng[ix].rmin)
850
849
if (rng[ix].rmax == LONG_MIN)
852
if (val <= rng[ix].rmax)
851
if (pOptDesc->optArg.argInt <= rng[ix].rmax)
858
855
option_usage_fp = stderr;
861
859
optionShowRange(pOptions, pOptDesc, (void *)rng, 1);
865
if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) {
866
free((void *)pOptDesc->optArg.argString);
867
pOptDesc->fOptState &= ~OPTST_ALLOC_ARG;
869
pOptDesc->optArg.argInt = val;
871
861
#endif /* defined OPENSSL */
872
/* extracted from /usr/local/gnu/share/autogen/optmain.tpl near line 107 */
862
/* extracted from optmain.tlib near line 128 */
874
864
#if defined(TEST_NTP_KEYGEN_OPTS) /* TEST MAIN PROCEDURE: */
876
866
extern void optionPutShell(tOptions*);
879
main(int argc, char** argv)
869
main(int argc, char ** argv)
881
int res = EXIT_SUCCESS;
871
int res = NTP_KEYGEN_EXIT_SUCCESS;
882
872
(void)optionProcess(&ntp_keygenOptions, argc, argv);
883
873
optionPutShell(&ntp_keygenOptions);
884
874
res = ferror(stdout);
911
901
pzRes = strdup(pzRes);
912
902
if (pzRes == NULL) {
913
903
fputs(_("No memory for duping translated strings\n"), stderr);
904
exit(NTP_KEYGEN_EXIT_FAILURE);
919
static void coerce_it(void** s) { *s = AO_gettext(*s); }
920
#define COERSION(_f) \
921
coerce_it((void*)&(ntp_keygenOptions._f))
909
static void coerce_it(void** s) { *s = AO_gettext(*s);
924
913
* This invokes the translation code (e.g. gettext(3)).
927
916
translate_option_strings(void)
918
tOptions * const pOpt = &ntp_keygenOptions;
930
921
* Guard against re-translation. It won't work. The strings will have
931
922
* been changed by the first pass through this code. One shot only.
933
924
if (option_usage_text.field_ct != 0) {
936
926
* Do the translations. The first pointer follows the field count
937
927
* field. The field count field is the size of a pointer.
939
tOptDesc* pOD = ntp_keygenOptions.pOptDesc;
940
char** ppz = (char**)(void*)&(option_usage_text);
941
int ix = option_usage_text.field_ct;
929
tOptDesc * pOD = pOpt->pOptDesc;
930
char ** ppz = (char**)(void*)&(option_usage_text);
931
int ix = option_usage_text.field_ct;
945
935
*ppz = AO_gettext(*ppz);
946
936
} while (--ix > 0);
948
COERSION(pzCopyright);
949
COERSION(pzCopyNotice);
950
COERSION(pzFullVersion);
951
COERSION(pzUsageTitle);
938
coerce_it((void*)&(pOpt->pzCopyright));
939
coerce_it((void*)&(pOpt->pzCopyNotice));
940
coerce_it((void*)&(pOpt->pzFullVersion));
941
coerce_it((void*)&(pOpt->pzUsageTitle));
942
coerce_it((void*)&(pOpt->pzExplain));
943
coerce_it((void*)&(pOpt->pzDetail));
944
coerce_it((void*)&(pOpt->pzPackager));
954
945
option_usage_text.field_ct = 0;
956
for (ix = ntp_keygenOptions.optCt; ix > 0; ix--, pOD++)
947
for (ix = pOpt->optCt; ix > 0; ix--, pOD++)
957
948
coerce_it((void*)&(pOD->pzText));
960
if ((ntp_keygenOptions.fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) {
961
tOptDesc* pOD = ntp_keygenOptions.pOptDesc;
951
if ((pOpt->fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) {
952
tOptDesc * pOD = pOpt->pOptDesc;
964
for (ix = ntp_keygenOptions.optCt; ix > 0; ix--, pOD++) {
955
for (ix = pOpt->optCt; ix > 0; ix--, pOD++) {
965
956
coerce_it((void*)&(pOD->pz_Name));
966
957
coerce_it((void*)&(pOD->pz_DisableName));
967
958
coerce_it((void*)&(pOD->pz_DisablePfx));