| 101 | } |
| 102 | |
| 103 | static int canonical_name(const char *host, struct strbuf *out) |
| 104 | { |
| 105 | int status = -1; |
| 106 | |
| 107 | #ifndef NO_IPV6 |
| 108 | struct addrinfo hints, *ai; |
| 109 | memset (&hints, '\0', sizeof (hints)); |
| 110 | hints.ai_flags = AI_CANONNAME; |
| 111 | if (!getaddrinfo(host, NULL, &hints, &ai)) { |
| 112 | if (ai && ai->ai_canonname && strchr(ai->ai_canonname, '.')) { |
| 113 | strbuf_addstr(out, ai->ai_canonname); |
| 114 | status = 0; |
| 115 | } |
| 116 | freeaddrinfo(ai); |
| 117 | } |
| 118 | #else |
| 119 | struct hostent *he = gethostbyname(host); |
| 120 | if (he && strchr(he->h_name, '.')) { |
| 121 | strbuf_addstr(out, he->h_name); |
| 122 | status = 0; |
| 123 | } |
| 124 | #endif /* NO_IPV6 */ |
| 125 | |
| 126 | return status; |
| 127 | } |
| 128 | |
| 129 | static void add_domainname(struct strbuf *out, int *is_bogus) |
| 130 | { |
no test coverage detected