http_digest: Fixed memory leaks from commit 6f8d8131b1
contributors.sh: split lists using " and "

... and require the space after the filtering to make the filter able to
remove names.
THANKS-filter: added another Michał Górny version we've used
tool_strdup.c: include the tool strdup.h

... not the lib/ one that the tool no longer uses!
build: Fixed Visual Studio project file generation of strdup.[c|h]

As the curl command-line tool now includes it's own version of strdup(),
for platforms that don't have it, fixed up the git respository Visual
Studio project file generator to not include the version from lib in the
tool project files, rather than having both lib\strdup.[c|h] and
src\tool_strdup.[c|h] present.
tests: fix memleak in server/resolve.c

This makes LeakSanitizer happy.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
tests: fix libhostname visibility

I noticed that a patched cmake build would pass tests with a fake local
hostname, but the autotools build skips them:

    got unexpected host name back, LD_PRELOAD failed

It turns out that -fvisibility=hidden hides the symbol, and since the
tests are not part of libcurl, it fails too. Just remove the LIBCURL
guard.

Broken since cURL 7.30 (commit 83a42ee20ea7fc25abb61c0b7ef56ebe712d7093,
"curl.h: stricter CURL_EXTERN linkage decorations logic").

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
cmake: fix HAVE_GETHOSTNAME definition

Otherwise Curl_gethostname always fails. Windows has gethostname
since Vista according to
http://msdn.microsoft.com/en-us/library/ms738527%28VS.85%29.aspx, but
accordings to byte_bucket's VC 2005 documentation, it is available even
in Windows 95. (possibly after installing a Platform SDK, the
Windows Server 2003 SP1 Platform SDK should be sufficient).

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
cmake: build libhostname for test suite

Used by some test cases via LD_PRELOAD in order to fake the host name.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
cmake: add ENABLE_THREADED_RESOLVER, rename ARES

Fix detection of the AsynchDNS feature which not just depends on
pthreads support, but also on whether USE_POSIX_THREADS is set or not.
Caught by test 1014.

This patch adds a new ENABLE_THREADED_RESOLVER option (corresponding to
--enable-threaded-resolver of autotools) which also needs a check for
HAVE_PTHREAD_H.

For symmetry with autotools, CURL_USE_ARES is renamed to ENABLE_ARES
(--enable-ares). Checks that test for the availability actually use
USE_ARES instead as that is the result of whether a-res is available or
not (in practice this does not matter as CARES is marked as required
package, but nevertheless it is better to write the intent).

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
symbol-scan.pl: do not require autotools

Makes test1119 pass when building with cmake.

configurehelp.pm is generated by configure (autotools). As cmake does
not provide a separate variable for the C preprocessor, default to cpp.
Before commit ef24ecde68a5f577a7f0f423a767620f09a0ab16 ("symbol-scan:
use configure script knowledge about how to run the C preprocessor"),
this tool would also use 'cpp'.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
tests: use single quotes for some tests

This prepares for a future patch where commands are not executed by a
shell anymore, but by perl. In the future, Text::ParseWords will be used
to convert a command to an array.

According to 2.2.3 Double-Quotes, chapter Shell Command Language of
The Base Specifications Issue 6 (IEEE Std 1003.1 2004), double quotes
should not touch characters other than

    $ ` " \ <newline>

Unfortunately, perls Text::ParseWords does not handle this correctly,
removing the slash for everything else. Avoid this incompatibility by
using single quotes instead.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
tests/test22: expand a backtick command

This is the only user of the backtick operator in the command. As the
commands will soon not be executed by a shell anymore (but by perl),
replace the command with its output.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
runtests.pl: safer system() calls

Command invocation via runclient() (which calls system()) using a string
invokes the shell. This has the problem that tests which load
libhostname.so via LD_PRELOAD break when the library cannot be loaded
into the shell (when cURL is built with AddressSanitizer for example).

Fix this issue by making runclient() accept the command as array
which causes a bypass of sh. Replace system() by IPC::Run to allow
I/O redirection. Note that sh is only bypassed if curl is a binary as is
the case with cmake or with the curl binary installed via `make
install`. This patch does not fix the issue with the libtool wrapper of
autotools.

precheck is now also wrapped into runclient rather than using backticks
to take advantage of the sh bypass.

Implementation details: as runclient has become more sophisticated and
can also return stdout, get rid of runclientoutput.

Note for the curious: previously a gdb invocation would feed stdin via
'set args <input'. This only works because the command is interpreted as
a shell command. After this patch stdin is fed directly.

Detection of the `valgrind --tool` option was previously done by
invoking grep. Remove this use of grep. While at it, remove
`valgrind --version` invocation to determine whether `--log-file`
should be used instead of `--logfile`. Parse this information directly
from `valgrind --help` which was executed earlier.

As for differences in log file, these are just whitespace (trailing
space for `curl --version` command, spaces after redirection operator)
and quoting (quotes typically get stripped).

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
runtests.pl: simplify command environment handling

Rather than saving valid environment variables for restoration later,
use 'local' to limit the environment changes to the block executing
a command.

Rationale: LD_PRELOAD may not work with all executables. Previously
it would break on the shell when compiled with AddressSanitizer
(-fsanitize=address), but that is avoided by not executing string
commands anymore. gdb would still be executed with LD_PRELOAD though,
so setting $ENV in this way was not sustainable.

After this patch, environment variables are passed to executions of
precheck (for chkhostname), command (for curl) and postcheck (for
symmetry with precheck, it does not actually use it).

Note that this autotools with AddressSanitizer enabled is still
incompatible with this mode of execution as 'curl' is a libtool wrapper.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
configure: adjust tests to avoid -Werror breakage

These series allow ./configure to run when CFLAGS contains -Werror.

Search for AC_LANG_PROGRAM in *.m4, configure.ac and void-cast all
unused variables. Furthermore, a sin6_scope_id variable is cast void and
two main functions gained an explicit int return value.

While gethostname and inet_ntop in curl-functions.m4 got their
parameters and const-correctness fixed, it was not trivially possible to
fix AC_LANG_FUNC_LINK_TRY which fails with "conflicting types for
built-in function 'strdup'" (for example). This patch does not fix that
remaining error, see also the autoconf manual:

    "It is considered to be severely broken, and in the future will be
    removed in favor of actual function calls (with properly typed
    arguments)."

While at it, update copyright years.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
lib/connect: restrict IP/TCP options to said sockets

This patch prepares for adding UNIX domain sockets support.

TCP_NODELAY and TCP_KEEPALIVE are specific to TCP/IP sockets, so do not
apply these to other socket types. bindlocal only works for IP sockets
(independent of TCP/UDP), so filter that out too for other types.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
sws: move away from IPv4/IPv4-only assumption

Instead of depending the socket domain type on use_ipv6, specify the
domain type (AF_INET / AF_INET6) as variable. An enum is used here with
switch to avoid compiler warnings in connect_to, complaining that rc
is possibly undefined (which is not possible as socket_domain is
always set).

Besides abstracting the socket type, make the debugging messages be
independent on IP (introduce location_str which points to "port XXXXX").
Rename "ipv_inuse" to "socket_type" and tighten the scope (main).

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
sws: restrict TCP_NODELAY to IP sockets

TCP_NODELAY does not make sense for Unix sockets, so enable it only if
the socket is using IP.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
sws: add UNIX domain socket support

This extends sws with a --unix-socket option which causes the port to
be ignored (as the server now listens on the path specified by
--unix-socket). This feature will be available in the following patch
that enables checking for UNIX domain socket support.

Proxy support (CONNECT) is not considered nor tested. It does not make
sense anyway, first connecting through a TCP proxy, then let that TCP
proxy connect to a UNIX socket.

Signed-off-by: Peter Wu <peter@lekensteyn.nl>