]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
utils: add the "-VV" option for listing compile time configuration summary
authorDaniel Salzman <daniel.salzman@nic.cz>
Mon, 23 Oct 2023 11:17:55 +0000 (13:17 +0200)
committerDaniel Salzman <daniel.salzman@nic.cz>
Wed, 25 Oct 2023 17:41:53 +0000 (19:41 +0200)
40 files changed:
doc/man/kcatalogprint.8in
doc/man/kdig.1in
doc/man/keymgr.8in
doc/man/khost.1in
doc/man/kjournalprint.8in
doc/man/knotc.8in
doc/man/knotd.8in
doc/man/knsec3hash.1in
doc/man/knsupdate.1in
doc/man/kxdpgun.8in
doc/man/kzonecheck.1in
doc/man/kzonesign.1in
doc/man_kcatalogprint.rst
doc/man_kdig.rst
doc/man_keymgr.rst
doc/man_khost.rst
doc/man_kjournalprint.rst
doc/man_knotc.rst
doc/man_knotd.rst
doc/man_knsec3hash.rst
doc/man_knsupdate.rst
doc/man_kxdpgun.rst
doc/man_kzonecheck.rst
doc/man_kzonesign.rst
src/contrib/string.c
src/contrib/string.h
src/knot/ctl/commands.c
src/utils/common/params.h
src/utils/kcatalogprint/main.c
src/utils/kdig/kdig_params.c
src/utils/keymgr/main.c
src/utils/khost/khost_params.c
src/utils/kjournalprint/main.c
src/utils/knotc/main.c
src/utils/knotd/main.c
src/utils/knsec3hash/knsec3hash.c
src/utils/knsupdate/knsupdate_params.c
src/utils/kxdpgun/main.c
src/utils/kzonecheck/main.c
src/utils/kzonesign/main.c

index fe8fd29da8ef18850a0f8c49901041fee220f1de..b4e2f494d2d24a08f6737f979a1241532ab41495 100644 (file)
@@ -63,7 +63,8 @@ Filter the output by member zone name.
 Print the program help.
 .TP
 \fB\-V\fP, \fB\-\-version\fP
-Print the program version.
+Print the program version. The option \fB\-VV\fP makes the program
+print the compile time configuration summary.
 .UNINDENT
 .SH EXIT VALUES
 .sp
index 12d874e6eedc6e7a7c7555e5c044da06f51720fc..952bb26fc303d6804464e415653e24ae8d7c5b36 100644 (file)
@@ -132,7 +132,8 @@ is provided, empty question section is set.
 An explicit \fIquery_type\fP specification. See possible values above.
 .TP
 \fB\-V\fP, \fB\-\-version\fP
-Print the program version.
+Print the program version. The option \fB\-VV\fP makes the program
+print the compile time configuration summary.
 .TP
 \fB\-x\fP \fIaddress\fP
 Send a reverse (PTR) query for IPv4 or IPv6 \fIaddress\fP\&. The correct name, class
index e32a5d914cbf7263f10262dae55b38d80b112e64..fbe23426531a0783a71537a6967b649bfbc6244e 100644 (file)
@@ -96,7 +96,8 @@ Force colorized output in the normal mode.
 Print the program help.
 .TP
 \fB\-V\fP, \fB\-\-version\fP
-Print the program version.
+Print the program version. The option \fB\-VV\fP makes the program
+print the compile time configuration summary.
 .UNINDENT
 .sp
 \fBNOTE:\fP
index d0f0e7c6c8474c5b9d2b8ea40524770477b93746..d82d522d249ec4343336b29fbbddc572a6fc254d 100644 (file)
@@ -80,7 +80,8 @@ Use the TCP protocol.
 Enable verbose output.
 .TP
 \fB\-V\fP, \fB\-\-version\fP
-Print the program version.
+Print the program version. The option \fB\-VV\fP makes the program
+print the compile time configuration summary.
 .TP
 \fB\-w\fP
 Wait forever for the reply.
index 506ffbec87c5455ca45dd3aa821c255bc243401a..4924e2afa20bc81f9f641747a1f8d1719571e0e5 100644 (file)
@@ -90,7 +90,8 @@ Force colorized output.
 Print the program help.
 .TP
 \fB\-V\fP, \fB\-\-version\fP
-Print the program version.
+Print the program version. The option \fB\-VV\fP makes the program
+print the compile time configuration summary.
 .UNINDENT
 .SH EXIT VALUES
 .sp
index db0bb74430a7b438273575e6768480965553a0c3..dfeabf25b589b7029b40eb77d0dbcf33da1f6bc6 100644 (file)
@@ -88,7 +88,8 @@ Enable debug output.
 Print the program help.
 .TP
 \fB\-V\fP, \fB\-\-version\fP
-Print the program version.
+Print the program version. The option \fB\-VV\fP makes the program
+print the compile time configuration summary.
 .UNINDENT
 .SS Actions
 .INDENT 0.0
index 13cee343940f65d0310731d8b61f5dfbfe38e5c8..234fb8eea6b5eda19f2d281199140cc796639d31 100644 (file)
@@ -69,7 +69,8 @@ Enable debug output.
 Print the program help.
 .TP
 \fB\-V\fP, \fB\-\-version\fP
-Print the program version.
+Print the program version. The option \fB\-VV\fP makes the program
+print the compile time configuration summary.
 .UNINDENT
 .SS Signals
 .sp
index fc1dc5a174de331aa537a97678dfc86afd1eb8d5..aba77d4beca319d27f66c3c09b1b6cf114c241f9 100644 (file)
@@ -35,6 +35,8 @@ knsec3hash \- Simple utility to compute NSEC3 hash
 \fBknsec3hash\fP \fIsalt\fP \fIalgorithm\fP \fIiterations\fP \fIname\fP
 .sp
 \fBknsec3hash\fP \fIalgorithm\fP \fIflags\fP \fIiterations\fP \fIsalt\fP \fIname\fP
+.sp
+\fBknsec3hash\fP [\fI\-h\fP] [\fI\-V\fP]
 .SH DESCRIPTION
 .sp
 This utility generates a NSEC3 hash for a given domain name and parameters of NSEC3 hash.
@@ -56,6 +58,16 @@ Specifies the domain name to be hashed.
 \fIflags\fP
 Specifies NSEC3 flags as an unsigned integer.
 .UNINDENT
+.SS Options
+.INDENT 0.0
+.TP
+\fB\-h\fP, \fB\-\-help\fP
+Print the program help.
+.TP
+\fB\-V\fP, \fB\-\-version\fP
+Print the program version. The option \fB\-VV\fP makes the program
+print the compile time configuration summary.
+.UNINDENT
 .SH EXIT VALUES
 .sp
 Exit status of 0 means successful operation. Any other exit status indicates
index 91a9394e2f1eb282d97aa28adae87dfbb40ce725..2849a277a13a343f4d76ee21e013bc876bd1051a 100644 (file)
@@ -77,7 +77,8 @@ The default is 12. If set to zero, the timeout is infinite.
 Use a TCP connection.
 .TP
 \fB\-V\fP, \fB\-\-version\fP
-Print the program version.
+Print the program version. The option \fB\-VV\fP makes the program
+print the compile time configuration summary.
 .TP
 \fB\-y\fP [\fIalg\fP:]\fIname\fP:\fIkey\fP
 Use the TSIG key with a name \fIname\fP to authenticate the request. The \fIalg\fP
index e5e9a88894e46e4702c1d2af83cbd7e58d1c4d48..ef8ad618e716a97ddaa44beba3441b581e104add 100644 (file)
@@ -136,7 +136,8 @@ with \fB\-\-quic=R\fP or with low QPS. Otherwise, too many files are generated.
 Print the program help.
 .TP
 \fB\-V\fP, \fB\-\-version\fP
-Print the program version.
+Print the program version. The option \fB\-VV\fP makes the program
+print the compile time configuration summary.
 .UNINDENT
 .SS Queries file format
 .sp
index a10c64f6dff8068a125ba15d2ce5e57951021d15..e9c907c5895a5abeb427e8025ad7409eda17da2f 100644 (file)
@@ -74,7 +74,8 @@ Enable debug output.
 Print the program help.
 .TP
 \fB\-V\fP, \fB\-\-version\fP
-Print the program version.
+Print the program version. The option \fB\-VV\fP makes the program
+print the compile time configuration summary.
 .UNINDENT
 .SH EXIT VALUES
 .sp
index 170fd107d4786cdab713094f360e3077ad9a9f70..135840b925a7f9e1e738920b8bdbc3274315ca8f 100644 (file)
@@ -78,7 +78,8 @@ specified by timestamp.
 Print the program help.
 .TP
 \fB\-V\fP, \fB\-\-version\fP
-Print the program version.
+Print the program version. The option \fB\-VV\fP makes the program
+print the compile time configuration summary.
 .UNINDENT
 .SH EXIT VALUES
 .sp
index 31af770492b8f9293cc00ed5f8ed45ef3980f15f..9e62a9da1d560929472fe730e2d997a816764eb6 100644 (file)
@@ -40,7 +40,8 @@ Options
   Print the program help.
 
 **-V**, **--version**
-  Print the program version.
+  Print the program version. The option **-VV** makes the program
+  print the compile time configuration summary.
 
 Exit values
 -----------
index d40efe8e10cd8bc9d3b80baa6ef8344989cfaca0..b77caa9ab1670a12bcda7fa5a786673228793efe 100644 (file)
@@ -111,7 +111,8 @@ Options
   An explicit *query_type* specification. See possible values above.
 
 **-V**, **--version**
-  Print the program version.
+  Print the program version. The option **-VV** makes the program
+  print the compile time configuration summary.
 
 **-x** *address*
   Send a reverse (PTR) query for IPv4 or IPv6 *address*. The correct name, class
index 481292d1b227297d93fbbb587b924564c5d329d7..503cac50420bf469c128d98b71da983259cbc06a 100644 (file)
@@ -73,7 +73,8 @@ Options
   Print the program help.
 
 **-V**, **--version**
-  Print the program version.
+  Print the program version. The option **-VV** makes the program
+  print the compile time configuration summary.
 
 .. NOTE::
    Keymgr runs with the same user privileges as configured for :doc:`knotd<man_knotd>`.
index 76fa9c81d31d1d234a7556589bf638ad43217c69..69c66d96f99e77800d595c593a1eb596d768e845 100644 (file)
@@ -57,7 +57,8 @@ Options
   Enable verbose output.
 
 **-V**, **--version**
-  Print the program version.
+  Print the program version. The option **-VV** makes the program
+  print the compile time configuration summary.
 
 **-w**
   Wait forever for the reply.
index fc743128059dc2b18993bdc582f8ef87e143d3d2..33cdde7bbc926e0e131fd35f01932ec77aa7c046 100644 (file)
@@ -67,7 +67,8 @@ Options
   Print the program help.
 
 **-V**, **--version**
-  Print the program version.
+  Print the program version. The option **-VV** makes the program
+  print the compile time configuration summary.
 
 Exit values
 -----------
index 5c16b522c1762bc3b10d8e3dd78a974b9e123ad3..6fad8f3a8724d4ed4b577cfe91161977bd2c82e1 100644 (file)
@@ -65,7 +65,8 @@ Options
   Print the program help.
 
 **-V**, **--version**
-  Print the program version.
+  Print the program version. The option **-VV** makes the program
+  print the compile time configuration summary.
 
 Actions
 .......
index beb12a907aedca2437f3329a92d639a048773914..d467f4fbbabf7df2683b8d42b33f2438b615b9cf 100644 (file)
@@ -46,7 +46,8 @@ Options
   Print the program help.
 
 **-V**, **--version**
-  Print the program version.
+  Print the program version. The option **-VV** makes the program
+  print the compile time configuration summary.
 
 Signals
 .......
index 946cad9f54d88498b67daf25038aa75fbddfdc06..157f9471ca1e05604907ac6c121087bb6671da27 100644 (file)
@@ -10,6 +10,8 @@ Synopsis
 
 :program:`knsec3hash` *algorithm* *flags* *iterations* *salt* *name*
 
+:program:`knsec3hash` [*-h*] [*-V*]
+
 Description
 -----------
 
@@ -33,6 +35,16 @@ Parameters
 *flags*
   Specifies NSEC3 flags as an unsigned integer.
 
+Options
+.......
+
+**-h**, **--help**
+  Print the program help.
+
+**-V**, **--version**
+  Print the program version. The option **-VV** makes the program
+  print the compile time configuration summary.
+
 Exit values
 -----------
 
index 38feb96e6cb758f74b1412e6f271e19ad9c03799..996dc49c5b7993da37d72c9669f57bee8143d14b 100644 (file)
@@ -54,7 +54,8 @@ Options
   Use a TCP connection.
 
 **-V**, **--version**
-  Print the program version.
+  Print the program version. The option **-VV** makes the program
+  print the compile time configuration summary.
 
 **-y** [*alg*:]\ *name*:*key*
   Use the TSIG key with a name *name* to authenticate the request. The *alg*
index c98fb04b103e7cf9bc74321d12d8cd9e193e999a..5bd88634620f75482ac3028aa0f947d9a5a6c9f8 100644 (file)
@@ -111,7 +111,8 @@ Options
   Print the program help.
 
 **-V**, **--version**
-  Print the program version.
+  Print the program version. The option **-VV** makes the program
+  print the compile time configuration summary.
 
 Queries file format
 ...................
index 44fd0b9e35c4ce73152b7a0929f255de5d060e96..d251742d88d181af455a6af0fd47516458e17eed 100644 (file)
@@ -51,7 +51,8 @@ Options
   Print the program help.
 
 **-V**, **--version**
-  Print the program version.
+  Print the program version. The option **-VV** makes the program
+  print the compile time configuration summary.
 
 Exit values
 -----------
index 9552afac8d4ba50260b956ec4d11a1612da62dfc..e87a0592f1ca2f114bd57f2296364350b493541f 100644 (file)
@@ -55,7 +55,8 @@ Options
   Print the program help.
 
 **-V**, **--version**
-  Print the program version.
+  Print the program version. The option **-VV** makes the program
+  print the compile time configuration summary.
 
 Exit values
 -----------
index 272116e725dbe9386b448b35803a57e474f9f08b..9c8817f329e4a661a6e0ba9edb08349ca0dd9c9e 100644 (file)
@@ -1,4 +1,4 @@
-/*  Copyright (C) 2021 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/*  Copyright (C) 2023 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -36,6 +36,8 @@
 #include "contrib/ctype.h"
 #include "contrib/tolower.h"
 
+const char *configure_summary = CONFIGURE_SUMMARY;
+
 uint8_t *memdup(const uint8_t *data, size_t data_size)
 {
        uint8_t *result = (uint8_t *)malloc(data_size);
index ad3c990bae0ffd10e5197562c805c7591bb02159..3e113b1514993806f76c7508273ed2c02211736d 100644 (file)
@@ -1,4 +1,4 @@
-/*  Copyright (C) 2022 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/*  Copyright (C) 2023 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -24,6 +24,8 @@
 #include <stddef.h>
 #include <stdint.h>
 
+extern const char *configure_summary;
+
 /*!
  * \brief Create a copy of a binary buffer.
  *
index 135b2967dd8c53893b9a51142c26fff8aba72823..b1d5ea6d7829347af19cc05701c61f1374c0af73 100644 (file)
@@ -1900,7 +1900,7 @@ static int server_status(ctl_args_t *args)
                               conf()->cache.srv_xdp_threads, conf()->cache.srv_bg_threads,
                               running_bkg_wrk, wrk_queue);
        } else if (strcasecmp(type, "configure") == 0) {
-               ret = snprintf(buff, sizeof(buff), "%s", CONFIGURE_SUMMARY);
+               ret = snprintf(buff, sizeof(buff), "%s", configure_summary);
        } else if (strcasecmp(type, "cert-key") == 0) {
                uint8_t pin[128];
                size_t pin_len = server_cert_pin(args->server, pin, sizeof(pin));
index 8b7565e98aef600f55fd6bc50a214abfd6e34056..be5f54c046aca090b827667684a5831db85a6942 100644 (file)
@@ -22,6 +22,7 @@
 #include <stdio.h>
 
 #include "libknot/libknot.h"
+#include "contrib/string.h"
 #include "contrib/ucw/lists.h"
 
 #define DEFAULT_IPV4_NAME      "127.0.0.1"
@@ -118,9 +119,15 @@ typedef struct {
        param_handle_f handler;
 } param_t;
 
-inline static void print_version(const char *program_name)
+inline static void print_version(const char *prog_name, bool verbose)
 {
-       printf("%s (Knot DNS), version %s\n", program_name, PACKAGE_VERSION);
+       if (prog_name != NULL) {
+               printf("%s, ", prog_name);
+       }
+       printf("Knot DNS %s\n", PACKAGE_VERSION);
+       if (verbose) {
+               printf("\n%s\n", configure_summary);
+       }
 }
 
 /*!
index 0172347ad0854d18cd95565a3abe42dda6bb5036..28175aeb096941dad6c2bc9cfa642e78bba47f94 100644 (file)
@@ -108,7 +108,7 @@ int main(int argc, char *argv[])
                { "catalog", required_argument, NULL, 'a' },
                { "member",  required_argument, NULL, 'm' },
                { "help",    no_argument,       NULL, 'h' },
-               { "version", no_argument,       NULL, 'V' },
+               { "version", optional_argument, NULL, 'V' },
                { NULL }
        };
 
@@ -116,7 +116,7 @@ int main(int argc, char *argv[])
        signal_init_std();
 
        int opt = 0;
-       while ((opt = getopt_long(argc, argv, "c:C:D:a:m:hV", opts, NULL)) != -1) {
+       while ((opt = getopt_long(argc, argv, "c:C:D:a:m:hV::", opts, NULL)) != -1) {
                switch (opt) {
                case 'c':
                        if (util_conf_init_file(optarg) != KNOT_EOK) {
@@ -147,7 +147,7 @@ int main(int argc, char *argv[])
                        print_help();
                        goto success;
                case 'V':
-                       print_version(PROGRAM_NAME);
+                       print_version(PROGRAM_NAME, optarg != NULL);
                        goto success;
                default:
                        print_help();
index f72fbd2b5350b72071e6c3325902dab1a06b3928..471132cd640180616d4ddd16d2288d7345fbf254 100644 (file)
@@ -2516,12 +2516,7 @@ static int parse_opt1(const char *opt, const char *value, kdig_params_t *params,
                *index += add;
                break;
        case 'V':
-               if (len > 1) {
-                       ERR("invalid option -%s", opt);
-                       return KNOT_ENOTSUP;
-               }
-
-               print_version(PROGRAM_NAME);
+               print_version(PROGRAM_NAME, len > 1);
                params->stop = true;
                break;
        case 'x':
@@ -2597,8 +2592,8 @@ static int parse_opt1(const char *opt, const char *value, kdig_params_t *params,
                if (strcmp(opt, "-help") == 0) {
                        print_help();
                        params->stop = true;
-               } else if (strcmp(opt, "-version") == 0) {
-                       print_version(PROGRAM_NAME);
+               } else if (strncmp(opt, "-version", 8) == 0) {
+                       print_version(PROGRAM_NAME, strlen(opt) > 9);
                        params->stop = true;
                } else {
                        ERR("invalid option: -%s", opt);
index 355fd3a626d09a557a2cf316d4c52cefb3dcbfe9..8d36e004077a3a76a35bab959a9d138cce1eb476 100644 (file)
@@ -310,7 +310,7 @@ int main(int argc, char *argv[])
                { "mono",     no_argument,       NULL, 'x' },
                { "color",    no_argument,       NULL, 'X' },
                { "help",     no_argument,       NULL, 'h' },
-               { "version",  no_argument,       NULL, 'V' },
+               { "version",  optional_argument, NULL, 'V' },
                { "json",     no_argument,       NULL, 'j' },
                { NULL }
        };
@@ -327,7 +327,7 @@ int main(int argc, char *argv[])
        list_params.color = isatty(STDOUT_FILENO);
 
        int opt = 0, parm = 0;
-       while ((opt = getopt_long(argc, argv, "c:C:D:t:ejlbxXhV", opts, NULL)) != -1) {
+       while ((opt = getopt_long(argc, argv, "c:C:D:t:ejlbxXhV::", opts, NULL)) != -1) {
                switch (opt) {
                case 'c':
                        if (util_conf_init_file(optarg) != KNOT_EOK) {
@@ -376,7 +376,7 @@ int main(int argc, char *argv[])
                        print_help();
                        goto success;
                case 'V':
-                       print_version(PROGRAM_NAME);
+                       print_version(PROGRAM_NAME, optarg != NULL);
                        goto success;
                default:
                        print_help();
index 1423e0996e94a69d77151ebcecaabff56ea27bcf..de95d9b637634eb587938322402149f0a45837a4 100644 (file)
@@ -1,4 +1,4 @@
-/*  Copyright (C) 2022 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/*  Copyright (C) 2023 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -251,14 +251,14 @@ int khost_parse(kdig_params_t *params, int argc, char *argv[])
 
        // Long options.
        struct option opts[] = {
-               { "help",    no_argument, NULL, 'h' },
-               { "version", no_argument, NULL, 'V' },
+               { "help",    no_argument,       NULL, 'h' },
+               { "version", optional_argument, NULL, 'V' },
                { NULL }
        };
 
        // Command line options processing.
        int opt = 0;
-       while ((opt = getopt_long(argc, argv, "46adhrsTvVwc:t:R:W:", opts, NULL))
+       while ((opt = getopt_long(argc, argv, "46adhrsTvV::wc:t:R:W:", opts, NULL))
               != -1) {
                switch (opt) {
                case '4':
@@ -294,7 +294,7 @@ int khost_parse(kdig_params_t *params, int argc, char *argv[])
                        conf->style.show_footer = true;
                        break;
                case 'V':
-                       print_version(PROGRAM_NAME);
+                       print_version(PROGRAM_NAME, optarg != NULL);
                        params->stop = false;
                        return KNOT_EOK;
                case 'w':
index 3ba0019592a66b825929ae4acf13506f413ba182..a5c935b69bd84af768a9d6c803891edf5d8ea3d2 100644 (file)
@@ -346,7 +346,7 @@ int main(int argc, char *argv[])
                { "mono",      no_argument,       NULL, 'x' },
                { "color",     no_argument,       NULL, 'X' },
                { "help",      no_argument,       NULL, 'h' },
-               { "version",   no_argument,       NULL, 'V' },
+               { "version",   optional_argument, NULL, 'V' },
                { NULL }
        };
 
@@ -354,7 +354,7 @@ int main(int argc, char *argv[])
        signal_init_std();
 
        int opt = 0;
-       while ((opt = getopt_long(argc, argv, "c:C:D:l:s:zHdnxXhV", opts, NULL)) != -1) {
+       while ((opt = getopt_long(argc, argv, "c:C:D:l:s:zHdnxXhV::", opts, NULL)) != -1) {
                switch (opt) {
                case 'c':
                        if (util_conf_init_file(optarg) != KNOT_EOK) {
@@ -404,7 +404,7 @@ int main(int argc, char *argv[])
                        print_help();
                        goto success;
                case 'V':
-                       print_version(PROGRAM_NAME);
+                       print_version(PROGRAM_NAME, optarg != NULL);
                        goto success;
                default:
                        print_help();
index dad3671e54de61176fb9f0b5d34b939b3c1ae025..274ab6dad27c33d6e21849e57a3177e7a22e9807 100644 (file)
@@ -82,7 +82,7 @@ int main(int argc, char **argv)
                { "color",         no_argument,       NULL, 'X' },
                { "verbose",       no_argument,       NULL, 'v' },
                { "help",          no_argument,       NULL, 'h' },
-               { "version",       no_argument,       NULL, 'V' },
+               { "version",       optional_argument, NULL, 'V' },
                { NULL }
        };
 
@@ -97,7 +97,7 @@ int main(int argc, char **argv)
 
        /* Parse command line arguments */
        int opt = 0;
-       while ((opt = getopt_long(argc, argv, "+c:C:m:s:t:befxXvhV", opts, NULL)) != -1) {
+       while ((opt = getopt_long(argc, argv, "+c:C:m:s:t:befxXvhV::", opts, NULL)) != -1) {
                switch (opt) {
                case 'c':
                        params.orig_config = optarg;
@@ -147,7 +147,7 @@ int main(int argc, char **argv)
                        print_help();
                        return EXIT_SUCCESS;
                case 'V':
-                       print_version(PROGRAM_NAME);
+                       print_version(PROGRAM_NAME, optarg != NULL);
                        return EXIT_SUCCESS;
                default:
                        print_help();
index 2e4ac02da476e1e1882bbb5c9d6df341fbbec33b..1bf7c4540de6ae4e5700d7532a2bdc4065d67d02 100644 (file)
@@ -44,6 +44,7 @@
 #include "knot/common/systemd.h"
 #include "knot/server/server.h"
 #include "knot/server/tcp-handler.h"
+#include "utils/common/params.h"
 
 #define PROGRAM_NAME "knotd"
 
@@ -362,11 +363,6 @@ static void print_help(void)
               CONF_MAPSIZE, RUN_DIR "/knot.sock");
 }
 
-static void print_version(void)
-{
-       printf("%s (Knot DNS), version %s\n", PROGRAM_NAME, PACKAGE_VERSION);
-}
-
 static int set_config(const char *confdb, const char *config, size_t max_conf_size)
 {
        if (config != NULL && confdb != NULL) {
@@ -439,7 +435,7 @@ int main(int argc, char **argv)
                { "daemonize",     optional_argument, NULL, 'd' },
                { "verbose",       no_argument,       NULL, 'v' },
                { "help",          no_argument,       NULL, 'h' },
-               { "version",       no_argument,       NULL, 'V' },
+               { "version",       optional_argument, NULL, 'V' },
                { NULL }
        };
 
@@ -448,7 +444,7 @@ int main(int argc, char **argv)
 
        /* Parse command line arguments. */
        int opt = 0;
-       while ((opt = getopt_long(argc, argv, "c:C:m:s:dvhV", opts, NULL)) != -1) {
+       while ((opt = getopt_long(argc, argv, "c:C:m:s:dvhV::", opts, NULL)) != -1) {
                switch (opt) {
                case 'c':
                        config = optarg;
@@ -480,7 +476,7 @@ int main(int argc, char **argv)
                        print_help();
                        return EXIT_SUCCESS;
                case 'V':
-                       print_version();
+                       print_version(PROGRAM_NAME, optarg != NULL);
                        return EXIT_SUCCESS;
                default:
                        print_help();
index a7bac978d46e61de0e00c2b1f7d180bc6b670018..08d420316c8cebc7e314f15b93fcf0ebf67cf79b 100644 (file)
@@ -1,4 +1,4 @@
-/*  Copyright (C) 2022 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/*  Copyright (C) 2023 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -103,19 +103,19 @@ static bool parse_nsec3_params(dnssec_nsec3_params_t *params, const char *salt_s
 int main(int argc, char *argv[])
 {
        struct option options[] = {
-               { "help",    no_argument, NULL, 'h' },
-               { "version", no_argument, NULL, 'V' },
+               { "help",    no_argument,       NULL, 'h' },
+               { "version", optional_argument, NULL, 'V' },
                { NULL }
        };
 
        int opt = 0;
-       while ((opt = getopt_long(argc, argv, "hV", options, NULL)) != -1) {
+       while ((opt = getopt_long(argc, argv, "hV::", options, NULL)) != -1) {
                switch(opt) {
                case 'h':
                        print_help();
                        return EXIT_SUCCESS;
                case 'V':
-                       print_version(PROGRAM_NAME);
+                       print_version(PROGRAM_NAME, optarg != NULL);
                        return EXIT_SUCCESS;
                default:
                        print_help();
index f9fa41fb90594cf5c7f2253705a000d9d595433e..44ac9f3c92ad9b59264ffb5fa599b7cb8117de8a 100644 (file)
@@ -1,4 +1,4 @@
-/*  Copyright (C) 2022 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/*  Copyright (C) 2023 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -190,14 +190,14 @@ int knsupdate_parse(knsupdate_params_t *params, int argc, char *argv[])
 
        // Long options.
        struct option opts[] = {
-               { "help",    no_argument, NULL, 'h' },
-               { "version", no_argument, NULL, 'V' },
+               { "help",    no_argument,       NULL, 'h' },
+               { "version", optional_argument, NULL, 'V' },
                { NULL }
        };
 
        /* Command line options processing. */
        int opt = 0;
-       while ((opt = getopt_long(argc, argv, "dhDvVp:t:r:y:k:", opts, NULL))
+       while ((opt = getopt_long(argc, argv, "dhDvV::p:t:r:y:k:", opts, NULL))
               != -1) {
                switch (opt) {
                case 'd':
@@ -212,7 +212,7 @@ int knsupdate_parse(knsupdate_params_t *params, int argc, char *argv[])
                        params->protocol = PROTO_TCP;
                        break;
                case 'V':
-                       print_version(PROGRAM_NAME);
+                       print_version(PROGRAM_NAME, optarg != NULL);
                        params->stop = true;
                        return KNOT_EOK;
                case 'p':
index 3a0dabe2e91a2745cdb53414db1c4223cdd87e01..5a5e94c463db64df405374744c3a3143edfd41c0 100644 (file)
@@ -1213,7 +1213,7 @@ static bool get_opts(int argc, char *argv[], xdp_gun_ctx_t *ctx)
 {
        struct option opts[] = {
                { "help",       no_argument,       NULL, 'h' },
-               { "version",    no_argument,       NULL, 'V' },
+               { "version",    optional_argument, NULL, 'V' },
                { "duration",   required_argument, NULL, 't' },
                { "qps",        required_argument, NULL, 'Q' },
                { "batch",      required_argument, NULL, 'b' },
@@ -1237,13 +1237,13 @@ static bool get_opts(int argc, char *argv[], xdp_gun_ctx_t *ctx)
        bool default_at_once = true;
        double argf;
        char *argcp, *local_ip = NULL, *filename = NULL;
-       while ((opt = getopt_long(argc, argv, "hVt:Q:b:rp:T::U::F:I:l:i:L:R:v:m:G:", opts, NULL)) != -1) {
+       while ((opt = getopt_long(argc, argv, "hV::t:Q:b:rp:T::U::F:I:l:i:L:R:v:m:G:", opts, NULL)) != -1) {
                switch (opt) {
                case 'h':
                        print_help();
                        exit(EXIT_SUCCESS);
                case 'V':
-                       print_version(PROGRAM_NAME);
+                       print_version(PROGRAM_NAME, optarg != NULL);
                        exit(EXIT_SUCCESS);
                case 't':
                        assert(optarg);
index 3a2b620add57e6f03a83e56b8421fffef30e3f20..521ae8817036322da6868cb357074e3220fab252 100644 (file)
@@ -78,7 +78,7 @@ int main(int argc, char *argv[])
                { "print",   no_argument,       NULL, 'p' },
                { "verbose", no_argument,       NULL, 'v' },
                { "help",    no_argument,       NULL, 'h' },
-               { "version", no_argument,       NULL, 'V' },
+               { "version", optional_argument, NULL, 'V' },
                { NULL }
        };
 
@@ -87,7 +87,7 @@ int main(int argc, char *argv[])
 
        /* Parse command line arguments */
        int opt = 0;
-       while ((opt = getopt_long(argc, argv, "o:t:d:pvVh", opts, NULL)) != -1) {
+       while ((opt = getopt_long(argc, argv, "o:t:d:pvV::h", opts, NULL)) != -1) {
                switch (opt) {
                case 'o':
                        origin = optarg;
@@ -102,7 +102,7 @@ int main(int argc, char *argv[])
                        print_help();
                        return EXIT_SUCCESS;
                case 'V':
-                       print_version(PROGRAM_NAME);
+                       print_version(PROGRAM_NAME, optarg != NULL);
                        return EXIT_SUCCESS;
                case 'd':
                        optional = str2bool(optarg) ? SEMCHECK_DNSSEC_ON : SEMCHECK_DNSSEC_OFF;
index e70abb64c752c2352379f589f3bf18734054dfb3..fd43bdbc7688e909626b6201cecd140192dc05cf 100644 (file)
@@ -204,7 +204,7 @@ int main(int argc, char *argv[])
                { "verify" ,   no_argument,       NULL, 'v' },
                { "time",      required_argument, NULL, 't' },
                { "help",      no_argument,       NULL, 'h' },
-               { "version",   no_argument,       NULL, 'V' },
+               { "version",   optional_argument, NULL, 'V' },
                { NULL }
        };
 
@@ -212,7 +212,7 @@ int main(int argc, char *argv[])
        signal_init_std();
 
        int opt = 0;
-       while ((opt = getopt_long(argc, argv, "c:C:o:rvt:hV", opts, NULL)) != -1) {
+       while ((opt = getopt_long(argc, argv, "c:C:o:rvt:hV::", opts, NULL)) != -1) {
                switch (opt) {
                case 'c':
                        if (util_conf_init_file(optarg) != KNOT_EOK) {
@@ -245,7 +245,7 @@ int main(int argc, char *argv[])
                        print_help();
                        goto success;
                case 'V':
-                       print_version(PROGRAM_NAME);
+                       print_version(PROGRAM_NAME, optarg != NULL);
                        goto success;
                default:
                        print_help();