summaryrefslogtreecommitdiff
path: root/ares_gethostbyname.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2007-02-19 02:03:58 (GMT)
committerYang Tse <yangsita@gmail.com>2007-02-19 02:03:58 (GMT)
commit679a67566037cd74c608f78b8de165063d1c3f75 (patch)
tree09f6c70e0d2f7226e448a4afa644cb9729784a9a /ares_gethostbyname.c
parent385e6d0eea338bc49bceb0696f02c799732d90a1 (diff)
downloadc-ares-679a67566037cd74c608f78b8de165063d1c3f75.zip
c-ares-679a67566037cd74c608f78b8de165063d1c3f75.tar.gz
c-ares-679a67566037cd74c608f78b8de165063d1c3f75.tar.bz2
add debug messages for initialization failures
Diffstat (limited to 'ares_gethostbyname.c')
-rw-r--r--ares_gethostbyname.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/ares_gethostbyname.c b/ares_gethostbyname.c
index 00d7886..1bd5ac9 100644
--- a/ares_gethostbyname.c
+++ b/ares_gethostbyname.c
@@ -248,6 +248,7 @@ static int file_lookup(const char *name, int family, struct hostent **host)
FILE *fp;
char **alias;
int status;
+ int error;
#ifdef WIN32
char PATH_HOSTS[MAX_PATH];
@@ -280,8 +281,22 @@ static int file_lookup(const char *name, int family, struct hostent **host)
fp = fopen(PATH_HOSTS, "r");
if (!fp)
- return ARES_ENOTFOUND;
-
+ {
+ error = ERRNO;
+ switch(error)
+ {
+ case ENOENT:
+ case ESRCH:
+ return ARES_ENOTFOUND;
+ 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 (strcasecmp((*host)->h_name, name) == 0)