https://github.com/andy5995/canfigger
A lightweight library designed to parse configuration files
https://github.com/andy5995/canfigger
c config configuration-files gpl-3-or-later library mesonbuild parser small-projects
Last synced: about 1 year ago
JSON representation
A lightweight library designed to parse configuration files
- Host: GitHub
- URL: https://github.com/andy5995/canfigger
- Owner: andy5995
- License: mit
- Created: 2021-05-30T06:49:51.000Z (about 5 years ago)
- Default Branch: trunk
- Last Pushed: 2025-01-11T14:33:09.000Z (over 1 year ago)
- Last Synced: 2025-05-13T03:18:16.152Z (about 1 year ago)
- Topics: c, config, configuration-files, gpl-3-or-later, library, mesonbuild, parser, small-projects
- Language: C
- Homepage: https://andy5995.github.io/canfigger/
- Size: 339 KB
- Stars: 12
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.txt
- License: LICENSE
Awesome Lists containing this project
README
[![codeql-badge]][codeql-url]
[![actions-c-badge]][actions-c-url]
[![cirrus-badge]][cirrus-url]
[![windows-badge]][windows-url]
# canfigger v0.3.1-dev
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.
* [website/API documentation and examples](https://andy5995.github.io/canfigger/)
* [source on GitHub](https://github.com/andy5995/canfigger/)
* [releases](https://github.com/andy5995/canfigger/releases)
## 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, ':');
## Dependencies
None
## Building
meson setup _build
cd _build
ninja
For configuration options, use `meson configure` (see the [Meson
docs](https://mesonbuild.com/) for detailed usage).
## Tests
meson test (-v)
## Example program
An example program will be built when you run `ninja`. It will read
`examplerc` in the source root directory. If you want to try it with a
different config file, give `example` the name of a config file as an
argument.
## Using canfigger in your project
If canfigger is not available for your operating system or distribution, you
can copy the required sources (and the LICENSE file) into your project and add
them to your build system. The line `include ` from the top of the
.c file will need to be removed, as it is normally generated during the Meson
setup and only contains version information.
Alternatively, if your project uses Meson, you can add a [wrap
file](https://mesonbuild.com/Wrap-dependency-system-manual.html#wrap-dependency-system-manual)
for canfigger in your 'subprojects' directory.
## Projects using canfigger
* [rmw](https://theimpossibleastronaut.github.io/rmw-website/)
[codeql-badge]: https://github.com/andy5995/canfigger/workflows/CodeQL/badge.svg
[codeql-url]: https://github.com/andy5995/canfigger/actions?query=workflow%3ACodeQL
[actions-c-badge]: https://github.com/andy5995/canfigger/actions/workflows/c-cpp.yml/badge.svg
[actions-c-url]: https://github.com/andy5995/canfigger/actions/workflows/c-cpp.yml
[cirrus-badge]:https://api.cirrus-ci.com/github/andy5995/canfigger.svg
[cirrus-url]:https://cirrus-ci.com/github/andy5995/canfigger
[windows-badge]:https://github.com/andy5995/canfigger/actions/workflows/windows.yml/badge.svg
[windows-url]:https://github.com/andy5995/canfigger/actions/workflows/windows.yml