From ac90832389e0cf11644bab4c6b4ea1d9da635daa Mon Sep 17 00:00:00 2001 From: inoguchi Date: Wed, 24 Mar 2021 12:07:39 +0000 Subject: [PATCH] Add option type OPTION_ORDER To handle incremental order value, added new option type OPTION_ORDER. openssl(1) x509 requires this option handling, since, - -CA and -signkey require to set both filename and incremental 'num'. - -dates requires to set two variables in a row, startdate and enddate. and this couldn't be solved by OPTION_FLAG_ORD. ok tb@ and "I'd move forward with your current plan." from jsing@ --- usr.bin/openssl/apps.c | 6 +++++- usr.bin/openssl/apps.h | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/usr.bin/openssl/apps.c b/usr.bin/openssl/apps.c index 24a28c7ca52..396a693c6fb 100644 --- a/usr.bin/openssl/apps.c +++ b/usr.bin/openssl/apps.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apps.c,v 1.58 2021/03/17 18:08:32 jsing Exp $ */ +/* $OpenBSD: apps.c,v 1.59 2021/03/24 12:07:39 inoguchi Exp $ */ /* * Copyright (c) 2014 Joel Sing * @@ -2304,6 +2304,10 @@ options_parse(int argc, char **argv, const struct option *opts, char **unnamed, *opt->opt.ulvalue |= opt->ulvalue; break; + case OPTION_ORDER: + *opt->opt.order = ++(*opt->order); + break; + default: fprintf(stderr, "option %s - unknown type %i\n", opt->name, opt->type); diff --git a/usr.bin/openssl/apps.h b/usr.bin/openssl/apps.h index 10612a9c979..d5f3706ee75 100644 --- a/usr.bin/openssl/apps.h +++ b/usr.bin/openssl/apps.h @@ -1,4 +1,4 @@ -/* $OpenBSD: apps.h,v 1.24 2020/09/09 12:47:46 inoguchi Exp $ */ +/* $OpenBSD: apps.h,v 1.25 2021/03/24 12:07:39 inoguchi Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -304,6 +304,7 @@ struct option { OPTION_VALUE_AND, OPTION_VALUE_OR, OPTION_UL_VALUE_OR, + OPTION_ORDER, } type; union { char **arg; @@ -315,9 +316,11 @@ struct option { int *value; unsigned long *ulvalue; time_t *tvalue; + int *order; } opt; const int value; const unsigned long ulvalue; + int *order; }; void options_usage(const struct option *opts); -- 2.20.1