Fix checkresult output processing.

Checkresult output submitted through files is stored as a single line
with newlines (and backslashes) escaped so Core can read the complete
output as one line. The corresponding unescaping was not performed when
reading back from the files. These changes correct this by unescaping
the output after it is read from the checkresult file, and before any
further processing. We now use one newline-delimited format internally
for output data from all sources (checkresults spool, command file,
workers).

Perfdata from the first line was not being concatenated correctly to
following lines. A space is now concatenated before additional lines,
and a terminal space is not added to only be trimmed off later.

In support of these changes a new unescape_newlines() functions was
added to base/utils.c that performs the converse of the existing
escape_newlines(). Both of these functions allocate exactly the memory
needed for the new string they return, and not assume a worst case.
Using the improved escape_newlines() to escape the long_output at the
end of parse_check_output() eliminates an unnecessary malloc()/free()
pair.

The line processing code in parse_check_output() was strdup()ing each
line it processed, and then memmove()ing the remaining input to the
beginning of its buffer. As the memove() and earlier processing modify
the input buffer anyway, this alloc/copy/free/move is entirely unneeded:
the per-line processing can use the input buf directly. Modifying the
line processing loop to update buf to point at the next line to process
eliminates the extra memory movement.

Additionally, the checkresults spool directory is now installed with the
same ownership and permissions as the external command directory. This
allows members of the Nagios Command group (nagcmd by default) to submit
checkresults by default, and also keeps reinstalls or upgrades from
resetting the ownership and permissions.

All checkresult output, single or multiple line, and from all sources,
should now be parsed correctly (and more efficiently) by Core.
Don't crash with no perfdata on first line.

Check db2.buf is not NULL before dereferencing. Since dbuf_init()
initializes an empty dbuf, the buf member will be NULL until it is
allocated in dbuf_strcat().
Hanndle empty short output more sensibly.

When the first line of output contained perfdata but no short output,
the perfdata portion of the line was used as the short output. The
short output is now taken to be an empty string in these cases.

Cases where the first output line is entirely empty (no whitespace)
are still handled as "(No output returned from plugin)", whether or
not additional lines follow.

These situations are unusual, and likely indicate a misbehaving check,
but are not disallowed by our documented output format.

Additionally: avoid no-op iterations of the line processing loop on
empty input or end of input; and clarify/cleanup some comments.
Rename base/utils.c:unescape_newlines() to avoid confusion and conflicts, and make it static for now.
Merge remote branch 'remotes/origin/fix-0616-checkresult-output'