From 1cb342c794f88a110551fd76c9c150609898de86 Mon Sep 17 00:00:00 2001 From: jsing Date: Thu, 1 Jan 2015 14:28:00 +0000 Subject: [PATCH] Provide option types for binary AND, binary OR and silently discarding an option. --- usr.bin/openssl/apps.c | 10 +++++++++- usr.bin/openssl/apps.h | 5 ++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/usr.bin/openssl/apps.c b/usr.bin/openssl/apps.c index d3c31947f35..5a6bb7a2ee5 100644 --- a/usr.bin/openssl/apps.c +++ b/usr.bin/openssl/apps.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apps.c,v 1.22 2014/12/28 16:51:31 jsing Exp $ */ +/* $OpenBSD: apps.c,v 1.23 2015/01/01 14:28:00 jsing Exp $ */ /* * Copyright (c) 2014 Joel Sing * @@ -2359,6 +2359,14 @@ options_parse(int argc, char **argv, struct option *opts, char **unnamed, *opt->opt.value = opt->value; break; + case OPTION_VALUE_AND: + *opt->opt.value &= opt->value; + break; + + case OPTION_VALUE_OR: + *opt->opt.value |= opt->value; + 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 f0571480e28..dddfeeea7ff 100644 --- a/usr.bin/openssl/apps.h +++ b/usr.bin/openssl/apps.h @@ -1,4 +1,4 @@ -/* $OpenBSD: apps.h,v 1.12 2014/12/28 16:22:37 jsing Exp $ */ +/* $OpenBSD: apps.h,v 1.13 2015/01/01 14:28:00 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -290,10 +290,13 @@ struct option { OPTION_ARG_FORMAT, OPTION_ARG_FUNC, OPTION_ARG_INT, + OPTION_DISCARD, OPTION_FUNC, OPTION_FLAG, OPTION_FLAG_ORD, OPTION_VALUE, + OPTION_VALUE_AND, + OPTION_VALUE_OR, } type; union { char **arg; -- 2.20.1