ensure writes to the edited ini are never lost

Following on from commit 0.3-11-g231aaaf which fulfilled the "AC",
ACID properties for updating a file, this employs locking
to fulfil the Isolation ACID property, to ensure that
writes are not lost in the presence of overlapping writers.

Locking is quite painful on GNU/Linux and even more so cross platform.
I noticed the following useful notes while implementing this scheme:
  http://upsilon.cc/~zack/teaching/1314/progsyst/cours-07-flock.pdf
  http://0pointer.de/blog/projects/locking.html
  http://www.dwheeler.com/secure-class/Secure-Programs-HOWTO/avoid-race.html
  http://rcrowley.org/2010/01/06/things-unix-can-do-atomically.html

In summary we use two schemes that should work on most platforms,
and on most distributed file systems.  The schemes are keyed on
the --inplace option (which was renamed from --rewrite since it
now also pertains to --get).

The default scheme is to use a separate lock file alongside
the file being operated on, created with O_EXCL.  This is used
because the default file replacement scheme also needs to be
able to create files alongside a file being replaced.  Also
the fcntl() type locks used in the other scheme are not possible
when the locking files are not persistent.

The scheme used when --inplace is selected, since the file
being edited is persistent is the fcntl.LOCK_EX on POSIX and
msvcrt.LK_LOCK on windows.

The caveats of each method are:

  --inplace mode locking caveats:
    - File must be writeable
    - File should be generally non readable to avoid read lock DoS
  default replace mode locking caveats:
    - Possibility of stale lock files left on crash leading to deadlock
    - Less responsive when there is contention
    - Contention between readers