diff options
author | jsing <> | 2014-12-28 15:48:52 +0000 |
---|---|---|
committer | jsing <> | 2014-12-28 15:48:52 +0000 |
commit | 0a741ac7e42db811df0097733917db45dc05779e (patch) | |
tree | 133d9e945c00870d0638caa5e38213bcb77fe251 /src/usr.bin/openssl/apps.c | |
parent | e4c7f4f3a5e8f184315c03f7e5313a6caf8e5be6 (diff) | |
download | openbsd-0a741ac7e42db811df0097733917db45dc05779e.tar.gz openbsd-0a741ac7e42db811df0097733917db45dc05779e.tar.bz2 openbsd-0a741ac7e42db811df0097733917db45dc05779e.zip |
Provide a mechanism for option parsing to return the number of arguments
that it has consumed. This allows for the handling of multiple unnamed
arguments, including lists of filenames.
Diffstat (limited to '')
-rw-r--r-- | src/usr.bin/openssl/apps.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/usr.bin/openssl/apps.c b/src/usr.bin/openssl/apps.c index 506e421cc1..7c774e4077 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.17 2014/12/28 15:05:38 jsing Exp $ */ | 1 | /* $OpenBSD: apps.c,v 1.18 2014/12/28 15:48:52 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -2242,7 +2242,8 @@ options_usage(struct option *opts) | |||
2242 | } | 2242 | } |
2243 | 2243 | ||
2244 | int | 2244 | int |
2245 | options_parse(int argc, char **argv, struct option *opts, char **unnamed) | 2245 | options_parse(int argc, char **argv, struct option *opts, char **unnamed, |
2246 | int *argsused) | ||
2246 | { | 2247 | { |
2247 | const char *errstr; | 2248 | const char *errstr; |
2248 | struct option *opt; | 2249 | struct option *opt; |
@@ -2260,6 +2261,8 @@ options_parse(int argc, char **argv, struct option *opts, char **unnamed) | |||
2260 | 2261 | ||
2261 | /* Single unnamed argument (without leading hyphen). */ | 2262 | /* Single unnamed argument (without leading hyphen). */ |
2262 | if (*p++ != '-') { | 2263 | if (*p++ != '-') { |
2264 | if (argsused != NULL) | ||
2265 | goto done; | ||
2263 | if (unnamed == NULL) | 2266 | if (unnamed == NULL) |
2264 | goto unknown; | 2267 | goto unknown; |
2265 | if (*unnamed != NULL) | 2268 | if (*unnamed != NULL) |
@@ -2344,6 +2347,10 @@ options_parse(int argc, char **argv, struct option *opts, char **unnamed) | |||
2344 | } | 2347 | } |
2345 | } | 2348 | } |
2346 | 2349 | ||
2350 | done: | ||
2351 | if (argsused != NULL) | ||
2352 | *argsused = i; | ||
2353 | |||
2347 | return (0); | 2354 | return (0); |
2348 | 2355 | ||
2349 | toomany: | 2356 | toomany: |