Fix endianness problems outwith CRAM code

In swap_data(), for 'B' we must copy the count into  n  when it is in
host format.  In test/sam.c, the same count is in host format while we
are checking it.  Hat tip @azlicic, cf #99; partial fix for #98.
Set NM/MD creation to be on by default.

Also amended the test harness to ignore NM and MD changes.  This isn't
ideal, but as we have no explicit tests for the validity of NM or MD
at the moment then it is sufficient.
synced_reader: Removed unused code
vcf: Change of bcf_hdr_add_sample() usage.

To increase performance with thousands of samples, bcf_hdr_sync() is called
only when explicitly requested by passing NULL.
Add sam_open_mode() API function

Aids in parsing options like -Ocram.  Requires documentation, but we'll
add that when we're sure the API is stable (in particular, having the
caller pre-supply the "w" is perhaps not ideal).
Remove val_unused -- use HTS_UNUSED instead

This macro is in the HTS namespace, so less collision-prone.
bcf_write: Error message instead of assert + propagate the error up
vcf_parse: Detect incorrect number of columns
vcf: Fix BCF syncing when only partially unpacked
vcf: Fixes in bcf_translate
bgzf: Do not end prematurely on non-critical Z_BUF_ERROR zlib error
vcf: Fix bcf_hdr_id2hrec, col_type parameter is needed as well
bcf_trim_als: Propagate error instead of assert
bcf_update_alleles: Reference length with INFO/END

must be set explicitly by the caller. If unset, bcf_write()
calls strlen(ref) to set it in order for indexing to work.
Fix in index initialization
Fixed bug in bcf1_sync. The main cause of the bug is as follows:
bcf_unpack(bcf_rec, BCF_UN_STR);
bcf_update_id(bcf_rec, id);
This causes bcf_rec->d.shared_dirty to be set.
duplicate = bcf_dup(bcf_rec);
This calls bcf1_sync(). Since bcf_rec->d.shared_dirty is set, the shared
data is re-created in tmp.s, bcf_rec->shared.s is freed and
bcf_rec->shared.s = tmp.s. However, bcf_rec->unpack_ptr and
bcf_rec->d.info[i].vptr still point to the old shared.s region which is
invalidated.
The fix is done by assigning bcf_rec->unpack_ptr and the vptr fields
after tmp.s is fully constructed in bcf1_sync. I use unpack_offset and
offset_array to track the offsets of these fields with respect to tmp.s
Improved bug fix of bcf1_sync() from the commit 2504243:

- additional data structures are not necessary
- FORMAT fields were not treated

Updated VCF API tests to cover situations where unpacked
structures are synced and edited again.
synced_reader: Consider non-variant sites as matching in comparisons
Add extern "C" around API to enable C++ linking