Electronic structure and ferromagnetism of transition-metal-impurity-doped zinc oxide