Avoid depending on hash order in gdoc.

Previously, gdoc had a hash of regexp replacements for each output
format, and applied the replacements in the order that "keys" returned
for the hash. However, not all orders are safe -- and now that Perl 5.18
randomises hash order per-process, it only worked sometimes!

For example, this order is OK:

'is a #gnutls_session_t structure.'
'\@([A-Za-z0-9_]+)\s*' -> 'is a #gnutls_session_t structure.'
'\%([A-Za-z0-9_]+)' -> 'is a #gnutls_session_t structure.'
'\#([A-Za-z0-9_]+)' -> 'is a @code{gnutls_session_t}  structure.'
'([A-Za-z0-9_]+\(\))' -> 'is a @code{gnutls_session_t}  structure.'

This one, however, winds up producing invalid texinfo:

'is a #gnutls_session_t structure.'
'\%([A-Za-z0-9_]+)' -> 'is a #gnutls_session_t structure.'
'([A-Za-z0-9_]+\(\))' -> 'is a #gnutls_session_t structure.'
'\#([A-Za-z0-9_]+)' -> 'is a @code{gnutls_session_t}  structure.'
'\@([A-Za-z0-9_]+)\s*' -> 'is a  @code{code} {gnutls_session_t}  structure.'

This patch turns the hash into a list, so the replacements will always
be done in the intended order.

Signed-off-by: Adam Sampson <ats@offog.org>
Detect socket() error responses correctly.

The code was testing the wrong variable...

Signed-off-by: Adam Sampson <ats@offog.org>
Use socketpair() rather than TCP connections.

Besides simplifying the code, this also makes it possible to run "make check"
in parallel -- previously this didn't work because several tests were trying to
bind the same port.

Signed-off-by: Adam Sampson <ats@offog.org>
Disable tests that use socketpair on _WIN32.

socketpair isn't provided on Windows, so these tests should just exit
77.

Note that resume-dtls.c already had a guard like this -- I've rewritten
it to match the others, but socketpair (presumably!) isn't the only
reason that test is disabled on Win32.

Signed-off-by: Adam Sampson <ats@offog.org>
gnutls priority string parsing bug fix

Fix priority string parsing (example: "NONE:+MAC-ALL:-SHA1:+SHA1" misses SHA1 and has MD5 twice)

prio_remove doesn't zero the removed element, prio_add (and perhaps
other functions) assumes the list to be zero terminated.

Make prio_remove zero the element at the end, and use the actual length
of the list in prio_add.

Relying on the trailing zero will fail if the list is full, and might
lead to invalid memory accesses as the loop won't stop until it finds
either the algorithm identifier or 0.
doc update
avoid leaking a buffer element when _gnutls_stream_read returns 0
X.509 server example updated to include OCSP stapling
Merge remote-tracking branch 'origin/master'