From fd28b85e9709b57eef9d1062300aacf2a3b78dab Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Sat, 4 Jan 2020 18:41:20 -0500 Subject: Import getopt_config from pounce --- litterbox.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'litterbox.c') diff --git a/litterbox.c b/litterbox.c index 4c97794..3fac55a 100644 --- a/litterbox.c +++ b/litterbox.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -27,6 +28,11 @@ #include "database.h" +int getopt_config( + int argc, char *const *argv, const char *optstring, + const struct option *longopts, int *longindex +); + static struct tls *client; static void clientWrite(const char *ptr, size_t len) { @@ -624,8 +630,26 @@ int main(int argc, char *argv[]) { const char *user = NULL; const char *pass = NULL; + const char *Opts = "!N:Qd:h:ij:l:mn:p:qu:vw:"; + const struct option LongOpts[] = { + { "insecure", no_argument, NULL, '!' }, + { "network", required_argument, NULL, 'N' }, + { "public-query", no_argument, NULL, 'Q' }, + { "database", required_argument, NULL, 'd' }, + { "host", required_argument, NULL, 'h' }, + { "join", required_argument, NULL, 'j' }, + { "limit", required_argument, NULL, 'l' }, + { "nick", required_argument, NULL, 'n' }, + { "port", required_argument, NULL, 'p' }, + { "private-query", no_argument, NULL, 'q' }, + { "user", required_argument, NULL, 'u' }, + { "verbose", no_argument, NULL, 'v' }, + { "pass", required_argument, NULL, 'w' }, + {0}, + }; + int opt; - while (0 < (opt = getopt(argc, argv, "!N:Qd:h:ij:l:mn:p:qu:vw:"))) { + while (0 < (opt = getopt_config(argc, argv, Opts, LongOpts, NULL))) { switch (opt) { break; case '!': insecure = true; break; case 'N': defaultNetwork = optarg; -- cgit 1.4.1