summaryrefslogtreecommitdiff
path: root/ares_gethostbyaddr.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2007-02-16 19:17:05 +0000
committerYang Tse <yangsita@gmail.com>2007-02-16 19:17:05 +0000
commit8595ddf7c49ab6d73345ba682a58455ad849f39c (patch)
tree26ebe36693ba532ffb67914013226fb581354120 /ares_gethostbyaddr.c
parent69fa44735497e10ca7c49075455da1370b7d7484 (diff)
downloadc-ares-8595ddf7c49ab6d73345ba682a58455ad849f39c.tar.gz
c-ares-8595ddf7c49ab6d73345ba682a58455ad849f39c.tar.bz2
c-ares-8595ddf7c49ab6d73345ba682a58455ad849f39c.zip
add debug messages for fopen() failures
Diffstat (limited to 'ares_gethostbyaddr.c')
-rw-r--r--ares_gethostbyaddr.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/ares_gethostbyaddr.c b/ares_gethostbyaddr.c
index 41bf916..6c80eb9 100644
--- a/ares_gethostbyaddr.c
+++ b/ares_gethostbyaddr.c
@@ -216,9 +216,26 @@ static int file_lookup(union ares_addr *addr, int family, struct hostent **host)
return ARES_ENOTFOUND;
#endif
+ int error;
+
fp = fopen(PATH_HOSTS, "r");
if (!fp)
- return ARES_ENOTFOUND;
+ {
+ error = ERRNO;
+ switch(error)
+ {
+ case ENOENT:
+ return ARES_ENOTFOUND;
+ break;
+ default:
+ DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n",
+ error, strerror(error)));
+ DEBUGF(fprintf(stderr, "Error opening file: %s\n",
+ PATH_HOSTS));
+ *host = NULL;
+ return ARES_EFILE;
+ }
+ }
while ((status = ares__get_hostent(fp, family, host)) == ARES_SUCCESS)
{
if (family != (*host)->h_addrtype)