...
 
Commits (2)
Copyright (c) 1992, 2013, 2014, 2015 Juergen Nickelsen <ni@w21.org>
Copyright (c) 1992, 2013, 2014, 2015, 2018 Juergen Nickelsen <ni@w21.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
......
# Copyright (C) 1992, 2013, 2014 Juergen Nickelsen <ni@w21.org>.
# Copyright (C) 1992, 2013, 2014, 2015, 2018 Juergen Nickelsen <ni@w21.org>.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
......@@ -42,7 +42,7 @@ nslook : nslook.c version Makefile
version:
bdate=$$(date "+%Y%m%d:%H%M%S $$USER@$$HOST") ;\
printf "#define VERSION \"nslook (c) 1992-2015 J. Nickelsen <ni@w21.org> build $$bdate\"\\n" > version.h
printf "#define VERSION \"nslook (c) 1992-2018 J. Nickelsen <ni@w21.org> build $$bdate\"\\n" > version.h
nslook.ps: nslook.1
groff -man nslook.1 > nslook.ps
......
......@@ -100,6 +100,7 @@ one line as in \fC/etc/hosts\fP.
With
.B \-l ,
show the reverse lookup of the found IP address as well.
With medium format, print the hostname first.
.TP
.B \-x
Print an extensive dump of the \fCaddrinfo\fP struct returned by
......
......@@ -139,6 +139,18 @@ void do_lookup (char *astring)
}
}
void print_medium(const char *ipaddr, const char *name)
{
if (reverse) {
printf("%-39s %s\n", name, ipaddr);
} else {
/* have space for IPv6 addresses */
printf("%-39s %s\n", ipaddr, name);
}
}
/* Try to interpret the argument string as an IPv4 or IPv6 address, look it up,
* and show the result. If the argument string does not contain the textual
* representation of an IP address, return 0, otherwise 1.
......@@ -201,7 +213,7 @@ int lookup_address(char *astring)
printf("ip address: %s\n", ipaddr);
break;
case F_MEDIUM:
printf("%-39s %s\n", ipaddr, hostname);
print_medium(ipaddr, hostname);
break;
case F_SHORT:
puts(hostname);
......@@ -283,7 +295,7 @@ void display_result(char *name, const char *ipaddr, struct addrinfo *ai)
if (!hostname) {
hostname = name;
}
printf("%-39s %s\n", ipaddr, hostname);
print_medium(ipaddr, hostname);
break;
case F_SHORT:
printf("%s\n", ipaddr);
......