arbitrary number of arguments. This will allow for more complex option
handling as required by some of the openssl(1) applications.
-/* $OpenBSD: apps.c,v 1.19 2014/12/28 16:10:33 jsing Exp $ */
+/* $OpenBSD: apps.c,v 1.20 2014/12/28 16:22:37 jsing Exp $ */
/*
* Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
*
struct option *opt;
long long val;
char *arg, *p;
+ int fmt, used;
int ord = 0;
int i, j;
- int fmt;
if (unnamed != NULL)
*unnamed = NULL;
goto unknown;
}
+ /* See if there is a matching option... */
for (j = 0; opts[j].name != NULL; j++) {
opt = &opts[j];
if (strcmp(p, opt->name) == 0)
*opt->opt.arg = argv[i];
break;
+ case OPTION_ARGV_FUNC:
+ if (opt->opt.argvfunc(argc - i, &argv[i], &used) != 0)
+ return (1);
+ i += used - 1;
+ break;
+
case OPTION_ARG_FORMAT:
fmt = str2fmt(argv[i]);
if (fmt == FORMAT_UNDEF) {
-/* $OpenBSD: apps.h,v 1.11 2014/12/28 15:48:52 jsing Exp $ */
+/* $OpenBSD: apps.h,v 1.12 2014/12/28 16:22:37 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
const char *desc;
enum {
OPTION_ARG,
+ OPTION_ARGV_FUNC,
OPTION_ARG_FORMAT,
OPTION_ARG_FUNC,
OPTION_ARG_INT,
union {
char **arg;
int (*argfunc)(char *arg);
+ int (*argvfunc)(int argc, char **argv, int *argsused);
int *flag;
int (*func)(void);
int *value;