MCPcopy Create free account
hub / github.com/git/git / canonical_name

Function canonical_name

ident.c:103–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103static 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
129static void add_domainname(struct strbuf *out, int *is_bogus)
130{

Callers 1

add_domainnameFunction · 0.85

Calls 1

strbuf_addstrFunction · 0.85

Tested by

no test coverage detected