The Hasse principle and the Brauer-Manin obstruction for curves