This answer is supposing that you want to roll your own parser using Standard C. In practice it is usually better to use an existing parser because they have already thought of and handled all the weird things that can come up.
My high level approach would be:
- Read a line
- Pass pointer to start of this line to a function
parse_line
:- Use
strcspn
on the pointer to identify the location of the first:
or;
(aborting if no marker found) - Save the text so far as the property name
- While the parsing pointer points to
;
:
- Use
- Call a function
extract_name_value_pair
passing address of your parsing pointer.