Allow to pipe events in json format though a unix socket/fifo

Requested by:	PC-BSD

Conflicts:
	libpkg/pkg_config.c
Do not forget that pkg.h.in has to be modified not pkg.h

Conflicts:
	libpkg/pkg.h.in
Fix merging
Fix a typo and push the message in a data object

Reported by:	jilles
Add errno to the struct pkg_event.e_errno so errno is not accidentally overwritten somewhere in the middle.
Add error message in json for ERRNO events, add the errno number to the data object

Suggested by:	jilles
Show errors with the right errno
Escape strings before appending them to json

Conflicts:
	libpkg/pkg_event.c