X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fresolve-host%2Fresolve-host.c;h=068756cab1ea55c61cffa0a777e2de4ae4388093;hb=1dcca8e5fe679b21a7203d6e35d58aa7aa83bbe1;hp=c39b582373313054361fb2568ff709d47f4f9a85;hpb=51323288fc628a5cac50914df915545d685b793e;p=elogind.git
diff --git a/src/resolve-host/resolve-host.c b/src/resolve-host/resolve-host.c
index c39b58237..068756cab 100644
--- a/src/resolve-host/resolve-host.c
+++ b/src/resolve-host/resolve-host.c
@@ -19,14 +19,12 @@
along with systemd; If not, see .
***/
-#include
#include
#include
#include "sd-bus.h"
#include "bus-util.h"
#include "bus-error.h"
-#include "bus-errors.h"
#include "in-addr-util.h"
#include "af-list.h"
#include "build.h"
@@ -155,7 +153,7 @@ static int resolve_host(sd_bus *bus, const char *name) {
r = in_addr_to_string(family, a, &pretty);
if (r < 0) {
- log_error("%s: failed to print address: %s", name, strerror(-r));
+ log_error_errno(r, "%s: failed to print address: %m", name);
continue;
}
@@ -466,14 +464,14 @@ static void help(void) {
" -p --protocol=PROTOCOL Look via protocol\n"
" -t --type=TYPE Query RR with DNS type\n"
" -c --class=CLASS Query RR with DNS class\n"
- " --no-legend Do not print column headers\n"
+ " --legend[=BOOL] Do [not] print column headers\n"
, program_invocation_short_name);
}
static int parse_argv(int argc, char *argv[]) {
enum {
ARG_VERSION = 0x100,
- ARG_NO_LEGEND,
+ ARG_LEGEND,
};
static const struct option options[] = {
@@ -481,7 +479,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "version", no_argument, NULL, ARG_VERSION },
{ "type", required_argument, NULL, 't' },
{ "class", required_argument, NULL, 'c' },
- { "no-legend", no_argument, NULL, ARG_NO_LEGEND },
+ { "legend", optional_argument, NULL, ARG_LEGEND },
{ "protocol", required_argument, NULL, 'p' },
{}
};
@@ -513,10 +511,8 @@ static int parse_argv(int argc, char *argv[]) {
case 'i':
arg_ifindex = if_nametoindex(optarg);
- if (arg_ifindex <= 0) {
- log_error("Unknown interfaces %s: %m", optarg);
- return -errno;
- }
+ if (arg_ifindex <= 0)
+ return log_error_errno(errno, "Unknown interfaces %s: %m", optarg);
break;
case 't':
@@ -548,8 +544,17 @@ static int parse_argv(int argc, char *argv[]) {
break;
- case ARG_NO_LEGEND:
- arg_legend = false;
+ case ARG_LEGEND:
+ if (optarg) {
+ r = parse_boolean(optarg);
+ if (r < 0) {
+ log_error("Failed to parse --legend= argument");
+ return r;
+ }
+
+ arg_legend = !!r;
+ } else
+ arg_legend = false;
break;
case 'p':
@@ -605,7 +610,7 @@ int main(int argc, char **argv) {
r = sd_bus_open_system(&bus);
if (r < 0) {
- log_error("sd_bus_open_system: %s", strerror(-r));
+ log_error_errno(r, "sd_bus_open_system: %m");
goto finish;
}