Add htole32 replacement and proper header detection of endian.h.

This is far enough from its `#if` that it'd be a kindness to the reader to put a comment after it saying which `#if` it closes.