diff options
author | Daniel Stenberg <daniel@haxx.se> | 2008-11-19 15:16:16 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2008-11-19 15:16:16 +0000 |
commit | 8a6b51d5601ab65f64514bb80c567f5f5e103bc1 (patch) | |
tree | 8b4194d66157386613da0caa2a62c1338ea508f0 /ares_gethostbyname.c | |
parent | 8a34a3a045a76282b81bbda780204a1633a64398 (diff) | |
download | c-ares-8a6b51d5601ab65f64514bb80c567f5f5e103bc1.tar.gz c-ares-8a6b51d5601ab65f64514bb80c567f5f5e103bc1.tar.bz2 c-ares-8a6b51d5601ab65f64514bb80c567f5f5e103bc1.zip |
- Brad Spencer brought the new function ares_gethostbyname_file() which simply
resolves a host name from the given file, using the regular hosts syntax.
Diffstat (limited to 'ares_gethostbyname.c')
-rw-r--r-- | ares_gethostbyname.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/ares_gethostbyname.c b/ares_gethostbyname.c index a32da8f..9662db5 100644 --- a/ares_gethostbyname.c +++ b/ares_gethostbyname.c @@ -289,6 +289,31 @@ static int fake_hostent(const char *name, int family, ares_host_callback callbac return 1; } +/* This is an API method */ +int ares_gethostbyname_file(ares_channel channel, const char *name, + int family, struct hostent **host) +{ + /* We only take the channel to ensure that ares_init() been called. */ + if(channel == NULL) + { + /* Anything will do, really. This seems fine, and is consistent with + other error cases. */ + *host = NULL; + return ARES_ENOTFOUND; + } + + /* Just chain to the internal implementation we use here; it's exactly + * what we want. + */ + const int result = file_lookup(name, family, host); + if(result != ARES_SUCCESS) + { + /* We guarantee a NULL hostent on failure. */ + *host = NULL; + } + return result; +} + static int file_lookup(const char *name, int family, struct hostent **host) { FILE *fp; |