Implementation of input-files.
This also implements the programmatic interface input-files-prog. The flag progp, passed to some of the implementation functions below, says whether the programmatic interface has been called.