From 51234868c810b6704dd04988bba2016a0f12b918 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Sat, 9 Aug 2014 11:22:47 +0200 Subject: allow to use long command line arguments --- dyndhcpd.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dyndhcpd.c b/dyndhcpd.c index 8bc1f34..59a197a 100644 --- a/dyndhcpd.c +++ b/dyndhcpd.c @@ -16,10 +16,21 @@ #include #include #include +#include #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; -- cgit v1.2.3-70-g09d2