genhash: ensure CLRF{2} HTML body separator won't slip

Previously, the code (mistakenly) relied on \r\n\r\n sequence being read
from non-blocking socket in one go, which is not always the case.

This patch builds upon existing infrastructure to "minimize buffer using
no 2*CR/LF found yet" that was probably designed for what is completed
now -- keep up to 4 last bytes of the last read at the beginning of the
working buffer (as these might fit the separator or its part that would
be missed upon subsequent processing), append read data from the current
one and only then try to extract the beginning of HTML body start from
it.  This should guarantee we never miss this event.

Previously, it was possible as observed with, e.g., Python
SimpleHTTPServer.  In such case, the MD5SUM returned was that
of empty string: d41d8cd98f00b204e9800998ecf8427e.

In the wider context of the project, it can have some negative
consequences.  Even after this changeset is applied, it might still
be recommendable to recheck the hash against the output of, e.g.:

  curl -k ${URL} | md5sum

but only in case no redirections or similar fancy things are present.

Also added is an executable test;  demonstration of the issue and
the fix is as follows (dot denotes success, 10 errors encountered
lead to premature exit):

$ ./genhash-test.sh
> Test TESTFILE=genhash-test.sh with
> MD5SUM=0fcdd1e13b2eb119f2eadf73463d2169
> Using GENHASH=../bin/genhash
> Waiting for Python SimpleHTTPServer...
> Serving HTTP on 0.0.0.0 port 8000 ...
> Python SimpleHTTPServer started

BEFORE:

> d41d8cd98f00b204e9800998ecf8427e
> .
> d41d8cd98f00b204e9800998ecf8427e
>
> d41d8cd98f00b204e9800998ecf8427e
>
> d41d8cd98f00b204e9800998ecf8427e
>
> d41d8cd98f00b204e9800998ecf8427e
> ..
> d41d8cd98f00b204e9800998ecf8427e
>
> d41d8cd98f00b204e9800998ecf8427e
>
> d41d8cd98f00b204e9800998ecf8427e
>
> d41d8cd98f00b204e9800998ecf8427e
>
> d41d8cd98f00b204e9800998ecf8427e
>
> --- 10 ---

AFTER:

> .....................................................................
> .....................................................................
> .....................................................................
> .....................................................................
> .....................................................................
> .....................................................................
> .....................................................................
> .................
> --- 0 ---

As apparent, previously the success was random, now it should be
reliable.

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
genhash: generalize the hash algo parts, add SHA1

This patch adds support for hash algo suite extension with SHA1 being
a first one to be available together with a default MD5.

The remaining change on the health-checker subsystem side is to make
analogous modifications and to teach it to recognize the intended
hash algorithm based on the length of the digest (provided that extra
care is taken that no two algorithms will ever alias in this regard).

Also the test script for genhash was extended to conditionally use SHA1.

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
genhash: clean up the hash algo generalizing step

Access to the hash-specific context was simplified as I've now checked
some C guarantees regarding union/it's members initial address vs.
aligning so now extra inlined accessor function is needed.
This simplified the code a bit.

Also now the hash-specific object is directly pointed to by SOCK object
instead of carrying just the index to the table of hashes and doing
the respective access via a global again and again.

Next, I've concentrated some hash-related declarations to the new hash.h
file.  This was mostly motivated by a need to break the circular include
dependency that have arisen.  As a consequence, part of the recent clutter
I brought in was removed again.  Most of FEAT_SHA1 conditional compilation
is here.

Previously separated table in main carrying the hash IDs to be printed
in the help screen was merged into the table carrying all the other
necessary information about the particular hashes.

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Merge pull request #28 from jnpkrn/master

genhash: HTTP handling fix, hash algo suite extension, and test script