- if (opt_short) {
- s = strchr(buf, '.');
- if (!s)
- s = buf;
- *s = 0;
- puts(buf);
- } else if (opt_domain) {
- s = strchr(buf, '.');
- puts(s ? s + 1 : "");
- } else if (opt_ip) {
- h = gethostbyname(buf);
- if (!h) {
- printf("Host not found\n");
- exit(1);
+ hp = xgethostbyname(buf);
+ p = strchr(hp->h_name, '.');
+ if (type == 'f') {
+ puts(hp->h_name);
+ } else if (type == 's') {
+ if (p != NULL) {
+ *p = 0;
+ }
+ puts(hp->h_name);
+ } else if (type == 'd') {
+ if (p) puts(p + 1);
+ } else if (type == 'i') {
+ while (hp->h_addr_list[0]) {
+ printf("%s ", inet_ntoa(*(struct in_addr *) (*hp->h_addr_list++)));