Skip to content

andy5995/canfigger

Repository files navigation

codeql-badge actions-c-badge cirrus-badge windows-badge

canfigger v0.3.2999

Canfigger is a lightweight C language library designed to parse configuration files. It provides functionality to read them and represent their contents as a linked list of key-value pairs, along with associated attributes for each pair.

Format

The following config file example represents the format handled by canfigger:

foo = bar
blue = color, shiny
statement = hello world, obvious

# An option with no value or attributes
FeatureFooEnabled

# key, value with 2 attributes
dhcp-range = 192.168.0.50, 192.168.0.150, 12

# key, value with 9 attributes
solar_system = sun, Mercury, Venus, Earth, Mars, Jupiter, Saturn, Neptune, Uranus, Pluto

You can change the attribute delimiter character by passing it as the second argument:

canfigger_parse_file(filename_ptr, ':');

Platform path helpers

Canfigger also provides canfigger_config_dir(), canfigger_data_dir(), and canfigger_path_join() for locating the standard per-user config and data directories on Linux (XDG), macOS, and Windows. See the API documentation for details.

Dependencies

None

Building

meson setup _build
cd _build
ninja

For configuration options, use meson configure (see the Meson docs for detailed usage).

Tests

meson test (-v)

Example programs

Example programs will be built when you run ninja. If you want to try them with a different config file, give them the name of a config file as an argument.