Standard INI parser

Hi all,
Is there a standard INI parser library commonly used in the BSD community, ideally one built into FreeBSD? I need to parse several INI files and would prefer not to import a 3rd party library into this application. This is a C application.
Thanks
 
Look at the wikipedia page for INI file. If you have GTK installed, you would have one already.

If the ini file format is simple (no comments, no special characters, no continuation lines), then parsing it would take half hour for an experienced C programmer; less than trying to interface to an existing library. This assumes that you have control over the ini file format and can legislate away complex and bizarre stuff in the input file.

If you have a choice to select a better file format (ilke kpa said), pretty much anything is better than INI. Even XML.
 
I do not have control over the INI format, it must be INI.
And while INI files are inherently simple, this could be arbitrarily complex.
 
Well, look at that Wikipedia page for libraries. And obviously do a web search.

Do you have to do the parsing in C? String handling in C is doable, but tedious, difficult, and error-prone. It might be a better idea to use a language with better string handling tools (Python, Perl, ...) for pre-processing the INI into a super-safe and easy format, and then sucking that into C.
 
It might be a better idea to use a language with better string handling tools (Python, Perl, ...) for pre-processing the INI into a super-safe and easy format, and then sucking that into C.
+1 for Python. Not only is it fairly easy to implement (ideally, as a dictionary), but Python 3 even provides a module (1, 2) just for that purpose.
 
[edit]Never mind, I can't read. My comments are not relevant.[/edit]

Perl has a built in INI parser. It is dead simple to use. Just point it at the INI file and you get a data structure.

People tend to pick their language first, then go find the libraries. I don't think you mentioned what language you want to use.
 
Last edited:
Back
Top