diff options
| author | jsing <> | 2015-07-15 13:54:34 +0000 |
|---|---|---|
| committer | jsing <> | 2015-07-15 13:54:34 +0000 |
| commit | 54df0addc5c67cbdbda56821f44ae7e2937dc466 (patch) | |
| tree | cc2003ab0da4d8c980719e372679ce99c10982a0 /src | |
| parent | 5f53df987283606068383152434ac994e82890e6 (diff) | |
| download | openbsd-54df0addc5c67cbdbda56821f44ae7e2937dc466.tar.gz openbsd-54df0addc5c67cbdbda56821f44ae7e2937dc466.tar.bz2 openbsd-54df0addc5c67cbdbda56821f44ae7e2937dc466.zip | |
Add OPTION_ARG_LONG for handling of options with a long type.
ok doug@
Diffstat (limited to '')
| -rw-r--r-- | src/usr.bin/openssl/apps.c | 15 | ||||
| -rw-r--r-- | src/usr.bin/openssl/apps.h | 4 |
2 files changed, 16 insertions, 3 deletions
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 @@ | |||
| 1 | /* $OpenBSD: apps.c,v 1.27 2015/06/19 07:18:58 bcook Exp $ */ | 1 | /* $OpenBSD: apps.c,v 1.28 2015/07/15 13:54:34 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
| 4 | * | 4 | * |
| @@ -2284,7 +2284,8 @@ options_parse(int argc, char **argv, struct option *opts, char **unnamed, | |||
| 2284 | if (opt->type == OPTION_ARG || | 2284 | if (opt->type == OPTION_ARG || |
| 2285 | opt->type == OPTION_ARG_FORMAT || | 2285 | opt->type == OPTION_ARG_FORMAT || |
| 2286 | opt->type == OPTION_ARG_FUNC || | 2286 | opt->type == OPTION_ARG_FUNC || |
| 2287 | opt->type == OPTION_ARG_INT) { | 2287 | opt->type == OPTION_ARG_INT || |
| 2288 | opt->type == OPTION_ARG_LONG) { | ||
| 2288 | if (++i >= argc) { | 2289 | if (++i >= argc) { |
| 2289 | fprintf(stderr, "missing %s argument for -%s\n", | 2290 | fprintf(stderr, "missing %s argument for -%s\n", |
| 2290 | opt->argname, opt->name); | 2291 | opt->argname, opt->name); |
| @@ -2328,6 +2329,16 @@ options_parse(int argc, char **argv, struct option *opts, char **unnamed, | |||
| 2328 | *opt->opt.value = (int)val; | 2329 | *opt->opt.value = (int)val; |
| 2329 | break; | 2330 | break; |
| 2330 | 2331 | ||
| 2332 | case OPTION_ARG_LONG: | ||
| 2333 | val = strtonum(argv[i], 0, LONG_MAX, &errstr); | ||
| 2334 | if (errstr != NULL) { | ||
| 2335 | fprintf(stderr, "%s %s argument for -%s\n", | ||
| 2336 | errstr, opt->argname, opt->name); | ||
| 2337 | return (1); | ||
| 2338 | } | ||
| 2339 | *opt->opt.lvalue = (long)val; | ||
| 2340 | break; | ||
| 2341 | |||
| 2331 | case OPTION_DISCARD: | 2342 | case OPTION_DISCARD: |
| 2332 | break; | 2343 | break; |
| 2333 | 2344 | ||
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 @@ | |||
| 1 | /* $OpenBSD: apps.h,v 1.13 2015/01/01 14:28:00 jsing Exp $ */ | 1 | /* $OpenBSD: apps.h,v 1.14 2015/07/15 13:54:34 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -290,6 +290,7 @@ struct option { | |||
| 290 | OPTION_ARG_FORMAT, | 290 | OPTION_ARG_FORMAT, |
| 291 | OPTION_ARG_FUNC, | 291 | OPTION_ARG_FUNC, |
| 292 | OPTION_ARG_INT, | 292 | OPTION_ARG_INT, |
| 293 | OPTION_ARG_LONG, | ||
| 293 | OPTION_DISCARD, | 294 | OPTION_DISCARD, |
| 294 | OPTION_FUNC, | 295 | OPTION_FUNC, |
| 295 | OPTION_FLAG, | 296 | OPTION_FLAG, |
| @@ -304,6 +305,7 @@ struct option { | |||
| 304 | int (*argvfunc)(int argc, char **argv, int *argsused); | 305 | int (*argvfunc)(int argc, char **argv, int *argsused); |
| 305 | int *flag; | 306 | int *flag; |
| 306 | int (*func)(void); | 307 | int (*func)(void); |
| 308 | long *lvalue; | ||
| 307 | int *value; | 309 | int *value; |
| 308 | } opt; | 310 | } opt; |
| 309 | const int value; | 311 | const int value; |
