Commit 00cdf305 authored by Jason Madden's avatar Jason Madden

Update c-ares to 1.11.0

- Replaced the whole directory with current source. This adds a few more
  scripts that we could remove again if desired, but it's easier just to
  be able to copy everything.
- However, the new test directory requires c++11, which travis doesn't
  have, so it's ditabled.
- The invocation of configure had to lose the CONFIG_FILES= param,
  because with that set, configure would fail to create the Makefile
  which in turn caused the whole thing to fail.
parent 08d41220
......@@ -49,6 +49,13 @@ c-ares/adig
c-ares/ahost
c-ares/Makefile
c-ares/libtool
c-ares/libcares.pc
c-ares/test/.deps
c-ares/test/Makefile
c-ares/test/config.log
c-ares/test/config.status
c-ares/test/libtool
c-ares/test/stamp-h1
libev/.deps
libev/Makefile
libev/config.log
......
......@@ -33,6 +33,8 @@ recursive-include scripts *.sh
prune */__pycache__
global-exclude *.so
global-exclude *.o
global-exclude *.lo
global-exclude *.la
global-exclude config.log config.status
prune doc/_build
global-exclude *.pyc
......
......@@ -167,6 +167,6 @@ test-py27-cffi: $(PY27)
GEVENT_CORE_CFFI_ONLY=1 PYTHON=python2.7 PATH=$(BUILD_RUNTIMES)/versions/python2.7/bin:$(PATH) make develop toxtest
test-py27-noembed: $(PY27)
cd libev && ./configure && make
cd c-ares && ./configure && make
cd libev && ./configure --disable-dependency-tracking && make
cd c-ares && ./configure --disable-dependency-tracking && make
CPPFLAGS="-Ilibev -Ic-ares" LDFLAGS="-Llibev/.libs -Lc-ares/.libs" LD_LIBRARY_PATH="$(PWD)/libev/.libs:$(PWD)/c-ares/.libs" EMBED=0 GEVENT_CORE_CEXT_ONLY=1 PYTHON=python2.7 PATH=$(BUILD_RUNTIMES)/versions/python2.7/bin:$(PATH) make develop fulltoxtest
......@@ -16,6 +16,7 @@ Bram Matthys
Dan Fandrich
Daniel Johnson
Daniel Stenberg
David Drysdale
David Stuart
Denis Bilenko
Dima Tisnek
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -55,12 +55,15 @@ EXTRA_DIST = AUTHORS CHANGES README.cares Makefile.inc Makefile.dj \
Makefile.m32 Makefile.netware Makefile.msvc Makefile.Watcom $(man_MANS) \
config-win32.h RELEASE-NOTES libcares.pc.in buildconf get_ver.awk maketgz \
TODO ares_build.h.in $(PDFPAGES) cares.rc README.msvc $(MSVCFILES) \
$(CSOURCES) $(HHEADERS) config-dos.h acountry.1 adig.1 ahost.1 INSTALL
$(CSOURCES) $(HHEADERS) config-dos.h acountry.1 adig.1 ahost.1 INSTALL \
README.md
CLEANFILES = $(PDFPAGES) $(HTMLPAGES)
DISTCLEANFILES = ares_build.h
DIST_SUBDIRS = test
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libcares.pc
......@@ -127,6 +130,10 @@ libcares_la_CFLAGS_EXTRA += $(CFLAG_CARES_SYMBOL_HIDING)
libcares_la_CPPFLAGS_EXTRA += -DCARES_SYMBOL_HIDING
endif
@CODE_COVERAGE_RULES@
libcares_la_LDFLAGS += $(CODE_COVERAGE_LDFLAGS)
libcares_la_CFLAGS_EXTRA += $(CODE_COVERAGE_CFLAGS)
libcares_la_CFLAGS = $(AM_CFLAGS) $(libcares_la_CFLAGS_EXTRA)
libcares_la_CPPFLAGS = $(AM_CPPFLAGS) $(libcares_la_CPPFLAGS_EXTRA)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -82,6 +82,7 @@ MANPAGES = ares_cancel.3 \
ares_free_hostent.3 \
ares_free_string.3 \
ares_get_servers.3 \
ares_get_servers_ports.3 \
ares_gethostbyaddr.3 \
ares_gethostbyname.3 \
ares_gethostbyname_file.3 \
......@@ -107,8 +108,16 @@ MANPAGES = ares_cancel.3 \
ares_save_options.3 \
ares_search.3 \
ares_send.3 \
ares_set_local_dev.3 \
ares_set_local_ip4.3 \
ares_set_local_ip6.3 \
ares_set_servers.3 \
ares_set_servers_csv.3 \
ares_set_servers_ports.3 \
ares_set_servers_ports_csv.3 \
ares_set_socket_callback.3 \
ares_set_socket_configure_callback.3 \
ares_set_sortlist.3 \
ares_strerror.3 \
ares_timeout.3 \
ares_version.3 \
......@@ -126,6 +135,7 @@ HTMLPAGES = ares_cancel.html \
ares_free_hostent.html \
ares_free_string.html \
ares_get_servers.html \
ares_get_servers_ports.html \
ares_gethostbyaddr.html \
ares_gethostbyname.html \
ares_gethostbyname_file.html \
......@@ -150,8 +160,16 @@ HTMLPAGES = ares_cancel.html \
ares_save_options.html \
ares_search.html \
ares_send.html \
ares_set_local_dev.html \
ares_set_local_ip4.html \
ares_set_local_ip6.html \
ares_set_servers.html \
ares_set_servers_csv.html \
ares_set_servers_ports.html \
ares_set_servers_ports_csv.html \
ares_set_socket_callback.html \
ares_set_socket_configure_callback.html \
ares_set_sortlist.html \
ares_strerror.html \
ares_timeout.html \
ares_version.html \
......@@ -169,6 +187,7 @@ PDFPAGES = ares_cancel.pdf \
ares_free_hostent.pdf \
ares_free_string.pdf \
ares_get_servers.pdf \
ares_get_servers_ports.pdf \
ares_gethostbyaddr.pdf \
ares_gethostbyname.pdf \
ares_gethostbyname_file.pdf \
......@@ -193,8 +212,16 @@ PDFPAGES = ares_cancel.pdf \
ares_save_options.pdf \
ares_search.pdf \
ares_send.pdf \
ares_set_local_dev.pdf \
ares_set_local_ip4.pdf \
ares_set_local_ip6.pdf \
ares_set_servers.pdf \
ares_set_servers_csv.pdf \
ares_set_servers_ports.pdf \
ares_set_servers_ports_csv.pdf \
ares_set_socket_callback.pdf \
ares_set_socket_configure_callback.pdf \
ares_set_sortlist.pdf \
ares_strerror.pdf \
ares_timeout.pdf \
ares_version.pdf \
......
......@@ -125,6 +125,12 @@ CC_VERS_NUM = 110
CC_VERS_NUM = 110
!ELSEIF "$(_NMAKE_VER)" == "11.00.60315.1"
CC_VERS_NUM = 110
!ELSEIF "$(_NMAKE_VER)" == "11.00.61030.0"
CC_VERS_NUM = 110
!ELSEIF "$(_NMAKE_VER)" == "12.00.21005.1"
CC_VERS_NUM = 120
!ELSEIF "$(_NMAKE_VER)" == "14.00.23026.0"
CC_VERS_NUM = 140
!ELSE
! MESSAGE Unknown value for _NMAKE_VER macro: "$(_NMAKE_VER)"
! MESSAGE Please, report this condition on the c-ares development
......
Major changes since:
* see the CHANGES file
Major changes in release 1.1.1:
* ares should now compile as C++ code (no longer uses reserved word
"class").
* Added SRV support to adig test program.
* Fixed a few error handling bugs in query processing.
Major changes in release 1.1.0:
* Added ares_free_string() function so that memory can be freed in the
same layer as it is allocated, a desirable feature in some
environments.
* A few of the ares_dns.h macros are fixed to use the proper bitwise
operator.
* Fixed a couple of fenceposts fixed in ares_expand_name()'s
bounds-checking.
* In process_timeouts(), extract query->next before calling
next_server() and possibly freeing the query structure.
* Casted arguments to ctype macros casted to unsigned char, since not
all char values are valid inputs to those macros according to ANSI.
c-ares
======
This package is based on ares 1.1.1 (written by Greg Hudson). I decided to
fork and release a separate project since the ares author didn't want the
improvements that were vital for our use of it.
This package is based on ares 1.1.1 (written by Greg Hudson). Daniel Stenberg
decided to fork and release a separate project since the original ares author
didn't want the improvements that were vital for our use of it.
This package is dubbed 'c-ares' since I (Daniel Stenberg) wanted this for use
within the curl project (hence the letter C) and it makes a nice pun. Also,
c-ares is not API compatible with ares: a new name makes that more obvious to
the public.
This package is dubbed 'c-ares' since Daniel wanted this for use within the
curl project (hence the letter C) and it makes a nice pun. c-ares is not API
compatible with ares: a new name makes that more obvious to the public.
The original libares was distributed at athena-dist.mit.edu:pub/ATHENA/ares.
The original libares was distributed at
ftp://athena-dist.mit.edu:pub/ATHENA/ares (which seems to not be alive
anymore). A local copy of the original ares package is kept here:
http://c-ares.haxx.se/download/ares-1.1.1.tar.gz
c-ares
======
[![Build Status](https://travis-ci.org/c-ares/c-ares.svg?branch=master)](https://travis-ci.org/c-ares/c-ares)
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/03i7151772eq3wn3/branch/master?svg=true)](https://ci.appveyor.com/project/c-ares/c-ares)
[![Coverage Status](https://coveralls.io/repos/c-ares/c-ares/badge.svg?branch=master&service=github)](https://coveralls.io/github/c-ares/c-ares?branch=master)
This is c-ares, an asynchronous resolver library. It is intended for
applications which need to perform DNS queries without blocking, or need to
perform multiple DNS queries in parallel. The primary examples of such
......@@ -8,7 +12,7 @@ applications are servers which communicate with multiple clients and programs
with graphical user interfaces.
The full source code is available in the 'c-ares' release archives, and in a
git repository: http://github.com/bagder/c-ares
git repository: http://github.com/c-ares/c-ares
If you find bugs, correct flaws, have questions or have comments in general in
regard to c-ares (or by all means the original ares too), get in touch with us
......@@ -18,34 +22,34 @@ c-ares is of course distributed under the same MIT-style license as the
original ares.
You'll find all c-ares details and news here:
http://c-ares.haxx.se/
NOTES FOR C-ARES HACKERS
Notes for c-ares hackers
------------------------
* The distributed ares_build.h file is only intended to be used on systems
* The distributed `ares_build.h` file is only intended to be used on systems
which can not run the also distributed configure script.
* The distributed ares_build.h file is generated as a copy of ares_build.h.dist
* The distributed `ares_build.h` file is generated as a copy of `ares_build.h.dist`
when the c-ares source code distribution archive file is originally created.
* If you check out from git on a non-configure platform, you must run the
appropriate buildconf* script to set up ares_build.h and other local files
before being able of compiling the library.
appropriate `buildconf*` script to set up `ares_build.h` and other local files
before being able to compile the library.
* On systems capable of running the configure script, the configure process
will overwrite the distributed ares_build.h file with one that is suitable
* On systems capable of running the `configure` script, the `configure` process
will overwrite the distributed `ares_build.h` file with one that is suitable
and specific to the library being configured and built, this new file is
generated from the ares_build.h.in template file.
generated from the `ares_build.h.in` template file.
* If you intend to distribute an already compiled c-ares library you _MUST_
also distribute along with it the generated ares_build.h which has been
* If you intend to distribute an already compiled c-ares library you **MUST**
also distribute along with it the generated `ares_build.h` which has been
used to compile it. Otherwise the library will be of no use for the users of
the library that you have built. It is _your_ responsibility to provide this
the library that you have built. It is **your** responsibility to provide this
file. No one at the c-ares project can know how you have built the library.
* File ares_build.h includes platform and configuration dependent info,
* File `ares_build.h` includes platform and configuration dependent info,
and must not be modified by anyone. Configure script generates it for you.
* We cannot assume anything else but very basic compiler features being
......@@ -56,3 +60,4 @@ NOTES FOR C-ARES HACKERS
* Comments must be written in the old-style /* unnested C-fashion */
* Try to keep line lengths below 80 columns.
___ __ _ _ __ ___ ___
/ __| ___ / _` | '__/ _ \/ __|
| (_ |___| (_| | | | __/\__ \
\___| \__,_|_| \___||___/
How to build c-ares using MSVC or Visual Studio
=================================================
How to build using MSVC from the command line
---------------------------------------------
Open a command prompt window and ensure that the environment is properly
set up in order to use MSVC or Visual Studio compiler tools.
Change to c-ares source folder where Makefile.msvc file is located and run:
> nmake -f Makefile.msvc
This will build all c-ares libraries as well as three sample programs.
Once the above command has finished a new folder named MSVCXX will exist
below the folder where makefile.msvc is found. The name of the folder
depends on the MSVC compiler version being used to build c-ares.
Below the MSVCXX folder there will exist four folders named 'cares',
'ahost', 'acountry', and 'adig'. The 'cares' folder is the one that
holds the c-ares libraries you have just generated, the other three
hold sample programs that use the libraries.
The above command builds four versions of the c-ares library, dynamic
and static versions and each one in release and debug flavours. Each
of these is found in folders named dll-release, dll-debug, lib-release,
and lib-debug, which hang from the 'cares' folder mentioned above. Each
sample program also has folders with the same names to reflect which
library version it is using.
How to install using MSVC from the command line
-----------------------------------------------
In order to allow easy usage of c-ares libraries it may be convenient to
install c-ares libraries and header files to a common subdirectory tree.
Once that c-ares libraries have been built using procedure described above,
use same command prompt window to define environment variable INSTALL_DIR
to designate the top subdirectory where installation of c-ares libraries and
header files will be done.
> set INSTALL_DIR=c:\c-ares
Afterwards, run following command to actually perform the installation:
> nmake -f Makefile.msvc install
Installation procedure will copy c-ares libraries to subdirectory 'lib' and
c-ares header files to subdirectory 'include' below the INSTALL_DIR subdir.
When environment variable INSTALL_DIR is not defined, installation is done
to c-ares source folder where Makefile.msvc file is located.
How to build using Visual Studio 6 IDE
--------------------------------------
A VC++ 6.0 reference workspace (vc6aws.dsw) is available within the 'vc'
folder to allow proper building of the library and sample programs.
1) Open the vc6aws.dsw workspace with MSVC6's IDE.
2) Select 'Build' from top menu.
3) Select 'Batch Build' from dropdown menu.
4) Make sure that the sixteen project configurations are 'checked'.
5) Click on the 'Build' button.
6) Once the sixteen project configurations are built you are done.
Dynamic and static c-ares libraries are built in debug and release flavours,
and can be located each one in its own subdirectory, dll-debug, dll-release,
lib-debug and lib-release, all of them below the 'vc\cares' subdirectory.
In the same way four executable versions of each sample program are built,
each using its respective library. The resulting sample executables are
located in its own subdirectory, dll-debug, dll-release, lib-debug and
lib-release, below the 'vc\acountry', 'vc\adig' and 'vc\ahost'folders.
These reference VC++ 6.0 configurations are generated using the dynamic CRT.
How to build using Visual Studio 2003 or newer IDE
--------------------------------------------------
First you have to convert the VC++ 6.0 reference workspace and project files
to the Visual Studio IDE version you are using, following next steps:
1) Open vc\vc6aws.dsw with VS20XX.
2) Allow VS20XX to update all projects and workspaces.
3) Save ALL and close VS20XX.
4) Open vc\vc6aws.sln with VS20XX.
5) Select batch build, check 'all' projects and click 'build' button.
Same comments relative to generated files and folders as done above for
Visual Studio 6 IDE apply here.
Relationship between c-ares library file names and versions
-----------------------------------------------------------
c-ares static release library version files:
libcares.lib -> static release library
c-ares static debug library version files:
libcaresd.lib -> static debug library
c-ares dynamic release library version files:
cares.dll -> dynamic release library
cares.lib -> import library for the dynamic release library
cares.exp -> export file for the dynamic release library
c-ares dynamic debug library version files:
caresd.dll -> dynamic debug library
caresd.lib -> import library for the dynamic debug library
caresd.exp -> export file for the dynamic debug library
caresd.pdb -> debug symbol file for the dynamic debug library
How to use c-ares static libraries
----------------------------------
When using the c-ares static library in your program, you will have to
define preprocessor symbol CARES_STATICLIB while building your program,
otherwise you will get errors at linkage stage.
Have Fun!
c-ares version 1.10.0
c-ares version 1.11.0
Changes:
o Added ares_create_query(), to be used instead of ares_mkquery()
o ares_inet_ntop() and ares_inet_pton() are now recognized c-ares functions
o Add a unit test suite
o Allow builds with code converage with --enable-code-coverage configure option
o Allow library-wide override of malloc/free
o Allow multiple -s options to the ahost command
o api: Expose the ares_library_initialized() function
o api: Add ares_set_sortlist(3) entrypoint
o api: Add entrypoints to allow use of per-server ports
o api: introduce `ares_parse_txt_reply_ext`
o api: Add ares_set_socket_configure_callback()
Bug fixes:
o include the ares_parse_soa_reply.* files in the tarball
o read_udp_packets: bail out loop on bad sockets
o get_DNS_AdaptersAddresses: fix IPv6 parsing
o adig: perror() doesn't work for socket errors on windows
o ares_parse_aaaa_reply: fix memory leak
o setup_once.h: HP-UX <sys/socket.h> issue workaround
o configure: several fixes
o config-dos.h: define strerror() to strerror_s_() for High-C
o config-dos.h: define HAVE_CLOSE_S for MSDOS/Watt-32
o ares_build.h.dist: enhance non-configure GCC ABI detection logic
o ares.h: stricter CARES_EXTERN linkage decorations logic
o ares_cancel(): cancel requests safely
o protocol parsing: check input data stricter
o library init: be recursive, reference count inits/cleanups
o ares_parse_txt_reply: return a ares_txt_reply node for each sub-string
o ares_set_servers_csv: fixed IPv6 address parsing
o build: fix build on msvc11
o timeadd: make static
o timeoffset: made static and private
o nowarn: use <limits.h> instead of configure for size of long
o single_domain: Invalid memory access for empty string input
o ares_build.h: fix building on 64-bit powerpc
o Allow specification of search domain in ahost
o Don't override explicitly specified search domains
o ares_parse_soa_reply: Do not leak rr_name on allocation failure
o Update ahost man page to describe -s option
o host_callback: Fall back to AF_INET on searching with AF_UNSPEC
o Add -t u option to ahost
o CONTRIBUTING: added
o ares_set_servers_csv: fix NULL dereference
o Fix integer shift overflow if both tcp_socket and udp_socket are set
o fix acountry memory leak
o lookup_service: prevent tmpbuf from overrunning
o ares_getnameinfo.3: there is no ares_getaddrinfo
o init_by_defaults: Continue loop if space for hostname not large enough
o Destroy options if ares_save_options fails
o ares__read_line: free buf on realloc failure
o added define for visual studio 2013
o windows: fix slow DNS lookup issue
o Use libresolv to initialize cares on iPhone targets
o buildconf: remove check for libtool, it only requires libtoolize
o init_by_resolv_conf: Don't exit loop early leaving uninitialized entries
o ahost: check the select() return code
o configure_socket: explicitly ignore return code
o read_tcp_data: don't try to use NULL pointer after malloc failure
o Distribute all man pages
o ares_expand_name: check for valid bits in label length
o ares__read_line: clear buf pointer on realloc failure
o process_answer: fix things up correctly when removing EDNS option
o ares_parse_txt_reply: propagate errors from per-substring loop
o ares_gethostbyname: don't leak valid-but-empty hostent
o ares_init_options: don't lose init failure
o ares_dup: clear new channel on failure
o config_sortlist: free any existing sortlist on (re)alloc failure
o ares_striendstr: fix so non-NULL return can happen
o bitncmp: update comment to match code behaviour
o ares_set_servers_csv.3: make return type match code
o init_by_resolv_conf: ignore `fopen` errors to use default values
o Use "resolve" as synonym of "dns" in nsswitch.conf
o ares_win32_init: make LoadLibrary work when using UNICODE too
o dist: Distribute README.md
o configure: build silently by default
o ares_dup.3: remove mention of nonexistent function
Thanks go to these friendly people for their efforts and contributions:
Eugeny Gladkih, Yang Tse, Gisle Vanem, Guenter Knauf, Horatiu Popescu,
Alexander Klauer, Patrick Valsecchi, Paul Saab, Keith Shaw,
Alex Loukissas
Andrew Andkjar, Andrew Ayer, Daniel Stenberg, David Drysdale,
Doug Kwan, Fedor Indutny, Frederic Germain, Gisle Vanem, Gregor Jasny,
Guenter Knauf, Jakub Hrozek, Lei Shi, Nicolas "Pixel" Noble,
Svante Karlsson, Tor Arntsen, Yang Tse
Have fun!
This diff is collapsed.
This diff is collapsed.
......@@ -71,8 +71,8 @@
static const char *usage = "acountry [-vh?] {host|addr} ...\n";
static const char nerd_fmt[] = "%u.%u.%u.%u.zz.countries.nerd.dk";
static const char *nerd_ver1 = nerd_fmt + 14;
static const char *nerd_ver2 = nerd_fmt + 11;
static const char *nerd_ver1 = nerd_fmt + 14; /* .countries.nerd.dk */
static const char *nerd_ver2 = nerd_fmt + 11; /* .zz.countries.nerd.dk */
static int verbose = 0;
#define TRACE(fmt) do { \
......@@ -200,7 +200,9 @@ static void wait_ares(ares_channel channel)
if (nfds == 0)
break;
tvp = ares_timeout(channel, NULL, &tv);
select(nfds, &read_fds, &write_fds, NULL, tvp);
nfds = select(nfds, &read_fds, &write_fds, NULL, tvp);
if (nfds < 0)
continue;
ares_process(channel, &read_fds, &write_fds);
}
}
......@@ -559,9 +561,10 @@ static void find_country_from_cname(const char *cname, struct in_addr addr)
if (ver_1)
{
const char *dot = strchr(cname, '.');
if ((z0 != 'z' && z1 != 'z') || dot != cname+4)
if (dot != cname+4)
{
printf("Unexpected CNAME %s (ver_1)\n", cname);
free(ccopy);
return;
}
}
......@@ -572,12 +575,14 @@ static void find_country_from_cname(const char *cname, struct in_addr addr)
if (z0 != 'z' && z1 != 'z')
{
printf("Unexpected CNAME %s (ver_2)\n", cname);
free(ccopy);
return;
}
}
else
{
printf("Unexpected CNAME %s (ver?)\n", cname);
free(ccopy);
return;
}
......@@ -614,4 +619,3 @@ static void find_country_from_cname(const char *cname, struct in_addr addr)
}
free(ccopy);
}
......@@ -52,6 +52,8 @@ static void usage(void);
int main(int argc, char **argv)
{
struct ares_options options;
int optmask = 0;
ares_channel channel;
int status, nfds, c, addr_family = AF_INET;
fd_set read_fds, write_fds;
......@@ -65,6 +67,8 @@ int main(int argc, char **argv)
WSAStartup(wVersionRequested, &wsaData);
#endif
memset(&options, 0, sizeof(options));
status = ares_library_init(ARES_LIB_INIT_ALL);
if (status != ARES_SUCCESS)
{
......@@ -72,7 +76,7 @@ int main(int argc, char **argv)
return 1;
}
while ((c = ares_getopt(argc,argv,"dt:h")) != -1)
while ((c = ares_getopt(argc,argv,"dt:hs:")) != -1)
{
switch (c)
{
......@@ -81,11 +85,20 @@ int main(int argc, char **argv)
dbug_init();
#endif
break;
case 's':
optmask |= ARES_OPT_DOMAINS;
options.ndomains++;
options.domains = realloc(options.domains,
options.ndomains * sizeof(char *));
options.domains[options.ndomains - 1] = strdup(optarg);
break;
case 't':
if (!strcasecmp(optarg,"a"))
addr_family = AF_INET;
else if (!strcasecmp(optarg,"aaaa"))
addr_family = AF_INET6;
else if (!strcasecmp(optarg,"u"))
addr_family = AF_UNSPEC;
else
usage();
break;
......@@ -101,7 +114,7 @@ int main(int argc, char **argv)
if (argc < 1)
usage();
status = ares_init(&channel);
status = ares_init_options(&channel, &options, optmask);
if (status != ARES_SUCCESS)
{
fprintf(stderr, "ares_init: %s\n", ares_strerror(status));
......@@ -130,13 +143,16 @@ int main(int argc, char **argv)
/* Wait for all queries to complete. */
for (;;)
{
int res;
FD_ZERO(&read_fds);
FD_ZERO(&write_fds);
nfds = ares_fds(channel, &read_fds, &write_fds);
if (nfds == 0)
break;
tvp = ares_timeout(channel, NULL, &tv);
select(nfds, &read_fds, &write_fds, NULL, tvp);
res = select(nfds, &read_fds, &write_fds, NULL, tvp);
if (-1 == res)
break;
ares_process(channel, &read_fds, &write_fds);
}
......@@ -185,6 +201,6 @@ static void callback(void *arg, int status, int timeouts, struct hostent *host)
static void usage(void)
{
fprintf(stderr, "usage: ahost [-t {a|aaaa}] {host|addr} ...\n");
fprintf(stderr, "usage: ahost [-t {a|aaaa|u}] {host|addr} ...\n");
exit(1);
}
......@@ -294,8 +294,19 @@ typedef int (*ares_sock_create_callback)(ares_socket_t socket_fd,
int type,
void *data);
typedef int (*ares_sock_config_callback)(ares_socket_t socket_fd,
int type,
void *data);
CARES_EXTERN int ares_library_init(int flags);
CARES_EXTERN int ares_library_init_mem(int flags,
void *(*amalloc)(size_t size),
void (*afree)(void *ptr),
void *(*arealloc)(void *ptr, size_t size));
CARES_EXTERN int ares_library_initialized(void);
CARES_EXTERN void ares_library_cleanup(void);
CARES_EXTERN const char *ares_version(int *version);
......@@ -337,6 +348,13 @@ CARES_EXTERN void ares_set_socket_callback(ares_channel channel,
ares_sock_create_callback callback,
void *user_data);
CARES_EXTERN void ares_set_socket_configure_callback(ares_channel channel,
ares_sock_config_callback callback,
void *user_data);
CARES_EXTERN int ares_set_sortlist(ares_channel channel,
const char *sortstr);
CARES_EXTERN void ares_send(ares_channel channel,
const unsigned char *qbuf,
int qlen,
......@@ -474,6 +492,17 @@ struct ares_txt_reply {
size_t length; /* length excludes null termination */
};
/* NOTE: This structure is a superset of ares_txt_reply
*/
struct ares_txt_ext {
struct ares_txt_ext *next;
unsigned char *txt;
size_t length;
/* 1 - if start of new record
* 0 - if a chunk in the same record */
unsigned char record_start;
};
struct ares_naptr_reply {
struct ares_naptr_reply *next;
unsigned char *flags;
......@@ -537,6 +566,10 @@ CARES_EXTERN int ares_parse_txt_reply(const unsigned char* abuf,
int alen,
struct ares_txt_reply** txt_out);
CARES_EXTERN int ares_parse_txt_reply_ext(const unsigned char* abuf,
int alen,
struct ares_txt_ext** txt_out);
CARES_EXTERN int ares_parse_naptr_reply(const unsigned char* abuf,
int alen,
struct ares_naptr_reply** naptr_out);
......@@ -553,7 +586,6 @@ CARES_EXTERN void ares_free_data(void *dataptr);
CARES_EXTERN const char *ares_strerror(int code);
/* TODO: Hold port here as well. */
struct ares_addr_node {
struct ares_addr_node *next;
int family;
......@@ -563,15 +595,32 @@ struct ares_addr_node {
} addr;
};
struct ares_addr_port_node {
struct ares_addr_port_node *next;
int family;
union {
struct in_addr addr4;
struct ares_in6_addr addr6;
} addr;
int udp_port;
int tcp_port;
};
CARES_EXTERN int ares_set_servers(ares_channel channel,
struct ares_addr_node *servers);
CARES_EXTERN int ares_set_servers_ports(ares_channel channel,
struct ares_addr_port_node *servers);
/* Incomming string format: host[:port][,host[:port]]... */
CARES_EXTERN int ares_set_servers_csv(ares_channel channel,
const char* servers);
CARES_EXTERN int ares_set_servers_ports_csv(ares_channel channel,
const char* servers);
CARES_EXTERN int ares_get_servers(ares_channel channel,
struct ares_addr_node **servers);
CARES_EXTERN int ares_get_servers_ports(ares_channel channel,
struct ares_addr_port_node **servers);
CARES_EXTERN const char *ares_inet_ntop(int af, const void *src, char *dst,
ares_socklen_t size);
......
......@@ -30,14 +30,14 @@ void ares__close_sockets(ares_channel channel, struct server_state *server)
sendreq = server->qhead;
server->qhead = sendreq->next;
if (sendreq->data_storage != NULL)
free(sendreq->data_storage);
free(sendreq);
ares_free(sendreq->data_storage);
ares_free(sendreq);
}
server->qtail = NULL;
/* Reset any existing input buffer. */
if (server->tcp_buffer)
free(server->tcp_buffer);
ares_free(server->tcp_buffer);
server->tcp_buffer = NULL;
server->tcp_lenbuf_pos = 0;
......
......@@ -94,7 +94,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
p++;
if (!*p)
/* Ignore line if reached end of line. */
continue;
continue; /* LCOV_EXCL_LINE: trailing whitespace already stripped */
/* Pointer to start of host name. */
txthost = p;
......@@ -164,7 +164,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
*/
/* Allocate memory for the hostent structure. */
hostent = malloc(sizeof(struct hostent));
hostent = ares_malloc(sizeof(struct hostent));
if (!hostent)
break;
......@@ -173,16 +173,16 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
hostent->h_addr_list = NULL;
/* Copy official host name. */
hostent->h_name = strdup(txthost);
hostent->h_name = ares_strdup(txthost);
if (!hostent->h_name)
break;
/* Copy network address. */
hostent->h_addr_list = malloc(2 * sizeof(char *));
hostent->h_addr_list = ares_malloc(2 * sizeof(char *));
if (!hostent->h_addr_list)
break;
hostent->h_addr_list[1] = NULL;
hostent->h_addr_list[0] = malloc(addrlen);
hostent->h_addr_list[0] = ares_malloc(addrlen);
if (!hostent->h_addr_list[0])
break;
if (addr.family == AF_INET)
......@@ -191,7 +191,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
memcpy(hostent->h_addr_list[0], &addr.addrV6, sizeof(addr.addrV6));
/* Copy aliases. */
hostent->h_aliases = malloc((naliases + 1) * sizeof(char *));
hostent->h_aliases = ares_malloc((naliases + 1) * sizeof(char *));
if (!hostent->h_aliases)
break;
alias = hostent->h_aliases;
......@@ -207,7 +207,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
while (*q && ISSPACE(*q))
q++;
*p = '\0';
if ((*alias = strdup(txtalias)) == NULL)
if ((*alias = ares_strdup(txtalias)) == NULL)
break;
alias++;
txtalias = *q ? q : NULL;
......@@ -221,7 +221,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
hostent->h_length = aresx_uztoss(addrlen);
/* Free line buffer. */
free(line);
ares_free(line);
/* Return hostent successfully */
*host = hostent;
......@@ -231,7 +231,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
/* If allocated, free line buffer. */
if (line)
free(line);
ares_free(line);
if (status == ARES_SUCCESS)
{
......@@ -239,20 +239,20 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
if (hostent)
{
if (hostent->h_name)
free((char *) hostent->h_name);
ares_free((char *) hostent->h_name);
if (hostent->h_aliases)
{
for (alias = hostent->h_aliases; *alias; alias++)
free(*alias);
free(hostent->h_aliases);
ares_free(*alias);
ares_free(hostent->h_aliases);
}
if (hostent->h_addr_list)
{
if (hostent->h_addr_list[0])
free(hostent->h_addr_list[0]);
free(hostent->h_addr_list);
ares_free(hostent->h_addr_list[0]);
ares_free(hostent->h_addr_list);
}
free(hostent);
ares_free(hostent);
}
return ARES_ENOMEM;
}
......
......@@ -36,7 +36,7 @@ int ares__read_line(FILE *fp, char **buf, size_t *bufsize)
if (*buf == NULL)
{
*buf = malloc(128);
*buf = ares_malloc(128);
if (!*buf)
return ARES_ENOMEM;
*bufsize = 128;
......@@ -59,9 +59,13 @@ int ares__read_line(FILE *fp, char **buf, size_t *bufsize)
continue;
/* Allocate more space. */
newbuf = realloc(*buf, *bufsize * 2);
newbuf = ares_realloc(*buf, *bufsize * 2);
if (!newbuf)
{
ares_free(*buf);
*buf = NULL;
return ARES_ENOMEM;
}
*buf = newbuf;
*bufsize *= 2;
}
......
......@@ -56,7 +56,7 @@ struct timeval ares__tvnow(void)
*/
#ifdef HAVE_GETTIMEOFDAY
else
(void)gettimeofday(&now, NULL);
(void)gettimeofday(&now, NULL); /* LCOV_EXCL_LINE */
#else
else {
now.tv_sec = (long)time(NULL);
......
This diff is collapsed.
......@@ -2,7 +2,7 @@
#define __CARES_BUILD_H
/* Copyright (C) 2009 - 2010 by Daniel Stenberg et al
/* Copyright (C) 2009 - 2013 by Daniel Stenberg et al
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
......@@ -216,10 +216,12 @@
/* ===================================== */
#elif defined(__GNUC__)
# if defined(__i386__) || defined(__ppc__)
# define CARES_SIZEOF_LONG 4
# elif defined(__x86_64__) || defined(__ppc64__)
# if defined(__LP64__) || \
defined(__x86_64__) || defined(__ppc64__)
# define CARES_SIZEOF_LONG 8
# elif defined(__ILP32__) || \
defined(__i386__) || defined(__ppc__) || defined(__arm__)
# define CARES_SIZEOF_LONG 4
# endif
# define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
......
......@@ -9,9 +9,18 @@
/* when building as static part of libcurl */
#undef BUILDING_LIBCURL
/* Defined for build that exposes internal static functions for testing. */
#undef CARES_EXPOSE_STATICS
/* Defined for build with symbol hiding. */
#undef CARES_SYMBOL_HIDING
/* Definition to make a library symbol externally visible. */
#undef CARES_SYMBOL_SCOPE_EXTERN
/* Use resolver library to configure cares */
#undef CARES_USE_LIBRESOLV
/* if a /etc/inet dir is being used */
#undef ETC_INET
......@@ -322,8 +331,7 @@
/* Define to 1 if you have the ws2tcpip.h header file. */
#undef HAVE_WS2TCPIP_H
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
/* Define to the sub-directory where libtool stores uninstalled libraries. */
#undef LT_OBJDIR
/* Define to 1 if you need the malloc.h header file even with stdlib.h */
......@@ -338,9 +346,6 @@
/* Define to 1 if _THREAD_SAFE preprocessor symbol must be defined. */
#undef NEED_THREAD_SAFE
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#undef NO_MINUS_C_MINUS_O
/* cpu-machine-OS */
#undef OS
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment