The Generation of Magnetic Fields in Astrophysical Bodies. I. The Dynamo Equations