From: Jean-Michel Vourgère Date: Mon, 2 Nov 2015 14:32:26 +0000 (+0100) Subject: Switch rrd_daemon to use long options X-Git-Tag: v1.6.0~25^2~2^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F682%2Fhead;p=thirdparty%2Frrdtool-1.x.git Switch rrd_daemon to use long options This includes --help option (Fixes https://github.com/oetiker/rrdtool-1.x/issues/495) --- diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c index ed9b1035..b8bf37f3 100644 --- a/src/rrd_daemon.c +++ b/src/rrd_daemon.c @@ -3880,6 +3880,30 @@ static int cleanup (void) /* {{{ */ static int read_options (int argc, char **argv) /* {{{ */ { + struct optparse_long longopts[] = { + {NULL, 'a', OPTPARSE_REQUIRED}, + {NULL, 'B', OPTPARSE_NONE}, + {NULL, 'b', OPTPARSE_REQUIRED}, + {NULL, 'F', OPTPARSE_NONE}, + {NULL, 'f', OPTPARSE_REQUIRED}, + {NULL, 'g', OPTPARSE_NONE}, + {NULL, 'G', OPTPARSE_REQUIRED}, + {"help", 'h', OPTPARSE_NONE}, + {NULL, 'j', OPTPARSE_REQUIRED}, + {NULL, 'L', OPTPARSE_NONE}, + {NULL, 'l', OPTPARSE_REQUIRED}, + {NULL, 'm', OPTPARSE_REQUIRED}, + {NULL, 'O', OPTPARSE_NONE}, + {NULL, 'P', OPTPARSE_REQUIRED}, + {NULL, 'p', OPTPARSE_REQUIRED}, + {NULL, 'R', OPTPARSE_NONE}, + {NULL, 's', OPTPARSE_REQUIRED}, + {NULL, 't', OPTPARSE_REQUIRED}, + {NULL, 'U', OPTPARSE_REQUIRED}, + {NULL, 'w', OPTPARSE_REQUIRED}, + {NULL, 'z', OPTPARSE_REQUIRED}, + {0} + }; struct optparse options; int option; int status = 0; @@ -3893,8 +3917,7 @@ static int read_options (int argc, char **argv) /* {{{ */ default_socket.socket_permissions = (mode_t)-1; optparse_init(&options, argc, argv); - while ((option = optparse(&options, "?a:Bb:Ff:gG:hj:Ll:m:OP:p:Rs:t:U:w:z:")) != -1) - { + while ((option = optparse_long(&options, longopts, NULL)) != -1) { switch (option) { case 'O': @@ -4276,8 +4299,11 @@ static int read_options (int argc, char **argv) /* {{{ */ } break; - case 'h': case '?': + fprintf(stderr, "%s\n", options.errmsg); + /* no break */ + + case 'h': printf ("RRDCacheD %s\n" "Copyright (C) 2008,2009 Florian octo Forster and Kevin Brintnall\n" "\n" @@ -4316,9 +4342,9 @@ static int read_options (int argc, char **argv) /* {{{ */ "to the rrdcached(1) manual page.\n", VERSION); if (option == 'h') - status = -1; - else status = 1; + else + status = -1; break; } /* switch (option) */ } /* while (opt != -1) */