Write a C program, called msg.c, that reads messages from an input file (or stdin) and verifies whether the messages are valid or not. We developed a protocol for reading messages from a device. There are different length messages. Each message has rules, described below. Messages are separated by anewline.. Each message is followed by a description, some examples, and a Deterministic Finite State Automaton (DFA) which recognizes the message. Before input is read, we are instate 1. We transition states on each character read. If, at the end of input, we are in an accepting state (double circle), then the message is valid. E201022011101F Starts with an E followed by a string of digits 0 1 or 2 followed by an F. E.g.: Starts with a P, followed by arbitrary number of BC (including none). E.g.: РВСВСВС Starts with a Q . Followed by a string of 6 and 7, where the number of 7 s must be odd.E.g.: Q7 Q76767 Q66666676666 ork: Starts with an M, followed by a foo or an eep. E.g.: MPBC ME2010201F Input You will read input from the filename provided as the first argument on the command line. If you cannot open it for reading, print a meaningful message, and quit. If no filename is provided,you will read from stdin . Note, stdin is of type FILE*, and can be read exactly like a file. Output Print out the message, followed by a space, then OK if the message is valid, FAIL otherwise.One per line. Hints You maybe find these helpful. If you do not, that is okay. They are not directives. Read each line, parse the string, or Use fgetc(), parse the input directly Make a function for each message foo: еер: op:

Fig: 1

Fig: 2

Fig: 3

Fig: 4

Fig: 5

Fig: 6

Fig: 7

Fig: 8

Fig: 9

Fig: 10

Fig: 11

Fig: 12

Fig: 13

Fig: 14

Fig: 15

Fig: 16

Fig: 17

Fig: 18

Fig: 19

Fig: 20

Fig: 21

Fig: 22

Fig: 23

Fig: 24

Fig: 25

Fig: 26

Fig: 27

Fig: 28

Fig: 29

Fig: 30

Fig: 31

Fig: 32