diff options
author | jsing <> | 2014-08-28 14:15:28 +0000 |
---|---|---|
committer | jsing <> | 2014-08-28 14:15:28 +0000 |
commit | 31c9e04aeb255ae1ae51c6f06be5e4714c9e9054 (patch) | |
tree | 7ad8821d2764d0d699b6be9caad478781a13d65f /src/usr.bin/openssl/apps.c | |
parent | f430ac8944374866d079eae7d55e530af6edae73 (diff) | |
download | openbsd-31c9e04aeb255ae1ae51c6f06be5e4714c9e9054.tar.gz openbsd-31c9e04aeb255ae1ae51c6f06be5e4714c9e9054.tar.bz2 openbsd-31c9e04aeb255ae1ae51c6f06be5e4714c9e9054.zip |
Add option handling with a callback function for argument processing.
Diffstat (limited to 'src/usr.bin/openssl/apps.c')
-rw-r--r-- | src/usr.bin/openssl/apps.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/usr.bin/openssl/apps.c b/src/usr.bin/openssl/apps.c index 76977ec44a..7a5def5007 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.7 2014/08/28 13:55:19 jsing Exp $ */ | 1 | /* $OpenBSD: apps.c,v 1.8 2014/08/28 14:15:28 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -2280,6 +2280,7 @@ options_parse(int argc, char **argv, struct option *opts, char **unnamed) | |||
2280 | 2280 | ||
2281 | if (opt->type == OPTION_ARG || | 2281 | if (opt->type == OPTION_ARG || |
2282 | opt->type == OPTION_ARG_FORMAT || | 2282 | opt->type == OPTION_ARG_FORMAT || |
2283 | opt->type == OPTION_ARG_FUNC || | ||
2283 | opt->type == OPTION_ARG_INT) { | 2284 | opt->type == OPTION_ARG_INT) { |
2284 | if (++i >= argc) { | 2285 | if (++i >= argc) { |
2285 | fprintf(stderr, | 2286 | fprintf(stderr, |
@@ -2305,6 +2306,11 @@ options_parse(int argc, char **argv, struct option *opts, char **unnamed) | |||
2305 | *opt->opt.value = fmt; | 2306 | *opt->opt.value = fmt; |
2306 | break; | 2307 | break; |
2307 | 2308 | ||
2309 | case OPTION_ARG_FUNC: | ||
2310 | if (opt->opt.func(opt, argv[i]) != 0) | ||
2311 | return (1); | ||
2312 | break; | ||
2313 | |||
2308 | case OPTION_ARG_INT: | 2314 | case OPTION_ARG_INT: |
2309 | val = strtonum(argv[i], 0, INT_MAX, &errstr); | 2315 | val = strtonum(argv[i], 0, INT_MAX, &errstr); |
2310 | if (errstr != NULL) { | 2316 | if (errstr != NULL) { |