Split ECPGdo() in constituent parts

This splits ECPGdo() into ecpg_prologue(), ecpg_do() and
ecpg_epilogue(), and renames free_params() into ecpg_free_params() and
exports it.  This makes it possible for future code to use these
routines for their own purposes.

There is no user-visible functionality change here, only code
reorganization.

Zoltán Böszörményi

Reviewed by Antonin Houska.  Larger, older versions of this patch were
reviewed by Noah Misch and Michael Meskes.