Fix memory leak; use in-memory buffer rather than tmpfile

- The way I was iterating through the list of keys was stupid, causing all but
  the last element in the list to not be freed. Fix:

    - for (; keys != NULL; keys = g_list_next(keys)) {
    + for (node = keys; node; node = node->next) {

- Use a GString rather than a tmpfile as the buffer for the generated XML.
- Replace threaded, blocking TCP socket IO with an async socket service.
- Use lowercase_with_underscore for all functions.

Change-Id: Iffb5eb6621f4a277970356a2b5e0bd3713506e66