diff options
author | jsing <> | 2014-12-28 14:21:42 +0000 |
---|---|---|
committer | jsing <> | 2014-12-28 14:21:42 +0000 |
commit | a8ff639ef64a4a39745c3e48767ad1ae0daa8aae (patch) | |
tree | 9d3a06168c584d1ca915a233182c758c542e7f67 /src | |
parent | 070fa2ca836397fc6db2744ec5f57833916b6511 (diff) | |
download | openbsd-a8ff639ef64a4a39745c3e48767ad1ae0daa8aae.tar.gz openbsd-a8ff639ef64a4a39745c3e48767ad1ae0daa8aae.tar.bz2 openbsd-a8ff639ef64a4a39745c3e48767ad1ae0daa8aae.zip |
Provide two different function pointers for option function callbacks. This
allows for simpler code in the common cases and will allow for further
extension to support the complex cases.
Diffstat (limited to 'src')
-rw-r--r-- | src/usr.bin/openssl/apps.c | 6 | ||||
-rw-r--r-- | src/usr.bin/openssl/apps.h | 5 | ||||
-rw-r--r-- | src/usr.bin/openssl/ecparam.c | 10 | ||||
-rw-r--r-- | src/usr.bin/openssl/version.c | 6 |
4 files changed, 14 insertions, 13 deletions
diff --git a/src/usr.bin/openssl/apps.c b/src/usr.bin/openssl/apps.c index 009f48652a..47c418f424 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.14 2014/12/14 14:42:06 jsing Exp $ */ | 1 | /* $OpenBSD: apps.c,v 1.15 2014/12/28 14:21:42 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -2298,7 +2298,7 @@ options_parse(int argc, char **argv, struct option *opts, char **unnamed) | |||
2298 | break; | 2298 | break; |
2299 | 2299 | ||
2300 | case OPTION_ARG_FUNC: | 2300 | case OPTION_ARG_FUNC: |
2301 | if (opt->func(opt, argv[i]) != 0) | 2301 | if (opt->opt.argfunc(argv[i]) != 0) |
2302 | return (1); | 2302 | return (1); |
2303 | break; | 2303 | break; |
2304 | 2304 | ||
@@ -2314,7 +2314,7 @@ options_parse(int argc, char **argv, struct option *opts, char **unnamed) | |||
2314 | break; | 2314 | break; |
2315 | 2315 | ||
2316 | case OPTION_FUNC: | 2316 | case OPTION_FUNC: |
2317 | if (opt->func(opt, NULL) != 0) | 2317 | if (opt->opt.func() != 0) |
2318 | return (1); | 2318 | return (1); |
2319 | break; | 2319 | break; |
2320 | 2320 | ||
diff --git a/src/usr.bin/openssl/apps.h b/src/usr.bin/openssl/apps.h index b2b7e85107..b069d2d29b 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.9 2014/12/14 14:42:06 jsing Exp $ */ | 1 | /* $OpenBSD: apps.h,v 1.10 2014/12/28 14:21:42 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 | * |
@@ -296,10 +296,11 @@ struct option { | |||
296 | } type; | 296 | } type; |
297 | union { | 297 | union { |
298 | char **arg; | 298 | char **arg; |
299 | int (*argfunc)(char *arg); | ||
299 | int *flag; | 300 | int *flag; |
301 | int (*func)(void); | ||
300 | int *value; | 302 | int *value; |
301 | } opt; | 303 | } opt; |
302 | int (*func)(struct option *opt, char *arg); | ||
303 | const int value; | 304 | const int value; |
304 | }; | 305 | }; |
305 | 306 | ||
diff --git a/src/usr.bin/openssl/ecparam.c b/src/usr.bin/openssl/ecparam.c index 1441fa7d2a..57797a8e4e 100644 --- a/src/usr.bin/openssl/ecparam.c +++ b/src/usr.bin/openssl/ecparam.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ecparam.c,v 1.6 2014/12/14 14:45:33 jsing Exp $ */ | 1 | /* $OpenBSD: ecparam.c,v 1.7 2014/12/28 14:21:42 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Written by Nils Larsch for the OpenSSL project. | 3 | * Written by Nils Larsch for the OpenSSL project. |
4 | */ | 4 | */ |
@@ -111,7 +111,7 @@ static struct { | |||
111 | } ecparam_config; | 111 | } ecparam_config; |
112 | 112 | ||
113 | static int | 113 | static int |
114 | ecparam_opt_form(struct option *opt, char *arg) | 114 | ecparam_opt_form(char *arg) |
115 | { | 115 | { |
116 | if (strcmp(arg, "compressed") == 0) | 116 | if (strcmp(arg, "compressed") == 0) |
117 | ecparam_config.form = POINT_CONVERSION_COMPRESSED; | 117 | ecparam_config.form = POINT_CONVERSION_COMPRESSED; |
@@ -127,7 +127,7 @@ ecparam_opt_form(struct option *opt, char *arg) | |||
127 | } | 127 | } |
128 | 128 | ||
129 | static int | 129 | static int |
130 | ecparam_opt_enctype(struct option *opt, char *arg) | 130 | ecparam_opt_enctype(char *arg) |
131 | { | 131 | { |
132 | if (strcmp(arg, "explicit") == 0) | 132 | if (strcmp(arg, "explicit") == 0) |
133 | ecparam_config.asn1_flag = 0; | 133 | ecparam_config.asn1_flag = 0; |
@@ -159,7 +159,7 @@ struct option ecparam_options[] = { | |||
159 | .desc = "Specify point conversion form:\n" | 159 | .desc = "Specify point conversion form:\n" |
160 | " compressed, uncompressed (default), hybrid", | 160 | " compressed, uncompressed (default), hybrid", |
161 | .type = OPTION_ARG_FUNC, | 161 | .type = OPTION_ARG_FUNC, |
162 | .func = ecparam_opt_form, | 162 | .opt.argfunc = ecparam_opt_form, |
163 | }, | 163 | }, |
164 | #ifndef OPENSSL_NO_ENGINE | 164 | #ifndef OPENSSL_NO_ENGINE |
165 | { | 165 | { |
@@ -237,7 +237,7 @@ struct option ecparam_options[] = { | |||
237 | .desc = "Specify EC parameter ASN.1 encoding type:\n" | 237 | .desc = "Specify EC parameter ASN.1 encoding type:\n" |
238 | " explicit, named_curve (default)", | 238 | " explicit, named_curve (default)", |
239 | .type = OPTION_ARG_FUNC, | 239 | .type = OPTION_ARG_FUNC, |
240 | .func = ecparam_opt_enctype, | 240 | .opt.argfunc = ecparam_opt_enctype, |
241 | }, | 241 | }, |
242 | { | 242 | { |
243 | .name = "text", | 243 | .name = "text", |
diff --git a/src/usr.bin/openssl/version.c b/src/usr.bin/openssl/version.c index db9c98e977..953d0c3afe 100644 --- a/src/usr.bin/openssl/version.c +++ b/src/usr.bin/openssl/version.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: version.c,v 1.3 2014/10/13 02:46:14 bcook Exp $ */ | 1 | /* $OpenBSD: version.c,v 1.4 2014/12/28 14:21:42 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 | * |
@@ -145,7 +145,7 @@ static struct { | |||
145 | } version_config; | 145 | } version_config; |
146 | 146 | ||
147 | static int | 147 | static int |
148 | version_all_opts(struct option *opt, char *arg) | 148 | version_all_opts(void) |
149 | { | 149 | { |
150 | version_config.cflags = 1; | 150 | version_config.cflags = 1; |
151 | version_config.date = 1; | 151 | version_config.date = 1; |
@@ -162,7 +162,7 @@ static struct option version_options[] = { | |||
162 | .name = "a", | 162 | .name = "a", |
163 | .desc = "All information (same as setting all other flags)", | 163 | .desc = "All information (same as setting all other flags)", |
164 | .type = OPTION_FUNC, | 164 | .type = OPTION_FUNC, |
165 | .func = version_all_opts, | 165 | .opt.func = version_all_opts, |
166 | }, | 166 | }, |
167 | { | 167 | { |
168 | .name = "b", | 168 | .name = "b", |