开发者

C based conf file reader

My code uses a text based conf file with key=value type entries. I want to add sections feature for file, i.e. search for number of sections, se开发者_运维问答arch for particular key in a section.

I was wondering if there are any libraries/functions which already does this, that I can reuse. My suspicion is yes, since lot of gnu software uses such files. If getopt for cmd line flags exists, something like a conf file reader should also exist. But I just can't find it. Any information is appreciated.


Glib provides functions for reading 'key=value' type configuration files. See: http://library.gnome.org/devel/glib/stable/glib-Key-value-file-parser.html.


Unfortunately, there is a lot of variation with the syntax for those files. There are a couple libraries which do this, it looks like GConf and libconfig might be what you're looking for.

In situations like these, I sometimes peek at the source code to Git to see how it's handled there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜