summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2014-08-30 15:14:03 +0000
committerjsing <>2014-08-30 15:14:03 +0000
commit3016f0d916cff2fa5c93e769e25ded6c34e7fb73 (patch)
tree8ed740b7b669337787dbbd76c503eee8d41199e2 /src
parent8e6e28726f906fbe995c6de7cd80d82e57955744 (diff)
downloadopenbsd-3016f0d916cff2fa5c93e769e25ded6c34e7fb73.tar.gz
openbsd-3016f0d916cff2fa5c93e769e25ded6c34e7fb73.tar.bz2
openbsd-3016f0d916cff2fa5c93e769e25ded6c34e7fb73.zip
Move the callback function pointer outside the opt union so that the option
values are useable by the function. Also provide an option type that calls a function without consuming/passing an argument.
Diffstat (limited to 'src')
-rw-r--r--src/usr.bin/openssl/apps.c9
-rw-r--r--src/usr.bin/openssl/apps.h5
2 files changed, 10 insertions, 4 deletions
diff --git a/src/usr.bin/openssl/apps.c b/src/usr.bin/openssl/apps.c
index 7a5def5007..4aac0ff6d2 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.8 2014/08/28 14:15:28 jsing Exp $ */ 1/* $OpenBSD: apps.c,v 1.9 2014/08/30 15:14:03 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -2307,7 +2307,7 @@ options_parse(int argc, char **argv, struct option *opts, char **unnamed)
2307 break; 2307 break;
2308 2308
2309 case OPTION_ARG_FUNC: 2309 case OPTION_ARG_FUNC:
2310 if (opt->opt.func(opt, argv[i]) != 0) 2310 if (opt->func(opt, argv[i]) != 0)
2311 return (1); 2311 return (1);
2312 break; 2312 break;
2313 2313
@@ -2322,6 +2322,11 @@ options_parse(int argc, char **argv, struct option *opts, char **unnamed)
2322 *opt->opt.value = (int)val; 2322 *opt->opt.value = (int)val;
2323 break; 2323 break;
2324 2324
2325 case OPTION_FUNC:
2326 if (opt->func(opt, NULL) != 0)
2327 return (1);
2328 break;
2329
2325 case OPTION_FLAG: 2330 case OPTION_FLAG:
2326 *opt->opt.flag = 1; 2331 *opt->opt.flag = 1;
2327 break; 2332 break;
diff --git a/src/usr.bin/openssl/apps.h b/src/usr.bin/openssl/apps.h
index 277dcc3699..ea6be60a44 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.6 2014/08/28 14:15:28 jsing Exp $ */ 1/* $OpenBSD: apps.h,v 1.7 2014/08/30 15:14:03 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 *
@@ -291,6 +291,7 @@ struct option {
291 OPTION_ARG_FORMAT, 291 OPTION_ARG_FORMAT,
292 OPTION_ARG_FUNC, 292 OPTION_ARG_FUNC,
293 OPTION_ARG_INT, 293 OPTION_ARG_INT,
294 OPTION_FUNC,
294 OPTION_FLAG, 295 OPTION_FLAG,
295 OPTION_FLAG_ORD, 296 OPTION_FLAG_ORD,
296 OPTION_VALUE, 297 OPTION_VALUE,
@@ -298,9 +299,9 @@ struct option {
298 union { 299 union {
299 char **arg; 300 char **arg;
300 int *flag; 301 int *flag;
301 int (*func)(struct option *opt, char *arg);
302 int *value; 302 int *value;
303 } opt; 303 } opt;
304 int (*func)(struct option *opt, char *arg);
304 const int value; 305 const int value;
305}; 306};
306 307