diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2014-12-28 15:48:53 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2014-12-28 15:48:53 +0000 |
commit | 2a00c3ba2d6dd23ec91a9bd0bfe23c815c7ea804 (patch) | |
tree | ec5cb2c17afb9b4b72d4181bf6f0be7965d66ce3 /usr.bin/openssl/apps.c | |
parent | 70224308c131509e526e86c51cb3143582e529a4 (diff) |
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 'usr.bin/openssl/apps.c')
-rw-r--r-- | usr.bin/openssl/apps.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/usr.bin/openssl/apps.c b/usr.bin/openssl/apps.c index 506e421cc12..7c774e40776 100644 --- a/usr.bin/openssl/apps.c +++ b/usr.bin/openssl/apps.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apps.c,v 1.17 2014/12/28 15:05:38 jsing Exp $ */ +/* $OpenBSD: apps.c,v 1.18 2014/12/28 15:48:52 jsing Exp $ */ /* * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> * @@ -2242,7 +2242,8 @@ options_usage(struct option *opts) } int -options_parse(int argc, char **argv, struct option *opts, char **unnamed) +options_parse(int argc, char **argv, struct option *opts, char **unnamed, + int *argsused) { const char *errstr; struct option *opt; @@ -2260,6 +2261,8 @@ options_parse(int argc, char **argv, struct option *opts, char **unnamed) /* Single unnamed argument (without leading hyphen). */ if (*p++ != '-') { + if (argsused != NULL) + goto done; if (unnamed == NULL) goto unknown; if (*unnamed != NULL) @@ -2344,6 +2347,10 @@ options_parse(int argc, char **argv, struct option *opts, char **unnamed) } } +done: + if (argsused != NULL) + *argsused = i; + return (0); toomany: |