comparison dbutil.c @ 172:3e49d8d18005

* respect DO_HOST_LOOKUP config option
author Matt Johnston <matt@ucc.asn.au>
date Mon, 28 Feb 2005 10:15:16 +0000
parents 0cfba3034be5
children 257f09a63dab
comparison
equal deleted inserted replaced
171:8e68dbe8687b 172:3e49d8d18005
395 395
396 char hbuf[NI_MAXHOST]; 396 char hbuf[NI_MAXHOST];
397 char sbuf[NI_MAXSERV]; 397 char sbuf[NI_MAXSERV];
398 int ret; 398 int ret;
399 unsigned int len; 399 unsigned int len;
400 #ifdef DO_HOST_LOOKUP
401 const int flags = NI_NUMERICSERV;
402 #else
403 const int flags = NI_NUMERICHOST | NI_NUMERICSERV;
404 #endif
400 405
401 len = sizeof(struct sockaddr_storage); 406 len = sizeof(struct sockaddr_storage);
402 /* Some platforms such as Solaris 8 require that len is the length 407 /* Some platforms such as Solaris 8 require that len is the length
403 * of the specific structure. */ 408 * of the specific structure. */
404 if (addr->ss_family == AF_INET) { 409 if (addr->ss_family == AF_INET) {
408 if (addr->ss_family == AF_INET6) { 413 if (addr->ss_family == AF_INET6) {
409 len = sizeof(struct sockaddr_in6); 414 len = sizeof(struct sockaddr_in6);
410 } 415 }
411 #endif 416 #endif
412 417
418
413 ret = getnameinfo((struct sockaddr*)addr, len, hbuf, sizeof(hbuf), 419 ret = getnameinfo((struct sockaddr*)addr, len, hbuf, sizeof(hbuf),
414 sbuf, sizeof(sbuf), NI_NUMERICSERV); 420 sbuf, sizeof(sbuf), flags);
415 421
416 if (ret != 0) { 422 if (ret != 0) {
417 /* On some systems (Darwin does it) we get EINTR from getnameinfo 423 /* On some systems (Darwin does it) we get EINTR from getnameinfo
418 * somehow. Eew. So we'll just return the IP, since that doesn't seem 424 * somehow. Eew. So we'll just return the IP, since that doesn't seem
419 * to exhibit that behaviour. */ 425 * to exhibit that behaviour. */