From 370c300ca14472f9c425a65aae243e3b9a143858 Mon Sep 17 00:00:00 2001 From: jsing <> Date: Wed, 15 Jul 2015 13:54:34 +0000 Subject: Add OPTION_ARG_LONG for handling of options with a long type. ok doug@ --- src/usr.bin/openssl/apps.c | 15 +++++++++++++-- src/usr.bin/openssl/apps.h | 4 +++- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/usr.bin/openssl/apps.c b/src/usr.bin/openssl/apps.c index 2b2c0a9c1c..586b3c624a 100644 --- a/src/usr.bin/openssl/apps.c +++ b/src/usr.bin/openssl/apps.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apps.c,v 1.27 2015/06/19 07:18:58 bcook Exp $ */ +/* $OpenBSD: apps.c,v 1.28 2015/07/15 13:54:34 jsing Exp $ */ /* * Copyright (c) 2014 Joel Sing * @@ -2284,7 +2284,8 @@ options_parse(int argc, char **argv, struct option *opts, char **unnamed, if (opt->type == OPTION_ARG || opt->type == OPTION_ARG_FORMAT || opt->type == OPTION_ARG_FUNC || - opt->type == OPTION_ARG_INT) { + opt->type == OPTION_ARG_INT || + opt->type == OPTION_ARG_LONG) { if (++i >= argc) { fprintf(stderr, "missing %s argument for -%s\n", opt->argname, opt->name); @@ -2328,6 +2329,16 @@ options_parse(int argc, char **argv, struct option *opts, char **unnamed, *opt->opt.value = (int)val; break; + case OPTION_ARG_LONG: + val = strtonum(argv[i], 0, LONG_MAX, &errstr); + if (errstr != NULL) { + fprintf(stderr, "%s %s argument for -%s\n", + errstr, opt->argname, opt->name); + return (1); + } + *opt->opt.lvalue = (long)val; + break; + case OPTION_DISCARD: break; diff --git a/src/usr.bin/openssl/apps.h b/src/usr.bin/openssl/apps.h index dddfeeea7f..f6e0a8ce19 100644 --- a/src/usr.bin/openssl/apps.h +++ b/src/usr.bin/openssl/apps.h @@ -1,4 +1,4 @@ -/* $OpenBSD: apps.h,v 1.13 2015/01/01 14:28:00 jsing Exp $ */ +/* $OpenBSD: apps.h,v 1.14 2015/07/15 13:54:34 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -290,6 +290,7 @@ struct option { OPTION_ARG_FORMAT, OPTION_ARG_FUNC, OPTION_ARG_INT, + OPTION_ARG_LONG, OPTION_DISCARD, OPTION_FUNC, OPTION_FLAG, @@ -304,6 +305,7 @@ struct option { int (*argvfunc)(int argc, char **argv, int *argsused); int *flag; int (*func)(void); + long *lvalue; int *value; } opt; const int value; -- cgit v1.2.3-55-g6feb