~ubuntu-branches/debian/sid/ntp/sid

« back to all changes in this revision

Viewing changes to util/ntp-keygen-opts.c

  • Committer: Package Import Robot
  • Author(s): Peter Eisentraut
  • Date: 2012-02-27 13:55:56 UTC
  • mfrom: (1.2.12)
  • Revision ID: package-import@ubuntu.com-20120227135556-dkx4mkod5trl5bgt
Tags: 1:4.2.6.p5+dfsg-1
* New upstream release (closes: #644673)
* Updated instructions on generating autotools.patch
* Updated standards version

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*  
2
2
 *  EDIT THIS FILE WITH CAUTION  (ntp-keygen-opts.c)
3
3
 *  
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
7
7
 *
8
 
 * Generated from AutoOpts 34:0:9 templates.
 
8
 * Generated from AutoOpts 35:0:10 templates.
9
9
 *
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
17
17
 *
18
18
 * This source file is copyrighted and licensed under the following terms:
19
19
 *
20
 
 * ntp-keygen copyright (c) 1970-2011 David L. Mills and/or others - all rights reserved
21
 
 *
22
 
 * see html/copyright.html
 
20
 *  see html/copyright.html
 
21
 *  
23
22
 */
24
23
 
25
24
#include <sys/types.h>
 
25
 
26
26
#include <limits.h>
27
27
#include <stdio.h>
28
28
#include <stdlib.h>
29
29
#include <errno.h>
30
 
extern FILE * option_usage_fp;
31
30
#define OPTION_CODE_COMPILE 1
32
31
#include "ntp-keygen-opts.h"
33
32
 
34
33
#ifdef  __cplusplus
35
34
extern "C" {
36
35
#endif
 
36
extern FILE * option_usage_fp;
37
37
 
38
38
/* TRANSLATORS: choose the translation for option names wisely because you
39
39
                cannot ever change your mind. */
40
 
tSCC zCopyright[] =
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 */
43
 
;
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";
46
45
 
47
46
extern tUsageProc optionUsage;
48
47
 
59
58
#ifndef NULL
60
59
#  define NULL 0
61
60
#endif
62
 
#ifndef EXIT_SUCCESS
63
 
#  define  EXIT_SUCCESS 0
64
 
#endif
65
 
#ifndef EXIT_FAILURE
66
 
#  define  EXIT_FAILURE 1
67
 
#endif
68
61
 
69
62
/*
70
63
 *  Certificate option description:
402
395
 *  if multiple copies are allowed.
403
396
 */
404
397
static tOptProc
405
 
    doOptModulus, doUsageOpt;
 
398
    doUsageOpt;
406
399
 
407
400
/*
408
401
 *  #define map the "normal" callout procs to the test ones...
417
410
extern tOptProc
418
411
    optionBooleanVal,    optionNestedVal,     optionNumericVal,
419
412
    optionPagedUsage,    optionPrintVersion,  optionResetOpt,
420
 
    optionStackArg,      optionTimeVal,       optionUnstackArg,
421
 
    optionVersionStderr;
 
413
    optionStackArg,      optionTimeDate,      optionTimeVal,
 
414
    optionUnstackArg,    optionVersionStderr;
422
415
static tOptProc
423
416
    doOptSet_Debug_Level, doUsageOpt;
424
417
 
439
432
 *
440
433
 *  Define the Ntp_Keygen Option Descriptions.
441
434
 */
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,
727
720
 */
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] = {
737
730
 
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 */
745
738
 
746
739
#if defined(ENABLE_NLS)
747
740
# define OPTPROC_BASE OPTPROC_TRANSLATE
758
751
# define PKGDATADIR ""
759
752
#endif
760
753
 
 
754
#ifndef  WITH_PACKAGER
 
755
# define ntp_keygen_packager_info NULL
 
756
#else
 
757
static char const ntp_keygen_packager_info[] =
 
758
    "Packaged by " WITH_PACKAGER
 
759
 
 
760
# ifdef WITH_PACKAGER_VERSION
 
761
        " ("WITH_PACKAGER_VERSION")"
 
762
# endif
 
763
 
 
764
# ifdef WITH_PACKAGER_BUG_REPORTS
 
765
    "\nReport ntp_keygen bugs to " WITH_PACKAGER_BUG_REPORTS
 
766
# endif
 
767
    "\n";
 
768
#endif
 
769
 
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 */
781
790
    /*
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,
791
800
    NULL, NULL,
792
 
    PKGDATADIR
 
801
    PKGDATADIR, ntp_keygen_packager_info
793
802
};
794
803
 
795
804
/*
796
805
 *  Create the static procedure(s) declared above.
797
806
 */
798
807
static void
799
 
doUsageOpt(
800
 
    tOptions*   pOptions,
801
 
    tOptDesc*   pOptDesc )
 
808
doUsageOpt(tOptions * pOptions, tOptDesc * pOptDesc)
802
809
{
803
810
    (void)pOptions;
804
 
    USAGE(EXIT_SUCCESS);
 
811
    USAGE(NTP_KEYGEN_EXIT_SUCCESS);
805
812
}
806
813
 
807
814
#if ! defined(TEST_NTP_KEYGEN_OPTS)
813
820
static void
814
821
doOptSet_Debug_Level(tOptions* pOptions, tOptDesc* pOptDesc)
815
822
{
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 );
818
825
}
819
826
#endif /* defined(TEST_NTP_KEYGEN_OPTS) */
828
835
{
829
836
    static const struct {long const rmin, rmax;} rng[1] = {
830
837
        { 256, 2048 } };
831
 
    long val;
832
838
    int  ix;
833
 
    char * pzEnd;
834
839
 
835
840
    if (pOptions <= OPTPROC_EMIT_LIMIT)
836
841
        goto emit_ranges;
837
 
 
838
 
    errno = 0;
839
 
    val = strtol(pOptDesc->optArg.argString, &pzEnd, 0);
840
 
    if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0))
841
 
        goto bad_value;
842
 
 
843
 
    if (*pzEnd != '\0')
844
 
        goto bad_value;
 
842
    optionNumericVal(pOptions, pOptDesc);
 
843
 
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)
849
 
            goto valid_return;
 
847
        if (pOptDesc->optArg.argInt == rng[ix].rmin)
 
848
            return;
850
849
        if (rng[ix].rmax == LONG_MIN)
851
850
            continue;
852
 
        if (val <= rng[ix].rmax)
853
 
            goto valid_return;
 
851
        if (pOptDesc->optArg.argInt <= rng[ix].rmax)
 
852
            return;
854
853
    }
855
854
 
856
 
  bad_value:
857
 
 
858
855
    option_usage_fp = stderr;
859
856
 
860
 
  emit_ranges:
 
857
emit_ranges:
 
858
 
861
859
    optionShowRange(pOptions, pOptDesc, (void *)rng, 1);
862
 
    return;
863
 
 
864
 
  valid_return:
865
 
    if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) {
866
 
        free((void *)pOptDesc->optArg.argString);
867
 
        pOptDesc->fOptState &= ~OPTST_ALLOC_ARG;
868
 
    }
869
 
    pOptDesc->optArg.argInt = val;
870
860
}
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 */
873
863
 
874
864
#if defined(TEST_NTP_KEYGEN_OPTS) /* TEST MAIN PROCEDURE: */
875
865
 
876
866
extern void optionPutShell(tOptions*);
877
867
 
878
868
int
879
 
main(int argc, char** argv)
 
869
main(int argc, char ** argv)
880
870
{
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);
887
877
    return res;
888
878
}
889
879
#endif  /* defined TEST_NTP_KEYGEN_OPTS */
890
 
/* extracted from /usr/local/gnu/share/autogen/optcode.tpl near line 641 */
 
880
/* extracted from optcode.tlib near line 666 */
891
881
 
892
882
#if ENABLE_NLS
893
883
#include <stdio.h>
911
901
    pzRes = strdup(pzRes);
912
902
    if (pzRes == NULL) {
913
903
        fputs(_("No memory for duping translated strings\n"), stderr);
914
 
        exit(EXIT_FAILURE);
 
904
        exit(NTP_KEYGEN_EXIT_FAILURE);
915
905
    }
916
906
    return pzRes;
917
907
}
918
908
 
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);
 
910
}
922
911
 
923
912
/*
924
913
 *  This invokes the translation code (e.g. gettext(3)).
926
915
static void
927
916
translate_option_strings(void)
928
917
{
 
918
    tOptions * const pOpt = &ntp_keygenOptions;
 
919
 
929
920
    /*
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.
932
923
     */
933
924
    if (option_usage_text.field_ct != 0) {
934
 
 
935
925
        /*
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.
938
928
         */
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;
942
932
 
943
933
        do {
944
934
            ppz++;
945
935
            *ppz = AO_gettext(*ppz);
946
936
        } while (--ix > 0);
947
937
 
948
 
        COERSION(pzCopyright);
949
 
        COERSION(pzCopyNotice);
950
 
        COERSION(pzFullVersion);
951
 
        COERSION(pzUsageTitle);
952
 
        COERSION(pzExplain);
953
 
        COERSION(pzDetail);
 
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;
955
946
 
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));
958
949
    }
959
950
 
960
 
    if ((ntp_keygenOptions.fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) {
961
 
        tOptDesc* pOD = ntp_keygenOptions.pOptDesc;
962
 
        int       ix;
 
951
    if ((pOpt->fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) {
 
952
        tOptDesc * pOD = pOpt->pOptDesc;
 
953
        int        ix;
963
954
 
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));