MCPcopy Create free account
hub / github.com/acl-dev/acl / resolve_name

Function resolve_name

lib_acl/samples/resolve/main.cpp:8–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6
7#if !defined(MACOSX) && !defined(ACL_SUNOS5) && !defined(MINGW)
8static ACL_DNS_DB *resolve_name(const char *name)
9{
10 struct hostent *h_addrp = NULL;
11 struct hostent h_buf;
12 int err = 0, n;
13 char buf[4096];
14 char **pptr;
15 ACL_DNS_DB *res;
16 ACL_HOSTNAME *h_host;
17
18 printf("%s: gethostbyname name: %s\n", __FUNCTION__, name);
19
20 n = gethostbyname_r(name, &h_buf, buf, sizeof(buf), &h_addrp, &err);
21 if (n) {
22 printf("%s: gethostbyname %s error\n", __FUNCTION__, name);
23 return NULL;
24 }
25
26 res = acl_netdb_new(name);
27 for (pptr = h_addrp->h_addr_list; *pptr != NULL; pptr++) {
28 h_host = (ACL_HOSTNAME*) acl_mycalloc(1, sizeof(ACL_HOSTNAME));
29
30 memset(&h_host->saddr, 0, sizeof(h_host->saddr));
31 if ((int) sizeof(h_host->saddr.in.sin_addr) > h_addrp->h_length)
32 n = h_addrp->h_length;
33 else
34 n = (int) sizeof(h_host->saddr.in.sin_addr);
35
36 memcpy(&h_host->saddr.in.sin_addr, *pptr, n);
37 acl_inet_ntoa(h_host->saddr.in.sin_addr,
38 h_host->ip, sizeof(h_host->ip));
39
40 (void) acl_array_append(res->h_db, h_host);
41 res->size++;
42 }
43
44 return res;
45}
46#endif
47
48static ACL_DNS_DB *resolve_addr(const char *name)

Callers 1

testFunction · 0.85

Calls 5

acl_netdb_newFunction · 0.85
memcpyFunction · 0.85
acl_inet_ntoaFunction · 0.85
acl_array_appendFunction · 0.85
gethostbyname_rFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…