Measurement of charm fragmentation fractions in photoproduction at HERA