An extension of the Wagner theory of alloy oxidation and sulfidation