diff options
Diffstat (limited to 'conf.c')
| -rw-r--r-- | conf.c | 25 |
1 files changed, 21 insertions, 4 deletions
@@ -1153,17 +1153,34 @@ static void conf_sock_listen(const struct ctx *c) /** * conf_tap_fd() - Read tap fd as supplied by -F command line option - * @arg: Argument to -F command line option + * @argc: Argument count + * @argv: Command line options + * + * Return: fd number from --fd option, or -1 if not supplied */ -int conf_tap_fd(const char *arg) +int conf_tap_fd(int argc, char **argv) { - const char *p = arg; + const struct option optfd[] = { { "fd", required_argument, NULL, 'F' }, + { 0 }, }; + const char *fdarg = NULL, *p; unsigned long val; + int name; + + optind = 0; + do { + name = getopt_long(argc, argv, "-:F:", optfd, NULL); + if (name == 'F') + fdarg = optarg; + } while (name != -1); + + if (!fdarg) + return -1; + p = fdarg; if (!parse_unsigned(&p, 0, &val) || !parse_eoi(p) || val > INT_MAX || (val != STDIN_FILENO && val <= STDERR_FILENO)) - die("Invalid --fd: %s", arg); + die("Invalid --fd: %s", fdarg); return val; } |
