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 JXON, 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
)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 (34 kB of compiled binary using GCC), libconfini has been conceived as a shared library (but it may be used as a static library as well).
On most Unix-like systems, it is possible to install libconfini using the following common steps:
If the configure
script is missing from your package you need to generate it by running the autogen.sh
script. By default autogen.sh
will also run the configure
script immediately after having generated it, so you may directly type the make
command directly after autogen.sh
. To list different options use autogen.sh --help
.
An unofficial port of libconfini for Cygwin is also available.
This library is free software. You can redistribute it and/or modify it under the terms of the GPL3 license. See COPYING for details.