Hmm, this patch adds a function connectDatabase() to pg_restore, but a function that's almost identical already exists in pg_dumpall. I suggest they should be unified. Maybe create a new file for connection management routines? (since this clearly doesn't fit common.c nor dumputils.c).
-- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/ "In Europe they call me Niklaus Wirth; in the US they call me Nickel's worth. That's because in Europe they call me by name, and in the US by value!"