generate_packets.py: Separate functions for writing each output file
Part of #43927. Break up the code for each of the six different output files (common/packets_gen.[ch], client/packhand_gen.[ch], and server/hand_gen.[ch]) into separate functions.
Part of #43927. Break up the code for each of the six different output files (common/packets_gen.[ch], client/packhand_gen.[ch], and server/hand_gen.[ch]) into separate functions.