F/template related refactors

This is the first of my series of pull request, against current master. It contains a few refactors I did while creating the $(template) template function, and later the mechanism to define user-defined template functions in the syslog-ng configuration.

These patches were already reviewed, and oked in the f/assorted-changes-for-integration branch.

Each of the patches survive a "make check" separately.

Please merge!