[systemd-devel] Configuration file parser library

Lennart Poettering lennart at poettering.net
Sun Nov 10 13:54:21 PST 2013


On Sat, 09.11.13 09:02, Chris Morgan (chmorgan at gmail.com) wrote:

> Hello.
> 
> I wanted to implement a configuration file format for an application of
> mine that uses a similar format to what systemd uses. I was wondering if
> the parser used today was from an external library. I googled a bit but
> wasn't able to dig anything up. I haven't looked at the code in detail yet.

We use our homegrown code for parsing configuration files. It's fancier
these days than it used to be (even using gperf perfect hash tables for
key lookup), but it's nothing I'd ever want to see used outside of our
specific domain of low-level system components.

Use GLib's GKeyFile in other projects. We try to stay compatible with
it, however only in one way, i.e. so that GKeyFile can be used to write
configuration files for systemd and has access to all features of
systemd, however, not all systemd configuration files can be read by
GKeyFile. (the reason for that is mostly that we allow multiple
assignments to the same key, which GKeyFile (currently) doesn't allow,
and more suggests pushing a serialization of multiple assignments into
the same line, which is really difficult to read though as we believe,
and systemd runs into this quite often).

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list