ares_build.h: fix building on 64-bit powerpc

There are two issues.

1. gcc actually does not use __ppc__ and __ppc64__ but __PPC__ and
__PPC64__.  The tests of __ILP32__ and __LP64__ are sufficient for gcc.

2. clang defines __GNU__ and defines both __ppc64__ and __ppc__ when
targeting ppc64.  This makes CARES_SIZEOF_LONG to be 4 on a ppc64 system
when building with clang.

My patch is two change the order of the checks so that we check the
64-bit case first.
ares_parse_aaaa_reply: fix leak when reply contains 1 alias and no address
Revert "ares_parse_aaaa_reply: fix leak when reply contains 1 alias and no address"

This reverts commit 440110b303fdbfadb3ad53d30eeb98cc45d70451.
Allow specification of search domain in ahost

Add the "-s domain" command line option to override the search
domains.
Don't override explicitly specified search domains

Only set search domains from /etc/resolv.conf if there isn't a value
already present in the channel.
ares_parse_soa_reply: Do not leak rr_name on allocation failure

If ares_malloc_data failed, already allocated rr_name would go out of
scope.
Update ahost man page to describe -s option.

Commit ee22246507c9 added the -s <domain> option to the
ahost command, but neglected to update the man page to
describe it.

Also fix typo in description of -t option.
Move memset call below platform-specific declarations

A GitHub commenter [1] says that my recent change to ahost.c has
problems compiling on Windows + C89 platforms.

[1]  https://github.com/bagder/c-ares/commit/ee22246507c9#commitcomment-6587616
host_callback: Fall back to AF_INET on searching with AF_UNSPEC

Previously, when an ares_gethostbyname() searched with AF_UNSPEC and the
first AF_INET6 call only returned CNAMEs, the host_callback never
retried AF_INET.

This patch makes sure than on ARES_SUCCESS, the result of AF_INET6 is
taken as authoritative only if the result contains some addresses.
Add -t u option to ahost

Add an option to allow specification of the AF_UNSPEC
address family.
CONTRIBUTING: add file to indicate mailing list is preferred
Comment in ares_ipv6.h
Null check before dereference

Fix Coverity error CID 56880

Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
Fix integer shift overflow if both tcp_socket and udp_socket are set

The problem occurs if at the start of the loop the sockindex is at the
last valid ARES_GETSOCK_MAXNUM position. If then both udp_socket and
tcp_socket are valid, sockindex gets incremented for UDP first and
points one entry behind the array for the tcp block.
So the fix is to check after every increment of sockindex if it is still
valid.

Fix Coverity error CID 56878

Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
Free temporary variable in error path

Fix Coverity CID 56890

Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
Re-start loop if select fails

Fix Coverity error CID 56882

Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
Prevent tmpbuf from overrunning

Fix Coverity error CID 56886.

Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
ares_getnameinfo.3: there is no ares_getaddrinfo
Continue loop if space for hostname not large enough

When attempting to build a search domain from the local hostname
(used as a fallback when no other methods have given a search
domain), the code doubles the buffer size on each loop iteration.

However, the loop previously had a WHILE_FALSE terminator so the continue
statement exited the loop rather than going round again.
Destroy options if ares_save_options fails

It's possible that, if ares_save_options failed, the opts structure
would contain some allocated memory. Calling ares_destroy_options in
this case is safe, because ares_save_options zeroes out the memory
initially.