Search for neutrinos from the Sun and the Earth with the MACRO detector