libconfini
Yet another INI parser
|
Yet another INI parser
libconfini is the ultimate and most consistent INI file parser library written in C. It focuses on standardization and parsing exactness and is at ease with almost every type of file containing key/value pairs.
The library is fast and suitable for embedded systems. Its algorithms are written from scratch and do not depend on any external library, except for the C standard headers stdio.h, stdlib.h and stdint.h.
Rather than storing the parsed data, libconfini gives the developer the freedom to choose what to do with them through a custom callback invoked for each INI node read. The API has been designed to be powerful, flexible and simple to use.
With libconfini you will find in INI files the same serialization power you would normally find in other heavily structured formats (such as JSON, YAML, TOML), but with the advantage of using the most human-readable configuration format ever invented (thanks to their informal status, INI files are indeed more fluid and human-readable than formats explicitly designed with this purpose, such as YAML and TOML).
[foo]
; absolute nesting, as in [foo.bar]
; relative nesting, as in [.bar]
)"Hello world"
and "He"l'lo' world
, or between foo bar
and foo bar
)CR
, Unix' LF
, Windows' CR
+LF
, RISC OS Open's LF
+CR
)log.ini:
example.c:
Output:
For more details, please read the Library Functions Manual (man libconfini
– a standalone HTML version is available here) and the manual of the header file (man confini.h
). The code is available on GitHub under madmurphy/libconfini).
Despite the small footprint, libconfini has been conceived as a shared library (but it can be used as a static library as well). An automatic list of the distributions that ship the library already compiled is available here.
If a pre-compiled package for your platform is not available, on most Unix-like systems it is possible to install libconfini using the following common steps:
If the strip
utility is not available on your machine, use make install
instead (it will produce larger binaries)
For a minimum installation without development files (i.e. static libraries, headers, documentation, examples, etc.) use ./configure --disable-devel
.
If the configure
script is missing from your package you need to generate it by running the bootstrap
script. By default, bootstrap
will also run the configure
script immediately after having generated it, so you may type the make
command directly after bootstrap
. To list different options use ./bootstrap --help
.
If you are using Microsoft Windows, a batch script for compiling libconfini with MinGW without Bash is available (mgwmake.bat
). If you are interested in using Autotools for compiling libconfini under Microsoft Windows, you can integrate MinGW with MSYS, or you can directly use MSYS2. Alternatively, an unofficial port of libconfini for Cygwin is available.
For further information, see INSTALL.
This library is free software. You can redistribute it and/or modify it under the terms of the GPL license version 3 or any later version. See COPYING for details.