I'm trying to parse an iCal input file according to RFC 5545. Specifically: -Property name -Optional parameters, each starting with semicolon ";" and possibly having multiple comma-separated values (parameter values may be double-quoted in which case they could contain colons, semicolons, and commas) -Colon ":" -Property value
Example line:
> ORGANIZER;CN=Obi-WanKenobi;SENTBY="mailto:obiwan@padawan.com":mailto:laowaion@padawan.com
in this case the line would be read into a buffer and parsed (using strtok currently) like this: Organizer is the property name; CN=Obi-WanKenobi and SENTBY="mailto:obiwan@padawan.com" are parameters; mailto:lauwaion@padawan.com is the property value.
I have no idea where to start. The different input cases are almost infinite and I haven't been able to figure out an effective algorithm to cover all of said cases. Is strtok the way to go? or is there another C library that has a more intelligent parser? Need someone to put me on the right track.
I'd suggest that you start with looking at existing C implementation:
Above answers are addressing your immediate question but you might hit other issues as you progress through the RFC5545 standard and looking at what others have done may be helpful