diff --git a/doc/man/kzonecheck.1in b/doc/man/kzonecheck.1in index 31e4d87573d87130a2d7ea3315d71b3ec604f0ba..cfc02767c1761f01c13556518f1a2b4dcc69813b 100644 --- a/doc/man/kzonecheck.1in +++ b/doc/man/kzonecheck.1in @@ -32,7 +32,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] .. .SH SYNOPSIS .sp -\fBkzonecheck\fP [\fIoptions\fP] \fIzone\-file\fP +\fBkzonecheck\fP [\fIoptions\fP] \fIfilename\fP .SH DESCRIPTION .sp The utility checks zone file syntax and runs semantic checks on the zone @@ -59,7 +59,7 @@ Print the program version. .UNINDENT .SH SEE ALSO .sp -\fBknotd(8)\fP, \fBknot.conf(5)\fP +\fBknotd(8)\fP, \fBknot.conf(5)\fP\&. .SH AUTHOR CZ.NIC Labs <http://www.knot-dns.cz> .SH COPYRIGHT diff --git a/doc/man_kzonecheck.rst b/doc/man_kzonecheck.rst index 61f20bf8ffbcca556cc7f137659f4c3196ccdc81..5ca1f27477c589c8e6f50377228ca78af6667c9c 100644 --- a/doc/man_kzonecheck.rst +++ b/doc/man_kzonecheck.rst @@ -6,7 +6,7 @@ kzonecheck – Knot DNS zone file checking tool Synopsis -------- -:program:`kzonecheck` [*options*] *zone-file* +:program:`kzonecheck` [*options*] *filename* Description ----------- @@ -19,7 +19,7 @@ Please, refer to the ``semantic-checks`` configuration option in :manpage:`knot.conf(5)` for the full list of available semantic checks. Options -.......... +....... **-o**, **--origin** *origin* Zone origin. If not specified, the origin is determined from the file name @@ -37,4 +37,4 @@ Options See Also -------- -:manpage:`knotd(8)`, :manpage:`knot.conf(5)` +:manpage:`knotd(8)`, :manpage:`knot.conf(5)`. diff --git a/src/utils/kzonecheck/main.c b/src/utils/kzonecheck/main.c index 2d6fb3b5e47bef7ec8deacc32a91bfdac68ed21e..eaffe42acba69b512de302995c87ebaba6494717 100644 --- a/src/utils/kzonecheck/main.c +++ b/src/utils/kzonecheck/main.c @@ -28,23 +28,21 @@ static void print_help(void) { - printf("Usage: %s [parameters] <zonefile>\n" + printf("Usage: %s [parameters] <filename>\n" "\n" "Parameters:\n" - " -o, --origin <zone_origin> Zone name\n" - " (default filename or\n" - " filename without trailing .zone)\n" - " -v, --verbose Enable debug output.\n" - " -h, --help Print the program help.\n" - " -V, --version Print the program version.\n" + " -o, --origin <zone_origin> Zone name.\n" + " (default filename or filename without .zone)\n" + " -v, --verbose Enable debug output.\n" + " -h, --help Print the program help.\n" + " -V, --version Print the program version.\n" "\n", PROGRAM_NAME); } int main(int argc, char *argv[]) { - char *filename = NULL; - char *zonename = NULL; + const char *origin = NULL; bool verbose = false; FILE *outfile = stdout; @@ -58,11 +56,11 @@ int main(int argc, char *argv[]) }; /* Parse command line arguments */ - int opt = 0, li = 0; - while ((opt = getopt_long(argc, argv, "o:vVh", opts, &li)) != -1) { + int opt = 0; + while ((opt = getopt_long(argc, argv, "o:vVh", opts, NULL)) != -1) { switch (opt) { case 'o': - zonename = strdup(optarg); + origin = optarg; break; case 'v': verbose = true; @@ -86,15 +84,20 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } - filename = argv[optind]; + char *filename = argv[optind]; - if (zonename == NULL) { - /* Get zone name from file name */ + char *zonename; + if (origin == NULL) { + /* Get zone name from file name. */ const char *ext = ".zone"; zonename = basename(filename); if (strcmp(zonename + strlen(zonename) - strlen(ext), ext) == 0) { zonename = strndup(zonename, strlen(zonename) - strlen(ext)); + } else { + zonename = strdup(zonename); } + } else { + zonename = strdup(origin); } /* TODO: Remove logging from zone loading. */