- 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 = xgethostbyname(buf);
- puts(inet_ntoa(*(struct in_addr *) (h->h_addr)));
- } else {
- puts(buf);
+ 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++)));
+ }
+ printf("\n");