MB-6945 Backport file format refactor from indexer

Pulling in changes from commit c7b1432 on the indexer branch.
Originally reviewed at http://review.couchbase.org/19815

These changes consolidate the file format definition and
make code dealing with the file format cleaner, and also
make it much easier to change the file format.

Change-Id: I4ee37e66f451fb77fcc3f6264a262c9bbb5417e6
Reviewed-on: http://review.couchbase.org/22103
Reviewed-by: Jens Alfke <jens@couchbase.com>
Reviewed-by: Damien Katz <damien@couchbase.com>
Tested-by: Damien Katz <damien@couchbase.com>
MB-6945 Increase rev_seq width to 48 bits

Also moving rev_seq before content_meta for better alignment.

Change-Id: Iac25b95ff4f1ace7145eb2b9f01e26bfeee7cf69
Reviewed-on: http://review.couchbase.org/22104
Reviewed-by: Damien Katz <damien@couchbase.com>
Tested-by: Steve Yen <steve.yen@gmail.com>
MB-7306 Fix to the memory leak in lookup_callback()

Change-Id: Id7d73a09c55d965405aae4d50ce2f9d63057e3ba
Reviewed-on: http://review.couchbase.org/22966
Reviewed-by: Jin Lim <jin@couchbase.com>
Tested-by: Jin Lim <jin@couchbase.com>
Reviewed-by: Aaron Miller <apage43@ninjawhale.com>
MB-7297 Use size_t for python wrapping for 32-bit support

The couchstore/couch_db.h uses size_t for several struct fields, and
size_t can be either 32-bits or 64-bits, depending on platform.
So, instead of c_ulonglong, use c_size_t for those fields.

Here, we assume sizeof(off_t) == sizeof(size_t). Not a 100%
bulletproof assumption, but it seems to work on tests.

Additionally, use uint64_t for the couchstore_open_db() flags
parameter rather than the platform-specific int.

Change-Id: I36898d0260d44d57fe16ff7e16c7759c4686b4e4
Reviewed-on: http://review.couchbase.org/22969
Tested-by: Steve Yen <steve.yen@gmail.com>
Reviewed-by: Aaron Miller <apage43@ninjawhale.com>
Tested-by: Aaron Miller <apage43@ninjawhale.com>
MB-100: use optimized 64-bit byteswap code on GNU/Linux

glibc does not have htonll but it does have bswap_64 as well as bsd's
htobe64. bswap_64 is more than good enough.

Change-Id: Iab325a0a5872d3a9379dac565ea177fe4bf6d9cb
Reviewed-on: http://review.couchbase.org/21493
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aaron Miller <apage43@ninjawhale.com>
Reviewed-by: Damien Katz <damien@couchbase.com>
Reviewed-by: Aaron Miller <apage43@ninjawhale.com>
Merge tag '2.0.0' into master

2.0.0

* tag '2.0.0':
  MB-7297 Use size_t for python wrapping for 32-bit support
  MB-7306 Fix to the memory leak in lookup_callback()

Change-Id: I97cacb5970f7f7ac3bacaf05394b987697fd79c3
MB-6486 Can print out a local doc with dbdump

Example usage, for getting vbucket states:
 ./couch_dbdump --local _local/vbstate /data/default/*.couch.*

Change-Id: I3b40096a5777ef6aa2272143be4039dd7bfd8951