>>In Win32 there is a set of functions that allow an application to store
>>configuration information. They are:
>fscanf(fp,"keyword=%s\n",string); /* assumes fp is fopen()ed */
>fscanf(fp,"keyword=%d\n",&number); /* assumes fp is fopen()ed */
>Of course, the standard file I/O error checking should be performed
>at each step (fopen/fcreat, fscanf/fprintf, fclose).
>>I'm just making the transition to Linux and am looking for functions that
>>perform the same functionality. I've seen .conf files in a lot of places
>>and figure that there must be a standard set of functions to access and
>>write data to these files.
Somewhat contrary to the above suggestion, I'll suggest a couple of
URLs to packages that provide somewhat more "intelligent" handling of
There is not a single "standard" or "definitive" approach or library,
and there is unlikely to be complete equanimity on the "right"
approach, which is quite fair enough because there are different kinds
of configuration information for which different behaviours are
<ftp://ftp.windowmaker.org/pub/libs> The libPropList library provides
an abstraction to read/write NeXTstep-style default databases.
"The libPropList library, hereafter referred to as PL, uses an opaque
data type to represent a tree structure made of strings, data blocks,
arrays and dictionaries (key-value pair lists). This structure can be
manipulated, written out to and read in from a file, and synchronized
with the contents of a file. The purpose of PL is to closely mimick
the behaviour of the property lists used in GNUstep and OPENSTEP
(there formed with the NSString, NSData, NSArray and NSDictionary
classes) and to be compatible with it. PL enables programs that use
configuration or preference files to make these compatible with
GNUstep or OPENSTEP's user defaults handling mechanism, without
needing to use Objective-C or GNUstep or OPENSTEP themselves."
<ULINK URL="http://www.thestuff.net/libcfg/?theme=lcars"> LibCFG
<ULINK URL="http://18.104.22.168/gmd/opStore/">opStore - Linux "Registry"
The GNOME and KDE "desktop environments" both have APIs to provide
somewhat-smart handling of configuration information.
None of these schemes are "definitively preferable," but I would
suggest considering using one of these schemes as they can provide
such advantages as:
- Already having debugged locking issues.
- Already being network-aware.
- Already providing debugged parsers.
- Providing enough structure/metadata as to allow tools to be
constructed to help manage the configuration data. ("Linuxconf or
COAS may already know how to treat it as part of the data they
There are ample valid indications that building up monstrous fragile
binary databases is "really dumb." The fragility of the Windows
Registry is a testament to that.
That does *not* provide a testament to the notion that "using some
common facilities to manage configuration data" is correspondingly a
really dumb idea.
Take a look at libProplist; that seems to be one of the more
well-thought-through configuration libraries...
"Lumping configuration data, security data, kernel tuning parameters,
etc. into one monstrous fragile binary data structure is really dumb."
- David F. Skoll