ccan/io: make io functions more generic.