基于C的conf文件阅读器

发布于 2024-08-18 23:07:59 字数 203 浏览 3 评论 0原文

我的代码使用基于文本的conf 文件,其中包含 key=value 类型条目。我想为文件添加节功能,即搜索节数,搜索节中的特定键。

我想知道是否有任何库/函数已经做到了这一点,我可以重用。我的怀疑是肯定的,因为很多 gnu 软件都使用这样的文件。如果 cmd 行标志的 getopt 存在,那么像 conf 文件阅读器之类的东西也应该存在。但我就是找不到它。任何信息表示赞赏。

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, search 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

誰認得朕 2024-08-25 23:07:59

Glib 提供了读取“key=value”类型配置文件的函数。请参阅:http://library.gnome。 org/devel/glib/stable/glib-Key-value-file-parser.html

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

秋意浓 2024-08-25 23:07:59

不幸的是,这些文件的语法有很多变化。有几个库可以执行此操作,看起来 GConf 和 libconfig 可能就是您正在寻找的。

在这种情况下,我有时会查看 Git 的源代码,看看它是如何处理的。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文