X-ray resonant magnetic scattering from structurally and magnetically rough interfaces in multilayered systems. I. Specular reflectivity