Is there any standard way of reading a kind of configuration like ini files for linux using c? I am working on a Linux based hand held and writing code in c.
Otherwise, I shall like to know about any alternatives.
Is there any standard way of reading a kind of configuration like ini files for linux using c? I am working on a Linux based hand held and writing code in c.
Otherwise, I shall like to know about any alternatives.
No, there isn't one standard way. I'm sorry, but that is probably the most precise answer :)
You could look at this list of Linux configuration file libraries, tho. That might be helpful.
If you can use the (excellent, in any C-based application) glib, it has a key-value file parser that is suitable for .ini-style files. Of course, you'd also get access to the various (very nice) data structures in glib, "for free".
I have explored and even used LibConfig. But the footprint is high and my usage is too simple. So, to reduce the footprint, I have rolled out my own implementation. The implementation is not too generic, in fact quite coupled as of now. The config file is parsed once at the time of starting the application and set to some global variables.