diff options
author | Christian Hesse <mail@eworm.de> | 2014-08-09 11:22:47 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2014-08-09 11:22:47 +0200 |
commit | 51234868c810b6704dd04988bba2016a0f12b918 (patch) | |
tree | 89506cd2e93ba2ee45bd14820b5e55925312a443 | |
parent | 87152f706fe56b6c44bbd3ea9c994cd8a60595b7 (diff) | |
download | dyndhcpd-51234868c810b6704dd04988bba2016a0f12b918.tar.gz dyndhcpd-51234868c810b6704dd04988bba2016a0f12b918.tar.zst |
allow to use long command line arguments
-rw-r--r-- | dyndhcpd.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -16,10 +16,21 @@ #include <stdlib.h> #include <unistd.h> #include <string.h> +#include <getopt.h> #include "config.h" #include "version.h" +const static char optstring[] = "c:hi:v"; +const static struct option options_long[] = { + /* name has_arg flag val */ + { "config", required_argument, NULL, 'c' }, + { "help", no_argument, NULL, 'h' }, + { "interface", required_argument, NULL, 'i' }, + { "verbose", no_argument, NULL, 'v' }, + { 0, 0, 0, 0 } +}; + /*** str_replace ***/ char * str_replace(char * original, const char * pattern, const char * replacement) { size_t const replen = strlen(replacement); @@ -86,7 +97,7 @@ int main(int argc, char ** argv) { printf("Starting dyndhcpd/" VERSION " (compiled: " __DATE__ ", " __TIME__ ")\n"); /* get command line options */ - while ((i = getopt(argc, argv, "c:hi:v")) != -1) + while ((i = getopt_long(argc, argv, optstring, options_long, NULL)) != -1) switch (i) { case 'c': config_template = optarg; |