summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsing <jsing@openbsd.org>2014-08-30 15:14:03 +0000
committerjsing <jsing@openbsd.org>2014-08-30 15:14:03 +0000
commit0c2cbfefde83c77a9db3c0ff397eabb9957cbdb8 (patch)
tree7d382a40026047fffb46a0c4cef558127b11cbb8
parentIndent. (diff)
downloadwireguard-openbsd-0c2cbfefde83c77a9db3c0ff397eabb9957cbdb8.tar.xz
wireguard-openbsd-0c2cbfefde83c77a9db3c0ff397eabb9957cbdb8.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.
-rw-r--r--usr.bin/openssl/apps.c9
-rw-r--r--usr.bin/openssl/apps.h5
2 files changed, 10 insertions, 4 deletions
diff --git a/usr.bin/openssl/apps.c b/usr.bin/openssl/apps.c
index 7a5def5007d..4aac0ff6d2d 100644
--- a/usr.bin/openssl/apps.c
+++ b/usr.bin/openssl/apps.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apps.c,v 1.8 2014/08/28 14:15:28 jsing Exp $ */
+/* $OpenBSD: apps.c,v 1.9 2014/08/30 15:14:03 jsing Exp $ */
/*
* Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
*
@@ -2307,7 +2307,7 @@ options_parse(int argc, char **argv, struct option *opts, char **unnamed)
break;
case OPTION_ARG_FUNC:
- if (opt->opt.func(opt, argv[i]) != 0)
+ if (opt->func(opt, argv[i]) != 0)
return (1);
break;
@@ -2322,6 +2322,11 @@ options_parse(int argc, char **argv, struct option *opts, char **unnamed)
*opt->opt.value = (int)val;
break;
+ case OPTION_FUNC:
+ if (opt->func(opt, NULL) != 0)
+ return (1);
+ break;
+
case OPTION_FLAG:
*opt->opt.flag = 1;
break;
diff --git a/usr.bin/openssl/apps.h b/usr.bin/openssl/apps.h
index 277dcc36997..ea6be60a447 100644
--- a/usr.bin/openssl/apps.h
+++ b/usr.bin/openssl/apps.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: apps.h,v 1.6 2014/08/28 14:15:28 jsing Exp $ */
+/* $OpenBSD: apps.h,v 1.7 2014/08/30 15:14:03 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -291,6 +291,7 @@ struct option {
OPTION_ARG_FORMAT,
OPTION_ARG_FUNC,
OPTION_ARG_INT,
+ OPTION_FUNC,
OPTION_FLAG,
OPTION_FLAG_ORD,
OPTION_VALUE,
@@ -298,9 +299,9 @@ struct option {
union {
char **arg;
int *flag;
- int (*func)(struct option *opt, char *arg);
int *value;
} opt;
+ int (*func)(struct option *opt, char *arg);
const int value;
};