I am looking for a good config file library for c that is not xml. Optimally I would really like one that also has python bindings. The best option I have come up with is to use a JSON library in both c and python. What would you recommend, or what method of reading/writing configuration settings do you prefer?
Asked
Active
Viewed 1,059 times
5
-
3What's wrong with JSON? If you extend this to YAML, it might be even easier to read. What problems do you foresee? – S.Lott Aug 04 '09 at 11:59
-
There is nothing wrong with JSON, I prefer JSON for most everything. My only hesitation was its strict syntax. I want the config file to be easily read/edited by a non-programmer, more beased on whitespace (should have mentioned that). YAML does exactly that! That is exactly what i want, thanks! – user19745 Aug 04 '09 at 12:21
4 Answers
0
You could use a pure python solution like ConfigObj and then simply use the CPython API to query for settings. This assumes that your application embeds Python. If it doesn't, and if you are shipping Python anyway, it might make sense to just embed it. Your C .exe won't get that much bigger if it's a dynamic link, and you will have all the flexibility of Python at your disposal.

Christopher
- 8,815
- 2
- 32
- 41
0
Despite being hated by techies and disowned by Microsoft, INI files are actually quite popular with users, as they are easy to understand and edit. They are also very simple to write parsers for, should your libraries not already support them.
-
1-1: ini files have weird limitations that make them hard to work with except in really simple cases. For those simple cases, a Python file full of assignment statements might be better. – S.Lott Aug 04 '09 at 12:46
-
Well they seemed to work OK for PHP and Samba, for instance. And what are those weird limitations? – Aug 04 '09 at 12:48
-
The structure of an INI (as parsed by configfile) is flat. No structure. So sections have composite names to impose a structure. The logging initialization file, for example, is hard to edit correctly because the section names depend on other ini settings. – S.Lott Aug 04 '09 at 13:58