Mark's networking code

As cleaned up by @ediosyncratic using git filter-branch (among other dangerous tools).
Includes several fixups from later in the branch, but I may have missed some.
Compiled locally and passes all unit and acceptance tests.  Let's see how it fares more widely ...

I suspect reviewing the gross diff is easiest, as there are (even after squashing out a few) quite a lot of changes of mind along the way.  Also: 106 commits.
kacfengine: the vars_in_arrays.cf test was added in the same commit, at least:
https://github.com/ediosyncratic/core/commit/859b4afd8d55c190f7fb26a17e89df32f7a40f16
This is a combination of two commits from Mark, f8393d: Fix to parse unexpanded array references containing scalar variables and a37482: Fix bug 5893; I took the latter to be a fixup of the former (since it undid its change to the regex) but I now see the story was more complex !  I can restore the mention of the redmine ticket to the commit message.