diff --git a/src/Makefile.am b/src/Makefile.am index dbcf6faa24332ca55fc505b9037a6950a1eae734..feb124b8dc052643780d84d3522469b90cff8f69 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ AM_CFLAGS = -std=c99 -D CM_MODPOLDIR=\"${pkgdatadir}\" -I$(top_srcdir)/lib -bin_PROGRAMS = cm classpol ecpp +bin_PROGRAMS = cm classpol ecpp ecpp-check if MPI bin_PROGRAMS += ecpp-mpi endif @@ -17,6 +17,10 @@ ecpp_LDADD = $(top_builddir)/lib/libcm.la ecpp_SOURCES = params.h params.c ecpp.c +ecpp_check_LDADD = $(top_builddir)/lib/libcm.la + +ecpp_check_SOURCES = params.h params.c ecpp-check.c + if MPI ecpp_mpi_LDADD = $(top_builddir)/lib/libcm_mpi.la diff --git a/src/params.c b/src/params.c index d80b09b74780e4185724c3116cae94b27fe39192..715dfc792947cebf38fb5652a4953490e88e4328 100644 --- a/src/params.c +++ b/src/params.c @@ -2,7 +2,7 @@ params.c - command line parameter evaluation -Copyright (C) 2009, 2010, 2021, 2022, 2023 Andreas Enge +Copyright (C) 2009, 2010, 2021, 2022, 2023, 2024 Andreas Enge This file is part of CM. @@ -37,6 +37,7 @@ static void print_t_options (void); static void print_phase_options (void); static void print_help (void); static void print_help_ecpp (void); +static void print_help_ecpp_check (void); static void print_libraries (void); /*****************************************************************************/ @@ -84,8 +85,7 @@ static void print_p_options (void) static void print_f_options (void) { - printf ("-f followed by a file name outputs the certificate to the " - "file.\n"); + printf ("-f followed by a file name for the certificate.\n"); } /*****************************************************************************/ @@ -135,6 +135,16 @@ static void print_help (void) /*****************************************************************************/ +static void print_help_ecpp_check (void) +{ + printf ("The following options are recognised: " + "'-f', '-h'.\n" + "-h prints this help.\n"); + print_f_options (); +} + +/*****************************************************************************/ + static void print_help_ecpp (void) { printf ("The following options are recognised: " @@ -360,3 +370,50 @@ void evaluate_parameters_ecpp (int argc, char* argv [], mpz_ptr n, } /*****************************************************************************/ + +void evaluate_parameters_ecpp_check (int argc, char* argv [], + char **filename) + /* And yet another version for the little program that checks ECPP + certificates stored in a file. */ +{ + int opt; + + *filename = NULL; + + while ((opt = getopt (argc, argv, "hf:")) != -1) { + switch (opt) { + case 'f': + if (optarg == NULL || optarg [0] == '-') { + print_f_options (); + exit (1); + } + else + *filename = optarg; + break; + case 'h': + print_help_ecpp_check (); + exit (0); + case '?': + if (isprint (optopt)) { + printf ("Unknown option '-%c'.\n", optopt); + print_help_ecpp_check (); + } + else { + printf ("Unknown option with character code %i.\n", optopt); + print_help_ecpp_check (); + } + exit (1); + default: + /* Should not occur. */ + exit (1); + } + } + if (*filename == NULL) { + print_f_options (); + exit (1); + } + + print_libraries (); +} + +/*****************************************************************************/ diff --git a/src/params.h b/src/params.h index adee2ffb1f3ace1617462c32f6e22c893ad268cf..ad0d8288bcd3e709bdf28f57c30b621f6246a319 100644 --- a/src/params.h +++ b/src/params.h @@ -2,7 +2,7 @@ params.h - header file for params.c -Copyright (C) 2009, 2010, 2015, 2021, 2022, 2023 Andreas Enge +Copyright (C) 2009, 2010, 2015, 2021, 2022, 2023, 2024 Andreas Enge This file is part of CM. @@ -37,6 +37,8 @@ extern void evaluate_parameters (int argc, char* argv [], int_cl_t *d, extern void evaluate_parameters_ecpp (int argc, char* argv [], mpz_ptr n, bool *output, char** filename, bool *verbose, bool *debug, bool *trust, bool *check, int *phases); +extern void evaluate_parameters_ecpp_check (int argc, char* argv [], + char** filename); #if defined (__cplusplus) }